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

Side by Side Diff: chrome/browser/supervised_user/supervised_user_browsertest.cc

Issue 335833003: Rename "managed (mode|user)" to "supervised user" (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments (+ a few other cleanups) Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/common/cancelable_request.h" 10 #include "chrome/browser/common/cancelable_request.h"
11 #include "chrome/browser/history/history_service_factory.h" 11 #include "chrome/browser/history/history_service_factory.h"
12 #include "chrome/browser/infobars/infobar_service.h" 12 #include "chrome/browser/infobars/infobar_service.h"
13 #include "chrome/browser/managed_mode/managed_mode_interstitial.h"
14 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h"
15 #include "chrome/browser/managed_mode/managed_user_constants.h"
16 #include "chrome/browser/managed_mode/managed_user_service.h"
17 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
18 #include "chrome/browser/managed_mode/managed_user_settings_service.h"
19 #include "chrome/browser/managed_mode/managed_user_settings_service_factory.h"
20 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/supervised_user/supervised_user_constants.h"
15 #include "chrome/browser/supervised_user/supervised_user_interstitial.h"
16 #include "chrome/browser/supervised_user/supervised_user_navigation_observer.h"
17 #include "chrome/browser/supervised_user/supervised_user_service.h"
18 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
19 #include "chrome/browser/supervised_user/supervised_user_settings_service.h"
20 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor y.h"
21 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_navigator.h" 22 #include "chrome/browser/ui/browser_navigator.h"
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" 24 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/test/base/in_process_browser_test.h" 27 #include "chrome/test/base/in_process_browser_test.h"
28 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
29 #include "components/infobars/core/confirm_infobar_delegate.h" 29 #include "components/infobars/core/confirm_infobar_delegate.h"
30 #include "components/infobars/core/infobar.h" 30 #include "components/infobars/core/infobar.h"
(...skipping 10 matching lines...) Expand all
41 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
42 42
43 using content::InterstitialPage; 43 using content::InterstitialPage;
44 using content::NavigationController; 44 using content::NavigationController;
45 using content::NavigationEntry; 45 using content::NavigationEntry;
46 using content::WebContents; 46 using content::WebContents;
47 47
48 namespace { 48 namespace {
49 49
50 // Tests the filter mode in which all sites are blocked by default. 50 // Tests the filter mode in which all sites are blocked by default.
51 class ManagedModeBlockModeTest : public InProcessBrowserTest { 51 class SupervisedUserBlockModeTest : public InProcessBrowserTest {
52 public: 52 public:
53 // Indicates whether the interstitial should proceed or not. 53 // Indicates whether the interstitial should proceed or not.
54 enum InterstitialAction { 54 enum InterstitialAction {
55 INTERSTITIAL_PROCEED, 55 INTERSTITIAL_PROCEED,
56 INTERSTITIAL_DONTPROCEED, 56 INTERSTITIAL_DONTPROCEED,
57 }; 57 };
58 58
59 ManagedModeBlockModeTest() : managed_user_service_(NULL) {} 59 SupervisedUserBlockModeTest() : supervised_user_service_(NULL) {}
60 virtual ~ManagedModeBlockModeTest() {} 60 virtual ~SupervisedUserBlockModeTest() {}
61 61
62 void CheckShownPageIsInterstitial(WebContents* tab) { 62 void CheckShownPageIsInterstitial(WebContents* tab) {
63 CheckShownPage(tab, content::PAGE_TYPE_INTERSTITIAL); 63 CheckShownPage(tab, content::PAGE_TYPE_INTERSTITIAL);
64 } 64 }
65 65
66 void CheckShownPageIsNotInterstitial(WebContents* tab) { 66 void CheckShownPageIsNotInterstitial(WebContents* tab) {
67 CheckShownPage(tab, content::PAGE_TYPE_NORMAL); 67 CheckShownPage(tab, content::PAGE_TYPE_NORMAL);
68 } 68 }
69 69
70 // Checks to see if the type of the current page is |page_type|. 70 // Checks to see if the type of the current page is |page_type|.
71 void CheckShownPage(WebContents* tab, content::PageType page_type) { 71 void CheckShownPage(WebContents* tab, content::PageType page_type) {
72 ASSERT_FALSE(tab->IsCrashed()); 72 ASSERT_FALSE(tab->IsCrashed());
73 NavigationEntry* entry = tab->GetController().GetActiveEntry(); 73 NavigationEntry* entry = tab->GetController().GetActiveEntry();
74 ASSERT_TRUE(entry); 74 ASSERT_TRUE(entry);
75 ASSERT_EQ(page_type, entry->GetPageType()); 75 ASSERT_EQ(page_type, entry->GetPageType());
76 } 76 }
77 77
78 void SendAccessRequest(WebContents* tab) { 78 void SendAccessRequest(WebContents* tab) {
79 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); 79 InterstitialPage* interstitial_page = tab->GetInterstitialPage();
80 ASSERT_TRUE(interstitial_page); 80 ASSERT_TRUE(interstitial_page);
81 81
82 // Get the ManagedModeInterstitial delegate. 82 // Get the SupervisedUserInterstitial delegate.
83 content::InterstitialPageDelegate* delegate = 83 content::InterstitialPageDelegate* delegate =
84 interstitial_page->GetDelegateForTesting(); 84 interstitial_page->GetDelegateForTesting();
85 85
86 // Simulate the click on the "request" button. 86 // Simulate the click on the "request" button.
87 delegate->CommandReceived("\"request\""); 87 delegate->CommandReceived("\"request\"");
88 } 88 }
89 89
90 void GoBack(WebContents* tab) { 90 void GoBack(WebContents* tab) {
91 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); 91 InterstitialPage* interstitial_page = tab->GetInterstitialPage();
92 ASSERT_TRUE(interstitial_page); 92 ASSERT_TRUE(interstitial_page);
93 93
94 // Get the ManagedModeInterstitial delegate. 94 // Get the SupervisedUserInterstitial delegate.
95 content::InterstitialPageDelegate* delegate = 95 content::InterstitialPageDelegate* delegate =
96 interstitial_page->GetDelegateForTesting(); 96 interstitial_page->GetDelegateForTesting();
97 97
98 // Simulate the click on the "back" button. 98 // Simulate the click on the "back" button.
99 delegate->CommandReceived("\"back\""); 99 delegate->CommandReceived("\"back\"");
100 } 100 }
101 101
102 protected: 102 protected:
103 virtual void SetUpOnMainThread() OVERRIDE { 103 virtual void SetUpOnMainThread() OVERRIDE {
104 // Set up the ManagedModeNavigationObserver manually since the profile was 104 // Set up the SupervisedUserNavigationObserver manually since the profile
105 // not managed when the browser was created. 105 // was not supervised when the browser was created.
106 content::WebContents* web_contents = 106 content::WebContents* web_contents =
107 browser()->tab_strip_model()->GetActiveWebContents(); 107 browser()->tab_strip_model()->GetActiveWebContents();
108 ManagedModeNavigationObserver::CreateForWebContents(web_contents); 108 SupervisedUserNavigationObserver::CreateForWebContents(web_contents);
109 109
110 Profile* profile = browser()->profile(); 110 Profile* profile = browser()->profile();
111 managed_user_service_ = ManagedUserServiceFactory::GetForProfile(profile); 111 supervised_user_service_ =
112 ManagedUserSettingsService* managed_user_settings_service = 112 SupervisedUserServiceFactory::GetForProfile(profile);
113 ManagedUserSettingsServiceFactory::GetForProfile(profile); 113 SupervisedUserSettingsService* supervised_user_settings_service =
114 managed_user_settings_service->SetLocalSettingForTesting( 114 SupervisedUserSettingsServiceFactory::GetForProfile(profile);
115 managed_users::kContentPackDefaultFilteringBehavior, 115 supervised_user_settings_service->SetLocalSettingForTesting(
116 supervised_users::kContentPackDefaultFilteringBehavior,
116 scoped_ptr<base::Value>( 117 scoped_ptr<base::Value>(
117 new base::FundamentalValue(ManagedModeURLFilter::BLOCK))); 118 new base::FundamentalValue(SupervisedUserURLFilter::BLOCK)));
118 } 119 }
119 120
120 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 121 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
121 // Enable the test server and remap all URLs to it. 122 // Enable the test server and remap all URLs to it.
122 ASSERT_TRUE(test_server()->Start()); 123 ASSERT_TRUE(test_server()->Start());
123 std::string host_port = test_server()->host_port_pair().ToString(); 124 std::string host_port = test_server()->host_port_pair().ToString();
124 command_line->AppendSwitchASCII(switches::kHostResolverRules, 125 command_line->AppendSwitchASCII(switches::kHostResolverRules,
125 "MAP *.example.com " + host_port + "," + 126 "MAP *.example.com " + host_port + "," +
126 "MAP *.new-example.com " + host_port + "," + 127 "MAP *.new-example.com " + host_port + "," +
127 "MAP *.a.com " + host_port); 128 "MAP *.a.com " + host_port);
128 129
129 command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf"); 130 command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf");
130 } 131 }
131 132
132 // Acts like a synchronous call to history's QueryHistory. Modified from 133 // Acts like a synchronous call to history's QueryHistory. Modified from
133 // history_querying_unittest.cc. 134 // history_querying_unittest.cc.
134 void QueryHistory(HistoryService* history_service, 135 void QueryHistory(HistoryService* history_service,
135 const std::string& text_query, 136 const std::string& text_query,
136 const history::QueryOptions& options, 137 const history::QueryOptions& options,
137 history::QueryResults* results) { 138 history::QueryResults* results) {
138 CancelableRequestConsumer history_request_consumer; 139 CancelableRequestConsumer history_request_consumer;
139 base::RunLoop run_loop; 140 base::RunLoop run_loop;
140 history_service->QueryHistory( 141 history_service->QueryHistory(
141 base::UTF8ToUTF16(text_query), 142 base::UTF8ToUTF16(text_query),
142 options, 143 options,
143 &history_request_consumer, 144 &history_request_consumer,
144 base::Bind(&ManagedModeBlockModeTest::QueryHistoryComplete, 145 base::Bind(&SupervisedUserBlockModeTest::QueryHistoryComplete,
145 base::Unretained(this), 146 base::Unretained(this),
146 results, 147 results,
147 &run_loop)); 148 &run_loop));
148 run_loop.Run(); // Will go until ...Complete calls Quit. 149 run_loop.Run(); // Will go until ...Complete calls Quit.
149 } 150 }
150 151
151 void QueryHistoryComplete(history::QueryResults* new_results, 152 void QueryHistoryComplete(history::QueryResults* new_results,
152 base::RunLoop* run_loop, 153 base::RunLoop* run_loop,
153 HistoryService::Handle /* handle */, 154 HistoryService::Handle /* handle */,
154 history::QueryResults* results) { 155 history::QueryResults* results) {
155 results->Swap(new_results); 156 results->Swap(new_results);
156 run_loop->Quit(); // Will return out to QueryHistory. 157 run_loop->Quit(); // Will return out to QueryHistory.
157 } 158 }
158 159
159 ManagedUserService* managed_user_service_; 160 SupervisedUserService* supervised_user_service_;
160 }; 161 };
161 162
162 class MockTabStripModelObserver : public TabStripModelObserver { 163 class MockTabStripModelObserver : public TabStripModelObserver {
163 public: 164 public:
164 explicit MockTabStripModelObserver(TabStripModel* tab_strip) 165 explicit MockTabStripModelObserver(TabStripModel* tab_strip)
165 : tab_strip_(tab_strip) { 166 : tab_strip_(tab_strip) {
166 tab_strip_->AddObserver(this); 167 tab_strip_->AddObserver(this);
167 } 168 }
168 169
169 ~MockTabStripModelObserver() { 170 ~MockTabStripModelObserver() {
170 tab_strip_->RemoveObserver(this); 171 tab_strip_->RemoveObserver(this);
171 } 172 }
172 173
173 MOCK_METHOD3(TabClosingAt, void(TabStripModel*, content::WebContents*, int)); 174 MOCK_METHOD3(TabClosingAt, void(TabStripModel*, content::WebContents*, int));
174 175
175 private: 176 private:
176 TabStripModel* tab_strip_; 177 TabStripModel* tab_strip_;
177 }; 178 };
178 179
179 // Navigates to a blocked URL. 180 // Navigates to a blocked URL.
180 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, 181 IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest,
181 SendAccessRequestOnBlockedURL) { 182 SendAccessRequestOnBlockedURL) {
182 GURL test_url("http://www.example.com/files/simple.html"); 183 GURL test_url("http://www.example.com/files/simple.html");
183 ui_test_utils::NavigateToURL(browser(), test_url); 184 ui_test_utils::NavigateToURL(browser(), test_url);
184 185
185 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 186 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
186 187
187 CheckShownPageIsInterstitial(tab); 188 CheckShownPageIsInterstitial(tab);
188 189
189 SendAccessRequest(tab); 190 SendAccessRequest(tab);
190 191
191 // TODO(sergiu): Properly check that the access request was sent here. 192 // TODO(sergiu): Properly check that the access request was sent here.
192 193
193 GoBack(tab); 194 GoBack(tab);
194 195
195 // Make sure that the tab is still there. 196 // Make sure that the tab is still there.
196 EXPECT_EQ(tab, browser()->tab_strip_model()->GetActiveWebContents()); 197 EXPECT_EQ(tab, browser()->tab_strip_model()->GetActiveWebContents());
197 198
198 CheckShownPageIsNotInterstitial(tab); 199 CheckShownPageIsNotInterstitial(tab);
199 } 200 }
200 201
201 // Navigates to a blocked URL in a new tab. We expect the tab to be closed 202 // Navigates to a blocked URL in a new tab. We expect the tab to be closed
202 // automatically on pressing the "back" button on the interstitial. 203 // automatically on pressing the "back" button on the interstitial.
203 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, OpenBlockedURLInNewTab) { 204 IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest, OpenBlockedURLInNewTab) {
204 TabStripModel* tab_strip = browser()->tab_strip_model(); 205 TabStripModel* tab_strip = browser()->tab_strip_model();
205 WebContents* prev_tab = tab_strip->GetActiveWebContents(); 206 WebContents* prev_tab = tab_strip->GetActiveWebContents();
206 207
207 // Open blocked URL in a new tab. 208 // Open blocked URL in a new tab.
208 GURL test_url("http://www.example.com/files/simple.html"); 209 GURL test_url("http://www.example.com/files/simple.html");
209 ui_test_utils::NavigateToURLWithDisposition( 210 ui_test_utils::NavigateToURLWithDisposition(
210 browser(), test_url, NEW_FOREGROUND_TAB, 211 browser(), test_url, NEW_FOREGROUND_TAB,
211 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 212 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
212 213
213 // Check that we got the interstitial. 214 // Check that we got the interstitial.
214 WebContents* tab = tab_strip->GetActiveWebContents(); 215 WebContents* tab = tab_strip->GetActiveWebContents();
215 CheckShownPageIsInterstitial(tab); 216 CheckShownPageIsInterstitial(tab);
216 217
217 // On pressing the "back" button, the new tab should be closed, and we should 218 // On pressing the "back" button, the new tab should be closed, and we should
218 // get back to the previous active tab. 219 // get back to the previous active tab.
219 MockTabStripModelObserver observer(tab_strip); 220 MockTabStripModelObserver observer(tab_strip);
220 EXPECT_CALL(observer, 221 EXPECT_CALL(observer,
221 TabClosingAt(tab_strip, tab, tab_strip->active_index())); 222 TabClosingAt(tab_strip, tab, tab_strip->active_index()));
222 GoBack(tab); 223 GoBack(tab);
223 EXPECT_EQ(prev_tab, tab_strip->GetActiveWebContents()); 224 EXPECT_EQ(prev_tab, tab_strip->GetActiveWebContents());
224 } 225 }
225 226
226 // Tests whether a visit attempt adds a special history entry. 227 // Tests whether a visit attempt adds a special history entry.
227 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, 228 IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest,
228 HistoryVisitRecorded) { 229 HistoryVisitRecorded) {
229 GURL allowed_url("http://www.example.com/files/simple.html"); 230 GURL allowed_url("http://www.example.com/files/simple.html");
230 231
231 // Set the host as allowed. 232 // Set the host as allowed.
232 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 233 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
233 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true); 234 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true);
234 ManagedUserSettingsService* managed_user_settings_service = 235 SupervisedUserSettingsService* supervised_user_settings_service =
235 ManagedUserSettingsServiceFactory::GetForProfile( 236 SupervisedUserSettingsServiceFactory::GetForProfile(
236 browser()->profile()); 237 browser()->profile());
237 managed_user_settings_service->SetLocalSettingForTesting( 238 supervised_user_settings_service->SetLocalSettingForTesting(
238 managed_users::kContentPackManualBehaviorHosts, 239 supervised_users::kContentPackManualBehaviorHosts,
239 dict.PassAs<base::Value>()); 240 dict.PassAs<base::Value>());
240 EXPECT_EQ( 241 EXPECT_EQ(
241 ManagedUserService::MANUAL_ALLOW, 242 SupervisedUserService::MANUAL_ALLOW,
242 managed_user_service_->GetManualBehaviorForHost(allowed_url.host())); 243 supervised_user_service_->GetManualBehaviorForHost(allowed_url.host()));
243 244
244 ui_test_utils::NavigateToURL(browser(), allowed_url); 245 ui_test_utils::NavigateToURL(browser(), allowed_url);
245 246
246 // Navigate to it and check that we don't get an interstitial. 247 // Navigate to it and check that we don't get an interstitial.
247 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 248 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
248 CheckShownPageIsNotInterstitial(tab); 249 CheckShownPageIsNotInterstitial(tab);
249 250
250 // Navigate to a blocked page and go back on the interstitial. 251 // Navigate to a blocked page and go back on the interstitial.
251 GURL blocked_url("http://www.new-example.com/files/simple.html"); 252 GURL blocked_url("http://www.new-example.com/files/simple.html");
252 ui_test_utils::NavigateToURL(browser(), blocked_url); 253 ui_test_utils::NavigateToURL(browser(), blocked_url);
253 254
254 tab = browser()->tab_strip_model()->GetActiveWebContents(); 255 tab = browser()->tab_strip_model()->GetActiveWebContents();
255 256
256 CheckShownPageIsInterstitial(tab); 257 CheckShownPageIsInterstitial(tab);
257 GoBack(tab); 258 GoBack(tab);
258 259
259 // Check that we went back to the first URL and that the manual behaviors 260 // Check that we went back to the first URL and that the manual behaviors
260 // have not changed. 261 // have not changed.
261 EXPECT_EQ(allowed_url.spec(), tab->GetURL().spec()); 262 EXPECT_EQ(allowed_url.spec(), tab->GetURL().spec());
262 EXPECT_EQ(ManagedUserService::MANUAL_ALLOW, 263 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW,
263 managed_user_service_->GetManualBehaviorForHost("www.example.com")); 264 supervised_user_service_->GetManualBehaviorForHost(
265 "www.example.com"));
264 EXPECT_EQ( 266 EXPECT_EQ(
265 ManagedUserService::MANUAL_NONE, 267 SupervisedUserService::MANUAL_NONE,
266 managed_user_service_->GetManualBehaviorForHost("www.new-example.com")); 268 supervised_user_service_->GetManualBehaviorForHost(
269 "www.new-example.com"));
267 270
268 // Query the history entry. 271 // Query the history entry.
269 HistoryService* history_service = HistoryServiceFactory::GetForProfile( 272 HistoryService* history_service = HistoryServiceFactory::GetForProfile(
270 browser()->profile(), Profile::EXPLICIT_ACCESS); 273 browser()->profile(), Profile::EXPLICIT_ACCESS);
271 history::QueryOptions options; 274 history::QueryOptions options;
272 history::QueryResults results; 275 history::QueryResults results;
273 QueryHistory(history_service, "", options, &results); 276 QueryHistory(history_service, "", options, &results);
274 277
275 // Check that the entries have the correct blocked_visit value. 278 // Check that the entries have the correct blocked_visit value.
276 ASSERT_EQ(2u, results.size()); 279 ASSERT_EQ(2u, results.size());
277 EXPECT_EQ(blocked_url.spec(), results[0].url().spec()); 280 EXPECT_EQ(blocked_url.spec(), results[0].url().spec());
278 EXPECT_TRUE(results[0].blocked_visit()); 281 EXPECT_TRUE(results[0].blocked_visit());
279 EXPECT_EQ(allowed_url.spec(), results[1].url().spec()); 282 EXPECT_EQ(allowed_url.spec(), results[1].url().spec());
280 EXPECT_FALSE(results[1].blocked_visit()); 283 EXPECT_FALSE(results[1].blocked_visit());
281 } 284 }
282 285
283 IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, Unblock) { 286 IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest, Unblock) {
284 GURL test_url("http://www.example.com/files/simple.html"); 287 GURL test_url("http://www.example.com/files/simple.html");
285 ui_test_utils::NavigateToURL(browser(), test_url); 288 ui_test_utils::NavigateToURL(browser(), test_url);
286 289
287 WebContents* web_contents = 290 WebContents* web_contents =
288 browser()->tab_strip_model()->GetActiveWebContents(); 291 browser()->tab_strip_model()->GetActiveWebContents();
289 292
290 CheckShownPageIsInterstitial(web_contents); 293 CheckShownPageIsInterstitial(web_contents);
291 294
292 content::WindowedNotificationObserver observer( 295 content::WindowedNotificationObserver observer(
293 content::NOTIFICATION_LOAD_STOP, 296 content::NOTIFICATION_LOAD_STOP,
294 content::NotificationService::AllSources()); 297 content::NotificationService::AllSources());
295 298
296 // Set the host as allowed. 299 // Set the host as allowed.
297 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 300 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
298 dict->SetBooleanWithoutPathExpansion(test_url.host(), true); 301 dict->SetBooleanWithoutPathExpansion(test_url.host(), true);
299 ManagedUserSettingsService* managed_user_settings_service = 302 SupervisedUserSettingsService* supervised_user_settings_service =
300 ManagedUserSettingsServiceFactory::GetForProfile( 303 SupervisedUserSettingsServiceFactory::GetForProfile(
301 browser()->profile()); 304 browser()->profile());
302 managed_user_settings_service->SetLocalSettingForTesting( 305 supervised_user_settings_service->SetLocalSettingForTesting(
303 managed_users::kContentPackManualBehaviorHosts, 306 supervised_users::kContentPackManualBehaviorHosts,
304 dict.PassAs<base::Value>()); 307 dict.PassAs<base::Value>());
305 EXPECT_EQ( 308 EXPECT_EQ(
306 ManagedUserService::MANUAL_ALLOW, 309 SupervisedUserService::MANUAL_ALLOW,
307 managed_user_service_->GetManualBehaviorForHost(test_url.host())); 310 supervised_user_service_->GetManualBehaviorForHost(test_url.host()));
308 311
309 observer.Wait(); 312 observer.Wait();
310 EXPECT_EQ(test_url, web_contents->GetURL()); 313 EXPECT_EQ(test_url, web_contents->GetURL());
311 } 314 }
312 315
313 } // namespace 316 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698