Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(957)

Side by Side Diff: chrome/test/data/extensions/api_test/bluetooth/test_discovery.js

Issue 10815072: Bluetooth API: improve discovery (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix licenses Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 function testDiscovery() { 5 function testDiscovery() {
6 chrome.test.assertEq(kExpectedDeviceNames.length, 6 chrome.test.assertEq(kExpectedDeviceNames.length,
7 discoveredDevices.length); 7 discoveredDevices.length);
8 for (var i = 0; i < kExpectedDeviceNames.length; ++i) { 8 for (var i = 0; i < kExpectedDeviceNames.length; ++i) {
9 chrome.test.assertEq(kExpectedDeviceNames[i], discoveredDevices[i].name); 9 chrome.test.assertEq(kExpectedDeviceNames[i],
10 discoveredDevices[i].name);
10 } 11 }
11 12
12 chrome.test.succeed(); 13 chrome.test.succeed();
13 } 14 }
14 15
15 function startTests() { 16 function startTests() {
16 chrome.test.runTests([testDiscovery]); 17 chrome.test.runTests([testDiscovery]);
17 } 18 }
18 19
19 function sendReady(callback) { 20 function sendReady(callback) {
20 chrome.test.sendMessage('ready', callback); 21 chrome.test.sendMessage('ready', callback);
21 } 22 }
22 23
23 function stopDiscoveryAndContinue() { 24 function stopDiscoveryAndContinue() {
24 chrome.experimental.bluetooth.stopDiscovery(); 25 chrome.experimental.bluetooth.stopDiscovery();
25 sendReady(startTests); 26 sendReady(startTests);
26 } 27 }
27 28
28 var kExpectedDeviceNames = ["d1"];
29 var discoveredDevices = []; 29 var discoveredDevices = [];
30 function recordDevice(device) { 30 function recordDevice(device) {
31 discoveredDevices.push(device); 31 discoveredDevices.push(device);
32 } 32 }
33 33
34 chrome.experimental.bluetooth.startDiscovery( 34 chrome.experimental.bluetooth.startDiscovery(
35 { deviceCallback:recordDevice }, 35 { deviceCallback:recordDevice },
36 function() { sendReady(stopDiscoveryAndContinue); }); 36 function() { sendReady(stopDiscoveryAndContinue); });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698