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

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

Issue 102163002: Revert 238283 "Infobar system refactor." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
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/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"
(...skipping 20 matching lines...) Expand all
31 31
32 void WebRtcTestBase::GetUserMediaAndAccept( 32 void WebRtcTestBase::GetUserMediaAndAccept(
33 content::WebContents* tab_contents) const { 33 content::WebContents* tab_contents) const {
34 GetUserMediaWithSpecificConstraintsAndAccept(tab_contents, 34 GetUserMediaWithSpecificConstraintsAndAccept(tab_contents,
35 kAudioVideoCallConstraints); 35 kAudioVideoCallConstraints);
36 } 36 }
37 37
38 void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndAccept( 38 void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndAccept(
39 content::WebContents* tab_contents, 39 content::WebContents* tab_contents,
40 const std::string& constraints) const { 40 const std::string& constraints) const {
41 InfoBar* infobar = GetUserMediaAndWaitForInfoBar(tab_contents, constraints); 41 MediaStreamInfoBarDelegate* infobar =
42 infobar->delegate()->AsConfirmInfoBarDelegate()->Accept(); 42 GetUserMediaAndWaitForInfoBar(tab_contents, constraints);
43 infobar->Accept();
43 CloseInfoBarInTab(tab_contents, infobar); 44 CloseInfoBarInTab(tab_contents, infobar);
44 45
45 // Wait for WebRTC to call the success callback. 46 // Wait for WebRTC to call the success callback.
46 const char kOkGotStream[] = "ok-got-stream"; 47 const char kOkGotStream[] = "ok-got-stream";
47 EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", kOkGotStream, 48 EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", kOkGotStream,
48 tab_contents)); 49 tab_contents));
49 } 50 }
50 51
51 void WebRtcTestBase::GetUserMediaAndDeny(content::WebContents* tab_contents) { 52 void WebRtcTestBase::GetUserMediaAndDeny(content::WebContents* tab_contents) {
52 return GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, 53 return GetUserMediaWithSpecificConstraintsAndDeny(tab_contents,
53 kAudioVideoCallConstraints); 54 kAudioVideoCallConstraints);
54 } 55 }
55 56
56 void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndDeny( 57 void WebRtcTestBase::GetUserMediaWithSpecificConstraintsAndDeny(
57 content::WebContents* tab_contents, 58 content::WebContents* tab_contents,
58 const std::string& constraints) const { 59 const std::string& constraints) const {
59 InfoBar* infobar = GetUserMediaAndWaitForInfoBar(tab_contents, constraints); 60 MediaStreamInfoBarDelegate* infobar =
60 infobar->delegate()->AsConfirmInfoBarDelegate()->Cancel(); 61 GetUserMediaAndWaitForInfoBar(tab_contents, constraints);
62 infobar->Cancel();
61 CloseInfoBarInTab(tab_contents, infobar); 63 CloseInfoBarInTab(tab_contents, infobar);
62 64
63 // Wait for WebRTC to call the fail callback. 65 // Wait for WebRTC to call the fail callback.
64 EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", 66 EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()",
65 kFailedWithPermissionDeniedError, tab_contents)); 67 kFailedWithPermissionDeniedError, tab_contents));
66 } 68 }
67 69
68 void WebRtcTestBase::GetUserMediaAndDismiss( 70 void WebRtcTestBase::GetUserMediaAndDismiss(
69 content::WebContents* tab_contents) const { 71 content::WebContents* tab_contents) const {
70 InfoBar* infobar = 72 MediaStreamInfoBarDelegate* infobar =
71 GetUserMediaAndWaitForInfoBar(tab_contents, kAudioVideoCallConstraints); 73 GetUserMediaAndWaitForInfoBar(tab_contents, kAudioVideoCallConstraints);
72 infobar->delegate()->InfoBarDismissed(); 74 infobar->InfoBarDismissed();
73 CloseInfoBarInTab(tab_contents, infobar); 75 CloseInfoBarInTab(tab_contents, infobar);
74 76
75 // A dismiss should be treated like a deny. 77 // A dismiss should be treated like a deny.
76 EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()", 78 EXPECT_TRUE(PollingWaitUntil("obtainGetUserMediaResult()",
77 kFailedWithPermissionDeniedError, tab_contents)); 79 kFailedWithPermissionDeniedError, tab_contents));
78 } 80 }
79 81
80 void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents, 82 void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents,
81 const std::string& constraints) const { 83 const std::string& constraints) const {
82 // TODO(phoglund): temporary debugging measure for crbug.com/281268. 84 // TODO(phoglund): temporary debugging measure for crbug.com/281268.
83 std::string javascript = 85 std::string javascript =
84 "if (typeof(doGetUserMedia) != typeof(Function)) {\n" 86 "if (typeof(doGetUserMedia) != typeof(Function)) {\n"
85 " console.log('hitting weird js load bug: diagnosing...');\n" 87 " console.log('hitting weird js load bug: diagnosing...');\n"
86 " for (var v in window) {\n" 88 " for (var v in window) {\n"
87 " if (window.hasOwnProperty(v)) console.log(v);\n" 89 " if (window.hasOwnProperty(v)) console.log(v);\n"
88 " }\n" 90 " }\n"
89 " window.domAutomationController.send('failed!');\n" 91 " window.domAutomationController.send('failed!');\n"
90 "}\n" 92 "}\n"
91 "else\n" 93 "else\n"
92 " doGetUserMedia(" + constraints + ");"; 94 " doGetUserMedia(" + constraints + ");";
93 // Request user media: this will launch the media stream info bar. 95 // Request user media: this will launch the media stream info bar.
94 std::string result; 96 std::string result;
95 EXPECT_TRUE(content::ExecuteScriptAndExtractString( 97 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
96 tab_contents, javascript, &result)); 98 tab_contents, javascript, &result));
97 EXPECT_EQ("ok-requested", result); 99 EXPECT_EQ("ok-requested", result);
98 } 100 }
99 101
100 InfoBar* WebRtcTestBase::GetUserMediaAndWaitForInfoBar( 102 MediaStreamInfoBarDelegate* WebRtcTestBase::GetUserMediaAndWaitForInfoBar(
101 content::WebContents* tab_contents, 103 content::WebContents* tab_contents,
102 const std::string& constraints) const { 104 const std::string& constraints) const {
103 content::WindowedNotificationObserver infobar_added( 105 content::WindowedNotificationObserver infobar_added(
104 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 106 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
105 content::NotificationService::AllSources()); 107 content::NotificationService::AllSources());
106 108
107 // Request user media: this will launch the media stream info bar. 109 // Request user media: this will launch the media stream info bar.
108 GetUserMedia(tab_contents, constraints); 110 GetUserMedia(tab_contents, constraints);
109 111
110 // Wait for the bar to pop up, then return it. 112 // Wait for the bar to pop up, then return it.
111 infobar_added.Wait(); 113 infobar_added.Wait();
112 content::Details<InfoBar::AddedDetails> details(infobar_added.details()); 114 content::Details<InfoBar::AddedDetails> details(infobar_added.details());
113 EXPECT_TRUE(details->delegate()->AsMediaStreamInfoBarDelegate()); 115 MediaStreamInfoBarDelegate* infobar = details->AsMediaStreamInfoBarDelegate();
114 return details.ptr(); 116 EXPECT_TRUE(infobar);
117 return infobar;
115 } 118 }
116 119
117 content::WebContents* WebRtcTestBase::OpenPageAndAcceptUserMedia( 120 content::WebContents* WebRtcTestBase::OpenPageAndAcceptUserMedia(
118 const GURL& url) const { 121 const GURL& url) const {
119 content::WindowedNotificationObserver infobar_added( 122 content::WindowedNotificationObserver infobar_added(
120 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, 123 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
121 content::NotificationService::AllSources()); 124 content::NotificationService::AllSources());
122 125
123 ui_test_utils::NavigateToURL(browser(), url); 126 ui_test_utils::NavigateToURL(browser(), url);
124 127
125 infobar_added.Wait(); 128 infobar_added.Wait();
126 129
127 content::WebContents* tab_contents = 130 content::WebContents* tab_contents =
128 browser()->tab_strip_model()->GetActiveWebContents(); 131 browser()->tab_strip_model()->GetActiveWebContents();
129 content::Details<InfoBar::AddedDetails> details(infobar_added.details()); 132 content::Details<InfoBar::AddedDetails> details(infobar_added.details());
130 InfoBar* infobar = details.ptr(); 133 MediaStreamInfoBarDelegate* infobar =
134 details->AsMediaStreamInfoBarDelegate();
131 EXPECT_TRUE(infobar); 135 EXPECT_TRUE(infobar);
132 infobar->delegate()->AsMediaStreamInfoBarDelegate()->Accept(); 136 infobar->Accept();
133 137
134 CloseInfoBarInTab(tab_contents, infobar); 138 CloseInfoBarInTab(tab_contents, infobar);
135 return tab_contents; 139 return tab_contents;
136 } 140 }
137 141
138 void WebRtcTestBase::CloseInfoBarInTab( 142 void WebRtcTestBase::CloseInfoBarInTab(
139 content::WebContents* tab_contents, 143 content::WebContents* tab_contents,
140 InfoBar* infobar) const { 144 MediaStreamInfoBarDelegate* infobar) const {
141 content::WindowedNotificationObserver infobar_removed( 145 content::WindowedNotificationObserver infobar_removed(
142 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, 146 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
143 content::NotificationService::AllSources()); 147 content::NotificationService::AllSources());
144 148
145 InfoBarService* infobar_service = 149 InfoBarService* infobar_service =
146 InfoBarService::FromWebContents(tab_contents); 150 InfoBarService::FromWebContents(tab_contents);
147 infobar_service->RemoveInfoBar(infobar); 151 infobar_service->RemoveInfoBar(infobar);
148 152
149 infobar_removed.Wait(); 153 infobar_removed.Wait();
150 } 154 }
(...skipping 12 matching lines...) Expand all
163 // The peer connection server lets our two tabs find each other and talk to 167 // The peer connection server lets our two tabs find each other and talk to
164 // each other (e.g. it is the application-specific "signaling solution"). 168 // each other (e.g. it is the application-specific "signaling solution").
165 void WebRtcTestBase::ConnectToPeerConnectionServer( 169 void WebRtcTestBase::ConnectToPeerConnectionServer(
166 const std::string& peer_name, 170 const std::string& peer_name,
167 content::WebContents* tab_contents) const { 171 content::WebContents* tab_contents) const {
168 std::string javascript = base::StringPrintf( 172 std::string javascript = base::StringPrintf(
169 "connect('http://localhost:%s', '%s');", 173 "connect('http://localhost:%s', '%s');",
170 PeerConnectionServerRunner::kDefaultPort, peer_name.c_str()); 174 PeerConnectionServerRunner::kDefaultPort, peer_name.c_str());
171 EXPECT_EQ("ok-connected", ExecuteJavascript(javascript, tab_contents)); 175 EXPECT_EQ("ok-connected", ExecuteJavascript(javascript, tab_contents));
172 } 176 }
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/media/webrtc_browsertest_base.h ('k') | trunk/src/chrome/browser/nacl_host/nacl_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698