| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 function testGetDevices() { |
| 6 chrome.test.assertEq(2, devices['all'].length); |
| 7 chrome.test.assertEq('d1', devices['all'][0].name); |
| 8 chrome.test.assertEq('d2', devices['all'][1].name); |
| 9 |
| 10 chrome.test.assertEq(1, devices['name'].length); |
| 11 chrome.test.assertEq('d1', devices['name'][0].name); |
| 12 |
| 13 chrome.test.assertEq(1, devices['uuid'].length); |
| 14 chrome.test.assertEq('d2', devices['uuid'][0].name); |
| 15 |
| 16 chrome.test.succeed(); |
| 17 } |
| 18 |
| 19 var devices = { |
| 20 'all': [], |
| 21 'name': [], |
| 22 'uuid': [] |
| 23 }; |
| 24 function recordDevicesInto(arrayKey) { |
| 25 return function(device) { |
| 26 devices[arrayKey].push(device); |
| 27 }; |
| 28 } |
| 29 |
| 30 chrome.experimental.bluetooth.getDevices( |
| 31 { |
| 32 deviceCallback:recordDevicesInto('all') |
| 33 }, |
| 34 function() { |
| 35 chrome.experimental.bluetooth.getDevices( |
| 36 { |
| 37 name:'fooservice', |
| 38 deviceCallback:recordDevicesInto('name') |
| 39 }, |
| 40 function() { |
| 41 chrome.experimental.bluetooth.getDevices( |
| 42 { |
| 43 uuid:'00000010-0000-1000-8000-00805f9b34fb', |
| 44 deviceCallback:recordDevicesInto('uuid') |
| 45 }, |
| 46 function() { |
| 47 chrome.test.sendMessage('ready', |
| 48 function(message) { |
| 49 chrome.test.runTests([ |
| 50 testGetDevices |
| 51 ]); |
| 52 }); |
| 53 }); |
| 54 }); |
| 55 }); |
| OLD | NEW |