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

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

Issue 1175443002: Revert of Convert the WebRtcTestBase to use infobar and bubble autoresponders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
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_service.h"
9 #include "chrome/browser/media/media_stream_devices_controller.h" 10 #include "chrome/browser/media/media_stream_devices_controller.h"
10 #include "chrome/browser/media/webrtc_browsertest_base.h" 11 #include "chrome/browser/media/webrtc_browsertest_base.h"
11 #include "chrome/browser/media/webrtc_browsertest_common.h" 12 #include "chrome/browser/media/webrtc_browsertest_common.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_tabstrip.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/browser/ui/website_settings/permission_bubble_manager.h" 17 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
17 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
18 #include "chrome/test/base/in_process_browser_test.h" 19 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/test_switches.h" 20 #include "chrome/test/base/test_switches.h"
20 #include "chrome/test/base/ui_test_utils.h" 21 #include "chrome/test/base/ui_test_utils.h"
21 #include "components/content_settings/core/browser/host_content_settings_map.h" 22 #include "components/content_settings/core/browser/host_content_settings_map.h"
22 #include "components/content_settings/core/common/content_settings_types.h" 23 #include "components/content_settings/core/common/content_settings_types.h"
24 #include "components/infobars/core/infobar.h"
23 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
24 #include "content/public/common/media_stream_request.h" 26 #include "content/public/common/media_stream_request.h"
25 #include "content/public/test/browser_test_utils.h" 27 #include "content/public/test/browser_test_utils.h"
26 #include "media/base/media_switches.h" 28 #include "media/base/media_switches.h"
27 #include "net/test/spawned_test_server/spawned_test_server.h" 29 #include "net/test/spawned_test_server/spawned_test_server.h"
28 30
29 // MediaStreamPermissionTest --------------------------------------------------- 31 // MediaStreamPermissionTest ---------------------------------------------------
30 32
31 class MediaStreamPermissionTest : public WebRtcTestBase, 33 class MediaStreamPermissionTest : public WebRtcTestBase,
32 public testing::WithParamInterface<bool> { 34 public testing::WithParamInterface<bool> {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // Dummy callback for when we deny the current request directly. 107 // Dummy callback for when we deny the current request directly.
106 static void OnMediaStreamResponse(const content::MediaStreamDevices& devices, 108 static void OnMediaStreamResponse(const content::MediaStreamDevices& devices,
107 content::MediaStreamRequestResult result, 109 content::MediaStreamRequestResult result,
108 scoped_ptr<content::MediaStreamUI> ui) {} 110 scoped_ptr<content::MediaStreamUI> ui) {}
109 111
110 DISALLOW_COPY_AND_ASSIGN(MediaStreamPermissionTest); 112 DISALLOW_COPY_AND_ASSIGN(MediaStreamPermissionTest);
111 }; 113 };
112 114
113 // Actual tests --------------------------------------------------------------- 115 // Actual tests ---------------------------------------------------------------
114 116
115 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestAllowingUserMedia) { 117 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
118 DISABLED_TestAllowingUserMedia) {
116 content::WebContents* tab_contents = LoadTestPageInTab(); 119 content::WebContents* tab_contents = LoadTestPageInTab();
117 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); 120 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
118 } 121 }
119 122
120 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestDenyingUserMedia) { 123 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
124 DISABLED_TestDenyingUserMedia) {
121 content::WebContents* tab_contents = LoadTestPageInTab(); 125 content::WebContents* tab_contents = LoadTestPageInTab();
122 GetUserMediaAndDeny(tab_contents); 126 GetUserMediaAndDeny(tab_contents);
123 } 127 }
124 128
125 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestDismissingRequest) { 129 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
130 DISABLED_TestDismissingInfobar) {
126 content::WebContents* tab_contents = LoadTestPageInTab(); 131 content::WebContents* tab_contents = LoadTestPageInTab();
127 GetUserMediaAndDismiss(tab_contents); 132 GetUserMediaAndDismiss(tab_contents);
128 } 133 }
129 134
130 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, 135 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
131 TestDenyingUserMediaIncognito) { 136 DISABLED_TestDenyingUserMediaIncognito) {
132 content::WebContents* tab_contents = LoadTestPageInIncognitoTab(); 137 content::WebContents* tab_contents = LoadTestPageInIncognitoTab();
133 GetUserMediaAndDeny(tab_contents); 138 GetUserMediaAndDeny(tab_contents);
134 } 139 }
135 140
136 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, 141 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
137 TestAcceptThenDenyWhichShouldBeSticky) { 142 DISABLED_TestAcceptThenDenyWhichShouldBeSticky) {
138 #if defined(OS_WIN) && defined(USE_ASH) 143 #if defined(OS_WIN) && defined(USE_ASH)
139 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 144 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
140 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 145 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
141 switches::kAshBrowserTests)) 146 switches::kAshBrowserTests))
142 return; 147 return;
143 #endif 148 #endif
144 149
145 content::WebContents* tab_contents = LoadTestPageInTab(); 150 content::WebContents* tab_contents = LoadTestPageInTab();
146 151
147 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); 152 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
148 GetUserMediaAndDeny(tab_contents); 153 GetUserMediaAndDeny(tab_contents);
149 154
150 // Should fail with permission denied, instead of hanging. 155 // Should fail with permission denied right away with no infobar popping up.
151 GetUserMedia(tab_contents, kAudioVideoCallConstraints); 156 GetUserMedia(tab_contents, kAudioVideoCallConstraints);
152 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", 157 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()",
153 kFailedWithPermissionDeniedError, 158 kFailedWithPermissionDeniedError,
154 tab_contents)); 159 tab_contents));
160 InfoBarService* infobar_service =
161 InfoBarService::FromWebContents(tab_contents);
162 EXPECT_EQ(0u, infobar_service->infobar_count());
155 } 163 }
156 164
157 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestAcceptIsNotSticky) { 165 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
166 DISABLED_TestAcceptIsNotSticky) {
158 content::WebContents* tab_contents = LoadTestPageInTab(); 167 content::WebContents* tab_contents = LoadTestPageInTab();
159 168
160 // If accept were sticky the second call would hang because it hangs if an 169 // If accept were sticky the second call would hang because it hangs if an
161 // infobar or bubble does not pop up. 170 // infobar does not pop up.
162 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); 171 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
163 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); 172 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
164 } 173 }
165 174
166 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestDismissIsNotSticky) { 175 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
176 DISABLED_TestDismissIsNotSticky) {
167 content::WebContents* tab_contents = LoadTestPageInTab(); 177 content::WebContents* tab_contents = LoadTestPageInTab();
168 178
169 // If dismiss were sticky the second call would hang because it hangs if an 179 // If dismiss were sticky the second call would hang because it hangs if an
170 // infobar or bubble does not pop up. 180 // infobar does not pop up.
171 GetUserMediaAndDismiss(tab_contents); 181 GetUserMediaAndDismiss(tab_contents);
172 GetUserMediaAndDismiss(tab_contents); 182 GetUserMediaAndDismiss(tab_contents);
173 } 183 }
174 184
175 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, 185 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
176 TestDenyingThenClearingStickyException) { 186 DISABLED_TestDenyingThenClearingStickyException) {
177 content::WebContents* tab_contents = LoadTestPageInTab(); 187 content::WebContents* tab_contents = LoadTestPageInTab();
178 188
179 GetUserMediaAndDeny(tab_contents); 189 GetUserMediaAndDeny(tab_contents);
180 190
181 HostContentSettingsMap* settings_map = 191 HostContentSettingsMap* settings_map =
182 browser()->profile()->GetHostContentSettingsMap(); 192 browser()->profile()->GetHostContentSettingsMap();
183 193
184 settings_map->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 194 settings_map->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
185 settings_map->ClearSettingsForOneType( 195 settings_map->ClearSettingsForOneType(
186 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 196 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
187 197
188 // If an infobar or bubble is not launched now, this will hang. 198 // If an infobar is not launched now, this will hang.
189 GetUserMediaAndDeny(tab_contents); 199 GetUserMediaAndDeny(tab_contents);
190 } 200 }
191 201
192 // Times out on win debug builds; http://crbug.com/295723 . 202 // Times out on win debug builds; http://crbug.com/295723 .
193 #if defined(OS_WIN) && !defined(NDEBUG) 203 #if defined(OS_WIN) && !defined(NDEBUG)
194 #define MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras \ 204 #define MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras \
195 DISABLED_DenyingMicDoesNotCauseStickyDenyForCameras 205 DISABLED_DenyingMicDoesNotCauseStickyDenyForCameras
196 #else 206 #else
197 #define MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras \ 207 #define MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras \
198 DenyingMicDoesNotCauseStickyDenyForCameras 208 DenyingMicDoesNotCauseStickyDenyForCameras
199 #endif 209 #endif
200 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, 210 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
201 MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras) { 211 MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras) {
202 content::WebContents* tab_contents = LoadTestPageInTab(); 212 content::WebContents* tab_contents = LoadTestPageInTab();
203 213
204 // If mic blocking also blocked cameras, the second call here would hang. 214 // If mic blocking also blocked cameras, the second call here would hang.
205 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, 215 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents,
206 kAudioOnlyCallConstraints); 216 kAudioOnlyCallConstraints);
207 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept( 217 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept(
208 tab_contents, kVideoOnlyCallConstraints)); 218 tab_contents, kVideoOnlyCallConstraints));
209 } 219 }
210 220
211 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, 221 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest,
212 DenyingCameraDoesNotCauseStickyDenyForMics) { 222 DISABLED_DenyingCameraDoesNotCauseStickyDenyForMics) {
213 content::WebContents* tab_contents = LoadTestPageInTab(); 223 content::WebContents* tab_contents = LoadTestPageInTab();
214 224
215 // If camera blocking also blocked mics, the second call here would hang. 225 // If camera blocking also blocked mics, the second call here would hang.
216 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, 226 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents,
217 kVideoOnlyCallConstraints); 227 kVideoOnlyCallConstraints);
218 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept( 228 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept(
219 tab_contents, kAudioOnlyCallConstraints)); 229 tab_contents, kAudioOnlyCallConstraints));
220 } 230 }
221 231
222 INSTANTIATE_TEST_CASE_P(MediaStreamPermissionTestWithParams, 232 INSTANTIATE_TEST_CASE_P(MediaStreamPermissionTestWithParams,
223 MediaStreamPermissionTest, 233 MediaStreamPermissionTest,
224 testing::Values(false, true)); 234 testing::Values(false, true));
OLDNEW
« no previous file with comments | « chrome/browser/infobars/infobar_responder.cc ('k') | chrome/browser/media/webrtc_browsertest_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698