| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // Wait until it loads. | 112 // Wait until it loads. |
| 113 bubble->OnManageLinkClicked(); | 113 bubble->OnManageLinkClicked(); |
| 114 ASSERT_NE(GetActiveTab(), original_tab); | 114 ASSERT_NE(GetActiveTab(), original_tab); |
| 115 content::TestNavigationObserver observer(GetActiveTab()); | 115 content::TestNavigationObserver observer(GetActiveTab()); |
| 116 observer.Wait(); | 116 observer.Wait(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 content::WebContents* GetActiveTab() { | 119 content::WebContents* GetActiveTab() { |
| 120 // First, we need to find the active browser window. It should be at | 120 // First, we need to find the active browser window. It should be at |
| 121 // the same desktop as the browser in which we invoked the bubble. | 121 // the same desktop as the browser in which we invoked the bubble. |
| 122 Browser* active_browser = chrome::FindLastActiveWithHostDesktopType( | 122 Browser* active_browser = chrome::FindLastActive(); |
| 123 browser()->host_desktop_type()); | |
| 124 return active_browser->tab_strip_model()->GetActiveWebContents(); | 123 return active_browser->tab_strip_model()->GetActiveWebContents(); |
| 125 } | 124 } |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 // Tests that clicking on the management link in the media bubble opens | 127 // Tests that clicking on the management link in the media bubble opens |
| 129 // the correct section of the settings UI. | 128 // the correct section of the settings UI. |
| 130 IN_PROC_BROWSER_TEST_F(ContentSettingBubbleModelMediaStreamTest, ManageLink) { | 129 IN_PROC_BROWSER_TEST_F(ContentSettingBubbleModelMediaStreamTest, ManageLink) { |
| 131 // For each of the three options, we click the management link and check if | 130 // For each of the three options, we click the management link and check if |
| 132 // the active tab loads the correct internal url. | 131 // the active tab loads the correct internal url. |
| 133 | 132 |
| 134 // The microphone bubble links to microphone exceptions. | 133 // The microphone bubble links to microphone exceptions. |
| 135 ManageMediaStreamSettings(TabSpecificContentSettings::MICROPHONE_ACCESSED); | 134 ManageMediaStreamSettings(TabSpecificContentSettings::MICROPHONE_ACCESSED); |
| 136 EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-mic"), | 135 EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-mic"), |
| 137 GetActiveTab()->GetLastCommittedURL()); | 136 GetActiveTab()->GetLastCommittedURL()); |
| 138 | 137 |
| 139 // The camera bubble links to camera exceptions. | 138 // The camera bubble links to camera exceptions. |
| 140 ManageMediaStreamSettings(TabSpecificContentSettings::CAMERA_ACCESSED); | 139 ManageMediaStreamSettings(TabSpecificContentSettings::CAMERA_ACCESSED); |
| 141 EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-camera"), | 140 EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-camera"), |
| 142 GetActiveTab()->GetLastCommittedURL()); | 141 GetActiveTab()->GetLastCommittedURL()); |
| 143 | 142 |
| 144 // The bubble for both media devices links to the the first section of the | 143 // The bubble for both media devices links to the the first section of the |
| 145 // default media content settings, which is the microphone section. | 144 // default media content settings, which is the microphone section. |
| 146 ManageMediaStreamSettings(TabSpecificContentSettings::MICROPHONE_ACCESSED | | 145 ManageMediaStreamSettings(TabSpecificContentSettings::MICROPHONE_ACCESSED | |
| 147 TabSpecificContentSettings::CAMERA_ACCESSED); | 146 TabSpecificContentSettings::CAMERA_ACCESSED); |
| 148 EXPECT_EQ(GURL("chrome://settings/content#media-stream-mic"), | 147 EXPECT_EQ(GURL("chrome://settings/content#media-stream-mic"), |
| 149 GetActiveTab()->GetLastCommittedURL()); | 148 GetActiveTab()->GetLastCommittedURL()); |
| 150 } | 149 } |
| OLD | NEW |