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

Side by Side Diff: chrome/browser/media/webrtc_browsertest_base.cc

Issue 216773002: Relanding Switched main WebRTC browser tests to use a more realistic video (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 #include "chrome/browser/media/webrtc_browsertest_base.h" 5 #include "chrome/browser/media/webrtc_browsertest_base.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/infobars/infobar.h" 10 #include "chrome/browser/infobars/infobar.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndAccept( 85 void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndAccept(
86 content::WebContents* tab_contents, 86 content::WebContents* tab_contents,
87 const std::string& constraints) const { 87 const std::string& constraints) const {
88 InfoBar* infobar = GetUserMediaAndWaitForInfoBar(tab_contents, constraints); 88 InfoBar* infobar = GetUserMediaAndWaitForInfoBar(tab_contents, constraints);
89 infobar->delegate()->AsConfirmInfoBarDelegate()->Accept(); 89 infobar->delegate()->AsConfirmInfoBarDelegate()->Accept();
90 CloseInfoBarInTab(tab_contents, infobar); 90 CloseInfoBarInTab(tab_contents, infobar);
91 91
92 // Wait for WebRTC to call the success callback. 92 // Wait for WebRTC to call the success callback.
93 const char kOkGotStream[] = "ok-got-stream"; 93 const char kOkGotStream[] = "ok-got-stream";
94 EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", kOkGotStream, 94 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", kOkGotStream,
95 tab_contents)); 95 tab_contents));
96 } 96 }
97 97
98 void WebRtcTestBase::GetUserMediaAndDeny(content::WebContents* tab_contents) { 98 void WebRtcTestBase::GetUserMediaAndDeny(content::WebContents* tab_contents) {
99 return GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, 99 return GetUserMediaWithSpecificConstraintsAndDeny(tab_contents,
100 kAudioVideoCallConstraints); 100 kAudioVideoCallConstraints);
101 } 101 }
102 102
103 void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndDeny( 103 void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndDeny(
104 content::WebContents* tab_contents, 104 content::WebContents* tab_contents,
105 const std::string& constraints) const { 105 const std::string& constraints) const {
106 InfoBar* infobar = GetUserMediaAndWaitForInfoBar(tab_contents, constraints); 106 InfoBar* infobar = GetUserMediaAndWaitForInfoBar(tab_contents, constraints);
107 infobar->delegate()->AsConfirmInfoBarDelegate()->Cancel(); 107 infobar->delegate()->AsConfirmInfoBarDelegate()->Cancel();
108 CloseInfoBarInTab(tab_contents, infobar); 108 CloseInfoBarInTab(tab_contents, infobar);
109 109
110 // Wait for WebRTC to call the fail callback. 110 // Wait for WebRTC to call the fail callback.
111 EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", 111 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()",
112 kFailedWithPermissionDeniedError, tab_contents)); 112 kFailedWithPermissionDeniedError,
113 tab_contents));
113 } 114 }
114 115
115 void WebRtcTestBase::GetUserMediaAndDismiss( 116 void WebRtcTestBase::GetUserMediaAndDismiss(
116 content::WebContents* tab_contents) const { 117 content::WebContents* tab_contents) const {
117 InfoBar* infobar = 118 InfoBar* infobar =
118 GetUserMediaAndWaitForInfoBar(tab_contents, kAudioVideoCallConstraints); 119 GetUserMediaAndWaitForInfoBar(tab_contents, kAudioVideoCallConstraints);
119 infobar->delegate()->InfoBarDismissed(); 120 infobar->delegate()->InfoBarDismissed();
120 CloseInfoBarInTab(tab_contents, infobar); 121 CloseInfoBarInTab(tab_contents, infobar);
121 122
122 // A dismiss should be treated like a deny. 123 // A dismiss should be treated like a deny.
123 EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", 124 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()",
124 kFailedWithPermissionDismissedError, 125 kFailedWithPermissionDismissedError,
125 tab_contents)); 126 tab_contents));
126 } 127 }
127 128
128 void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents, 129 void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents,
129 const std::string& constraints) const { 130 const std::string& constraints) const {
130 // Request user media: this will launch the media stream info bar. 131 // Request user media: this will launch the media stream info bar.
131 std::string result; 132 std::string result;
132 EXPECT_TRUE(content::ExecuteScriptAndExtractString( 133 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
133 tab_contents, "doGetUserMedia(" + constraints + ");", &result)); 134 tab_contents, "doGetUserMedia(" + constraints + ");", &result));
134 EXPECT_EQ("ok-requested", result); 135 EXPECT_EQ("ok-requested", result);
135 } 136 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 return result; 226 return result;
226 } 227 }
227 228
228 // The peer connection server lets our two tabs find each other and talk to 229 // The peer connection server lets our two tabs find each other and talk to
229 // each other (e.g. it is the application-specific "signaling solution"). 230 // each other (e.g. it is the application-specific "signaling solution").
230 void WebRtcTestBase::ConnectToPeerConnectionServer( 231 void WebRtcTestBase::ConnectToPeerConnectionServer(
231 const std::string& peer_name, 232 const std::string& peer_name,
232 content::WebContents* tab_contents) const { 233 content::WebContents* tab_contents) const {
233 std::string javascript = base::StringPrintf( 234 std::string javascript = base::StringPrintf(
234 "connect('http://localhost:%s', '%s');", 235 "connect('http://localhost:%s', '%s');",
235 PeerConnectionServerRunner::kDefaultPort, peer_name.c_str()); 236 test::PeerConnectionServerRunner::kDefaultPort, peer_name.c_str());
236 EXPECT_EQ("ok-connected", ExecuteJavascript(javascript, tab_contents)); 237 EXPECT_EQ("ok-connected", ExecuteJavascript(javascript, tab_contents));
237 } 238 }
238 239
239 void WebRtcTestBase::EstablishCall(content::WebContents* from_tab, 240 void WebRtcTestBase::EstablishCall(content::WebContents* from_tab,
240 content::WebContents* to_tab) const { 241 content::WebContents* to_tab) const {
241 ConnectToPeerConnectionServer("peer 1", from_tab); 242 ConnectToPeerConnectionServer("peer 1", from_tab);
242 ConnectToPeerConnectionServer("peer 2", to_tab); 243 ConnectToPeerConnectionServer("peer 2", to_tab);
243 244
244 EXPECT_EQ("ok-peerconnection-created", 245 EXPECT_EQ("ok-peerconnection-created",
245 ExecuteJavascript("preparePeerConnection()", from_tab)); 246 ExecuteJavascript("preparePeerConnection()", from_tab));
246 EXPECT_EQ("ok-added", ExecuteJavascript("addLocalStream()", from_tab)); 247 EXPECT_EQ("ok-added", ExecuteJavascript("addLocalStream()", from_tab));
247 EXPECT_EQ("ok-negotiating", ExecuteJavascript("negotiateCall()", from_tab)); 248 EXPECT_EQ("ok-negotiating", ExecuteJavascript("negotiateCall()", from_tab));
248 249
249 // Ensure the call gets up on both sides. 250 // Ensure the call gets up on both sides.
250 EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()", 251 EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
251 "active", from_tab)); 252 "active", from_tab));
252 EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()", 253 EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
253 "active", to_tab)); 254 "active", to_tab));
254 } 255 }
255 256
256 void WebRtcTestBase::HangUp(content::WebContents* from_tab) const { 257 void WebRtcTestBase::HangUp(content::WebContents* from_tab) const {
257 EXPECT_EQ("ok-call-hung-up", ExecuteJavascript("hangUp()", from_tab)); 258 EXPECT_EQ("ok-call-hung-up", ExecuteJavascript("hangUp()", from_tab));
258 } 259 }
259 260
260 void WebRtcTestBase::WaitUntilHangupVerified( 261 void WebRtcTestBase::WaitUntilHangupVerified(
261 content::WebContents* tab_contents) const { 262 content::WebContents* tab_contents) const {
262 EXPECT_TRUE(PollingWaitUntil("getPeerConnectionReadyState()", 263 EXPECT_TRUE(test::PollingWaitUntil("getPeerConnectionReadyState()",
263 "no-peer-connection", tab_contents)); 264 "no-peer-connection", tab_contents));
264 } 265 }
265 266
266 void WebRtcTestBase::DetectErrorsInJavaScript() { 267 void WebRtcTestBase::DetectErrorsInJavaScript() {
267 detect_errors_in_javascript_ = true; 268 detect_errors_in_javascript_ = true;
268 } 269 }
269 270
270 void WebRtcTestBase::StartDetectingVideo( 271 void WebRtcTestBase::StartDetectingVideo(
271 content::WebContents* tab_contents, 272 content::WebContents* tab_contents,
272 const std::string& video_element) const { 273 const std::string& video_element) const {
273 std::string javascript = base::StringPrintf( 274 std::string javascript = base::StringPrintf(
274 "startDetection('%s', 320, 240)", video_element.c_str()); 275 "startDetection('%s', 320, 240)", video_element.c_str());
275 EXPECT_EQ("ok-started", ExecuteJavascript(javascript, tab_contents)); 276 EXPECT_EQ("ok-started", ExecuteJavascript(javascript, tab_contents));
276 } 277 }
277 278
278 void WebRtcTestBase::WaitForVideoToPlay( 279 void WebRtcTestBase::WaitForVideoToPlay(
279 content::WebContents* tab_contents) const { 280 content::WebContents* tab_contents) const {
280 EXPECT_TRUE(PollingWaitUntil("isVideoPlaying()", "video-playing", 281 EXPECT_TRUE(test::PollingWaitUntil("isVideoPlaying()", "video-playing",
281 tab_contents)); 282 tab_contents));
282 } 283 }
OLDNEW
« no previous file with comments | « chrome/browser/media/chrome_webrtc_video_quality_browsertest.cc ('k') | chrome/browser/media/webrtc_browsertest_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698