| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 chrome.test.runTests([ | 5 chrome.test.runTests([ |
| 6 function waitForDeviceChangedEventTests() { | 6 function waitForDeviceChangedEventTests() { |
| 7 chrome.test.listenOnce(chrome.audio.OnDevicesChanged, function (devices) { | 7 chrome.test.listenOnce(chrome.audio.OnDevicesChanged, function (devices) { |
| 8 var deviceList = devices.map(function(device) { | 8 var deviceList = devices.map(function(device) { |
| 9 return { | 9 return { |
| 10 id: device.id, | 10 id: device.id, |
| 11 stableId: device.stableId, |
| 11 stableDeviceId: device.stableDeviceId, | 12 stableDeviceId: device.stableDeviceId, |
| 12 isInput: device.isInput, | 13 isInput: device.isInput, |
| 13 deviceType: device.deviceType, | 14 deviceType: device.deviceType, |
| 14 deviceName: device.deviceName, | 15 deviceName: device.deviceName, |
| 15 displayName: device.displayName | 16 displayName: device.displayName |
| 16 }; | 17 }; |
| 17 }).sort(function(lhs, rhs) { | 18 }).sort(function(lhs, rhs) { |
| 18 return Number.parseInt(lhs.id) - Number.parseInt(rhs.id); | 19 return Number.parseInt(lhs.id) - Number.parseInt(rhs.id); |
| 19 }); | 20 }); |
| 20 | 21 |
| 22 chrome.test.assertTrue(devices.length > 0); |
| 23 var hasStableId = !!devices[0].stableId; |
| 24 |
| 21 chrome.test.assertEq([{ | 25 chrome.test.assertEq([{ |
| 22 id: '40001', | 26 id: '40001', |
| 27 stableId: hasStableId ? '106606' /* 90001 ^ 0xFFFF */ : '', |
| 23 stableDeviceId: '90001', | 28 stableDeviceId: '90001', |
| 24 isInput: true, | 29 isInput: true, |
| 25 deviceType: 'USB', | 30 deviceType: 'USB', |
| 26 deviceName: 'Jabra Mic', | 31 deviceName: 'Jabra Mic', |
| 27 displayName: 'Jabra Mic 1' | 32 displayName: 'Jabra Mic 1' |
| 28 }, { | 33 }, { |
| 29 id: '40002', | 34 id: '40002', |
| 35 stableId: hasStableId ? '106605' /* 90002 ^ 0xFFFF */ : '', |
| 30 stableDeviceId: '90002', | 36 stableDeviceId: '90002', |
| 31 isInput: true, | 37 isInput: true, |
| 32 deviceType: 'USB', | 38 deviceType: 'USB', |
| 33 deviceName: 'Jabra Mic', | 39 deviceName: 'Jabra Mic', |
| 34 displayName: 'Jabra Mic 2' | 40 displayName: 'Jabra Mic 2' |
| 35 }], deviceList); | 41 }], deviceList); |
| 36 }); | 42 }); |
| 37 } | 43 } |
| 38 ]); | 44 ]); |
| 39 | 45 |
| 40 chrome.test.sendMessage('loaded'); | 46 chrome.test.sendMessage('loaded'); |
| OLD | NEW |