Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model_browsertest.cc

Issue 1273683002: Fix a forgotten return statement in BrowserContentSettingBubbleModelDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improved a comment. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/browser_content_setting_bubble_model_delegate.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h" 11 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h"
12 #include "chrome/browser/ui/browser_finder.h"
12 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 13 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
16 #include "components/content_settings/core/common/content_settings_types.h" 17 #include "components/content_settings/core/common/content_settings_types.h"
17 #include "content/public/test/test_navigation_observer.h" 18 #include "content/public/test/test_navigation_observer.h"
18 #include "net/test/spawned_test_server/spawned_test_server.h" 19 #include "net/test/spawned_test_server/spawned_test_server.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 const base::FilePath::CharType kDocRoot[] = 22 const base::FilePath::CharType kDocRoot[] =
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); 92 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT));
92 model->OnCustomLinkClicked(); 93 model->OnCustomLinkClicked();
93 94
94 content::TestNavigationObserver observer( 95 content::TestNavigationObserver observer(
95 browser()->tab_strip_model()->GetActiveWebContents()); 96 browser()->tab_strip_model()->GetActiveWebContents());
96 observer.Wait(); 97 observer.Wait();
97 98
98 EXPECT_FALSE(GetActiveTabSpecificContentSettings()->IsContentBlocked( 99 EXPECT_FALSE(GetActiveTabSpecificContentSettings()->IsContentBlocked(
99 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); 100 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT));
100 } 101 }
102
103 class ContentSettingBubbleModelMediaStreamTest : public InProcessBrowserTest {
104 public:
105 void ManageMediaStreamSettings(
106 TabSpecificContentSettings::MicrophoneCameraState state) {
107 // Create a bubble with the given camera and microphone access state.
108 TabSpecificContentSettings::FromWebContents(GetFirstTab())->
109 OnMediaStreamPermissionSet(
110 GetFirstTab()->GetLastCommittedURL(),
111 state, std::string(), std::string(), std::string(), std::string());
112 scoped_ptr<ContentSettingBubbleModel> bubble(
113 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
114 browser()->content_setting_bubble_model_delegate(),
115 GetFirstTab(),
116 browser()->profile(),
117 CONTENT_SETTINGS_TYPE_MEDIASTREAM));
118
119 // Click the management link, which opens in a new tab or window.
120 bubble->OnManageLinkClicked();
msw 2015/08/06 18:41:30 One more thought (sorry). You might actually want
msramek 2015/08/06 19:11:25 Well, but the nav observer waits for a specific ta
msw 2015/08/06 19:24:11 Hmm, good point. I hope GetActiveTab() doesn't ret
msramek 2015/08/11 13:07:41 Done. I inlined the original tab and added an asse
121 }
122
123 content::WebContents* GetActiveTab() {
124 // First, we need to find the active browser window. It should be at
125 // the same desktop as the browser in which we invoked the bubble.
126 Browser* active_browser = chrome::FindLastActiveWithHostDesktopType(
127 browser()->host_desktop_type());
128 return active_browser->tab_strip_model()->GetActiveWebContents();
129 }
130
131 private:
132 content::WebContents* GetFirstTab() {
133 return browser()->tab_strip_model()->GetWebContentsAt(0);
134 }
135 };
136
137 // Tests that clicking on the management link in the media bubble opens
138 // the correct section of the settings UI.
139 IN_PROC_BROWSER_TEST_F(ContentSettingBubbleModelMediaStreamTest, ManageLink) {
140 // For each of the three options, we click the management link and check if
141 // the active tab starts loading the correct internal url. We don't need to
142 // wait until the navigation finishes.
143
144 // The microphone bubble links to microphone exceptions.
145 ManageMediaStreamSettings(TabSpecificContentSettings::MICROPHONE_ACCESSED);
146 EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-mic"),
147 GetActiveTab()->GetVisibleURL());
148
149 // The camera bubble links to camera exceptions.
150 ManageMediaStreamSettings(TabSpecificContentSettings::CAMERA_ACCESSED);
151 EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-camera"),
152 GetActiveTab()->GetVisibleURL());
153
154 // The bubble for both media devices links to the the first section of the
155 // default media content settings, which is the microphone section.
156 ManageMediaStreamSettings(TabSpecificContentSettings::MICROPHONE_ACCESSED |
157 TabSpecificContentSettings::CAMERA_ACCESSED);
158 EXPECT_EQ(GURL("chrome://settings/content#media-stream-mic"),
159 GetActiveTab()->GetVisibleURL());
160 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_content_setting_bubble_model_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698