Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/infobars/infobar.h" | 9 #include "chrome/browser/infobars/infobar.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| 11 #include "chrome/browser/media/media_stream_infobar_delegate.h" | 11 #include "chrome/browser/media/media_stream_infobar_delegate.h" |
| 12 #include "chrome/browser/media/webrtc_browsertest_common.h" | 12 #include "chrome/browser/media/webrtc_browsertest_common.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_tabstrip.h" | |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 17 #include "content/public/test/browser_test_utils.h" | 18 #include "content/public/test/browser_test_utils.h" |
| 18 | 19 |
| 19 const char WebRtcTestBase::kAudioVideoCallConstraints[] = | 20 const char WebRtcTestBase::kAudioVideoCallConstraints[] = |
| 20 "'{audio: true, video: true}'"; | 21 "'{audio: true, video: true}'"; |
| 21 const char WebRtcTestBase::kAudioOnlyCallConstraints[] = "'{audio: true}'"; | 22 const char WebRtcTestBase::kAudioOnlyCallConstraints[] = "'{audio: true}'"; |
| 22 const char WebRtcTestBase::kVideoOnlyCallConstraints[] = "'{video: true}'"; | 23 const char WebRtcTestBase::kVideoOnlyCallConstraints[] = "'{video: true}'"; |
| 23 const char WebRtcTestBase::kFailedWithPermissionDeniedError[] = | 24 const char WebRtcTestBase::kFailedWithPermissionDeniedError[] = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 infobar->InfoBarDismissed(); | 75 infobar->InfoBarDismissed(); |
| 75 CloseInfoBarInTab(tab_contents, infobar); | 76 CloseInfoBarInTab(tab_contents, infobar); |
| 76 | 77 |
| 77 // A dismiss should be treated like a deny. | 78 // A dismiss should be treated like a deny. |
| 78 EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", | 79 EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", |
| 79 kFailedWithPermissionDeniedError, tab_contents)); | 80 kFailedWithPermissionDeniedError, tab_contents)); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents, | 83 void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents, |
| 83 const std::string& constraints) const { | 84 const std::string& constraints) const { |
| 84 // TODO(phoglund): temporary debugging measure for crbug.com/281268. | |
| 85 std::string javascript = | |
| 86 "if (typeof(doGetUserMedia) != typeof(Function)) {\n" | |
| 87 " console.log('hitting weird js load bug: diagnosing...');\n" | |
| 88 " for (var v in window) {\n" | |
| 89 " if (window.hasOwnProperty(v)) console.log(v);\n" | |
| 90 " }\n" | |
| 91 " window.domAutomationController.send('failed!');\n" | |
| 92 "}\n" | |
| 93 "else\n" | |
| 94 " doGetUserMedia(" + constraints + ");"; | |
| 95 // Request user media: this will launch the media stream info bar. | 85 // Request user media: this will launch the media stream info bar. |
| 96 std::string result; | 86 std::string result; |
| 97 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 87 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| 98 tab_contents, javascript, &result)); | 88 tab_contents, "doGetUserMedia(" + constraints + ");", &result)); |
| 99 EXPECT_EQ("ok-requested", result); | 89 EXPECT_EQ("ok-requested", result); |
| 100 } | 90 } |
| 101 | 91 |
| 102 MediaStreamInfoBarDelegate* WebRtcTestBase::GetUserMediaAndWaitForInfoBar( | 92 MediaStreamInfoBarDelegate* WebRtcTestBase::GetUserMediaAndWaitForInfoBar( |
| 103 content::WebContents* tab_contents, | 93 content::WebContents* tab_contents, |
| 104 const std::string& constraints) const { | 94 const std::string& constraints) const { |
| 105 content::WindowedNotificationObserver infobar_added( | 95 content::WindowedNotificationObserver infobar_added( |
| 106 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 96 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
| 107 content::NotificationService::AllSources()); | 97 content::NotificationService::AllSources()); |
| 108 | 98 |
| 109 // Request user media: this will launch the media stream info bar. | 99 // Request user media: this will launch the media stream info bar. |
| 110 GetUserMedia(tab_contents, constraints); | 100 GetUserMedia(tab_contents, constraints); |
| 111 | 101 |
| 112 // Wait for the bar to pop up, then return it. | 102 // Wait for the bar to pop up, then return it. |
| 113 infobar_added.Wait(); | 103 infobar_added.Wait(); |
| 114 content::Details<InfoBar::AddedDetails> details(infobar_added.details()); | 104 content::Details<InfoBar::AddedDetails> details(infobar_added.details()); |
| 115 MediaStreamInfoBarDelegate* infobar = details->AsMediaStreamInfoBarDelegate(); | 105 MediaStreamInfoBarDelegate* infobar = details->AsMediaStreamInfoBarDelegate(); |
| 116 EXPECT_TRUE(infobar); | 106 EXPECT_TRUE(infobar); |
| 117 return infobar; | 107 return infobar; |
| 118 } | 108 } |
| 119 | 109 |
| 110 content::WebContents* WebRtcTestBase::OpenPageAndGetUserMediaInNewTab( | |
| 111 const GURL& url) const { | |
| 112 chrome::AddTabAt(browser(), GURL(), -1, true); | |
| 113 ui_test_utils::NavigateToURL(browser(), url); | |
| 114 #if defined (OS_LINUX) | |
| 115 // Load the page again on Linux to work around crbug.com/281268. | |
| 116 ui_test_utils::NavigateToURL(browser(), url); | |
|
Ami GONE FROM CHROMIUM
2013/12/05 19:35:24
Shot in the dark: is it possible that NavigateToUR
tommi (sloooow) - chröme
2013/12/09 15:30:53
Is it possible to hook up to the onload event inst
| |
| 117 #endif | |
| 118 content::WebContents* new_tab = | |
| 119 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 120 GetUserMediaAndAccept(new_tab); | |
| 121 return new_tab; | |
| 122 } | |
| 123 | |
| 120 content::WebContents* WebRtcTestBase::OpenPageAndAcceptUserMedia( | 124 content::WebContents* WebRtcTestBase::OpenPageAndAcceptUserMedia( |
| 121 const GURL& url) const { | 125 const GURL& url) const { |
| 122 content::WindowedNotificationObserver infobar_added( | 126 content::WindowedNotificationObserver infobar_added( |
| 123 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 127 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
| 124 content::NotificationService::AllSources()); | 128 content::NotificationService::AllSources()); |
| 125 | 129 |
| 126 ui_test_utils::NavigateToURL(browser(), url); | 130 ui_test_utils::NavigateToURL(browser(), url); |
| 127 | 131 |
| 128 infobar_added.Wait(); | 132 infobar_added.Wait(); |
| 129 | 133 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 // The peer connection server lets our two tabs find each other and talk to | 171 // The peer connection server lets our two tabs find each other and talk to |
| 168 // each other (e.g. it is the application-specific "signaling solution"). | 172 // each other (e.g. it is the application-specific "signaling solution"). |
| 169 void WebRtcTestBase::ConnectToPeerConnectionServer( | 173 void WebRtcTestBase::ConnectToPeerConnectionServer( |
| 170 const std::string& peer_name, | 174 const std::string& peer_name, |
| 171 content::WebContents* tab_contents) const { | 175 content::WebContents* tab_contents) const { |
| 172 std::string javascript = base::StringPrintf( | 176 std::string javascript = base::StringPrintf( |
| 173 "connect('http://localhost:%s', '%s');", | 177 "connect('http://localhost:%s', '%s');", |
| 174 PeerConnectionServerRunner::kDefaultPort, peer_name.c_str()); | 178 PeerConnectionServerRunner::kDefaultPort, peer_name.c_str()); |
| 175 EXPECT_EQ("ok-connected", ExecuteJavascript(javascript, tab_contents)); | 179 EXPECT_EQ("ok-connected", ExecuteJavascript(javascript, tab_contents)); |
| 176 } | 180 } |
| OLD | NEW |