Chromium Code Reviews| Index: chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc |
| diff --git a/chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc b/chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc |
| index 19d44472321bff4fa15679ba9141ed6de6b1cfa5..0c1950bf6757b22f58bb4c1c0422d0474ff046ba 100644 |
| --- a/chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc |
| +++ b/chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc |
| @@ -5,7 +5,10 @@ |
| #include <string> |
| #include "base/bind.h" |
| +#include "base/callback.h" |
| #include "base/metrics/field_trial.h" |
| +#include "base/run_loop.h" |
| +#include "base/test/scoped_feature_list.h" |
| #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
| @@ -14,11 +17,14 @@ |
| #include "chrome/browser/media/webrtc/media_stream_devices_controller.h" |
| #include "chrome/browser/media/webrtc/webrtc_browsertest_base.h" |
| #include "chrome/browser/permissions/permission_context_base.h" |
| +#include "chrome/browser/permissions/permission_request.h" |
| #include "chrome/browser/permissions/permission_request_manager.h" |
| #include "chrome/browser/permissions/permission_util.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/permission_bubble/mock_permission_prompt_factory.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| +#include "chrome/common/chrome_features.h" |
| #include "chrome/common/pref_names.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| #include "components/content_settings/core/browser/host_content_settings_map.h" |
| @@ -29,7 +35,16 @@ |
| #include "content/public/test/mock_render_process_host.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| -class MediaStreamDevicesControllerTest : public WebRtcTestBase { |
| +enum class TestType { |
| + TEST_TYPE_START, |
| + DEFAULT = TEST_TYPE_START, |
| + TEST_WITH_GROUPED_MEDIA_REQUESTS, |
| + TEST_TYPE_END, |
| +}; |
| + |
| +class MediaStreamDevicesControllerTest |
| + : public WebRtcTestBase, |
| + public ::testing::WithParamInterface<int> { |
| public: |
| // TODO(raymes): When crbug.com/606138 is finished and the |
| // PermissionRequestManager is used to show all prompts on Android/Desktop |
| @@ -84,6 +99,8 @@ class MediaStreamDevicesControllerTest : public WebRtcTestBase { |
| std::unique_ptr<content::MediaStreamUI> ui) { |
| media_stream_devices_ = devices; |
| media_stream_result_ = result; |
| + quit_closure_.Run(); |
| + quit_closure_ = base::Closure(); |
| } |
| protected: |
| @@ -106,12 +123,14 @@ class MediaStreamDevicesControllerTest : public WebRtcTestBase { |
| void RequestPermissions(content::WebContents* web_contents, |
| const content::MediaStreamRequest& request, |
| const content::MediaResponseCallback& callback) { |
| + base::RunLoop run_loop; |
| + ASSERT_TRUE(quit_closure_.is_null()); |
| + quit_closure_ = run_loop.QuitClosure(); |
| MediaStreamDevicesController::RequestPermissionsWithDelegate( |
| request, callback, &prompt_delegate_); |
| + run_loop.Run(); |
| } |
| - TestPermissionPromptDelegate* prompt_delegate() { return &prompt_delegate_; } |
| - |
| // Sets the device policy-controlled |access| for |example_url_| to be for the |
| // selected |device_type|. |
| void SetDevicePolicy(DeviceType device_type, Access access) { |
| @@ -193,10 +212,67 @@ class MediaStreamDevicesControllerTest : public WebRtcTestBase { |
| GetContentSettings()->GetMicrophoneCameraState()); |
| } |
| + void SetPromptResponseType( |
| + PermissionRequestManager::AutoResponseType response_type) { |
| + if (base::FeatureList::IsEnabled( |
| + features::kUsePermissionManagerForMediaRequests)) { |
| + prompt_factory_->set_response_type(response_type); |
| + } else { |
| + prompt_delegate_.set_response_type(response_type); |
| + } |
| + } |
| + |
| + size_t TotalPromptRequestCount() { |
| + if (base::FeatureList::IsEnabled( |
| + features::kUsePermissionManagerForMediaRequests)) { |
| + return prompt_factory_->TotalRequestCount(); |
| + } else { |
| + return prompt_delegate_.TotalRequestCount(); |
| + } |
| + } |
| + |
| + bool WasPermissionShown(ContentSettingsType type) { |
| + if (base::FeatureList::IsEnabled( |
| + features::kUsePermissionManagerForMediaRequests)) { |
| + if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { |
| + return prompt_factory_->RequestTypeSeen( |
| + PermissionRequestType::PERMISSION_MEDIASTREAM_MIC); |
| + } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { |
| + return prompt_factory_->RequestTypeSeen( |
| + PermissionRequestType::PERMISSION_MEDIASTREAM_CAMERA); |
| + } else { |
| + NOTREACHED(); |
| + return false; |
| + } |
| + } else { |
| + return prompt_delegate_.WasRequested(type); |
| + } |
| + } |
| + |
| + void ResetPromptCounters() { |
| + if (base::FeatureList::IsEnabled( |
| + features::kUsePermissionManagerForMediaRequests)) { |
| + prompt_factory_->ResetCounts(); |
| + } else { |
| + prompt_delegate_.Reset(); |
| + } |
| + } |
| + |
| private: |
| void SetUpOnMainThread() override { |
| WebRtcTestBase::SetUpOnMainThread(); |
| + if (static_cast<TestType>(GetParam()) == |
| + TestType::TEST_WITH_GROUPED_MEDIA_REQUESTS) { |
| + scoped_feature_list_.InitAndEnableFeature( |
| + features::kUsePermissionManagerForMediaRequests); |
| + PermissionRequestManager* manager = |
| + PermissionRequestManager::FromWebContents( |
| + browser()->tab_strip_model()->GetActiveWebContents()); |
| + prompt_factory_.reset(new MockPermissionPromptFactory(manager)); |
| + manager->DisplayPendingRequests(); |
| + } |
| + |
| // Cleanup. |
| media_stream_devices_.clear(); |
| media_stream_result_ = content::NUM_MEDIA_REQUEST_RESULTS; |
| @@ -218,6 +294,12 @@ class MediaStreamDevicesControllerTest : public WebRtcTestBase { |
| video_devices); |
| } |
| + void TearDownOnMainThread() override { |
| + prompt_factory_.reset(); |
| + |
| + WebRtcTestBase::TearDownOnMainThread(); |
| + } |
| + |
| GURL example_url_; |
| const std::string example_audio_id_; |
| const std::string example_video_id_; |
| @@ -225,16 +307,21 @@ class MediaStreamDevicesControllerTest : public WebRtcTestBase { |
| content::MediaStreamDevices media_stream_devices_; |
| content::MediaStreamRequestResult media_stream_result_; |
| + base::Closure quit_closure_; |
| + |
| TestPermissionPromptDelegate prompt_delegate_; |
| + std::unique_ptr<MockPermissionPromptFactory> prompt_factory_; |
| + |
| + base::test::ScopedFeatureList scoped_feature_list_; |
| }; |
| // Request and allow microphone access. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndAllowMic) { |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, RequestAndAllowMic) { |
| InitWithUrl(GURL("https://www.example.com")); |
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); |
| // Ensure the prompt is accepted if necessary such that tab specific content |
| // settings are updated. |
| - prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
| RequestPermissions( |
| GetWebContents(), CreateRequest(example_audio_id(), std::string()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| @@ -257,12 +344,12 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndAllowMic) { |
| } |
| // Request and allow camera access. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndAllowCam) { |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, RequestAndAllowCam) { |
| InitWithUrl(GURL("https://www.example.com")); |
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); |
| // Ensure the prompt is accepted if necessary such that tab specific content |
| // settings are updated. |
| - prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
| RequestPermissions( |
| GetWebContents(), CreateRequest(std::string(), example_video_id()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| @@ -285,12 +372,12 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndAllowCam) { |
| } |
| // Request and block microphone access. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndBlockMic) { |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, RequestAndBlockMic) { |
| InitWithUrl(GURL("https://www.example.com")); |
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); |
| // Ensure the prompt is accepted if necessary such that tab specific content |
| // settings are updated. |
| - prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
| RequestPermissions( |
| GetWebContents(), CreateRequest(example_audio_id(), std::string()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| @@ -314,12 +401,12 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndBlockMic) { |
| } |
| // Request and block camera access. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndBlockCam) { |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, RequestAndBlockCam) { |
| InitWithUrl(GURL("https://www.example.com")); |
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_DENIED); |
| // Ensure the prompt is accepted if necessary such that tab specific content |
| // settings are updated. |
| - prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
| RequestPermissions( |
| GetWebContents(), CreateRequest(std::string(), example_video_id()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| @@ -343,14 +430,14 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, RequestAndBlockCam) { |
| } |
| // Request and allow microphone and camera access. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
| RequestAndAllowMicCam) { |
| InitWithUrl(GURL("https://www.example.com")); |
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); |
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); |
| // Ensure the prompt is accepted if necessary such that tab specific content |
| // settings are updated. |
| - prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
| RequestPermissions( |
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| @@ -378,14 +465,14 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| } |
| // Request and block microphone and camera access. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
| RequestAndBlockMicCam) { |
| InitWithUrl(GURL("https://www.example.com")); |
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); |
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_DENIED); |
| // Ensure the prompt is accepted if necessary such that tab specific content |
| // settings are updated. |
| - prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
| RequestPermissions( |
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| @@ -415,14 +502,14 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| } |
| // Request microphone and camera access. Allow microphone, block camera. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
| RequestMicCamBlockCam) { |
| InitWithUrl(GURL("https://www.example.com")); |
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_ALLOWED); |
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_DENIED); |
| // Ensure the prompt is accepted if necessary such that tab specific content |
| // settings are updated. |
| - prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
| RequestPermissions( |
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| @@ -451,14 +538,14 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| } |
| // Request microphone and camera access. Block microphone, allow camera. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
| RequestMicCamBlockMic) { |
| InitWithUrl(GURL("https://www.example.com")); |
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); |
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); |
| // Ensure the prompt is accepted if necessary such that tab specific content |
| // settings are updated. |
| - prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
| RequestPermissions( |
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| @@ -488,14 +575,14 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| // Request microphone access. Requesting camera should not change microphone |
| // state. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
| RequestCamDoesNotChangeMic) { |
| InitWithUrl(GURL("https://www.example.com")); |
| // Request mic and deny. |
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); |
| // Ensure the prompt is accepted if necessary such that tab specific content |
| // settings are updated. |
| - prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
| RequestPermissions( |
| GetWebContents(), CreateRequest(example_audio_id(), std::string()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| @@ -536,14 +623,14 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| } |
| // Denying mic access after camera access should still show the camera as state. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
| DenyMicDoesNotChangeCam) { |
| InitWithUrl(GURL("https://www.example.com")); |
| // Request cam and allow |
| SetDevicePolicy(DEVICE_TYPE_VIDEO, ACCESS_ALLOWED); |
| // Ensure the prompt is accepted if necessary such that tab specific content |
| // settings are updated. |
| - prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
| RequestPermissions( |
| GetWebContents(), CreateRequest(std::string(), example_video_id()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| @@ -576,7 +663,7 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| SetDevicePolicy(DEVICE_TYPE_AUDIO, ACCESS_DENIED); |
| // Ensure the prompt is accepted if necessary such that tab specific content |
| // settings are updated. |
| - prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
| RequestPermissions( |
| GetWebContents(), CreateRequest(example_audio_id(), std::string()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| @@ -648,7 +735,7 @@ struct ContentSettingsTestData { |
| // Test all combinations of cam/mic content settings. Then tests the result of |
| // clicking both accept/deny on the infobar. Both cam/mic are requested. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, ContentSettings) { |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, ContentSettings) { |
| InitWithUrl(GURL("https://www.example.com")); |
| static const ContentSettingsTestData tests[] = { |
| // Settings that won't result in an infobar. |
| @@ -677,32 +764,28 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, ContentSettings) { |
| for (auto& test : tests) { |
| SetContentSettings(test.mic, test.cam); |
| - prompt_delegate()->Reset(); |
| + ResetPromptCounters(); |
| // Accept or deny the infobar if it's showing. |
| if (test.ExpectMicInfobar() || test.ExpectCamInfobar()) { |
| if (test.accept_infobar) { |
| - prompt_delegate()->set_response_type( |
| - PermissionRequestManager::ACCEPT_ALL); |
| + SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
| } else { |
| - prompt_delegate()->set_response_type( |
| - PermissionRequestManager::DENY_ALL); |
| + SetPromptResponseType(PermissionRequestManager::DENY_ALL); |
| } |
| } else { |
| - prompt_delegate()->set_response_type(PermissionRequestManager::NONE); |
| + SetPromptResponseType(PermissionRequestManager::NONE); |
| } |
| RequestPermissions( |
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| base::Unretained(this))); |
| - ASSERT_LE(prompt_delegate()->TotalRequestCount(), 2u); |
| - ASSERT_EQ( |
| - test.ExpectMicInfobar(), |
| - prompt_delegate()->WasRequested(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
| + ASSERT_LE(TotalPromptRequestCount(), 2u); |
| + ASSERT_EQ(test.ExpectMicInfobar(), |
| + WasPermissionShown(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
| ASSERT_EQ(test.ExpectCamInfobar(), |
| - prompt_delegate()->WasRequested( |
| - CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
| + WasPermissionShown(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
| // Check the media stream result is expected and the devices returned are |
| // expected; |
| @@ -715,7 +798,7 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, ContentSettings) { |
| } |
| // Request and allow camera access on WebUI pages without prompting. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
| WebUIRequestAndAllowCam) { |
| InitWithUrl(GURL("chrome://test-page")); |
| RequestPermissions( |
| @@ -723,27 +806,25 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| base::Unretained(this))); |
| - ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); |
| + ASSERT_EQ(0u, TotalPromptRequestCount()); |
| ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); |
| ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); |
| ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); |
| } |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
| ExtensionRequestMicCam) { |
| InitWithUrl(GURL("chrome-extension://test-page")); |
| // Test that a prompt is required. |
| - prompt_delegate()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
| RequestPermissions( |
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| base::Unretained(this))); |
| - ASSERT_EQ(2u, prompt_delegate()->TotalRequestCount()); |
| - ASSERT_TRUE(prompt_delegate()->WasRequested( |
| - CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
| - ASSERT_TRUE( |
| - prompt_delegate()->WasRequested(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
| + ASSERT_EQ(2u, TotalPromptRequestCount()); |
| + ASSERT_TRUE(WasPermissionShown(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
| + ASSERT_TRUE(WasPermissionShown(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
| // Accept the prompt. |
| ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); |
| @@ -751,12 +832,12 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); |
| // Check that re-requesting allows without prompting. |
| - prompt_delegate()->Reset(); |
| + ResetPromptCounters(); |
| RequestPermissions( |
| GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| base::Unretained(this))); |
| - ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); |
| + ASSERT_EQ(0u, TotalPromptRequestCount()); |
| ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); |
| ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); |
| @@ -765,7 +846,7 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| // For Pepper request from insecure origin, even if it's ALLOW, it won't be |
| // changed to ASK. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
| PepperRequestInsecure) { |
| InitWithUrl(GURL("http://www.example.com")); |
| SetContentSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_ALLOW); |
| @@ -776,11 +857,11 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| content::MEDIA_OPEN_DEVICE_PEPPER_ONLY), |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| base::Unretained(this))); |
| - ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); |
| + ASSERT_EQ(0u, TotalPromptRequestCount()); |
| } |
| // Request and block microphone and camera access with kill switch. |
| -IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| +IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
| RequestAndKillSwitchMicCam) { |
| std::map<std::string, std::string> params; |
| params[PermissionUtil::GetPermissionString( |
| @@ -803,9 +884,15 @@ IN_PROC_BROWSER_TEST_F(MediaStreamDevicesControllerTest, |
| base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| base::Unretained(this))); |
| - ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); |
| + ASSERT_EQ(0u, TotalPromptRequestCount()); |
| ASSERT_EQ(content::MEDIA_DEVICE_KILL_SWITCH_ON, media_stream_result()); |
| ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); |
| ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); |
| } |
| + |
| +INSTANTIATE_TEST_CASE_P( |
| + MediaStreamDevicesControllerTestInstance, |
| + MediaStreamDevicesControllerTest, |
| + ::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.
|
| + static_cast<int>(TestType::TEST_TYPE_END))); |