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..0d2dabce449fb484c636ac419ad6c21a8753586c 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 |
| @@ -9,6 +9,7 @@ |
| #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" |
| +#include "chrome/browser/ui/browser_finder.h" |
| #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "chrome/test/base/in_process_browser_test.h" |
| @@ -98,3 +99,62 @@ IN_PROC_BROWSER_TEST_F(ContentSettingBubbleModelMixedScriptTest, Iframe) { |
| EXPECT_FALSE(GetActiveTabSpecificContentSettings()->IsContentBlocked( |
| CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); |
| } |
| + |
| +class ContentSettingBubbleModelMediaStreamTest : public InProcessBrowserTest { |
| + public: |
| + void ManageMediaStreamSettings( |
| + TabSpecificContentSettings::MicrophoneCameraState state) { |
| + // Create a bubble with the given camera and microphone access state. |
| + TabSpecificContentSettings::FromWebContents(GetFirstTab())-> |
| + OnMediaStreamPermissionSet( |
| + GetFirstTab()->GetLastCommittedURL(), |
| + state, std::string(), std::string(), std::string(), std::string()); |
| + scoped_ptr<ContentSettingBubbleModel> bubble( |
| + ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| + browser()->content_setting_bubble_model_delegate(), |
| + GetFirstTab(), |
| + browser()->profile(), |
| + CONTENT_SETTINGS_TYPE_MEDIASTREAM)); |
| + |
| + // Click the management link. |
|
msw
2015/08/06 18:23:20
nit "Click the management link, which opens in a n
msramek
2015/08/06 18:32:11
Done.
|
| + bubble->OnManageLinkClicked(); |
| + } |
| + |
| + content::WebContents* GetActiveTab() { |
| + // First, we need to find the active browser window. It should be at |
| + // the same desktop as the browser in which we invoked the bubble. |
| + Browser* active_browser = chrome::FindLastActiveWithHostDesktopType( |
| + browser()->host_desktop_type()); |
| + return active_browser->tab_strip_model()->GetActiveWebContents(); |
| + } |
| + |
| + private: |
| + content::WebContents* GetFirstTab() { |
| + return browser()->tab_strip_model()->GetWebContentsAt(0); |
| + } |
| +}; |
| + |
| +// 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) { |
| + // For each of the three options, we click the management link and check if |
| + // the active tab starts loading the correct internal url. We don't need to |
| + // wait until the navigation finishes. |
| + |
| + // The microphone bubble links to microphone exceptions. |
| + ManageMediaStreamSettings(TabSpecificContentSettings::MICROPHONE_ACCESSED); |
| + EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-mic"), |
| + GetActiveTab()->GetVisibleURL()); |
| + |
| + // The camera bubble links to camera exceptions. |
| + ManageMediaStreamSettings(TabSpecificContentSettings::CAMERA_ACCESSED); |
| + EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-camera"), |
| + GetActiveTab()->GetVisibleURL()); |
| + |
| + // The bubble for both media devices links to the the first section of the |
| + // default media content settings, which is the microphone section. |
| + ManageMediaStreamSettings(TabSpecificContentSettings::MICROPHONE_ACCESSED | |
| + TabSpecificContentSettings::CAMERA_ACCESSED); |
| + EXPECT_EQ(GURL("chrome://settings/content#media-stream-mic"), |
| + GetActiveTab()->GetVisibleURL()); |
| +} |