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

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

Issue 10915148: Change getDevices to use a DeviceCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test breakage Created 8 years, 3 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
Index: chrome/test/data/extensions/api_test/bluetooth/test_getdevices.js
diff --git a/chrome/test/data/extensions/api_test/bluetooth/test_getdevices.js b/chrome/test/data/extensions/api_test/bluetooth/test_getdevices.js
new file mode 100644
index 0000000000000000000000000000000000000000..a07ce857c9695d5c1e49260d8afe03ac17dacf81
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/bluetooth/test_getdevices.js
@@ -0,0 +1,55 @@
+// 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 testGetDevices() {
+ chrome.test.assertEq(2, devices['all'].length);
+ chrome.test.assertEq('d1', devices['all'][0].name);
+ chrome.test.assertEq('d2', devices['all'][1].name);
+
+ chrome.test.assertEq(1, devices['name'].length);
+ chrome.test.assertEq('d1', devices['name'][0].name);
+
+ chrome.test.assertEq(1, devices['uuid'].length);
+ chrome.test.assertEq('d2', devices['uuid'][0].name);
+
+ chrome.test.succeed();
+}
+
+var devices = {
+ 'all': [],
+ 'name': [],
+ 'uuid': []
+};
+function recordDevicesInto(arrayKey) {
+ return function(device) {
+ devices[arrayKey].push(device);
+ };
+}
+
+chrome.experimental.bluetooth.getDevices(
+ {
+ deviceCallback:recordDevicesInto('all')
+ },
+ function() {
+ chrome.experimental.bluetooth.getDevices(
+ {
+ name:'fooservice',
+ deviceCallback:recordDevicesInto('name')
+ },
+ function() {
+ chrome.experimental.bluetooth.getDevices(
+ {
+ uuid:'00000010-0000-1000-8000-00805f9b34fb',
+ deviceCallback:recordDevicesInto('uuid')
+ },
+ function() {
+ chrome.test.sendMessage('ready',
+ function(message) {
+ chrome.test.runTests([
+ testGetDevices
+ ]);
+ });
+ });
+ });
+ });

Powered by Google App Engine
This is Rietveld 408576698