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

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

Issue 2578473002: chrome.audio API: treat mute as system wide property (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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 chrome.test.assertFalse(updatedInput.gain === 55); 160 chrome.test.assertFalse(updatedInput.gain === 55);
161 updatedInput.isMuted = true; 161 updatedInput.isMuted = true;
162 updatedInput.gain = 55; 162 updatedInput.gain = 55;
163 163
164 var expectedOutput = deviceListToExpectedDevicesMap(originalOutputInfo); 164 var expectedOutput = deviceListToExpectedDevicesMap(originalOutputInfo);
165 // Update expected output devices with values that should be changed in 165 // Update expected output devices with values that should be changed in
166 // test. 166 // test.
167 var updatedOutput = expectedOutput['30001']; 167 var updatedOutput = expectedOutput['30001'];
168 chrome.test.assertFalse(updatedOutput.isMuted); 168 chrome.test.assertFalse(updatedOutput.isMuted);
169 chrome.test.assertFalse(updatedOutput.volume === 35); 169 chrome.test.assertFalse(updatedOutput.volume === 35);
170 updatedOutput.isMuted = true;
171 updatedOutput.volume = 35; 170 updatedOutput.volume = 35;
172 171
173 chrome.audio.setProperties('30001', { 172 chrome.audio.setProperties('30001', {
174 isMuted: true,
175 volume: 35 173 volume: 35
176 }, chrome.test.callbackPass(function() { 174 }, chrome.test.callbackPass(function() {
177 chrome.audio.setProperties('40002', { 175 chrome.audio.setProperties('40002', {
178 isMuted: true, 176 isMuted: true,
179 gain: 55 177 gain: 55
180 }, chrome.test.callbackPass(function() { 178 }, chrome.test.callbackPass(function() {
181 getDevices( 179 getDevices(
182 chrome.test.callbackPass(function(outputInfo, inputInfo) { 180 chrome.test.callbackPass(function(outputInfo, inputInfo) {
183 assertDevicesMatch(expectedInput, inputInfo); 181 assertDevicesMatch(expectedInput, inputInfo);
184 assertDevicesMatch(expectedOutput, outputInfo); 182 assertDevicesMatch(expectedOutput, outputInfo);
185 })); 183 }));
186 })); 184 }));
187 })); 185 }));
188 }); 186 });
189 }, 187 },
190 188
189 function inputMuteTest() {
190 var getMute = function(callback) {
191 chrome.audio.getMute('INPUT', chrome.test.callbackPass(callback));
192 };
193 getMute(function(originalValue) {
194 chrome.audio.setMute(
195 'INPUT', !originalValue, chrome.test.callbackPass(function() {
196 getMute(function(value) {
197 chrome.test.assertEq(!originalValue, value);
198 });
199 }));
200 });
201 },
202
203 function outputMuteTest() {
204 var getMute = function(callback) {
205 chrome.audio.getMute('OUTPUT', chrome.test.callbackPass(callback));
206 };
207 getMute(function(originalValue) {
208 chrome.audio.setMute(
209 'OUTPUT', !originalValue, chrome.test.callbackPass(function() {
210 getMute(function(value) {
211 chrome.test.assertEq(!originalValue, value);
212 });
213 }));
214 });
215 },
216
191 function setPropertiesInvalidValuesTest() { 217 function setPropertiesInvalidValuesTest() {
192 getDevices(function(originalOutputInfo, originalInputInfo) { 218 getDevices(function(originalOutputInfo, originalInputInfo) {
193 var expectedInput = deviceListToExpectedDevicesMap(originalInputInfo); 219 var expectedInput = deviceListToExpectedDevicesMap(originalInputInfo);
194 var expectedOutput = deviceListToExpectedDevicesMap(originalOutputInfo); 220 var expectedOutput = deviceListToExpectedDevicesMap(originalOutputInfo);
221 var expectedError = 'Could not set volume/gain properties';
195 222
196 chrome.audio.setProperties('30001', { 223 chrome.audio.setProperties(
197 isMuted: true, 224 '30001', {
198 // Output device - should have volume set. 225 isMuted: true,
199 gain: 55 226 // Output device - should have volume set.
200 }, chrome.test.callbackFail('Could not set properties', function() { 227 gain: 55
201 chrome.audio.setProperties('40002', { 228 },
202 isMuted: true, 229 chrome.test.callbackFail(expectedError, function() {
203 // Input device - should have gain set. 230 chrome.audio.setProperties(
204 volume:55 231 '40002', {
205 }, chrome.test.callbackFail('Could not set properties', function() { 232 isMuted: true,
206 // Assert that device properties haven't changed. 233 // Input device - should have gain set.
207 getDevices(function(outputInfo, inputInfo) { 234 volume: 55
208 assertDevicesMatch(expectedOutput, outputInfo); 235 },
209 assertDevicesMatch(expectedInput, inputInfo); 236 chrome.test.callbackFail(expectedError, function() {
210 }); 237 // Assert that device properties haven't changed.
211 })); 238 getDevices(function(outputInfo, inputInfo) {
212 })); 239 assertDevicesMatch(expectedOutput, outputInfo);
240 assertDevicesMatch(expectedInput, inputInfo);
241 });
242 }));
243 }));
213 }); 244 });
214 }, 245 },
215 246
216 function setActiveDevicesTest() { 247 function setActiveDevicesTest() {
217 chrome.audio.setActiveDevices({ 248 chrome.audio.setActiveDevices({
218 input: ['40002', '40003'], 249 input: ['40002', '40003'],
219 output: ['30001'] 250 output: ['30001']
220 }, chrome.test.callbackPass(function() { 251 }, chrome.test.callbackPass(function() {
221 getDevices(function(outputs, inputs) { 252 getDevices(function(outputs, inputs) {
222 chrome.test.assertEq( 253 chrome.test.assertEq(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 output: [] 328 output: []
298 }, chrome.test.callbackPass(function() { 329 }, chrome.test.callbackPass(function() {
299 getDevices(function(outputs, inputs) { 330 getDevices(function(outputs, inputs) {
300 chrome.test.assertEq([], getActiveDeviceIds(inputs)); 331 chrome.test.assertEq([], getActiveDeviceIds(inputs));
301 chrome.test.assertEq([], getActiveDeviceIds(outputs)); 332 chrome.test.assertEq([], getActiveDeviceIds(outputs));
302 }); 333 });
303 })); 334 }));
304 }); 335 });
305 }, 336 },
306 ]); 337 ]);
OLDNEW
« no previous file with comments | « extensions/test/data/api_test/audio/output_mute_change/background.js ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698