Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / bluetooth / discovery_callback / runtest.js
blob7e51edc4e0871a29416ce644790e156223d67910
1 // Copyright (c) 2012 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 = ["d1"];
7 function testDiscovery() {
8   chrome.test.assertEq(kExpectedDeviceNames.length,
9       discoveredDevices.length);
10   for (var i = 0; i < kExpectedDeviceNames.length; ++i) {
11     chrome.test.assertEq(kExpectedDeviceNames[i],
12         discoveredDevices[i].name);
13   }
15   chrome.test.succeed();
18 function startTests() {
19   chrome.test.runTests([testDiscovery]);
22 function sendReady(callback) {
23   chrome.test.sendMessage('ready', callback);
26 var discoveredDevices = [];
27 function recordDevice(device) {
28   discoveredDevices.push(device);
31 function stopDiscoveryAndContinue() {
32   chrome.bluetooth.stopDiscovery();
33   chrome.bluetooth.onDeviceAdded.removeListener(recordDevice);
34   sendReady(startTests);
37 chrome.bluetooth.onDeviceAdded.addListener(recordDevice);
38 chrome.bluetooth.startDiscovery(
39     function() { sendReady(stopDiscoveryAndContinue); });