OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" |
8 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/run_loop.h" |
| 11 #include "base/test/scoped_feature_list.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 12 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
11 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" | 14 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
12 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" | 15 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" |
13 #include "chrome/browser/media/webrtc/media_stream_device_permissions.h" | 16 #include "chrome/browser/media/webrtc/media_stream_device_permissions.h" |
14 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" | 17 #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" |
15 #include "chrome/browser/media/webrtc/webrtc_browsertest_base.h" | 18 #include "chrome/browser/media/webrtc/webrtc_browsertest_base.h" |
16 #include "chrome/browser/permissions/permission_context_base.h" | 19 #include "chrome/browser/permissions/permission_context_base.h" |
| 20 #include "chrome/browser/permissions/permission_request.h" |
17 #include "chrome/browser/permissions/permission_request_manager.h" | 21 #include "chrome/browser/permissions/permission_request_manager.h" |
18 #include "chrome/browser/permissions/permission_util.h" | 22 #include "chrome/browser/permissions/permission_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 25 #include "chrome/browser/ui/permission_bubble/mock_permission_prompt_factory.h" |
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 26 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 27 #include "chrome/common/chrome_features.h" |
22 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
23 #include "chrome/test/base/ui_test_utils.h" | 29 #include "chrome/test/base/ui_test_utils.h" |
24 #include "components/content_settings/core/browser/host_content_settings_map.h" | 30 #include "components/content_settings/core/browser/host_content_settings_map.h" |
25 #include "components/prefs/pref_service.h" | 31 #include "components/prefs/pref_service.h" |
26 #include "components/variations/variations_associated_data.h" | 32 #include "components/variations/variations_associated_data.h" |
27 #include "content/public/browser/render_frame_host.h" | 33 #include "content/public/browser/render_frame_host.h" |
28 #include "content/public/common/media_stream_request.h" | 34 #include "content/public/common/media_stream_request.h" |
29 #include "content/public/test/mock_render_process_host.h" | 35 #include "content/public/test/mock_render_process_host.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
31 | 37 |
32 class MediaStreamDevicesControllerTest : public WebRtcTestBase { | 38 enum class TestType { |
| 39 DEFAULT, |
| 40 TEST_WITH_GROUPED_MEDIA_REQUESTS, |
| 41 }; |
| 42 |
| 43 class MediaStreamDevicesControllerTest |
| 44 : public WebRtcTestBase, |
| 45 public ::testing::WithParamInterface<TestType> { |
33 public: | 46 public: |
34 // TODO(raymes): When crbug.com/606138 is finished and the | 47 // TODO(raymes): When crbug.com/606138 is finished and the |
35 // PermissionRequestManager is used to show all prompts on Android/Desktop | 48 // PermissionRequestManager is used to show all prompts on Android/Desktop |
36 // we should remove PermissionPromptDelegate and just use | 49 // we should remove PermissionPromptDelegate and just use |
37 // MockPermissionPromptFactory instead. The APIs are the same. | 50 // MockPermissionPromptFactory instead. The APIs are the same. |
38 class TestPermissionPromptDelegate | 51 class TestPermissionPromptDelegate |
39 : public MediaStreamDevicesController::PermissionPromptDelegate { | 52 : public MediaStreamDevicesController::PermissionPromptDelegate { |
40 public: | 53 public: |
41 void ShowPrompt(bool user_gesture, | 54 void ShowPrompt(bool user_gesture, |
42 content::WebContents* web_contents, | 55 content::WebContents* web_contents, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 : example_audio_id_("fake_audio_dev"), | 90 : example_audio_id_("fake_audio_dev"), |
78 example_video_id_("fake_video_dev"), | 91 example_video_id_("fake_video_dev"), |
79 media_stream_result_(content::NUM_MEDIA_REQUEST_RESULTS) {} | 92 media_stream_result_(content::NUM_MEDIA_REQUEST_RESULTS) {} |
80 | 93 |
81 // Dummy callback for when we deny the current request directly. | 94 // Dummy callback for when we deny the current request directly. |
82 void OnMediaStreamResponse(const content::MediaStreamDevices& devices, | 95 void OnMediaStreamResponse(const content::MediaStreamDevices& devices, |
83 content::MediaStreamRequestResult result, | 96 content::MediaStreamRequestResult result, |
84 std::unique_ptr<content::MediaStreamUI> ui) { | 97 std::unique_ptr<content::MediaStreamUI> ui) { |
85 media_stream_devices_ = devices; | 98 media_stream_devices_ = devices; |
86 media_stream_result_ = result; | 99 media_stream_result_ = result; |
| 100 quit_closure_.Run(); |
| 101 quit_closure_ = base::Closure(); |
87 } | 102 } |
88 | 103 |
89 protected: | 104 protected: |
90 enum DeviceType { DEVICE_TYPE_AUDIO, DEVICE_TYPE_VIDEO }; | 105 enum DeviceType { DEVICE_TYPE_AUDIO, DEVICE_TYPE_VIDEO }; |
91 enum Access { ACCESS_ALLOWED, ACCESS_DENIED }; | 106 enum Access { ACCESS_ALLOWED, ACCESS_DENIED }; |
92 | 107 |
93 const GURL& example_url() const { return example_url_; } | 108 const GURL& example_url() const { return example_url_; } |
94 | 109 |
95 TabSpecificContentSettings* GetContentSettings() { | 110 TabSpecificContentSettings* GetContentSettings() { |
96 return TabSpecificContentSettings::FromWebContents(GetWebContents()); | 111 return TabSpecificContentSettings::FromWebContents(GetWebContents()); |
97 } | 112 } |
98 | 113 |
99 const std::string& example_audio_id() const { return example_audio_id_; } | 114 const std::string& example_audio_id() const { return example_audio_id_; } |
100 const std::string& example_video_id() const { return example_video_id_; } | 115 const std::string& example_video_id() const { return example_video_id_; } |
101 | 116 |
102 content::MediaStreamRequestResult media_stream_result() const { | 117 content::MediaStreamRequestResult media_stream_result() const { |
103 return media_stream_result_; | 118 return media_stream_result_; |
104 } | 119 } |
105 | 120 |
106 void RequestPermissions(content::WebContents* web_contents, | 121 void RequestPermissions(content::WebContents* web_contents, |
107 const content::MediaStreamRequest& request, | 122 const content::MediaStreamRequest& request, |
108 const content::MediaResponseCallback& callback) { | 123 const content::MediaResponseCallback& callback) { |
| 124 base::RunLoop run_loop; |
| 125 ASSERT_TRUE(quit_closure_.is_null()); |
| 126 quit_closure_ = run_loop.QuitClosure(); |
109 MediaStreamDevicesController::RequestPermissionsWithDelegate( | 127 MediaStreamDevicesController::RequestPermissionsWithDelegate( |
110 request, callback, &prompt_delegate_); | 128 request, callback, &prompt_delegate_); |
| 129 run_loop.Run(); |
111 } | 130 } |
112 | 131 |
113 TestPermissionPromptDelegate* prompt_delegate() { return &prompt_delegate_; } | |
114 | |
115 // Sets the device policy-controlled |access| for |example_url_| to be for the | 132 // Sets the device policy-controlled |access| for |example_url_| to be for the |
116 // selected |device_type|. | 133 // selected |device_type|. |
117 void SetDevicePolicy(DeviceType device_type, Access access) { | 134 void SetDevicePolicy(DeviceType device_type, Access access) { |
118 PrefService* prefs = Profile::FromBrowserContext( | 135 PrefService* prefs = Profile::FromBrowserContext( |
119 GetWebContents()->GetBrowserContext())->GetPrefs(); | 136 GetWebContents()->GetBrowserContext())->GetPrefs(); |
120 const char* policy_name = NULL; | 137 const char* policy_name = NULL; |
121 switch (device_type) { | 138 switch (device_type) { |
122 case DEVICE_TYPE_AUDIO: | 139 case DEVICE_TYPE_AUDIO: |
123 policy_name = prefs::kAudioCaptureAllowed; | 140 policy_name = prefs::kAudioCaptureAllowed; |
124 break; | 141 break; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 203 } |
187 | 204 |
188 void InitWithUrl(const GURL& url) { | 205 void InitWithUrl(const GURL& url) { |
189 DCHECK(example_url_.is_empty()); | 206 DCHECK(example_url_.is_empty()); |
190 example_url_ = url; | 207 example_url_ = url; |
191 ui_test_utils::NavigateToURL(browser(), example_url_); | 208 ui_test_utils::NavigateToURL(browser(), example_url_); |
192 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED, | 209 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED, |
193 GetContentSettings()->GetMicrophoneCameraState()); | 210 GetContentSettings()->GetMicrophoneCameraState()); |
194 } | 211 } |
195 | 212 |
| 213 void SetPromptResponseType( |
| 214 PermissionRequestManager::AutoResponseType response_type) { |
| 215 if (base::FeatureList::IsEnabled( |
| 216 features::kUsePermissionManagerForMediaRequests)) { |
| 217 prompt_factory_->set_response_type(response_type); |
| 218 } else { |
| 219 prompt_delegate_.set_response_type(response_type); |
| 220 } |
| 221 } |
| 222 |
| 223 size_t TotalPromptRequestCount() { |
| 224 if (base::FeatureList::IsEnabled( |
| 225 features::kUsePermissionManagerForMediaRequests)) { |
| 226 return prompt_factory_->TotalRequestCount(); |
| 227 } else { |
| 228 return prompt_delegate_.TotalRequestCount(); |
| 229 } |
| 230 } |
| 231 |
| 232 bool WasPermissionShown(ContentSettingsType type) { |
| 233 if (base::FeatureList::IsEnabled( |
| 234 features::kUsePermissionManagerForMediaRequests)) { |
| 235 if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { |
| 236 return prompt_factory_->RequestTypeSeen( |
| 237 PermissionRequestType::PERMISSION_MEDIASTREAM_MIC); |
| 238 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { |
| 239 return prompt_factory_->RequestTypeSeen( |
| 240 PermissionRequestType::PERMISSION_MEDIASTREAM_CAMERA); |
| 241 } else { |
| 242 NOTREACHED(); |
| 243 return false; |
| 244 } |
| 245 } else { |
| 246 return prompt_delegate_.WasRequested(type); |
| 247 } |
| 248 } |
| 249 |
| 250 void ResetPromptCounters() { |
| 251 if (base::FeatureList::IsEnabled( |
| 252 features::kUsePermissionManagerForMediaRequests)) { |
| 253 prompt_factory_->ResetCounts(); |
| 254 } else { |
| 255 prompt_delegate_.Reset(); |
| 256 } |
| 257 } |
| 258 |
196 private: | 259 private: |
197 void SetUpOnMainThread() override { | 260 void SetUpOnMainThread() override { |
198 WebRtcTestBase::SetUpOnMainThread(); | 261 WebRtcTestBase::SetUpOnMainThread(); |
199 | 262 |
| 263 if (static_cast<TestType>(GetParam()) == |
| 264 TestType::TEST_WITH_GROUPED_MEDIA_REQUESTS) { |
| 265 scoped_feature_list_.InitAndEnableFeature( |
| 266 features::kUsePermissionManagerForMediaRequests); |
| 267 PermissionRequestManager* manager = |
| 268 PermissionRequestManager::FromWebContents( |
| 269 browser()->tab_strip_model()->GetActiveWebContents()); |
| 270 prompt_factory_.reset(new MockPermissionPromptFactory(manager)); |
| 271 manager->DisplayPendingRequests(); |
| 272 } |
| 273 |
200 // Cleanup. | 274 // Cleanup. |
201 media_stream_devices_.clear(); | 275 media_stream_devices_.clear(); |
202 media_stream_result_ = content::NUM_MEDIA_REQUEST_RESULTS; | 276 media_stream_result_ = content::NUM_MEDIA_REQUEST_RESULTS; |
203 | 277 |
204 content::MediaStreamDevices audio_devices; | 278 content::MediaStreamDevices audio_devices; |
205 content::MediaStreamDevice fake_audio_device( | 279 content::MediaStreamDevice fake_audio_device( |
206 content::MEDIA_DEVICE_AUDIO_CAPTURE, example_audio_id_, | 280 content::MEDIA_DEVICE_AUDIO_CAPTURE, example_audio_id_, |
207 "Fake Audio Device"); | 281 "Fake Audio Device"); |
208 audio_devices.push_back(fake_audio_device); | 282 audio_devices.push_back(fake_audio_device); |
209 MediaCaptureDevicesDispatcher::GetInstance()->SetTestAudioCaptureDevices( | 283 MediaCaptureDevicesDispatcher::GetInstance()->SetTestAudioCaptureDevices( |
210 audio_devices); | 284 audio_devices); |
211 | 285 |
212 content::MediaStreamDevices video_devices; | 286 content::MediaStreamDevices video_devices; |
213 content::MediaStreamDevice fake_video_device( | 287 content::MediaStreamDevice fake_video_device( |
214 content::MEDIA_DEVICE_VIDEO_CAPTURE, example_video_id_, | 288 content::MEDIA_DEVICE_VIDEO_CAPTURE, example_video_id_, |
215 "Fake Video Device"); | 289 "Fake Video Device"); |
216 video_devices.push_back(fake_video_device); | 290 video_devices.push_back(fake_video_device); |
217 MediaCaptureDevicesDispatcher::GetInstance()->SetTestVideoCaptureDevices( | 291 MediaCaptureDevicesDispatcher::GetInstance()->SetTestVideoCaptureDevices( |
218 video_devices); | 292 video_devices); |
219 } | 293 } |
220 | 294 |
| 295 void TearDownOnMainThread() override { |
| 296 prompt_factory_.reset(); |
| 297 |
| 298 WebRtcTestBase::TearDownOnMainThread(); |
| 299 } |
| 300 |
221 GURL example_url_; | 301 GURL example_url_; |
222 const std::string example_audio_id_; | 302 const std::string example_audio_id_; |
223 const std::string example_video_id_; | 303 const std::string example_video_id_; |
224 | 304 |
225 content::MediaStreamDevices media_stream_devices_; | 305 content::MediaStreamDevices media_stream_devices_; |
226 content::MediaStreamRequestResult media_stream_result_; | 306 content::MediaStreamRequestResult media_stream_result_; |
227 | 307 |
| 308 base::Closure quit_closure_; |
| 309 |
228 TestPermissionPromptDelegate prompt_delegate_; | 310 TestPermissionPromptDelegate prompt_delegate_; |
| 311 std::unique_ptr<MockPermissionPromptFactory> prompt_factory_; |
| 312 |
| 313 base::test::ScopedFeatureList scoped_feature_list_; |
229 }; | 314 }; |
230 | 315 |
231 // Request and allow microphone access. | 316 // Request and allow microphone access. |
232 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndAllowMic) { | 317 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, RequestAndAllowMic) { |
233 InitWithUrl(GURL("https://www.example.com")); | 318 InitWithUrl(GURL("https://www.example.com")); |
234 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); | 319 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); |
235 // Ensure the prompt is accepted if necessary such that tab specific content | 320 // Ensure the prompt is accepted if necessary such that tab specific content |
236 // settings are updated. | 321 // settings are updated. |
237 prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 322 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
238 RequestPermissions( | 323 RequestPermissions( |
239 GetWebContents(), CreateRequest(example_audio_id(), std::string()), | 324 GetWebContents(), CreateRequest(example_audio_id(), std::string()), |
240 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 325 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
241 base::Unretained(this))); | 326 base::Unretained(this))); |
242 | 327 |
243 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( | 328 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( |
244 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 329 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
245 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( | 330 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( |
246 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 331 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
247 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_ACCESSED, | 332 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_ACCESSED, |
248 GetContentSettings()->GetMicrophoneCameraState()); | 333 GetContentSettings()->GetMicrophoneCameraState()); |
249 EXPECT_EQ(example_audio_id(), | 334 EXPECT_EQ(example_audio_id(), |
250 GetContentSettings()->media_stream_requested_audio_device()); | 335 GetContentSettings()->media_stream_requested_audio_device()); |
251 EXPECT_EQ(example_audio_id(), | 336 EXPECT_EQ(example_audio_id(), |
252 GetContentSettings()->media_stream_selected_audio_device()); | 337 GetContentSettings()->media_stream_selected_audio_device()); |
253 EXPECT_EQ(std::string(), | 338 EXPECT_EQ(std::string(), |
254 GetContentSettings()->media_stream_requested_video_device()); | 339 GetContentSettings()->media_stream_requested_video_device()); |
255 EXPECT_EQ(std::string(), | 340 EXPECT_EQ(std::string(), |
256 GetContentSettings()->media_stream_selected_video_device()); | 341 GetContentSettings()->media_stream_selected_video_device()); |
257 } | 342 } |
258 | 343 |
259 // Request and allow camera access. | 344 // Request and allow camera access. |
260 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndAllowCam) { | 345 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, RequestAndAllowCam) { |
261 InitWithUrl(GURL("https://www.example.com")); | 346 InitWithUrl(GURL("https://www.example.com")); |
262 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); | 347 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); |
263 // Ensure the prompt is accepted if necessary such that tab specific content | 348 // Ensure the prompt is accepted if necessary such that tab specific content |
264 // settings are updated. | 349 // settings are updated. |
265 prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 350 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
266 RequestPermissions( | 351 RequestPermissions( |
267 GetWebContents(), CreateRequest(std::string(), example_video_id()), | 352 GetWebContents(), CreateRequest(std::string(), example_video_id()), |
268 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 353 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
269 base::Unretained(this))); | 354 base::Unretained(this))); |
270 | 355 |
271 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( | 356 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( |
272 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 357 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
273 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( | 358 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( |
274 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 359 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
275 EXPECT_EQ(TabSpecificContentSettings::CAMERA_ACCESSED, | 360 EXPECT_EQ(TabSpecificContentSettings::CAMERA_ACCESSED, |
276 GetContentSettings()->GetMicrophoneCameraState()); | 361 GetContentSettings()->GetMicrophoneCameraState()); |
277 EXPECT_EQ(std::string(), | 362 EXPECT_EQ(std::string(), |
278 GetContentSettings()->media_stream_requested_audio_device()); | 363 GetContentSettings()->media_stream_requested_audio_device()); |
279 EXPECT_EQ(std::string(), | 364 EXPECT_EQ(std::string(), |
280 GetContentSettings()->media_stream_selected_audio_device()); | 365 GetContentSettings()->media_stream_selected_audio_device()); |
281 EXPECT_EQ(example_video_id(), | 366 EXPECT_EQ(example_video_id(), |
282 GetContentSettings()->media_stream_requested_video_device()); | 367 GetContentSettings()->media_stream_requested_video_device()); |
283 EXPECT_EQ(example_video_id(), | 368 EXPECT_EQ(example_video_id(), |
284 GetContentSettings()->media_stream_selected_video_device()); | 369 GetContentSettings()->media_stream_selected_video_device()); |
285 } | 370 } |
286 | 371 |
287 // Request and block microphone access. | 372 // Request and block microphone access. |
288 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndBlockMic) { | 373 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, RequestAndBlockMic) { |
289 InitWithUrl(GURL("https://www.example.com")); | 374 InitWithUrl(GURL("https://www.example.com")); |
290 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); | 375 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); |
291 // Ensure the prompt is accepted if necessary such that tab specific content | 376 // Ensure the prompt is accepted if necessary such that tab specific content |
292 // settings are updated. | 377 // settings are updated. |
293 prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 378 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
294 RequestPermissions( | 379 RequestPermissions( |
295 GetWebContents(), CreateRequest(example_audio_id(), std::string()), | 380 GetWebContents(), CreateRequest(example_audio_id(), std::string()), |
296 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 381 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
297 base::Unretained(this))); | 382 base::Unretained(this))); |
298 | 383 |
299 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( | 384 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( |
300 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 385 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
301 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( | 386 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( |
302 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 387 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
303 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_ACCESSED | | 388 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_ACCESSED | |
304 TabSpecificContentSettings::MICROPHONE_BLOCKED, | 389 TabSpecificContentSettings::MICROPHONE_BLOCKED, |
305 GetContentSettings()->GetMicrophoneCameraState()); | 390 GetContentSettings()->GetMicrophoneCameraState()); |
306 EXPECT_EQ(example_audio_id(), | 391 EXPECT_EQ(example_audio_id(), |
307 GetContentSettings()->media_stream_requested_audio_device()); | 392 GetContentSettings()->media_stream_requested_audio_device()); |
308 EXPECT_EQ(example_audio_id(), | 393 EXPECT_EQ(example_audio_id(), |
309 GetContentSettings()->media_stream_selected_audio_device()); | 394 GetContentSettings()->media_stream_selected_audio_device()); |
310 EXPECT_EQ(std::string(), | 395 EXPECT_EQ(std::string(), |
311 GetContentSettings()->media_stream_requested_video_device()); | 396 GetContentSettings()->media_stream_requested_video_device()); |
312 EXPECT_EQ(std::string(), | 397 EXPECT_EQ(std::string(), |
313 GetContentSettings()->media_stream_selected_video_device()); | 398 GetContentSettings()->media_stream_selected_video_device()); |
314 } | 399 } |
315 | 400 |
316 // Request and block camera access. | 401 // Request and block camera access. |
317 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndBlockCam) { | 402 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, RequestAndBlockCam) { |
318 InitWithUrl(GURL("https://www.example.com")); | 403 InitWithUrl(GURL("https://www.example.com")); |
319 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_DENIED); | 404 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_DENIED); |
320 // Ensure the prompt is accepted if necessary such that tab specific content | 405 // Ensure the prompt is accepted if necessary such that tab specific content |
321 // settings are updated. | 406 // settings are updated. |
322 prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 407 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
323 RequestPermissions( | 408 RequestPermissions( |
324 GetWebContents(), CreateRequest(std::string(), example_video_id()), | 409 GetWebContents(), CreateRequest(std::string(), example_video_id()), |
325 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 410 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
326 base::Unretained(this))); | 411 base::Unretained(this))); |
327 | 412 |
328 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( | 413 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( |
329 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 414 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
330 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( | 415 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( |
331 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 416 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
332 EXPECT_EQ(TabSpecificContentSettings::CAMERA_ACCESSED | | 417 EXPECT_EQ(TabSpecificContentSettings::CAMERA_ACCESSED | |
333 TabSpecificContentSettings::CAMERA_BLOCKED, | 418 TabSpecificContentSettings::CAMERA_BLOCKED, |
334 GetContentSettings()->GetMicrophoneCameraState()); | 419 GetContentSettings()->GetMicrophoneCameraState()); |
335 EXPECT_EQ(std::string(), | 420 EXPECT_EQ(std::string(), |
336 GetContentSettings()->media_stream_requested_audio_device()); | 421 GetContentSettings()->media_stream_requested_audio_device()); |
337 EXPECT_EQ(std::string(), | 422 EXPECT_EQ(std::string(), |
338 GetContentSettings()->media_stream_selected_audio_device()); | 423 GetContentSettings()->media_stream_selected_audio_device()); |
339 EXPECT_EQ(example_video_id(), | 424 EXPECT_EQ(example_video_id(), |
340 GetContentSettings()->media_stream_requested_video_device()); | 425 GetContentSettings()->media_stream_requested_video_device()); |
341 EXPECT_EQ(example_video_id(), | 426 EXPECT_EQ(example_video_id(), |
342 GetContentSettings()->media_stream_selected_video_device()); | 427 GetContentSettings()->media_stream_selected_video_device()); |
343 } | 428 } |
344 | 429 |
345 // Request and allow microphone and camera access. | 430 // Request and allow microphone and camera access. |
346 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 431 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
347 RequestAndAllowMicCam) { | 432 RequestAndAllowMicCam) { |
348 InitWithUrl(GURL("https://www.example.com")); | 433 InitWithUrl(GURL("https://www.example.com")); |
349 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); | 434 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); |
350 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); | 435 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); |
351 // Ensure the prompt is accepted if necessary such that tab specific content | 436 // Ensure the prompt is accepted if necessary such that tab specific content |
352 // settings are updated. | 437 // settings are updated. |
353 prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 438 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
354 RequestPermissions( | 439 RequestPermissions( |
355 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 440 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
356 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 441 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
357 base::Unretained(this))); | 442 base::Unretained(this))); |
358 | 443 |
359 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( | 444 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( |
360 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 445 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
361 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( | 446 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( |
362 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 447 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
363 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( | 448 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( |
364 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 449 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
365 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( | 450 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( |
366 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 451 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
367 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_ACCESSED | | 452 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_ACCESSED | |
368 TabSpecificContentSettings::CAMERA_ACCESSED, | 453 TabSpecificContentSettings::CAMERA_ACCESSED, |
369 GetContentSettings()->GetMicrophoneCameraState()); | 454 GetContentSettings()->GetMicrophoneCameraState()); |
370 EXPECT_EQ(example_audio_id(), | 455 EXPECT_EQ(example_audio_id(), |
371 GetContentSettings()->media_stream_requested_audio_device()); | 456 GetContentSettings()->media_stream_requested_audio_device()); |
372 EXPECT_EQ(example_audio_id(), | 457 EXPECT_EQ(example_audio_id(), |
373 GetContentSettings()->media_stream_selected_audio_device()); | 458 GetContentSettings()->media_stream_selected_audio_device()); |
374 EXPECT_EQ(example_video_id(), | 459 EXPECT_EQ(example_video_id(), |
375 GetContentSettings()->media_stream_requested_video_device()); | 460 GetContentSettings()->media_stream_requested_video_device()); |
376 EXPECT_EQ(example_video_id(), | 461 EXPECT_EQ(example_video_id(), |
377 GetContentSettings()->media_stream_selected_video_device()); | 462 GetContentSettings()->media_stream_selected_video_device()); |
378 } | 463 } |
379 | 464 |
380 // Request and block microphone and camera access. | 465 // Request and block microphone and camera access. |
381 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 466 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
382 RequestAndBlockMicCam) { | 467 RequestAndBlockMicCam) { |
383 InitWithUrl(GURL("https://www.example.com")); | 468 InitWithUrl(GURL("https://www.example.com")); |
384 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); | 469 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); |
385 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_DENIED); | 470 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_DENIED); |
386 // Ensure the prompt is accepted if necessary such that tab specific content | 471 // Ensure the prompt is accepted if necessary such that tab specific content |
387 // settings are updated. | 472 // settings are updated. |
388 prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 473 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
389 RequestPermissions( | 474 RequestPermissions( |
390 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 475 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
391 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 476 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
392 base::Unretained(this))); | 477 base::Unretained(this))); |
393 | 478 |
394 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( | 479 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( |
395 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 480 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
396 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( | 481 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( |
397 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 482 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
398 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( | 483 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( |
399 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 484 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
400 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( | 485 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( |
401 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 486 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
402 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_ACCESSED | | 487 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_ACCESSED | |
403 TabSpecificContentSettings::MICROPHONE_BLOCKED | | 488 TabSpecificContentSettings::MICROPHONE_BLOCKED | |
404 TabSpecificContentSettings::CAMERA_ACCESSED | | 489 TabSpecificContentSettings::CAMERA_ACCESSED | |
405 TabSpecificContentSettings::CAMERA_BLOCKED, | 490 TabSpecificContentSettings::CAMERA_BLOCKED, |
406 GetContentSettings()->GetMicrophoneCameraState()); | 491 GetContentSettings()->GetMicrophoneCameraState()); |
407 EXPECT_EQ(example_audio_id(), | 492 EXPECT_EQ(example_audio_id(), |
408 GetContentSettings()->media_stream_requested_audio_device()); | 493 GetContentSettings()->media_stream_requested_audio_device()); |
409 EXPECT_EQ(example_audio_id(), | 494 EXPECT_EQ(example_audio_id(), |
410 GetContentSettings()->media_stream_selected_audio_device()); | 495 GetContentSettings()->media_stream_selected_audio_device()); |
411 EXPECT_EQ(example_video_id(), | 496 EXPECT_EQ(example_video_id(), |
412 GetContentSettings()->media_stream_requested_video_device()); | 497 GetContentSettings()->media_stream_requested_video_device()); |
413 EXPECT_EQ(example_video_id(), | 498 EXPECT_EQ(example_video_id(), |
414 GetContentSettings()->media_stream_selected_video_device()); | 499 GetContentSettings()->media_stream_selected_video_device()); |
415 } | 500 } |
416 | 501 |
417 // Request microphone and camera access. Allow microphone, block camera. | 502 // Request microphone and camera access. Allow microphone, block camera. |
418 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 503 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
419 RequestMicCamBlockCam) { | 504 RequestMicCamBlockCam) { |
420 InitWithUrl(GURL("https://www.example.com")); | 505 InitWithUrl(GURL("https://www.example.com")); |
421 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); | 506 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); |
422 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_DENIED); | 507 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_DENIED); |
423 // Ensure the prompt is accepted if necessary such that tab specific content | 508 // Ensure the prompt is accepted if necessary such that tab specific content |
424 // settings are updated. | 509 // settings are updated. |
425 prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 510 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
426 RequestPermissions( | 511 RequestPermissions( |
427 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 512 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
428 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 513 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
429 base::Unretained(this))); | 514 base::Unretained(this))); |
430 | 515 |
431 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( | 516 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( |
432 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 517 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
433 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( | 518 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( |
434 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 519 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
435 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( | 520 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( |
436 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 521 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
437 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( | 522 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( |
438 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 523 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
439 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_ACCESSED | | 524 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_ACCESSED | |
440 TabSpecificContentSettings::CAMERA_ACCESSED | | 525 TabSpecificContentSettings::CAMERA_ACCESSED | |
441 TabSpecificContentSettings::CAMERA_BLOCKED, | 526 TabSpecificContentSettings::CAMERA_BLOCKED, |
442 GetContentSettings()->GetMicrophoneCameraState()); | 527 GetContentSettings()->GetMicrophoneCameraState()); |
443 EXPECT_EQ(example_audio_id(), | 528 EXPECT_EQ(example_audio_id(), |
444 GetContentSettings()->media_stream_requested_audio_device()); | 529 GetContentSettings()->media_stream_requested_audio_device()); |
445 EXPECT_EQ(example_audio_id(), | 530 EXPECT_EQ(example_audio_id(), |
446 GetContentSettings()->media_stream_selected_audio_device()); | 531 GetContentSettings()->media_stream_selected_audio_device()); |
447 EXPECT_EQ(example_video_id(), | 532 EXPECT_EQ(example_video_id(), |
448 GetContentSettings()->media_stream_requested_video_device()); | 533 GetContentSettings()->media_stream_requested_video_device()); |
449 EXPECT_EQ(example_video_id(), | 534 EXPECT_EQ(example_video_id(), |
450 GetContentSettings()->media_stream_selected_video_device()); | 535 GetContentSettings()->media_stream_selected_video_device()); |
451 } | 536 } |
452 | 537 |
453 // Request microphone and camera access. Block microphone, allow camera. | 538 // Request microphone and camera access. Block microphone, allow camera. |
454 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 539 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
455 RequestMicCamBlockMic) { | 540 RequestMicCamBlockMic) { |
456 InitWithUrl(GURL("https://www.example.com")); | 541 InitWithUrl(GURL("https://www.example.com")); |
457 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); | 542 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); |
458 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); | 543 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); |
459 // Ensure the prompt is accepted if necessary such that tab specific content | 544 // Ensure the prompt is accepted if necessary such that tab specific content |
460 // settings are updated. | 545 // settings are updated. |
461 prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 546 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
462 RequestPermissions( | 547 RequestPermissions( |
463 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 548 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
464 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 549 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
465 base::Unretained(this))); | 550 base::Unretained(this))); |
466 | 551 |
467 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( | 552 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( |
468 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 553 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
469 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( | 554 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( |
470 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 555 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
471 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( | 556 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( |
472 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 557 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
473 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( | 558 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( |
474 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 559 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
475 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_ACCESSED | | 560 EXPECT_EQ(TabSpecificContentSettings::MICROPHONE_ACCESSED | |
476 TabSpecificContentSettings::MICROPHONE_BLOCKED | | 561 TabSpecificContentSettings::MICROPHONE_BLOCKED | |
477 TabSpecificContentSettings::CAMERA_ACCESSED, | 562 TabSpecificContentSettings::CAMERA_ACCESSED, |
478 GetContentSettings()->GetMicrophoneCameraState()); | 563 GetContentSettings()->GetMicrophoneCameraState()); |
479 EXPECT_EQ(example_audio_id(), | 564 EXPECT_EQ(example_audio_id(), |
480 GetContentSettings()->media_stream_requested_audio_device()); | 565 GetContentSettings()->media_stream_requested_audio_device()); |
481 EXPECT_EQ(example_audio_id(), | 566 EXPECT_EQ(example_audio_id(), |
482 GetContentSettings()->media_stream_selected_audio_device()); | 567 GetContentSettings()->media_stream_selected_audio_device()); |
483 EXPECT_EQ(example_video_id(), | 568 EXPECT_EQ(example_video_id(), |
484 GetContentSettings()->media_stream_requested_video_device()); | 569 GetContentSettings()->media_stream_requested_video_device()); |
485 EXPECT_EQ(example_video_id(), | 570 EXPECT_EQ(example_video_id(), |
486 GetContentSettings()->media_stream_selected_video_device()); | 571 GetContentSettings()->media_stream_selected_video_device()); |
487 } | 572 } |
488 | 573 |
489 // Request microphone access. Requesting camera should not change microphone | 574 // Request microphone access. Requesting camera should not change microphone |
490 // state. | 575 // state. |
491 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 576 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
492 RequestCamDoesNotChangeMic) { | 577 RequestCamDoesNotChangeMic) { |
493 InitWithUrl(GURL("https://www.example.com")); | 578 InitWithUrl(GURL("https://www.example.com")); |
494 // Request mic and deny. | 579 // Request mic and deny. |
495 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); | 580 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); |
496 // Ensure the prompt is accepted if necessary such that tab specific content | 581 // Ensure the prompt is accepted if necessary such that tab specific content |
497 // settings are updated. | 582 // settings are updated. |
498 prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 583 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
499 RequestPermissions( | 584 RequestPermissions( |
500 GetWebContents(), CreateRequest(example_audio_id(), std::string()), | 585 GetWebContents(), CreateRequest(example_audio_id(), std::string()), |
501 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 586 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
502 base::Unretained(this))); | 587 base::Unretained(this))); |
503 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( | 588 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( |
504 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 589 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
505 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( | 590 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( |
506 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 591 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
507 EXPECT_EQ(example_audio_id(), | 592 EXPECT_EQ(example_audio_id(), |
508 GetContentSettings()->media_stream_requested_audio_device()); | 593 GetContentSettings()->media_stream_requested_audio_device()); |
(...skipping 20 matching lines...) Expand all Loading... |
529 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 614 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
530 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( | 615 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( |
531 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 616 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
532 EXPECT_EQ(example_audio_id(), | 617 EXPECT_EQ(example_audio_id(), |
533 GetContentSettings()->media_stream_requested_audio_device()); | 618 GetContentSettings()->media_stream_requested_audio_device()); |
534 EXPECT_EQ(example_audio_id(), | 619 EXPECT_EQ(example_audio_id(), |
535 GetContentSettings()->media_stream_selected_audio_device()); | 620 GetContentSettings()->media_stream_selected_audio_device()); |
536 } | 621 } |
537 | 622 |
538 // Denying mic access after camera access should still show the camera as state. | 623 // Denying mic access after camera access should still show the camera as state. |
539 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 624 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
540 DenyMicDoesNotChangeCam) { | 625 DenyMicDoesNotChangeCam) { |
541 InitWithUrl(GURL("https://www.example.com")); | 626 InitWithUrl(GURL("https://www.example.com")); |
542 // Request cam and allow | 627 // Request cam and allow |
543 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); | 628 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); |
544 // Ensure the prompt is accepted if necessary such that tab specific content | 629 // Ensure the prompt is accepted if necessary such that tab specific content |
545 // settings are updated. | 630 // settings are updated. |
546 prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 631 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
547 RequestPermissions( | 632 RequestPermissions( |
548 GetWebContents(), CreateRequest(std::string(), example_video_id()), | 633 GetWebContents(), CreateRequest(std::string(), example_video_id()), |
549 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 634 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
550 base::Unretained(this))); | 635 base::Unretained(this))); |
551 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( | 636 EXPECT_TRUE(GetContentSettings()->IsContentAllowed( |
552 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 637 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
553 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( | 638 EXPECT_FALSE(GetContentSettings()->IsContentBlocked( |
554 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 639 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
555 EXPECT_EQ(example_video_id(), | 640 EXPECT_EQ(example_video_id(), |
556 GetContentSettings()->media_stream_requested_video_device()); | 641 GetContentSettings()->media_stream_requested_video_device()); |
(...skipping 12 matching lines...) Expand all Loading... |
569 dispatcher->SetTestVideoCaptureDevices(video_devices); | 654 dispatcher->SetTestVideoCaptureDevices(video_devices); |
570 std::unique_ptr<content::MediaStreamUI> video_stream_ui = | 655 std::unique_ptr<content::MediaStreamUI> video_stream_ui = |
571 dispatcher->GetMediaStreamCaptureIndicator()->RegisterMediaStream( | 656 dispatcher->GetMediaStreamCaptureIndicator()->RegisterMediaStream( |
572 GetWebContents(), video_devices); | 657 GetWebContents(), video_devices); |
573 video_stream_ui->OnStarted(base::Closure()); | 658 video_stream_ui->OnStarted(base::Closure()); |
574 | 659 |
575 // Request mic and deny. | 660 // Request mic and deny. |
576 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); | 661 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); |
577 // Ensure the prompt is accepted if necessary such that tab specific content | 662 // Ensure the prompt is accepted if necessary such that tab specific content |
578 // settings are updated. | 663 // settings are updated. |
579 prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 664 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
580 RequestPermissions( | 665 RequestPermissions( |
581 GetWebContents(), CreateRequest(example_audio_id(), std::string()), | 666 GetWebContents(), CreateRequest(example_audio_id(), std::string()), |
582 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 667 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
583 base::Unretained(this))); | 668 base::Unretained(this))); |
584 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( | 669 EXPECT_FALSE(GetContentSettings()->IsContentAllowed( |
585 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 670 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
586 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( | 671 EXPECT_TRUE(GetContentSettings()->IsContentBlocked( |
587 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 672 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
588 EXPECT_EQ(example_audio_id(), | 673 EXPECT_EQ(example_audio_id(), |
589 GetContentSettings()->media_stream_requested_audio_device()); | 674 GetContentSettings()->media_stream_requested_audio_device()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 // inputs. | 726 // inputs. |
642 content::MediaStreamRequestResult ExpectedMediaStreamResult() const { | 727 content::MediaStreamRequestResult ExpectedMediaStreamResult() const { |
643 if (ExpectMicAllowed() || ExpectCamAllowed()) | 728 if (ExpectMicAllowed() || ExpectCamAllowed()) |
644 return content::MEDIA_DEVICE_OK; | 729 return content::MEDIA_DEVICE_OK; |
645 return content::MEDIA_DEVICE_PERMISSION_DENIED; | 730 return content::MEDIA_DEVICE_PERMISSION_DENIED; |
646 } | 731 } |
647 }; | 732 }; |
648 | 733 |
649 // Test all combinations of cam/mic content settings. Then tests the result of | 734 // Test all combinations of cam/mic content settings. Then tests the result of |
650 // clicking both accept/deny on the infobar. Both cam/mic are requested. | 735 // clicking both accept/deny on the infobar. Both cam/mic are requested. |
651 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, ContentSettings) { | 736 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, ContentSettings) { |
652 InitWithUrl(GURL("https://www.example.com")); | 737 InitWithUrl(GURL("https://www.example.com")); |
653 static const ContentSettingsTestData tests[] = { | 738 static const ContentSettingsTestData tests[] = { |
654 // Settings that won't result in an infobar. | 739 // Settings that won't result in an infobar. |
655 {CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW, false}, | 740 {CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW, false}, |
656 {CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, false}, | 741 {CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, false}, |
657 {CONTENT_SETTING_BLOCK, CONTENT_SETTING_ALLOW, false}, | 742 {CONTENT_SETTING_BLOCK, CONTENT_SETTING_ALLOW, false}, |
658 {CONTENT_SETTING_BLOCK, CONTENT_SETTING_BLOCK, false}, | 743 {CONTENT_SETTING_BLOCK, CONTENT_SETTING_BLOCK, false}, |
659 | 744 |
660 // Settings that will result in an infobar. Test both accept and deny. | 745 // Settings that will result in an infobar. Test both accept and deny. |
661 {CONTENT_SETTING_ALLOW, CONTENT_SETTING_ASK, false}, | 746 {CONTENT_SETTING_ALLOW, CONTENT_SETTING_ASK, false}, |
662 {CONTENT_SETTING_ALLOW, CONTENT_SETTING_ASK, true}, | 747 {CONTENT_SETTING_ALLOW, CONTENT_SETTING_ASK, true}, |
663 | 748 |
664 {CONTENT_SETTING_ASK, CONTENT_SETTING_ASK, false}, | 749 {CONTENT_SETTING_ASK, CONTENT_SETTING_ASK, false}, |
665 {CONTENT_SETTING_ASK, CONTENT_SETTING_ASK, true}, | 750 {CONTENT_SETTING_ASK, CONTENT_SETTING_ASK, true}, |
666 | 751 |
667 {CONTENT_SETTING_BLOCK, CONTENT_SETTING_ASK, false}, | 752 {CONTENT_SETTING_BLOCK, CONTENT_SETTING_ASK, false}, |
668 {CONTENT_SETTING_BLOCK, CONTENT_SETTING_ASK, true}, | 753 {CONTENT_SETTING_BLOCK, CONTENT_SETTING_ASK, true}, |
669 | 754 |
670 {CONTENT_SETTING_ASK, CONTENT_SETTING_ALLOW, false}, | 755 {CONTENT_SETTING_ASK, CONTENT_SETTING_ALLOW, false}, |
671 {CONTENT_SETTING_ASK, CONTENT_SETTING_ALLOW, true}, | 756 {CONTENT_SETTING_ASK, CONTENT_SETTING_ALLOW, true}, |
672 | 757 |
673 {CONTENT_SETTING_ASK, CONTENT_SETTING_BLOCK, false}, | 758 {CONTENT_SETTING_ASK, CONTENT_SETTING_BLOCK, false}, |
674 {CONTENT_SETTING_ASK, CONTENT_SETTING_BLOCK, true}, | 759 {CONTENT_SETTING_ASK, CONTENT_SETTING_BLOCK, true}, |
675 }; | 760 }; |
676 | 761 |
677 for (auto& test : tests) { | 762 for (auto& test : tests) { |
678 SetContentSettings(test.mic, test.cam); | 763 SetContentSettings(test.mic, test.cam); |
679 | 764 |
680 prompt_delegate()->Reset(); | 765 ResetPromptCounters(); |
681 | 766 |
682 // Accept or deny the infobar if it's showing. | 767 // Accept or deny the infobar if it's showing. |
683 if (test.ExpectMicInfobar() || test.ExpectCamInfobar()) { | 768 if (test.ExpectMicInfobar() || test.ExpectCamInfobar()) { |
684 if (test.accept_infobar) { | 769 if (test.accept_infobar) { |
685 prompt_delegate()->set_response_type( | 770 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
686 PermissionRequestManager::ACCEPT_ALL); | |
687 } else { | 771 } else { |
688 prompt_delegate()->set_response_type( | 772 SetPromptResponseType(PermissionRequestManager::DENY_ALL); |
689 PermissionRequestManager::DENY_ALL); | |
690 } | 773 } |
691 } else { | 774 } else { |
692 prompt_delegate()->set_response_type(PermissionRequestManager::NONE); | 775 SetPromptResponseType(PermissionRequestManager::NONE); |
693 } | 776 } |
694 RequestPermissions( | 777 RequestPermissions( |
695 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 778 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
696 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 779 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
697 base::Unretained(this))); | 780 base::Unretained(this))); |
698 | 781 |
699 ASSERT_LE(prompt_delegate()->TotalRequestCount(), 2u); | 782 ASSERT_LE(TotalPromptRequestCount(), 2u); |
700 ASSERT_EQ( | 783 ASSERT_EQ(test.ExpectMicInfobar(), |
701 test.ExpectMicInfobar(), | 784 WasPermissionShown(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
702 prompt_delegate()->WasRequested(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | |
703 ASSERT_EQ(test.ExpectCamInfobar(), | 785 ASSERT_EQ(test.ExpectCamInfobar(), |
704 prompt_delegate()->WasRequested( | 786 WasPermissionShown(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
705 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | |
706 | 787 |
707 // Check the media stream result is expected and the devices returned are | 788 // Check the media stream result is expected and the devices returned are |
708 // expected; | 789 // expected; |
709 ASSERT_EQ(test.ExpectedMediaStreamResult(), media_stream_result()); | 790 ASSERT_EQ(test.ExpectedMediaStreamResult(), media_stream_result()); |
710 ASSERT_EQ(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE), | 791 ASSERT_EQ(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE), |
711 test.ExpectMicAllowed()); | 792 test.ExpectMicAllowed()); |
712 ASSERT_EQ(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE), | 793 ASSERT_EQ(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE), |
713 test.ExpectCamAllowed()); | 794 test.ExpectCamAllowed()); |
714 } | 795 } |
715 } | 796 } |
716 | 797 |
717 // Request and allow camera access on WebUI pages without prompting. | 798 // Request and allow camera access on WebUI pages without prompting. |
718 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 799 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
719 WebUIRequestAndAllowCam) { | 800 WebUIRequestAndAllowCam) { |
720 InitWithUrl(GURL("chrome://test-page")); | 801 InitWithUrl(GURL("chrome://test-page")); |
721 RequestPermissions( | 802 RequestPermissions( |
722 GetWebContents(), CreateRequest(std::string(), example_video_id()), | 803 GetWebContents(), CreateRequest(std::string(), example_video_id()), |
723 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 804 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
724 base::Unretained(this))); | 805 base::Unretained(this))); |
725 | 806 |
726 ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); | 807 ASSERT_EQ(0u, TotalPromptRequestCount()); |
727 | 808 |
728 ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); | 809 ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); |
729 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); | 810 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); |
730 ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); | 811 ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); |
731 } | 812 } |
732 | 813 |
733 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 814 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
734 ExtensionRequestMicCam) { | 815 ExtensionRequestMicCam) { |
735 InitWithUrl(GURL("chrome-extension://test-page")); | 816 InitWithUrl(GURL("chrome-extension://test-page")); |
736 // Test that a prompt is required. | 817 // Test that a prompt is required. |
737 prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); | 818 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
738 RequestPermissions( | 819 RequestPermissions( |
739 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 820 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
740 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 821 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
741 base::Unretained(this))); | 822 base::Unretained(this))); |
742 ASSERT_EQ(2u, prompt_delegate()->TotalRequestCount()); | 823 ASSERT_EQ(2u, TotalPromptRequestCount()); |
743 ASSERT_TRUE(prompt_delegate()->WasRequested( | 824 ASSERT_TRUE(WasPermissionShown(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
744 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 825 ASSERT_TRUE(WasPermissionShown(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
745 ASSERT_TRUE( | |
746 prompt_delegate()->WasRequested(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | |
747 | 826 |
748 // Accept the prompt. | 827 // Accept the prompt. |
749 ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); | 828 ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); |
750 ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); | 829 ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); |
751 ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); | 830 ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); |
752 | 831 |
753 // Check that re-requesting allows without prompting. | 832 // Check that re-requesting allows without prompting. |
754 prompt_delegate()->Reset(); | 833 ResetPromptCounters(); |
755 RequestPermissions( | 834 RequestPermissions( |
756 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 835 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
757 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 836 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
758 base::Unretained(this))); | 837 base::Unretained(this))); |
759 ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); | 838 ASSERT_EQ(0u, TotalPromptRequestCount()); |
760 | 839 |
761 ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); | 840 ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); |
762 ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); | 841 ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); |
763 ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); | 842 ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); |
764 } | 843 } |
765 | 844 |
766 // For Pepper request from insecure origin, even if it's ALLOW, it won't be | 845 // For Pepper request from insecure origin, even if it's ALLOW, it won't be |
767 // changed to ASK. | 846 // changed to ASK. |
768 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 847 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
769 PepperRequestInsecure) { | 848 PepperRequestInsecure) { |
770 InitWithUrl(GURL("http://www.example.com")); | 849 InitWithUrl(GURL("http://www.example.com")); |
771 SetContentSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW); | 850 SetContentSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW); |
772 | 851 |
773 RequestPermissions( | 852 RequestPermissions( |
774 GetWebContents(), | 853 GetWebContents(), |
775 CreateRequestWithType(example_audio_id(), std::string(), | 854 CreateRequestWithType(example_audio_id(), std::string(), |
776 content::MEDIA_OPEN_DEVICE_PEPPER_ONLY), | 855 content::MEDIA_OPEN_DEVICE_PEPPER_ONLY), |
777 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 856 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
778 base::Unretained(this))); | 857 base::Unretained(this))); |
779 ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); | 858 ASSERT_EQ(0u, TotalPromptRequestCount()); |
780 } | 859 } |
781 | 860 |
782 // Request and block microphone and camera access with kill switch. | 861 // Request and block microphone and camera access with kill switch. |
783 IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, | 862 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
784 RequestAndKillSwitchMicCam) { | 863 RequestAndKillSwitchMicCam) { |
785 std::map<std::string, std::string> params; | 864 std::map<std::string, std::string> params; |
786 params[PermissionUtil::GetPermissionString( | 865 params[PermissionUtil::GetPermissionString( |
787 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)] = | 866 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)] = |
788 PermissionContextBase::kPermissionsKillSwitchBlockedValue; | 867 PermissionContextBase::kPermissionsKillSwitchBlockedValue; |
789 params[PermissionUtil::GetPermissionString( | 868 params[PermissionUtil::GetPermissionString( |
790 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)] = | 869 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)] = |
791 PermissionContextBase::kPermissionsKillSwitchBlockedValue; | 870 PermissionContextBase::kPermissionsKillSwitchBlockedValue; |
792 variations::AssociateVariationParams( | 871 variations::AssociateVariationParams( |
793 PermissionContextBase::kPermissionsKillSwitchFieldStudy, | 872 PermissionContextBase::kPermissionsKillSwitchFieldStudy, |
794 "TestGroup", params); | 873 "TestGroup", params); |
795 base::FieldTrialList::CreateFieldTrial( | 874 base::FieldTrialList::CreateFieldTrial( |
796 PermissionContextBase::kPermissionsKillSwitchFieldStudy, | 875 PermissionContextBase::kPermissionsKillSwitchFieldStudy, |
797 "TestGroup"); | 876 "TestGroup"); |
798 InitWithUrl(GURL("https://www.example.com")); | 877 InitWithUrl(GURL("https://www.example.com")); |
799 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); | 878 SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); |
800 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); | 879 SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); |
801 RequestPermissions( | 880 RequestPermissions( |
802 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 881 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
803 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 882 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
804 base::Unretained(this))); | 883 base::Unretained(this))); |
805 | 884 |
806 ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); | 885 ASSERT_EQ(0u, TotalPromptRequestCount()); |
807 | 886 |
808 ASSERT_EQ(content::MEDIA_DEVICE_KILL_SWITCH_ON, media_stream_result()); | 887 ASSERT_EQ(content::MEDIA_DEVICE_KILL_SWITCH_ON, media_stream_result()); |
809 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); | 888 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); |
810 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); | 889 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); |
811 } | 890 } |
| 891 |
| 892 INSTANTIATE_TEST_CASE_P( |
| 893 MediaStreamDevicesControllerTestInstance, |
| 894 MediaStreamDevicesControllerTest, |
| 895 ::testing::Values(TestType::DEFAULT, |
| 896 TestType::TEST_WITH_GROUPED_MEDIA_REQUESTS)); |
OLD | NEW |