OLD | NEW |
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/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
29 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" | 29 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
30 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
31 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
32 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
33 #include "chrome/test/base/in_process_browser_test.h" | 33 #include "chrome/test/base/in_process_browser_test.h" |
34 #include "chrome/test/base/ui_test_utils.h" | 34 #include "chrome/test/base/ui_test_utils.h" |
35 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
36 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
37 | 37 |
| 38 #if defined(ENABLE_MANAGED_USERS) |
| 39 #include "chrome/browser/managed_mode/managed_mode_navigation_observer.h" |
| 40 #endif |
| 41 |
38 using extensions::Extension; | 42 using extensions::Extension; |
39 | 43 |
40 namespace { | 44 namespace { |
41 | 45 |
42 // Check that there are two browsers. Find the one that is not |browser|. | 46 // Check that there are two browsers. Find the one that is not |browser|. |
43 Browser* FindOneOtherBrowser(Browser* browser) { | 47 Browser* FindOneOtherBrowser(Browser* browser) { |
44 // There should only be one other browser. | 48 // There should only be one other browser. |
45 EXPECT_EQ(2u, chrome::GetBrowserCount(browser->profile(), | 49 EXPECT_EQ(2u, chrome::GetBrowserCount(browser->profile(), |
46 browser->host_desktop_type())); | 50 browser->host_desktop_type())); |
47 | 51 |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 } | 900 } |
897 | 901 |
898 class ManagedModeBrowserCreatorTest : public InProcessBrowserTest { | 902 class ManagedModeBrowserCreatorTest : public InProcessBrowserTest { |
899 protected: | 903 protected: |
900 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 904 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
901 InProcessBrowserTest::SetUpCommandLine(command_line); | 905 InProcessBrowserTest::SetUpCommandLine(command_line); |
902 command_line->AppendSwitch(switches::kEnableManagedUsers); | 906 command_line->AppendSwitch(switches::kEnableManagedUsers); |
903 } | 907 } |
904 }; | 908 }; |
905 | 909 |
| 910 #if defined(ENABLE_MANAGED_USERS) |
906 IN_PROC_BROWSER_TEST_F(ManagedModeBrowserCreatorTest, | 911 IN_PROC_BROWSER_TEST_F(ManagedModeBrowserCreatorTest, |
907 StartupManagedModeProfile) { | 912 StartupManagedModeProfile) { |
908 // Make this a managed profile. | 913 // Make this a managed profile. |
909 browser()->profile()->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, true); | 914 browser()->profile()->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, true); |
910 StartupBrowserCreator browser_creator; | 915 StartupBrowserCreator browser_creator; |
911 | 916 |
912 // Do a simple non-process-startup browser launch. | 917 // Do a simple non-process-startup browser launch. |
913 CommandLine dummy(CommandLine::NO_PROGRAM); | 918 CommandLine dummy(CommandLine::NO_PROGRAM); |
914 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, | 919 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, |
915 chrome::startup::IS_FIRST_RUN); | 920 chrome::startup::IS_FIRST_RUN); |
916 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); | 921 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); |
917 | 922 |
918 // This should have created a new browser window. | 923 // This should have created a new browser window. |
919 Browser* new_browser = FindOneOtherBrowser(browser()); | 924 Browser* new_browser = FindOneOtherBrowser(browser()); |
920 ASSERT_TRUE(new_browser); | 925 ASSERT_TRUE(new_browser); |
921 | 926 |
922 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 927 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
923 // There should be only one tab. | 928 // There should be only one tab. |
924 EXPECT_EQ(1, tab_strip->count()); | 929 EXPECT_EQ(1, tab_strip->count()); |
925 | 930 |
926 // And it should point to the managed user settings page. | 931 // And it should point to the managed user settings page. |
927 content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); | 932 content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); |
928 GURL expected(GURL(std::string(chrome::kChromeUISettingsURL) + | 933 GURL expected(GURL(std::string(chrome::kChromeUISettingsURL) + |
929 chrome::kManagedUserSettingsSubPage)); | 934 chrome::kManagedUserSettingsSubPage)); |
930 EXPECT_EQ(GURL(expected), web_contents->GetURL()); | 935 EXPECT_EQ(GURL(expected), web_contents->GetURL()); |
| 936 |
| 937 // And the managed user should be in elevated state. |
| 938 bool is_elevated = ManagedModeNavigationObserver::FromWebContents( |
| 939 web_contents)->is_elevated(); |
| 940 EXPECT_TRUE(is_elevated); |
931 } | 941 } |
932 | 942 |
| 943 #endif // ENABLE_MANAGED_USERS |
| 944 |
933 #endif // !OS_CHROMEOS | 945 #endif // !OS_CHROMEOS |
OLD | NEW |