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

Side by Side Diff: chrome/test/data/extensions/api_test/bluetooth/device_events/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
(Empty)
1 // Copyright (c) 2014 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 var kExpectedDeviceNames = {
6 "21:22:23:24:25:26": "the real d2",
7 "31:32:33:34:35:36": "d3"
8 };
9
10 function testDeviceEvents() {
11 var expectedAddresses = Object.keys(kExpectedDeviceNames);
12 chrome.test.assertEq(expectedAddresses.length, Object.keys(devices).length);
13
14 for (var i = 0; i < expectedAddresses.length; ++i) {
15 var address = expectedAddresses[i];
16 chrome.test.assertTrue(address in devices);
17 chrome.test.assertEq(kExpectedDeviceNames[address], devices[address].name);
18 }
19
20 chrome.test.succeed();
21 }
22
23 function startTests() {
24 chrome.test.runTests([testDeviceEvents]);
25 }
26
27 var devices = {};
28 function recordDevice(device) {
29 devices[device.address] = device;
30 }
31 function removeDevice(device) {
32 delete devices[device.address];
33 chrome.test.sendMessage('ready', startTests);
34 }
35
36 function stopDiscoveryAndContinue() {
37 chrome.bluetooth.stopDiscovery();
38 chrome.bluetooth.onDeviceAdded.removeListener(recordDevice);
39 sendReady(startTests);
40 }
41
42 chrome.bluetooth.onDeviceAdded.addListener(recordDevice);
43 chrome.bluetooth.onDeviceChanged.addListener(recordDevice);
44 chrome.bluetooth.onDeviceRemoved.addListener(removeDevice);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698