Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / bluetooth / device_events / runtest.js
blob603c33f09046567b6b007b6afd0596f4299cad54
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 var kExpectedDeviceNames = {
6   "21:22:23:24:25:26": "the real d2",
7   "31:32:33:34:35:36": "d3"
8 };
10 function testDeviceEvents() {
11   var expectedAddresses = Object.keys(kExpectedDeviceNames);
12   chrome.test.assertEq(expectedAddresses.length, Object.keys(devices).length);
14   for (var i = 0; i < expectedAddresses.length; ++i) {
15     var address = expectedAddresses[i];
16     chrome.test.assertTrue(address in devices);
17     chrome.test.assertEq(kExpectedDeviceNames[address], devices[address].name);
18   }
20   chrome.test.succeed();
23 function startTests() {
24   chrome.test.runTests([testDeviceEvents]);
27 var devices = {};
28 function recordDevice(device) {
29   devices[device.address] = device;
31 function removeDevice(device) {
32   delete devices[device.address];
33   chrome.test.sendMessage('ready', startTests);
36 function stopDiscoveryAndContinue() {
37   chrome.bluetooth.stopDiscovery();
38   chrome.bluetooth.onDeviceAdded.removeListener(recordDevice);
39   sendReady(startTests);
42 chrome.bluetooth.onDeviceAdded.addListener(recordDevice);
43 chrome.bluetooth.onDeviceChanged.addListener(recordDevice);
44 chrome.bluetooth.onDeviceRemoved.addListener(removeDevice);