Chromium Code Reviews| 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); |
| 921 content::WindowedNotificationObserver observer( | |
| 922 content::NOTIFICATION_LOAD_STOP, | |
| 923 content::NotificationService::AllSources()); | |
| 916 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); | 924 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); |
| 917 | 925 |
| 918 // This should have created a new browser window. | 926 // This should have created a new browser window. |
| 919 Browser* new_browser = FindOneOtherBrowser(browser()); | 927 Browser* new_browser = FindOneOtherBrowser(browser()); |
| 920 ASSERT_TRUE(new_browser); | 928 ASSERT_TRUE(new_browser); |
| 921 | 929 |
| 922 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 930 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 923 // There should be only one tab. | 931 // There should be only one tab. |
| 924 EXPECT_EQ(1, tab_strip->count()); | 932 EXPECT_EQ(1, tab_strip->count()); |
| 925 | 933 |
| 926 // And it should point to the managed user settings page. | 934 // And it should point to the managed user settings page. |
| 927 content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); | 935 content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); |
| 928 GURL expected(GURL(std::string(chrome::kChromeUISettingsURL) + | 936 GURL expected(GURL(std::string(chrome::kChromeUISettingsURL) + |
| 929 chrome::kManagedUserSettingsSubPage)); | 937 chrome::kManagedUserSettingsSubPage)); |
| 930 EXPECT_EQ(GURL(expected), web_contents->GetURL()); | 938 EXPECT_EQ(GURL(expected), web_contents->GetURL()); |
| 939 observer.Wait(); | |
| 940 | |
| 941 // And the managed user should be in elevated state. | |
|
James Hawkins
2013/04/10 16:16:15
// Managed user should...
| |
| 942 bool is_elevated = ManagedModeNavigationObserver::FromWebContents( | |
| 943 web_contents)->is_elevated(); | |
| 944 EXPECT_TRUE(is_elevated); | |
| 931 } | 945 } |
| 932 | 946 |
| 947 #endif // ENABLE_MANAGED_USERS | |
| 948 | |
| 933 #endif // !OS_CHROMEOS | 949 #endif // !OS_CHROMEOS |
| OLD | NEW |