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..dd3f9be5a634edbf07da7abcd9ad50ea8452631e 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,73 @@ 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) { |
| + // Open a tab for which we will invoke the media bubble. |
| + ui_test_utils::NavigateToURL( |
|
msw
2015/08/11 17:03:14
nit: follow the pattern of the other tests:
GURL u
msramek
2015/08/12 08:41:58
Well, I can separate the construction of the URL f
|
| + browser(), |
| + ui_test_utils::GetTestUrl( |
| + base::FilePath().AppendASCII("content_setting_bubble"), |
| + base::FilePath().AppendASCII("mixed_script.html"))); |
| + content::WebContents* original_tab = GetActiveTab(); |
| + |
| + // Create a bubble with the given camera and microphone access state. |
| + TabSpecificContentSettings::FromWebContents(original_tab)-> |
| + OnMediaStreamPermissionSet( |
| + original_tab->GetLastCommittedURL(), |
| + state, std::string(), std::string(), std::string(), std::string()); |
| + scoped_ptr<ContentSettingBubbleModel> bubble( |
| + ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| + browser()->content_setting_bubble_model_delegate(), |
| + original_tab, |
| + browser()->profile(), |
| + CONTENT_SETTINGS_TYPE_MEDIASTREAM)); |
| + |
| + // Click the management link, which opens in a new tab or window. |
| + // Wait until it loads. |
| + bubble->OnManageLinkClicked(); |
| + ASSERT_NE(GetActiveTab(), original_tab); |
| + content::TestNavigationObserver observer(GetActiveTab()); |
| + observer.Wait(); |
| + } |
| + |
| + 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(); |
| + } |
| +}; |
| + |
| +// Tests that clicking on the management link in the media bubble opens |
| +// the correct section of the settings UI. |
| +// TODO(msramek): This test can fail if the settings UI opens in a separate |
|
msw
2015/08/11 17:03:14
nit: put this in the CL description, not the code.
msramek
2015/08/12 08:41:58
Done.
|
| +// window, but BrowserList does not recognize the window as active yet. |
| +// Several rounds of testing on trybots suggest that this does not happen. |
| +// If it in fact does happen, disable this test, restrict it to the same-window |
| +// case, or fix it to wait for the new window to be focused. |
| +IN_PROC_BROWSER_TEST_F(ContentSettingBubbleModelMediaStreamTest, ManageLink) { |
| + // For each of the three options, we click the management link and check if |
| + // the active tab loads the correct internal url. |
| + |
| + // The microphone bubble links to microphone exceptions. |
| + ManageMediaStreamSettings(TabSpecificContentSettings::MICROPHONE_ACCESSED); |
| + EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-mic"), |
| + GetActiveTab()->GetLastCommittedURL()); |
| + |
| + // The camera bubble links to camera exceptions. |
| + ManageMediaStreamSettings(TabSpecificContentSettings::CAMERA_ACCESSED); |
| + EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-camera"), |
| + GetActiveTab()->GetLastCommittedURL()); |
| + |
| + // 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()->GetLastCommittedURL()); |
| +} |