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

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

Issue 177113013: Bluetooth: add Device events, and cleanup JS API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@arman-patch
Patch Set: I suck at rebase Created 6 years, 9 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
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 testGetDevices() { 5 function testGetDevices() {
6 chrome.test.assertEq(2, devices['all'].length); 6 chrome.test.assertEq(2, devices.length);
7 chrome.test.assertEq('d1', devices['all'][0].name); 7 chrome.test.assertEq('d1', devices[0].name);
8 chrome.test.assertEq('d2', devices['all'][1].name); 8 chrome.test.assertEq('d2', devices[1].name);
9
10 chrome.test.assertEq(1, devices['uuid'].length);
11 chrome.test.assertEq('d2', devices['uuid'][0].name);
12 9
13 chrome.test.succeed(); 10 chrome.test.succeed();
14 } 11 }
15 12
16 var devices = { 13 var devices = null;
17 'all': [],
18 'uuid': []
19 };
20
21 function recordDevicesInto(arrayKey) {
22 return function(device) {
23 devices[arrayKey].push(device);
24 };
25 }
26 14
27 function failOnError() { 15 function failOnError() {
28 if (chrome.runtime.lastError) { 16 if (chrome.runtime.lastError) {
29 chrome.test.fail(chrome.runtime.lastError.message); 17 chrome.test.fail(chrome.runtime.lastError.message);
30 } 18 }
31 } 19 }
32 20
33 chrome.bluetooth.getDevices( 21 chrome.bluetooth.getDevices(
34 {deviceCallback: recordDevicesInto('all')}, 22 function(result) {
35 function() {
36 failOnError(); 23 failOnError();
37 chrome.bluetooth.getDevices( 24 devices = result;
38 { 25 chrome.test.sendMessage('ready',
39 profile: {uuid: '00000010-0000-1000-8000-00805f9b34fb'}, 26 function(message) {
40 deviceCallback: recordDevicesInto('uuid') 27 chrome.test.runTests([testGetDevices]);
41 },
42 function() {
43 failOnError();
44 chrome.test.sendMessage('ready',
45 function(message) {
46 chrome.test.runTests([testGetDevices]);
47 });
48 }); 28 });
49 }); 29 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698