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 // Array of each device list update. |
| 6 var devices = []; |
| 7 |
| 8 chrome.test.sendMessage('ready', function(message) { |
| 9 if (message == 'setup') { |
| 10 function handleOnDeviceList(deviceList) { |
| 11 var newDevices = []; |
| 12 for (var i = 0; i < deviceList.length; ++i) { |
| 13 newDevices.push(deviceList[i]); |
| 14 } |
| 15 devices.push(newDevices); |
| 16 } |
| 17 chrome.dial.onDeviceList.addListener(handleOnDeviceList); |
| 18 |
| 19 chrome.test.sendMessage('setup', function(message) { |
| 20 if (message == 'go') { |
| 21 chrome.test.runTests([ |
| 22 function testEvents() { |
| 23 // Make sure there were 3 devices. |
| 24 chrome.test.assertEq(3, devices.length); |
| 25 |
| 26 // Make sure each update contained 1 more device than the previous. |
| 27 for (var i = 0; i < devices.length; ++i) { |
| 28 chrome.test.assertEq(i + 1, devices[i].length); |
| 29 } |
| 30 |
| 31 // Just check the first device in the first update and the last |
| 32 // device in the last update. |
| 33 // Not exposing the device id right now. |
| 34 chrome.test.assertTrue(!('deviceId' in devices[0][0])); |
| 35 chrome.test.assertEq("1", devices[0][0].deviceLabel); |
| 36 chrome.test.assertEq("http://1", |
| 37 devices[0][0].deviceDescriptionUrl); |
| 38 |
| 39 chrome.test.assertTrue(!('deviceId' in devices[2][2])); |
| 40 chrome.test.assertEq("3", devices[2][2].deviceLabel); |
| 41 chrome.test.assertEq("http://3", |
| 42 devices[2][2].deviceDescriptionUrl); |
| 43 |
| 44 chrome.test.succeed(); |
| 45 } |
| 46 ]); |
| 47 } |
| 48 }); |
| 49 } |
| 50 }); |
OLD | NEW |