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

Side by Side Diff: chrome/browser/managed_mode/managed_mode_resource_throttle_browsertest.cc

Issue 23868042: Mark supervised profiles as such immediately when they're created. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/managed_mode/managed_mode_resource_throttle.h" 5 #include "chrome/browser/managed_mode/managed_mode_resource_throttle.h"
6 6
7 #include "base/command_line.h"
7 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
8 #include "base/values.h" 9 #include "base/values.h"
9 #include "chrome/browser/managed_mode/managed_user_constants.h" 10 #include "chrome/browser/managed_mode/managed_user_constants.h"
10 #include "chrome/browser/managed_mode/managed_user_service.h" 11 #include "chrome/browser/managed_mode/managed_user_service.h"
11 #include "chrome/browser/managed_mode/managed_user_service_factory.h" 12 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
12 #include "chrome/browser/managed_mode/managed_user_settings_service.h" 13 #include "chrome/browser/managed_mode/managed_user_settings_service.h"
13 #include "chrome/browser/managed_mode/managed_user_settings_service_factory.h" 14 #include "chrome/browser/managed_mode/managed_user_settings_service_factory.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/common/chrome_switches.h"
16 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
17 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
18 #include "content/public/browser/navigation_entry.h" 20 #include "content/public/browser/navigation_entry.h"
19 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
20 #include "content/public/common/page_type.h" 22 #include "content/public/common/page_type.h"
21 #include "content/public/test/test_navigation_observer.h" 23 #include "content/public/test/test_navigation_observer.h"
22 #include "content/public/test/test_utils.h" 24 #include "content/public/test/test_utils.h"
23 #include "content/public/test/test_utils.h" 25 #include "content/public/test/test_utils.h"
24 26
25 using content::MessageLoopRunner; 27 using content::MessageLoopRunner;
26 using content::NavigationController; 28 using content::NavigationController;
27 using content::WebContents; 29 using content::WebContents;
28 30
29 class ManagedModeResourceThrottleTest : public InProcessBrowserTest { 31 class ManagedModeResourceThrottleTest : public InProcessBrowserTest {
30 protected: 32 protected:
31 ManagedModeResourceThrottleTest() : managed_user_service_(NULL) {} 33 ManagedModeResourceThrottleTest() : managed_user_service_(NULL) {}
32 virtual ~ManagedModeResourceThrottleTest() {} 34 virtual ~ManagedModeResourceThrottleTest() {}
33 35
34 private: 36 private:
35 virtual void SetUpOnMainThread() OVERRIDE; 37 virtual void SetUpOnMainThread() OVERRIDE;
38 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
36 39
37 ManagedUserService* managed_user_service_; 40 ManagedUserService* managed_user_service_;
38 }; 41 };
39 42
40 void ManagedModeResourceThrottleTest::SetUpOnMainThread() { 43 void ManagedModeResourceThrottleTest::SetUpOnMainThread() {
41 managed_user_service_ = 44 managed_user_service_ =
42 ManagedUserServiceFactory::GetForProfile(browser()->profile()); 45 ManagedUserServiceFactory::GetForProfile(browser()->profile());
43 managed_user_service_->InitForTesting(); 46 }
47
48 void ManagedModeResourceThrottleTest::SetUpCommandLine(
49 CommandLine* command_line) {
50 command_line->AppendSwitch(switches::kNewProfileIsSupervised);
44 } 51 }
45 52
46 // Tests that showing the blocking interstitial for a WebContents without a 53 // Tests that showing the blocking interstitial for a WebContents without a
47 // ManagedModeNavigationObserver doesn't crash. 54 // ManagedModeNavigationObserver doesn't crash.
48 IN_PROC_BROWSER_TEST_F(ManagedModeResourceThrottleTest, 55 IN_PROC_BROWSER_TEST_F(ManagedModeResourceThrottleTest,
49 NoNavigationObserverBlock) { 56 NoNavigationObserverBlock) {
50 Profile* profile = browser()->profile(); 57 Profile* profile = browser()->profile();
51 ManagedUserSettingsService* managed_user_settings_service = 58 ManagedUserSettingsService* managed_user_settings_service =
52 ManagedUserSettingsServiceFactory::GetForProfile(profile); 59 ManagedUserSettingsServiceFactory::GetForProfile(profile);
53 managed_user_settings_service->SetLocalSettingForTesting( 60 managed_user_settings_service->SetLocalSettingForTesting(
54 managed_users::kContentPackDefaultFilteringBehavior, 61 managed_users::kContentPackDefaultFilteringBehavior,
55 scoped_ptr<base::Value>( 62 scoped_ptr<base::Value>(
56 new base::FundamentalValue(ManagedModeURLFilter::BLOCK))); 63 new base::FundamentalValue(ManagedModeURLFilter::BLOCK)));
57 64
58 scoped_ptr<WebContents> web_contents( 65 scoped_ptr<WebContents> web_contents(
59 WebContents::Create(WebContents::CreateParams(profile))); 66 WebContents::Create(WebContents::CreateParams(profile)));
60 NavigationController& controller = web_contents->GetController(); 67 NavigationController& controller = web_contents->GetController();
61 content::TestNavigationObserver observer(web_contents.get()); 68 content::TestNavigationObserver observer(web_contents.get());
62 controller.LoadURL(GURL("http://www.example.com"), content::Referrer(), 69 controller.LoadURL(GURL("http://www.example.com"), content::Referrer(),
63 content::PAGE_TRANSITION_TYPED, std::string()); 70 content::PAGE_TRANSITION_TYPED, std::string());
64 observer.Wait(); 71 observer.Wait();
65 content::NavigationEntry* entry = controller.GetActiveEntry(); 72 content::NavigationEntry* entry = controller.GetActiveEntry();
66 ASSERT_TRUE(entry); 73 ASSERT_TRUE(entry);
67 EXPECT_EQ(content::PAGE_TYPE_INTERSTITIAL, entry->GetPageType()); 74 EXPECT_EQ(content::PAGE_TYPE_INTERSTITIAL, entry->GetPageType());
68 } 75 }
OLDNEW
« no previous file with comments | « chrome/browser/managed_mode/managed_mode_browsertest.cc ('k') | chrome/browser/managed_mode/managed_user_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698