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

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, 11 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 chrome.test.assertFalse(updatedInput.gain === 55); 154 chrome.test.assertFalse(updatedInput.gain === 55);
155 updatedInput.isMuted = true; 155 updatedInput.isMuted = true;
156 updatedInput.gain = 55; 156 updatedInput.gain = 55;
157 157
158 var expectedOutput = deviceListToExpectedDevicesMap(originalOutputInfo); 158 var expectedOutput = deviceListToExpectedDevicesMap(originalOutputInfo);
159 // Update expected output devices with values that should be changed in 159 // Update expected output devices with values that should be changed in
160 // test. 160 // test.
161 var updatedOutput = expectedOutput['30001']; 161 var updatedOutput = expectedOutput['30001'];
162 chrome.test.assertFalse(updatedOutput.isMuted); 162 chrome.test.assertFalse(updatedOutput.isMuted);
163 chrome.test.assertFalse(updatedOutput.volume === 35); 163 chrome.test.assertFalse(updatedOutput.volume === 35);
164 updatedOutput.isMuted = true;
165 updatedOutput.volume = 35; 164 updatedOutput.volume = 35;
166 165
167 chrome.audio.setProperties('30001', { 166 chrome.audio.setProperties('30001', {
168 isMuted: true,
169 volume: 35 167 volume: 35
170 }, chrome.test.callbackPass(function() { 168 }, chrome.test.callbackPass(function() {
171 chrome.audio.setProperties('40002', { 169 chrome.audio.setProperties('40002', {
172 isMuted: true, 170 isMuted: true,
173 gain: 55 171 gain: 55
174 }, chrome.test.callbackPass(function() { 172 }, chrome.test.callbackPass(function() {
175 chrome.audio.getInfo( 173 chrome.audio.getInfo(
176 chrome.test.callbackPass(function(outputInfo, inputInfo) { 174 chrome.test.callbackPass(function(outputInfo, inputInfo) {
177 assertDevicesMatch(expectedInput, inputInfo); 175 assertDevicesMatch(expectedInput, inputInfo);
178 assertDevicesMatch(expectedOutput, outputInfo); 176 assertDevicesMatch(expectedOutput, outputInfo);
179 })); 177 }));
180 })); 178 }));
181 })); 179 }));
182 }); 180 });
183 }, 181 },
184 182
183 function inputMuteTest() {
184 var getMute = function(callback) {
185 chrome.audio.getMute('INPUT', chrome.test.callbackPass(callback));
186 };
187 getMute(function(originalValue) {
188 chrome.audio.setMute('INPUT', !originalValue,
189 chrome.test.callbackPass(function() {
190 getMute(function(value) {
191 chrome.test.assertEq(!originalValue, value);
192 });
193 }));
194 });
195 },
196
197 function outputMuteTest() {
198 var getMute = function(callback) {
199 chrome.audio.getMute('OUTPUT', chrome.test.callbackPass(callback));
200 };
201 getMute(function(originalValue) {
202 chrome.audio.setMute('OUTPUT', !originalValue,
203 chrome.test.callbackPass(function() {
204 getMute(function(value) {
205 chrome.test.assertEq(!originalValue, value);
206 });
207 }));
208 });
209 },
210
185 function setPropertiesInvalidValuesTest() { 211 function setPropertiesInvalidValuesTest() {
186 chrome.audio.getInfo(function(originalOutputInfo, originalInputInfo) { 212 chrome.audio.getInfo(function(originalOutputInfo, originalInputInfo) {
187 chrome.test.assertNoLastError(); 213 chrome.test.assertNoLastError();
188 var expectedInput = deviceListToExpectedDevicesMap(originalInputInfo); 214 var expectedInput = deviceListToExpectedDevicesMap(originalInputInfo);
189 var expectedOutput = deviceListToExpectedDevicesMap(originalOutputInfo); 215 var expectedOutput = deviceListToExpectedDevicesMap(originalOutputInfo);
216 var expectedError = 'Could not set volume/gain properties';
190 217
191 chrome.audio.setProperties('30001', { 218 chrome.audio.setProperties('30001', {
192 isMuted: true, 219 isMuted: true,
193 // Output device - should have volume set. 220 // Output device - should have volume set.
194 gain: 55 221 gain: 55
195 }, chrome.test.callbackFail('Could not set properties', function() { 222 }, chrome.test.callbackFail(expectedError, function() {
196 chrome.audio.setProperties('40002', { 223 chrome.audio.setProperties('40002', {
197 isMuted: true, 224 isMuted: true,
198 // Input device - should have gain set. 225 // Input device - should have gain set.
199 volume:55 226 volume:55
200 }, chrome.test.callbackFail('Could not set properties', function() { 227 }, chrome.test.callbackFail(expectedError, function() {
201 // Assert that device properties haven't changed. 228 // Assert that device properties haven't changed.
202 chrome.audio.getInfo( 229 chrome.audio.getInfo(
203 chrome.test.callbackPass(function(outputInfo, inputInfo) { 230 chrome.test.callbackPass(function(outputInfo, inputInfo) {
204 assertDevicesMatch(expectedOutput, outputInfo); 231 assertDevicesMatch(expectedOutput, outputInfo);
205 assertDevicesMatch(expectedInput, inputInfo); 232 assertDevicesMatch(expectedInput, inputInfo);
206 })); 233 }));
207 })); 234 }));
208 })); 235 }));
209 }); 236 });
210 } 237 }
211 ]); 238 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698