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