Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/bluetooth/test_discovery.js |
| diff --git a/chrome/test/data/extensions/api_test/bluetooth/test_discovery.js b/chrome/test/data/extensions/api_test/bluetooth/test_discovery.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1248932184cf826bd0c299d82541ed7a195af40d |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/bluetooth/test_discovery.js |
| @@ -0,0 +1,37 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +function testDiscovery() { |
| + chrome.test.assertEq(kExpectedDeviceNames.length, |
| + discoveredDevices.length); |
| + for (var i = 0; i < kExpectedDeviceNames.length; ++i) { |
| + chrome.test.assertEq(kExpectedDeviceNames[i], discoveredDevices[i].name); |
| + } |
| + |
| + chrome.test.succeed(); |
| +} |
| + |
| +function startTests() { |
| + chrome.test.runTests([ testDiscovery ]); |
|
miket_OOO
2012/07/11 21:49:46
We're not super-consistent about whitespace on sin
bryeung
2012/07/12 01:02:40
Oops. Good catch.
|
| +} |
| + |
| +function sendReady(callback) { |
| + chrome.test.sendMessage('ready', callback); |
| +} |
| + |
| +function stopDiscoveryAndContinue() { |
| + chrome.experimental.bluetooth.stopDiscovery(); |
| + sendReady(startTests); |
| +} |
| + |
| +var kExpectedDeviceNames = ["d1"]; |
| +var discoveredDevices = []; |
| +function recordDevice(device) { |
| +console.log('Got device: ' + device.name); |
|
miket_OOO
2012/07/11 21:49:46
oops -- if you want to keep this in, please indent
bryeung
2012/07/12 01:02:40
Yep: another oops. Thanks.
|
| + discoveredDevices.push(device); |
| +} |
| + |
| +chrome.experimental.bluetooth.startDiscovery( |
| + { deviceCallback:recordDevice }, |
| + function() { sendReady(stopDiscoveryAndContinue); }); |