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

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

Issue 10695161: Bluetooth API: test discovery callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix patch Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/extensions/api_test/bluetooth/test_discovery.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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); });
« no previous file with comments | « chrome/test/data/extensions/api_test/bluetooth/test_discovery.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698