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

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

Issue 99333010: Working around the page load problem on Linux, re-enable tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years 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
« no previous file with comments | « chrome/browser/media/webrtc_browsertest_base.h ('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 // 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"
11 #include "chrome/browser/infobars/infobar_service.h" 11 #include "chrome/browser/infobars/infobar_service.h"
12 #include "chrome/browser/media/media_stream_infobar_delegate.h" 12 #include "chrome/browser/media/media_stream_infobar_delegate.h"
13 #include "chrome/browser/media/webrtc_browsertest_common.h" 13 #include "chrome/browser/media/webrtc_browsertest_common.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_tabstrip.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/test/base/ui_test_utils.h" 17 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "content/public/test/browser_test_utils.h" 19 #include "content/public/test/browser_test_utils.h"
19 20
20 const char WebRtcTestBase::kAudioVideoCallConstraints[] = 21 const char WebRtcTestBase::kAudioVideoCallConstraints[] =
21 "'{audio: true, video: true}'"; 22 "'{audio: true, video: true}'";
22 const char WebRtcTestBase::kAudioOnlyCallConstraints[] = "'{audio: true}'"; 23 const char WebRtcTestBase::kAudioOnlyCallConstraints[] = "'{audio: true}'";
23 const char WebRtcTestBase::kVideoOnlyCallConstraints[] = "'{video: true}'"; 24 const char WebRtcTestBase::kVideoOnlyCallConstraints[] = "'{video: true}'";
24 const char WebRtcTestBase::kFailedWithPermissionDeniedError[] = 25 const char WebRtcTestBase::kFailedWithPermissionDeniedError[] =
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 infobar->delegate()->InfoBarDismissed(); 111 infobar->delegate()->InfoBarDismissed();
111 CloseInfoBarInTab(tab_contents, infobar); 112 CloseInfoBarInTab(tab_contents, infobar);
112 113
113 // A dismiss should be treated like a deny. 114 // A dismiss should be treated like a deny.
114 EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", 115 EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()",
115 kFailedWithPermissionDeniedError, tab_contents)); 116 kFailedWithPermissionDeniedError, tab_contents));
116 } 117 }
117 118
118 void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents, 119 void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents,
119 const std::string& constraints) const { 120 const std::string& constraints) const {
120 // TODO(phoglund): temporary debugging measure for crbug.com/281268.
121 std::string javascript =
122 "if (typeof(doGetUserMedia) != typeof(Function)) {\n"
123 " console.log('hitting weird js load bug: diagnosing...');\n"
124 " for (var v in window) {\n"
125 " if (window.hasOwnProperty(v)) console.log(v);\n"
126 " }\n"
127 " window.domAutomationController.send('failed!');\n"
128 "}\n"
129 "else\n"
130 " doGetUserMedia(" + constraints + ");";
131 // Request user media: this will launch the media stream info bar. 121 // Request user media: this will launch the media stream info bar.
132 std::string result; 122 std::string result;
133 EXPECT_TRUE(content::ExecuteScriptAndExtractString( 123 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
134 tab_contents, javascript, &result)); 124 tab_contents, "doGetUserMedia(" + constraints + ");", &result));
135 EXPECT_EQ("ok-requested", result); 125 EXPECT_EQ("ok-requested", result);
136 } 126 }
137 127
138 InfoBar* WebRtcTestBase::GetUserMediaAndWaitForInfoBar( 128 InfoBar* WebRtcTestBase::GetUserMediaAndWaitForInfoBar(
139 content::WebContents* tab_contents, 129 content::WebContents* tab_contents,
140 const std::string& constraints) const { 130 const std::string& constraints) const {
141 content::WindowedNotificationObserver infobar_added( 131 content::WindowedNotificationObserver infobar_added(
142 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 132 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
143 content::NotificationService::AllSources()); 133 content::NotificationService::AllSources());
144 134
145 // Request user media: this will launch the media stream info bar. 135 // Request user media: this will launch the media stream info bar.
146 GetUserMedia(tab_contents, constraints); 136 GetUserMedia(tab_contents, constraints);
147 137
148 // Wait for the bar to pop up, then return it. 138 // Wait for the bar to pop up, then return it.
149 infobar_added.Wait(); 139 infobar_added.Wait();
150 content::Details<InfoBar::AddedDetails> details(infobar_added.details()); 140 content::Details<InfoBar::AddedDetails> details(infobar_added.details());
151 EXPECT_TRUE(details->delegate()->AsMediaStreamInfoBarDelegate()); 141 EXPECT_TRUE(details->delegate()->AsMediaStreamInfoBarDelegate());
152 return details.ptr(); 142 return details.ptr();
153 } 143 }
154 144
145 content::WebContents* WebRtcTestBase::OpenPageAndGetUserMediaInNewTab(
146 const GURL& url) const {
147 chrome::AddTabAt(browser(), GURL(), -1, true);
148 ui_test_utils::NavigateToURL(browser(), url);
149 #if defined (OS_LINUX)
150 // Load the page again on Linux to work around crbug.com/281268.
151 ui_test_utils::NavigateToURL(browser(), url);
152 #endif
153 content::WebContents* new_tab =
154 browser()->tab_strip_model()->GetActiveWebContents();
155 GetUserMediaAndAccept(new_tab);
156 return new_tab;
157 }
158
155 content::WebContents* WebRtcTestBase::OpenPageAndAcceptUserMedia( 159 content::WebContents* WebRtcTestBase::OpenPageAndAcceptUserMedia(
156 const GURL& url) const { 160 const GURL& url) const {
157 content::WindowedNotificationObserver infobar_added( 161 content::WindowedNotificationObserver infobar_added(
158 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 162 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
159 content::NotificationService::AllSources()); 163 content::NotificationService::AllSources());
160 164
161 ui_test_utils::NavigateToURL(browser(), url); 165 ui_test_utils::NavigateToURL(browser(), url);
162 166
163 infobar_added.Wait(); 167 infobar_added.Wait();
164 168
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 content::WebContents* tab_contents) const { 209 content::WebContents* tab_contents) const {
206 std::string javascript = base::StringPrintf( 210 std::string javascript = base::StringPrintf(
207 "connect('http://localhost:%s', '%s');", 211 "connect('http://localhost:%s', '%s');",
208 PeerConnectionServerRunner::kDefaultPort, peer_name.c_str()); 212 PeerConnectionServerRunner::kDefaultPort, peer_name.c_str());
209 EXPECT_EQ("ok-connected", ExecuteJavascript(javascript, tab_contents)); 213 EXPECT_EQ("ok-connected", ExecuteJavascript(javascript, tab_contents));
210 } 214 }
211 215
212 void WebRtcTestBase::DetectErrorsInJavaScript() { 216 void WebRtcTestBase::DetectErrorsInJavaScript() {
213 detect_errors_in_javascript_ = true; 217 detect_errors_in_javascript_ = true;
214 } 218 }
OLDNEW
« no previous file with comments | « chrome/browser/media/webrtc_browsertest_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698