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

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

Issue 664313004: SupervisedUserService cleanup: remove some dead code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | chrome/browser/supervised_user/supervised_user_service.h » ('j') | 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 "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/history/history_service_factory.h" 10 #include "chrome/browser/history/history_service_factory.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 GoBack(tab); 221 GoBack(tab);
222 run_loop.Run(); 222 run_loop.Run();
223 EXPECT_EQ(prev_tab, tab_strip->GetActiveWebContents()); 223 EXPECT_EQ(prev_tab, tab_strip->GetActiveWebContents());
224 } 224 }
225 225
226 // Tests whether a visit attempt adds a special history entry. 226 // Tests whether a visit attempt adds a special history entry.
227 IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest, 227 IN_PROC_BROWSER_TEST_F(SupervisedUserBlockModeTest,
228 HistoryVisitRecorded) { 228 HistoryVisitRecorded) {
229 GURL allowed_url("http://www.example.com/files/simple.html"); 229 GURL allowed_url("http://www.example.com/files/simple.html");
230 230
231 scoped_refptr<SupervisedUserURLFilter> filter =
232 supervised_user_service_->GetURLFilterForUIThread();
233
231 // Set the host as allowed. 234 // Set the host as allowed.
232 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 235 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
233 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true); 236 dict->SetBooleanWithoutPathExpansion(allowed_url.host(), true);
234 SupervisedUserSettingsService* supervised_user_settings_service = 237 SupervisedUserSettingsService* supervised_user_settings_service =
235 SupervisedUserSettingsServiceFactory::GetForProfile( 238 SupervisedUserSettingsServiceFactory::GetForProfile(
236 browser()->profile()); 239 browser()->profile());
237 supervised_user_settings_service->SetLocalSettingForTesting( 240 supervised_user_settings_service->SetLocalSettingForTesting(
238 supervised_users::kContentPackManualBehaviorHosts, dict.Pass()); 241 supervised_users::kContentPackManualBehaviorHosts, dict.Pass());
239 EXPECT_EQ( 242 EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
240 SupervisedUserService::MANUAL_ALLOW, 243 filter->GetFilteringBehaviorForURL(allowed_url));
241 supervised_user_service_->GetManualBehaviorForHost(allowed_url.host())); 244 EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
245 filter->GetFilteringBehaviorForURL(allowed_url.GetWithEmptyPath()));
242 246
243 ui_test_utils::NavigateToURL(browser(), allowed_url); 247 ui_test_utils::NavigateToURL(browser(), allowed_url);
244 248
245 // Navigate to it and check that we don't get an interstitial. 249 // Navigate to it and check that we don't get an interstitial.
246 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 250 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
247 CheckShownPageIsNotInterstitial(tab); 251 CheckShownPageIsNotInterstitial(tab);
248 252
249 // Navigate to a blocked page and go back on the interstitial. 253 // Navigate to a blocked page and go back on the interstitial.
250 GURL blocked_url("http://www.new-example.com/files/simple.html"); 254 GURL blocked_url("http://www.new-example.com/files/simple.html");
251 ui_test_utils::NavigateToURL(browser(), blocked_url); 255 ui_test_utils::NavigateToURL(browser(), blocked_url);
252 256
253 tab = browser()->tab_strip_model()->GetActiveWebContents(); 257 tab = browser()->tab_strip_model()->GetActiveWebContents();
254 258
255 CheckShownPageIsInterstitial(tab); 259 CheckShownPageIsInterstitial(tab);
256 GoBack(tab); 260 GoBack(tab);
257 261
258 // Check that we went back to the first URL and that the manual behaviors 262 // Check that we went back to the first URL and that the manual behaviors
259 // have not changed. 263 // have not changed.
260 EXPECT_EQ(allowed_url.spec(), tab->GetURL().spec()); 264 EXPECT_EQ(allowed_url.spec(), tab->GetURL().spec());
261 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, 265 EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
262 supervised_user_service_->GetManualBehaviorForHost( 266 filter->GetFilteringBehaviorForURL(allowed_url.GetWithEmptyPath()));
263 "www.example.com")); 267 EXPECT_EQ(SupervisedUserURLFilter::BLOCK,
264 EXPECT_EQ( 268 filter->GetFilteringBehaviorForURL(blocked_url.GetWithEmptyPath()));
265 SupervisedUserService::MANUAL_NONE,
266 supervised_user_service_->GetManualBehaviorForHost(
267 "www.new-example.com"));
268 269
269 // Query the history entry. 270 // Query the history entry.
270 HistoryService* history_service = HistoryServiceFactory::GetForProfile( 271 HistoryService* history_service = HistoryServiceFactory::GetForProfile(
271 browser()->profile(), Profile::EXPLICIT_ACCESS); 272 browser()->profile(), Profile::EXPLICIT_ACCESS);
272 history::QueryOptions options; 273 history::QueryOptions options;
273 history::QueryResults results; 274 history::QueryResults results;
274 QueryHistory(history_service, "", options, &results); 275 QueryHistory(history_service, "", options, &results);
275 276
276 // Check that the entries have the correct blocked_visit value. 277 // Check that the entries have the correct blocked_visit value.
277 ASSERT_EQ(2u, results.size()); 278 ASSERT_EQ(2u, results.size());
(...skipping 17 matching lines...) Expand all
295 content::NotificationService::AllSources()); 296 content::NotificationService::AllSources());
296 297
297 // Set the host as allowed. 298 // Set the host as allowed.
298 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 299 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
299 dict->SetBooleanWithoutPathExpansion(test_url.host(), true); 300 dict->SetBooleanWithoutPathExpansion(test_url.host(), true);
300 SupervisedUserSettingsService* supervised_user_settings_service = 301 SupervisedUserSettingsService* supervised_user_settings_service =
301 SupervisedUserSettingsServiceFactory::GetForProfile( 302 SupervisedUserSettingsServiceFactory::GetForProfile(
302 browser()->profile()); 303 browser()->profile());
303 supervised_user_settings_service->SetLocalSettingForTesting( 304 supervised_user_settings_service->SetLocalSettingForTesting(
304 supervised_users::kContentPackManualBehaviorHosts, dict.Pass()); 305 supervised_users::kContentPackManualBehaviorHosts, dict.Pass());
305 EXPECT_EQ( 306
306 SupervisedUserService::MANUAL_ALLOW, 307 scoped_refptr<SupervisedUserURLFilter> filter =
307 supervised_user_service_->GetManualBehaviorForHost(test_url.host())); 308 supervised_user_service_->GetURLFilterForUIThread();
309 EXPECT_EQ(SupervisedUserURLFilter::ALLOW,
310 filter->GetFilteringBehaviorForURL(test_url.GetWithEmptyPath()));
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
« no previous file with comments | « no previous file | chrome/browser/supervised_user/supervised_user_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698