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

Side by Side Diff: extensions/test/data/api_test/audio/test.js

Issue 2635983006: Final cleanup pass over audio device API (Closed)
Patch Set: . Created 3 years, 10 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
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 /** 5 /**
6 * Asserts that device property values match properties in |expectedProperties|. 6 * Asserts that device property values match properties in |expectedProperties|.
7 * The method will *not* assert that the device contains *only* properties 7 * The method will *not* assert that the device contains *only* properties
8 * specified in expected properties. 8 * specified in expected properties.
9 * @param {Object} expectedProperties Expected device properties. 9 * @param {Object} expectedProperties Expected device properties.
10 * @param {Object} device Device object to test. 10 * @param {Object} device Device object to test.
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 chrome.test.assertEq(sortedKeys(expectedDevices), sortedKeys(deviceIds)); 38 chrome.test.assertEq(sortedKeys(expectedDevices), sortedKeys(deviceIds));
39 39
40 devices.forEach(function(device) { 40 devices.forEach(function(device) {
41 assertDeviceMatches(expectedDevices[device.id], device); 41 assertDeviceMatches(expectedDevices[device.id], device);
42 }); 42 });
43 } 43 }
44 44
45 /** 45 /**
46 * 46 *
47 * @param {Array.<Object>} devices List of devices returned by getInfo 47 * @param {Array.<Object>} devices List of devices returned by
48 * @returns {Object.<string, Object>} List of devices formatted as map of 48 * chrome.audio.getInfo or chrome.audio.getDevices.
49 * @return {Object.<string, Object>} List of devices formatted as map of
49 * expected devices used to assert devices match expectation. 50 * expected devices used to assert devices match expectation.
50 */ 51 */
51 function deviceListToExpectedDevicesMap(devices) { 52 function deviceListToExpectedDevicesMap(devices) {
52 var expectedDevicesMap = {}; 53 var expectedDevicesMap = {};
53 devices.forEach(function(device) { 54 devices.forEach(function(device) {
54 expectedDevicesMap[device.id] = device; 55 expectedDevicesMap[device.id] = device;
55 }); 56 });
56 return expectedDevicesMap; 57 return expectedDevicesMap;
57 } 58 }
58 59
59 function getActiveDeviceIds(deviceList) { 60 /**
60 return deviceList 61 * @param {Array.<Object>} devices List of devices returned by
61 .filter(function(device) {return device.isActive;}) 62 * chrome.audio.getInfo or chrome.audio.getDevices.
62 .map(function(device) {return device.id}); 63 * @return {Array.<string>} Sorted list devices IDs for devices in |devices|.
63 } 64 */
64 65 function getDeviceIds(devices) {
65 function getDevices(callback) { 66 return devices.map(function(device) {return device.id;}).sort();
66 chrome.audio.getInfo(chrome.test.callbackPass(callback));
67 } 67 }
68 68
69 chrome.test.runTests([ 69 chrome.test.runTests([
70 function getInfoTest() { 70 function getInfoTest() {
71 // Test output devices. Maps device ID -> tested device properties. 71 // Test output devices. Maps device ID -> tested device properties.
72 var kTestOutputDevices = { 72 var kTestOutputDevices = {
73 '30001': { 73 '30001': {
74 id: '30001', 74 id: '30001',
75 name: 'Jabra Speaker: Jabra Speaker 1' 75 name: 'Jabra Speaker: Jabra Speaker 1'
76 }, 76 },
(...skipping 16 matching lines...) Expand all
93 '40002': { 93 '40002': {
94 id: '40002', 94 id: '40002',
95 name: 'Jabra Mic: Jabra Mic 2' 95 name: 'Jabra Mic: Jabra Mic 2'
96 }, 96 },
97 '40003': { 97 '40003': {
98 id: '40003', 98 id: '40003',
99 name: 'Webcam Mic: Logitech Webcam' 99 name: 'Webcam Mic: Logitech Webcam'
100 } 100 }
101 }; 101 };
102 102
103 getDevices(function(outputInfo, inputInfo) { 103 chrome.audio.getInfo(chrome.test.callbackPass(
104 assertDevicesMatch(kTestOutputDevices, outputInfo); 104 function(outputInfo, inputInfo) {
105 assertDevicesMatch(kTestInputDevices, inputInfo); 105 assertDevicesMatch(kTestOutputDevices, outputInfo);
106 }); 106 assertDevicesMatch(kTestInputDevices, inputInfo);
107 }));
108 },
109
110 function getDevicesTest() {
111 // Test output devices. Maps device ID -> tested device properties.
112 var kTestDevices = {
113 '30001': {
114 id: '30001',
115 stableDeviceId: '116606',
116 displayName: 'Jabra Speaker 1',
117 deviceName: 'Jabra Speaker',
118 streamType: 'OUTPUT'
119 },
120 '30002': {
121 id: '30002',
122 stableDeviceId: '116605',
123 displayName: 'Jabra Speaker 2',
124 deviceName: 'Jabra Speaker',
125 streamType: 'OUTPUT'
126 },
127 '30003': {
128 id: '30003',
129 stableDeviceId: '116604',
130 displayName: 'HDA Intel MID',
131 deviceName: 'HDMI output',
132 streamType: 'OUTPUT'
133 },
134 '40001': {
135 id: '40001',
136 stableDeviceId: '106606',
137 displayName: 'Jabra Mic 1',
138 deviceName: 'Jabra Mic',
139 streamType: 'INPUT'
140 },
141 '40002': {
142 id: '40002',
143 stableDeviceId: '106605',
144 displayName: 'Jabra Mic 2',
145 deviceName: 'Jabra Mic',
146 streamType: 'INPUT'
147 },
148 '40003': {
149 id: '40003',
150 stableDeviceId: '106604',
151 displayName: 'Logitech Webcam',
152 deviceName: 'Webcam Mic',
153 streamType: 'INPUT'
154 }
155 };
156
157 chrome.audio.getDevices({}, chrome.test.callbackPass(function(devices) {
158 assertDevicesMatch(kTestDevices, devices);
159 }));
160 },
161
162 function getInputDevicesTest() {
163 var kTestDevices = {
164 '40001': {
165 id: '40001',
166 streamType: 'INPUT'
167 },
168 '40002': {
169 id: '40002',
170 streamType: 'INPUT'
171 },
172 '40003': {
173 id: '40003',
174 streamType: 'INPUT'
175 }
176 };
177
178 chrome.audio.getDevices({
179 streamTypes: ['INPUT']
180 }, chrome.test.callbackPass(function(devices) {
181 assertDevicesMatch(kTestDevices, devices);
182 }));
183 },
184
185 function getOutputDevicesTest() {
186 var kTestDevices = {
187 '30001': {
188 id: '30001',
189 streamType: 'OUTPUT'
190 },
191 '30002': {
192 id: '30002',
193 streamType: 'OUTPUT'
194 },
195 '30003': {
196 id: '30003',
197 streamType: 'OUTPUT'
198 },
199 };
200
201 chrome.audio.getDevices({
202 streamTypes: ['OUTPUT']
203 }, chrome.test.callbackPass(function(devices) {
204 assertDevicesMatch(kTestDevices, devices);
205 }));
206 },
207
208 function getActiveDevicesTest() {
209 chrome.audio.getDevices({}, chrome.test.callbackPass(function(initial) {
210 var initialActiveDevices = initial.filter(function(device) {
211 return device.isActive;
212 });
213 chrome.test.assertTrue(initialActiveDevices.length > 0);
214
215 chrome.audio.getDevices({
216 isActive: true
217 }, chrome.test.callbackPass(function(devices) {
218 assertDevicesMatch(
219 deviceListToExpectedDevicesMap(initialActiveDevices),
220 devices);
221 }));
222
223 var initialActiveInputs = initialActiveDevices.filter(function(device) {
224 return device.streamType === 'INPUT';
225 });
226 chrome.test.assertTrue(initialActiveInputs.length > 0);
227
228 chrome.audio.getDevices({
229 isActive: true,
230 streamTypes: ['INPUT']
231 }, chrome.test.callbackPass(function(devices) {
232 assertDevicesMatch(
233 deviceListToExpectedDevicesMap(initialActiveInputs),
234 devices);
235 }));
236
237 var initialActiveOutputs = initialActiveDevices.filter(function(device) {
238 return device.streamType === 'OUTPUT';
239 });
240 chrome.test.assertTrue(initialActiveOutputs.length > 0);
241
242 chrome.audio.getDevices({
243 isActive: true,
244 streamTypes: ['OUTPUT']
245 }, chrome.test.callbackPass(function(devices) {
246 assertDevicesMatch(
247 deviceListToExpectedDevicesMap(initialActiveOutputs),
248 devices);
249 }));
250 }));
251 },
252
253 function getInactiveDevicesTest() {
254 chrome.audio.getDevices({}, chrome.test.callbackPass(function(initial) {
255 var initialInactiveDevices = initial.filter(function(device) {
256 return !device.isActive;
257 });
258 chrome.test.assertTrue(initialInactiveDevices.length > 0);
259
260 chrome.audio.getDevices({
261 isActive: false
262 }, chrome.test.callbackPass(function(devices) {
263 assertDevicesMatch(
264 deviceListToExpectedDevicesMap(initialInactiveDevices),
265 devices);
266 }));
267 }));
107 }, 268 },
108 269
109 function deprecatedSetActiveDevicesTest() { 270 function deprecatedSetActiveDevicesTest() {
110 //Test output devices. Maps device ID -> tested device properties. 271 //Test output devices. Maps device ID -> tested device properties.
111 var kTestOutputDevices = { 272 var kTestDevices = {
112 '30001': { 273 '30001': {
113 id: '30001', 274 id: '30001',
114 isActive: false 275 isActive: false
115 }, 276 },
116 '30002': { 277 '30002': {
117 id: '30002', 278 id: '30002',
118 isActive: false 279 isActive: false
119 }, 280 },
120 '30003': { 281 '30003': {
121 id: '30003', 282 id: '30003',
122 isActive: true 283 isActive: true
123 } 284 },
124 };
125
126 // Test input devices. Maps device ID -> tested device properties.
127 var kTestInputDevices = {
128 '40001': { 285 '40001': {
129 id: '40001', 286 id: '40001',
130 isActive: false 287 isActive: false
131 }, 288 },
132 '40002': { 289 '40002': {
133 id: '40002', 290 id: '40002',
134 isActive: true 291 isActive: true
135 }, 292 },
136 '40003': { 293 '40003': {
137 id: '40003', 294 id: '40003',
138 isActive: false 295 isActive: false
139 } 296 }
140 }; 297 };
141 298
142 chrome.audio.setActiveDevices([ 299 chrome.audio.setActiveDevices([
143 '30003', 300 '30003',
144 '40002' 301 '40002'
145 ], chrome.test.callbackPass(function() { 302 ], chrome.test.callbackPass(function() {
146 getDevices(function(outputInfo, inputInfo) { 303 chrome.audio.getDevices({}, chrome.test.callbackPass(function(devices) {
147 assertDevicesMatch(kTestOutputDevices, outputInfo); 304 assertDevicesMatch(kTestDevices, devices);
148 assertDevicesMatch(kTestInputDevices, inputInfo); 305 }));
149 });
150 })); 306 }));
151 }, 307 },
152 308
153 function setPropertiesTest() { 309 function deprecatedSetPropertiesTest() {
154 getDevices(function(originalOutputInfo, originalInputInfo) { 310 chrome.audio.getDevices({}, chrome.test.callbackPass(function(initial) {
155 var expectedInput = deviceListToExpectedDevicesMap(originalInputInfo); 311 var expectedDevices = deviceListToExpectedDevicesMap(initial);
312
156 // Update expected input devices with values that should be changed in 313 // Update expected input devices with values that should be changed in
157 // test. 314 // test.
158 var updatedInput = expectedInput['40002']; 315 var updatedInput = expectedDevices['40002'];
159 chrome.test.assertFalse(updatedInput.isMuted); 316 chrome.test.assertFalse(updatedInput.isMuted);
160 chrome.test.assertFalse(updatedInput.gain === 55); 317 chrome.test.assertFalse(updatedInput.gain === 55);
161 updatedInput.isMuted = true; 318 updatedInput.isMuted = true;
162 updatedInput.gain = 55; 319 updatedInput.level = 55;
163 320
164 var expectedOutput = deviceListToExpectedDevicesMap(originalOutputInfo);
165 // Update expected output devices with values that should be changed in 321 // Update expected output devices with values that should be changed in
166 // test. 322 // test.
167 var updatedOutput = expectedOutput['30001']; 323 var updatedOutput = expectedDevices['30001'];
168 chrome.test.assertFalse(updatedOutput.isMuted);
169 chrome.test.assertFalse(updatedOutput.volume === 35); 324 chrome.test.assertFalse(updatedOutput.volume === 35);
170 updatedOutput.volume = 35; 325 updatedOutput.level = 35;
171 326
172 chrome.audio.setProperties('30001', { 327 chrome.audio.setProperties('30001', {
173 volume: 35 328 volume: 35
174 }, chrome.test.callbackPass(function() { 329 }, chrome.test.callbackPass(function() {
175 chrome.audio.setProperties('40002', { 330 chrome.audio.setProperties('40002', {
176 isMuted: true, 331 isMuted: true,
177 gain: 55 332 gain: 55
178 }, chrome.test.callbackPass(function() { 333 }, chrome.test.callbackPass(function() {
179 getDevices( 334 chrome.audio.getDevices({}, chrome.test.callbackPass(
180 chrome.test.callbackPass(function(outputInfo, inputInfo) { 335 function(devices) {
181 assertDevicesMatch(expectedInput, inputInfo); 336 assertDevicesMatch(expectedDevices, devices);
182 assertDevicesMatch(expectedOutput, outputInfo); 337 }));
183 }));
184 })); 338 }));
185 })); 339 }));
186 }); 340 }));
187 }, 341 },
188 342
343 function setPropertiesTest() {
344 chrome.audio.getDevices({}, chrome.test.callbackPass(function(initial) {
345 var expectedDevices = deviceListToExpectedDevicesMap(initial);
346
347 // Update expected input devices with values that should be changed in
348 // test.
349 var updatedInput = expectedDevices['40002'];
350 chrome.test.assertFalse(updatedInput.gain === 65);
351 updatedInput.level = 65;
352
353 // Update expected output devices with values that should be changed in
354 // test.
355 var updatedOutput = expectedDevices['30001'];
356 chrome.test.assertFalse(updatedOutput.volume === 45);
357 updatedOutput.level = 45;
358
359 chrome.audio.setProperties('30001', {
360 level: 45
361 }, chrome.test.callbackPass(function() {
362 chrome.audio.setProperties('40002', {
363 level: 65
364 }, chrome.test.callbackPass(function() {
365 chrome.audio.getDevices({}, chrome.test.callbackPass(
366 function(devices) {
367 assertDevicesMatch(expectedDevices, devices);
368 }));
369 }));
370 }));
371 }));
372 },
373
374
189 function inputMuteTest() { 375 function inputMuteTest() {
190 var getMute = function(callback) { 376 var getMute = function(callback) {
191 chrome.audio.getMute('INPUT', chrome.test.callbackPass(callback)); 377 chrome.audio.getMute('INPUT', chrome.test.callbackPass(callback));
192 }; 378 };
193 getMute(function(originalValue) { 379 getMute(function(originalValue) {
194 chrome.audio.setMute( 380 chrome.audio.setMute(
195 'INPUT', !originalValue, chrome.test.callbackPass(function() { 381 'INPUT', !originalValue, chrome.test.callbackPass(function() {
196 getMute(function(value) { 382 getMute(function(value) {
197 chrome.test.assertEq(!originalValue, value); 383 chrome.test.assertEq(!originalValue, value);
198 }); 384 });
199 })); 385 }));
200 }); 386 });
201 }, 387 },
202 388
203 function outputMuteTest() { 389 function outputMuteTest() {
204 var getMute = function(callback) { 390 var getMute = function(callback) {
205 chrome.audio.getMute('OUTPUT', chrome.test.callbackPass(callback)); 391 chrome.audio.getMute('OUTPUT', chrome.test.callbackPass(callback));
206 }; 392 };
207 getMute(function(originalValue) { 393 getMute(function(originalValue) {
208 chrome.audio.setMute( 394 chrome.audio.setMute(
209 'OUTPUT', !originalValue, chrome.test.callbackPass(function() { 395 'OUTPUT', !originalValue, chrome.test.callbackPass(function() {
210 getMute(function(value) { 396 getMute(function(value) {
211 chrome.test.assertEq(!originalValue, value); 397 chrome.test.assertEq(!originalValue, value);
212 }); 398 });
213 })); 399 }));
214 }); 400 });
215 }, 401 },
216 402
217 function setPropertiesInvalidValuesTest() { 403 function setPropertiesInvalidValuesTest() {
218 getDevices(function(originalOutputInfo, originalInputInfo) { 404 chrome.audio.getDevices({}, chrome.test.callbackPass(function(initial) {
219 var expectedInput = deviceListToExpectedDevicesMap(originalInputInfo); 405 var expectedDevices = deviceListToExpectedDevicesMap(initial);
220 var expectedOutput = deviceListToExpectedDevicesMap(originalOutputInfo);
221 var expectedError = 'Could not set volume/gain properties'; 406 var expectedError = 'Could not set volume/gain properties';
222 407
223 chrome.audio.setProperties( 408 chrome.audio.setProperties('30001', {
224 '30001', { 409 isMuted: true,
225 isMuted: true, 410 // Output device - should have volume set.
226 // Output device - should have volume set. 411 gain: 55
227 gain: 55 412 }, chrome.test.callbackFail(expectedError, function() {
228 }, 413 chrome.audio.setProperties('40002', {
229 chrome.test.callbackFail(expectedError, function() { 414 isMuted: true,
230 chrome.audio.setProperties( 415 // Input device - should have gain set.
231 '40002', { 416 volume:55
232 isMuted: true, 417 }, chrome.test.callbackFail(expectedError, function() {
233 // Input device - should have gain set. 418 // Assert that device properties haven't changed.
234 volume: 55 419 chrome.audio.getDevices({},
235 }, 420 chrome.test.callbackPass(function(devices) {
236 chrome.test.callbackFail(expectedError, function() { 421 assertDevicesMatch(expectedDevices, devices);
237 // Assert that device properties haven't changed. 422 }));
238 getDevices(function(outputInfo, inputInfo) { 423 }));
239 assertDevicesMatch(expectedOutput, outputInfo); 424 }));
240 assertDevicesMatch(expectedInput, inputInfo); 425 }));
241 });
242 }));
243 }));
244 });
245 }, 426 },
246 427
247 function setActiveDevicesTest() { 428 function setActiveDevicesTest() {
248 chrome.audio.setActiveDevices({ 429 chrome.audio.setActiveDevices({
249 input: ['40002', '40003'], 430 input: ['40002', '40003'],
250 output: ['30001'] 431 output: ['30001']
251 }, chrome.test.callbackPass(function() { 432 }, chrome.test.callbackPass(function() {
252 getDevices(function(outputs, inputs) { 433 chrome.audio.getDevices({
253 chrome.test.assertEq( 434 isActive: true
254 ['40002', '40003'], getActiveDeviceIds(inputs).sort()); 435 }, chrome.test.callbackPass(function(activeDevices) {
255 chrome.test.assertEq(['30001'], getActiveDeviceIds(outputs)); 436 chrome.test.assertEq(['30001', '40002', '40003'],
256 }); 437 getDeviceIds(activeDevices));
438 }));
257 })); 439 }));
258 }, 440 },
259 441
260 function setActiveDevicesOutputOnlyTest() { 442 function setActiveDevicesOutputOnlyTest() {
261 getDevices(function(originalOutputs, originalInputs) { 443 chrome.audio.getDevices({
262 var originalActiveInputs = getActiveDeviceIds(originalInputs); 444 streamTypes: ['INPUT'],
263 chrome.test.assertTrue(originalActiveInputs.length > 0); 445 isActive: true
446 }, chrome.test.callbackPass(function(initial) {
447 var initialActiveInputs = getDeviceIds(initial);
448 chrome.test.assertTrue(initialActiveInputs.length > 0);
264 449
265 chrome.audio.setActiveDevices({ 450 chrome.audio.setActiveDevices({
266 output: ['30003'] 451 output: ['30003']
267 }, chrome.test.callbackPass(function() { 452 }, chrome.test.callbackPass(function() {
268 getDevices(function(outputs, inputs) { 453 chrome.audio.getDevices({
269 chrome.test.assertEq( 454 isActive: true
270 originalActiveInputs.sort(), getActiveDeviceIds(inputs).sort()); 455 }, chrome.test.callbackPass(function(devices) {
271 chrome.test.assertEq(['30003'], getActiveDeviceIds(outputs)); 456 var expected = ['30003'].concat(initialActiveInputs).sort();
272 }); 457 chrome.test.assertEq(expected, getDeviceIds(devices));
458 }));
273 })); 459 }));
274 }); 460 }));
275 }, 461 },
276 462
277 function setActiveDevicesFailInputTest() { 463 function setActiveDevicesFailInputTest() {
278 getDevices(function(originalOutputs, originalInputs) { 464 chrome.audio.getDevices({
279 var originalActiveInputs = getActiveDeviceIds(originalInputs).sort(); 465 isActive: true
280 chrome.test.assertTrue(originalActiveInputs.length > 0); 466 }, chrome.test.callbackPass(function(initial) {
281 467 var initialActiveIds = getDeviceIds(initial);
282 var originalActiveOutputs = getActiveDeviceIds(originalOutputs).sort(); 468 chrome.test.assertTrue(initialActiveIds.length > 0);
283 chrome.test.assertTrue(originalActiveOutputs.length > 0);
284 469
285 chrome.audio.setActiveDevices({ 470 chrome.audio.setActiveDevices({
286 input: ['0000000'], /* does not exist */ 471 input: ['0000000'], /* does not exist */
287 output: [] 472 output: []
288 }, chrome.test.callbackFail('Failed to set active devices.', function() { 473 }, chrome.test.callbackFail('Failed to set active devices.', function() {
289 getDevices(function(outputs, inputs) { 474 chrome.audio.getDevices({
290 chrome.test.assertEq( 475 isActive: true
291 originalActiveInputs, getActiveDeviceIds(inputs).sort()); 476 }, chrome.test.callbackPass(function(devices) {
292 chrome.test.assertEq( 477 chrome.test.assertEq(initialActiveIds, getDeviceIds(devices));
293 originalActiveOutputs, getActiveDeviceIds(outputs).sort()); 478 }));
294 });
295 })); 479 }));
296 }); 480 }));
297 }, 481 },
298 482
299 function setActiveDevicesFailOutputTest() { 483 function setActiveDevicesFailOutputTest() {
300 getDevices(function(originalOutputs, originalInputs) { 484 chrome.audio.getDevices({
301 var originalActiveInputs = getActiveDeviceIds(originalInputs).sort(); 485 isActive: true
302 chrome.test.assertTrue(originalActiveInputs.length > 0); 486 }, chrome.test.callbackPass(function(initial) {
303 487 var initialActiveIds = getDeviceIds(initial);
304 var originalActiveOutputs = getActiveDeviceIds(originalOutputs).sort(); 488 chrome.test.assertTrue(initialActiveIds.length > 0);
305 chrome.test.assertTrue(originalActiveOutputs.length > 0);
306 489
307 chrome.audio.setActiveDevices({ 490 chrome.audio.setActiveDevices({
308 input: [], 491 input: [],
309 output: ['40001'] /* id is input node ID */ 492 output: ['40001'] /* id is input node ID */
310 }, chrome.test.callbackFail('Failed to set active devices.', function() { 493 }, chrome.test.callbackFail('Failed to set active devices.', function() {
311 getDevices(function(outputs, inputs) { 494 chrome.audio.getDevices({
312 chrome.test.assertEq( 495 isActive: true
313 originalActiveInputs, getActiveDeviceIds(inputs).sort()); 496 }, chrome.test.callbackPass(function(devices) {
314 chrome.test.assertEq( 497 chrome.test.assertEq(initialActiveIds, getDeviceIds(devices));
315 originalActiveOutputs, getActiveDeviceIds(outputs).sort()); 498 }));
316 });
317 })); 499 }));
318 }); 500 }));
319 }, 501 },
320 502
321 function clearActiveDevicesTest() { 503 function clearActiveDevicesTest() {
322 getDevices(function(originalOutputs, originalInputs) { 504 chrome.audio.getDevices({
323 chrome.test.assertTrue(getActiveDeviceIds(originalInputs).length > 0); 505 isActive: true
324 chrome.test.assertTrue(getActiveDeviceIds(originalOutputs).length > 0); 506 }, chrome.test.callbackPass(function(initial) {
507 chrome.test.assertTrue(getDeviceIds(initial).length > 0);
325 508
326 chrome.audio.setActiveDevices({ 509 chrome.audio.setActiveDevices({
327 input: [], 510 input: [],
328 output: [] 511 output: []
329 }, chrome.test.callbackPass(function() { 512 }, chrome.test.callbackPass(function() {
330 getDevices(function(outputs, inputs) { 513 chrome.audio.getDevices({
331 chrome.test.assertEq([], getActiveDeviceIds(inputs)); 514 isActive: true
332 chrome.test.assertEq([], getActiveDeviceIds(outputs)); 515 }, chrome.test.callbackPass(function(devices) {
333 }); 516 chrome.test.assertEq([], devices);
517 }));
334 })); 518 }));
335 }); 519 }));
336 }, 520 },
337 ]); 521 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698