| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 verifyGetInfoOutput(outputs) { |
| 6 chrome.test.assertEq("30001", outputs[0].id); |
| 7 chrome.test.assertEq("Jabra Speaker: Jabra Speaker 1", outputs[0].name); |
| 8 |
| 9 chrome.test.assertEq("30002", outputs[1].id); |
| 10 chrome.test.assertEq("Jabra Speaker: Jabra Speaker 2", outputs[1].name); |
| 11 |
| 12 chrome.test.assertEq("30003", outputs[2].id); |
| 13 chrome.test.assertEq("HDMI output: HDA Intel MID", outputs[2].name); |
| 14 } |
| 15 |
| 16 function verifyGetInfoInput(inputs) { |
| 17 chrome.test.assertEq("40001", inputs[0].id); |
| 18 chrome.test.assertEq("Jabra Mic: Jabra Mic 1", inputs[0].name); |
| 19 |
| 20 chrome.test.assertEq("40002", inputs[1].id); |
| 21 chrome.test.assertEq("Jabra Mic: Jabra Mic 2", inputs[1].name); |
| 22 |
| 23 chrome.test.assertEq("40003", inputs[2].id); |
| 24 chrome.test.assertEq("Webcam Mic: Logitech Webcam", inputs[2].name); |
| 25 } |
| 26 |
| 27 function verifyGetDeviceInfo(devices) { |
| 28 chrome.test.assertEq("30001", devices[0].id); |
| 29 chrome.test.assertFalse(devices[0].isInput); |
| 30 chrome.test.assertEq("Jabra Speaker 1", devices[0].displayName); |
| 31 chrome.test.assertEq("Jabra Speaker", devices[0].deviceName); |
| 32 |
| 33 chrome.test.assertEq("30002", devices[1].id); |
| 34 chrome.test.assertFalse(devices[1].isInput); |
| 35 chrome.test.assertEq("Jabra Speaker 2", devices[1].displayName); |
| 36 chrome.test.assertEq("Jabra Speaker", devices[1].deviceName); |
| 37 |
| 38 chrome.test.assertEq("30003", devices[2].id); |
| 39 chrome.test.assertFalse(devices[2].isInput); |
| 40 chrome.test.assertEq("HDA Intel MID", devices[2].displayName); |
| 41 chrome.test.assertEq("HDMI output", devices[2].deviceName); |
| 42 |
| 43 chrome.test.assertEq("40001", devices[3].id); |
| 44 chrome.test.assertTrue(devices[3].isInput); |
| 45 chrome.test.assertEq("Jabra Mic 1", devices[3].displayName); |
| 46 chrome.test.assertEq("Jabra Mic", devices[3].deviceName); |
| 47 |
| 48 chrome.test.assertEq("40002", devices[4].id); |
| 49 chrome.test.assertTrue(devices[4].isInput); |
| 50 chrome.test.assertEq("Jabra Mic 2", devices[4].displayName); |
| 51 chrome.test.assertEq("Jabra Mic", devices[4].deviceName); |
| 52 |
| 53 chrome.test.assertEq("40003", devices[5].id); |
| 54 chrome.test.assertTrue(devices[5].isInput); |
| 55 chrome.test.assertEq("Logitech Webcam", devices[5].displayName); |
| 56 chrome.test.assertEq("Webcam Mic", devices[5].deviceName); |
| 57 } |
| 58 |
| 5 function verifyActiveDevices(output_id, input_id) { | 59 function verifyActiveDevices(output_id, input_id) { |
| 6 chrome.audio.getInfo( | 60 chrome.audio.getInfo( |
| 7 chrome.test.callbackPass(function(outputInfo, inputInfo) { | 61 chrome.test.callbackPass(function(outputInfo, inputInfo) { |
| 8 var outputFound = false; | 62 var outputFound = false; |
| 9 var inputFound = false; | 63 var inputFound = false; |
| 10 for (var i = 0; i < outputInfo.length; ++i) { | 64 for (var i = 0; i < outputInfo.length; ++i) { |
| 11 if (outputInfo[i].isActive) { | 65 if (outputInfo[i].isActive) { |
| 12 chrome.test.assertTrue(outputInfo[i].id == output_id); | 66 chrome.test.assertTrue(outputInfo[i].id == output_id); |
| 13 outputFound = true; | 67 outputFound = true; |
| 14 } | 68 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 verifyDeviceProperties(outputInfo.id, inputInfo.id, | 128 verifyDeviceProperties(outputInfo.id, inputInfo.id, |
| 75 outputProps, inputProps); | 129 outputProps, inputProps); |
| 76 })); | 130 })); |
| 77 })); | 131 })); |
| 78 } | 132 } |
| 79 | 133 |
| 80 chrome.test.runTests([ | 134 chrome.test.runTests([ |
| 81 function getInfoTest() { | 135 function getInfoTest() { |
| 82 chrome.audio.getInfo( | 136 chrome.audio.getInfo( |
| 83 chrome.test.callbackPass(function(outputInfo, inputInfo) { | 137 chrome.test.callbackPass(function(outputInfo, inputInfo) { |
| 138 verifyGetInfoOutput(outputInfo); |
| 139 verifyGetInfoInput(inputInfo); |
| 84 })); | 140 })); |
| 85 }, | 141 }, |
| 86 | 142 |
| 143 function getDeviceInfoTest() { |
| 144 chrome.audio.getDeviceInfo( |
| 145 chrome.test.callbackPass(function(devicesInfo) { |
| 146 verifyGetDeviceInfo(devicesInfo); |
| 147 })); |
| 148 }, |
| 149 |
| 87 function setActiveDevicesTest() { | 150 function setActiveDevicesTest() { |
| 88 chrome.audio.getInfo( | 151 chrome.audio.getInfo( |
| 89 chrome.test.callbackPass(function(outputInfo, inputInfo) { | 152 chrome.test.callbackPass(function(outputInfo, inputInfo) { |
| 90 setActiveDevicesAndVerify(outputInfo[2].id, inputInfo[1].id); | 153 setActiveDevicesAndVerify(outputInfo[2].id, inputInfo[1].id); |
| 91 })); | 154 })); |
| 92 }, | 155 }, |
| 93 | 156 |
| 94 function setPropertiesTest() { | 157 function setPropertiesTest() { |
| 95 chrome.audio.getInfo( | 158 chrome.audio.getInfo( |
| 96 chrome.test.callbackPass(function(outputInfo, inputInfo) { | 159 chrome.test.callbackPass(function(outputInfo, inputInfo) { |
| 97 setPropertiesAndVerify(outputInfo[0], inputInfo[1]); | 160 setPropertiesAndVerify(outputInfo[0], inputInfo[1]); |
| 98 })); | 161 })); |
| 99 } | 162 } |
| 100 ]); | 163 ]); |
| OLD | NEW |