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

Side by Side Diff: chrome/test/data/webrtc/getusermedia.js

Issue 1161153003: Convert the WebRtcTestBase to use infobar and bubble autoresponders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix MANUAL test Created 5 years, 6 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
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /** 7 /**
8 * See http://dev.w3.org/2011/webrtc/editor/getusermedia.html for more 8 * See http://dev.w3.org/2011/webrtc/editor/getusermedia.html for more
9 * information on getUserMedia. 9 * information on getUserMedia.
10 */ 10 */
(...skipping 21 matching lines...) Expand all
32 * Used as a shortcut. Moved to the top of the page due to race conditions. 32 * Used as a shortcut. Moved to the top of the page due to race conditions.
33 * @param {string} id is a case-sensitive string representing the unique ID of 33 * @param {string} id is a case-sensitive string representing the unique ID of
34 * the element being sought. 34 * the element being sought.
35 * @return {string} id returns the element object specified as a parameter 35 * @return {string} id returns the element object specified as a parameter
36 */ 36 */
37 $ = function(id) { 37 $ = function(id) {
38 return document.getElementById(id); 38 return document.getElementById(id);
39 }; 39 };
40 40
41 /** 41 /**
42 * This function asks permission to use the webcam and mic from the browser. It 42 * This function asks permission to use the webcam and mic from the browser.
43 * will return ok-requested to the test. This does not mean the request was 43 * Its callbacks will return either request-callback-granted or
44 * approved though. The test will then have to click past the dialog that 44 * request-callback-denied depending on the outcome. If the caller does not
45 * appears in Chrome, which will run either the OK or failed callback as a 45 * successfully resolve the request by granting or denying, the test will hang.
46 * a result. To see which callback was called, use obtainGetUserMediaResult(). 46 * To verify which callback was called, use obtainGetUserMediaResult().
47 * 47 *
48 * @param {!object} constraints Defines what to be requested, with mandatory 48 * @param {!object} constraints Defines what to be requested, with mandatory
49 * and optional constraints defined. The contents of this parameter depends 49 * and optional constraints defined. The contents of this parameter depends
50 * on the WebRTC version. 50 * on the WebRTC version.
51 */ 51 */
52 function doGetUserMedia(constraints) { 52 function doGetUserMedia(constraints) {
53 if (!getUserMedia) { 53 if (!getUserMedia) {
54 returnToTest('Browser does not support WebRTC.'); 54 returnToTest('Browser does not support WebRTC.');
55 return; 55 return;
56 } 56 }
57 debug('Requesting doGetUserMedia: constraints: ' + 57 debug('Requesting doGetUserMedia: constraints: ' +
58 JSON.stringify(constraints, null, 0).replace(/[\r\n]/g, '')); 58 JSON.stringify(constraints, null, 0).replace(/[\r\n]/g, ''));
59 getUserMedia(constraints, 59 getUserMedia(constraints,
60 function(stream) { 60 function(stream) {
61 ensureGotAllExpectedStreams_(stream, constraints); 61 ensureGotAllExpectedStreams_(stream, constraints);
62 getUserMediaOkCallback_(stream); 62 getUserMediaOkCallback_(stream);
63 }, 63 },
64 getUserMediaFailedCallback_); 64 getUserMediaFailedCallback_);
65 returnToTest('ok-requested');
66 } 65 }
67 66
68 /** 67 /**
69 * Must be called after calling doGetUserMedia. 68 * Must be called after calling doGetUserMedia.
70 * @return {string} Returns not-called-yet if we have not yet been called back 69 * @return {string} Returns not-called-yet if we have not yet been called back
71 * by WebRTC. Otherwise it returns either ok-got-stream or 70 * by WebRTC. Otherwise it returns either ok-got-stream or
72 * failed-with-error-x (where x is the error code from the error 71 * failed-with-error-x (where x is the error code from the error
73 * callback) depending on which callback got called by WebRTC. 72 * callback) depending on which callback got called by WebRTC.
74 */ 73 */
75 function obtainGetUserMediaResult() { 74 function obtainGetUserMediaResult() {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 148
150 /** 149 /**
151 * @private 150 * @private
152 * @param {MediaStream} stream Media stream. 151 * @param {MediaStream} stream Media stream.
153 */ 152 */
154 function getUserMediaOkCallback_(stream) { 153 function getUserMediaOkCallback_(stream) {
155 gLocalStream = stream; 154 gLocalStream = stream;
156 gRequestWebcamAndMicrophoneResult = 'ok-got-stream'; 155 gRequestWebcamAndMicrophoneResult = 'ok-got-stream';
157 156
158 attachMediaStream($('local-view'), stream); 157 attachMediaStream($('local-view'), stream);
158
159 returnToTest('request-callback-granted');
159 } 160 }
160 161
161 /** 162 /**
162 * @private 163 * @private
163 * @param {NavigatorUserMediaError} error Error containing details. 164 * @param {NavigatorUserMediaError} error Error containing details.
164 */ 165 */
165 function getUserMediaFailedCallback_(error) { 166 function getUserMediaFailedCallback_(error) {
166 // Translate from the old error to the new. Remove when rename fully deployed. 167 // Translate from the old error to the new. Remove when rename fully deployed.
167 var errorName = error.name; 168 var errorName = error.name;
168 169
169 debug('GetUserMedia FAILED: Maybe the camera is in use by another process?'); 170 debug('GetUserMedia FAILED: Maybe the camera is in use by another process?');
170 gRequestWebcamAndMicrophoneResult = 'failed-with-error-' + errorName; 171 gRequestWebcamAndMicrophoneResult = 'failed-with-error-' + errorName;
171 debug(gRequestWebcamAndMicrophoneResult); 172 debug(gRequestWebcamAndMicrophoneResult);
173
174 returnToTest('request-callback-denied');
172 } 175 }
OLDNEW
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698