Chromium Code Reviews| Index: chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc |
| diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc |
| index 238b3806240194b38e4b46f162b8a3d95603df14..c55866c1beaeeaf8892890e0709e36f3a41918b9 100644 |
| --- a/chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc |
| +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc |
| @@ -98,3 +98,69 @@ IN_PROC_BROWSER_TEST_F(ContentSettingBubbleModelMixedScriptTest, Iframe) { |
| EXPECT_FALSE(GetActiveTabSpecificContentSettings()->IsContentBlocked( |
| CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); |
| } |
| + |
| +class ContentSettingBubbleModelMediaStreamTest : public InProcessBrowserTest { |
| + public: |
| + scoped_ptr<ContentSettingBubbleModel> GetNewBubbleInTheFirstTab() { |
|
msw
2015/08/05 17:05:38
nit: rename this CreateBubble(), or better yet com
msramek
2015/08/05 17:39:28
Yep, that sounds good.
|
| + return make_scoped_ptr( |
| + ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| + browser()->content_setting_bubble_model_delegate(), |
| + GetFirstTab(), |
| + browser()->profile(), |
| + CONTENT_SETTINGS_TYPE_MEDIASTREAM)); |
| + } |
| + |
| + void SetAccessedDevices( |
| + TabSpecificContentSettings::MicrophoneCameraState state) { |
| + TabSpecificContentSettings::FromWebContents(GetFirstTab())-> |
| + OnMediaStreamPermissionSet( |
| + GetFirstTab()->GetLastCommittedURL(), |
| + state, device_name_, device_name_, device_name_, device_name_); |
| + } |
| + |
| + void WaitForNavigation() { |
| + content::TestNavigationObserver observer( |
| + browser()->tab_strip_model()->GetActiveWebContents()); |
|
msw
2015/08/05 17:05:38
nit: use GetFirstTab() here?
msramek
2015/08/05 17:39:28
No actually. The bubble itself is invoked for the
msw
2015/08/05 17:47:20
Acknowledged.
|
| + observer.Wait(); |
| + } |
| + |
| + private: |
| + content::WebContents* GetFirstTab() { |
| + return browser()->tab_strip_model()->GetWebContentsAt(0); |
| + } |
| + |
| + std::string device_name_ = "is not important for this test"; |
|
msw
2015/08/05 17:05:38
nit: can you remove this and just pass std::string
msramek
2015/08/05 17:39:28
Done.
|
| +}; |
| + |
| +// Tests that clicking on the management link in the media bubble opens |
| +// the correct section of the settings UI. |
| +IN_PROC_BROWSER_TEST_F(ContentSettingBubbleModelMediaStreamTest, ManageLink) { |
| + // The microphone bubble links to microphone exceptions. |
| + SetAccessedDevices(TabSpecificContentSettings::MICROPHONE_ACCESSED); |
| + scoped_ptr<ContentSettingBubbleModel> bubble = GetNewBubbleInTheFirstTab(); |
| + bubble->OnManageLinkClicked(); |
| + WaitForNavigation(); |
| + EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-mic"), |
| + browser()->tab_strip_model()-> |
| + GetActiveWebContents()->GetLastCommittedURL()); |
| + |
| + // The camera bubble links to camera exceptions. |
| + SetAccessedDevices(TabSpecificContentSettings::CAMERA_ACCESSED); |
| + bubble = GetNewBubbleInTheFirstTab(); |
| + bubble->OnManageLinkClicked(); |
| + WaitForNavigation(); |
| + EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-camera"), |
| + browser()->tab_strip_model()-> |
| + GetActiveWebContents()->GetLastCommittedURL()); |
| + |
| + // The bubble for both media devices links to the the first section of the |
| + // default media content settings, which is the microphone section. |
| + SetAccessedDevices(TabSpecificContentSettings::MICROPHONE_ACCESSED | |
| + TabSpecificContentSettings::CAMERA_ACCESSED); |
| + bubble = GetNewBubbleInTheFirstTab(); |
| + bubble->OnManageLinkClicked(); |
| + WaitForNavigation(); |
| + EXPECT_EQ(GURL("chrome://settings/content#media-stream-mic"), |
| + browser()->tab_strip_model()-> |
| + GetActiveWebContents()->GetLastCommittedURL()); |
| +} |