Chromium Code Reviews| Index: chrome/browser/ui/startup/startup_browser_creator_browsertest.cc |
| diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc |
| index aec9cf578fb04ec1e8a86e18b653d7f10aa17b2a..9fc83051348f0c0326d1d5502e87b79278f09ef2 100644 |
| --- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc |
| +++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc |
| @@ -92,7 +92,7 @@ class StartupBrowserCreatorTest : public ExtensionBrowserTest { |
| // Find the new browser. |
| Browser* other_browser = NULL; |
| - for (chrome::BrowserIterator it; !it.done() && !other_browser; it.Next()) { |
| + for (chrome::BrowserIterator it; !it.done() && !other_browser; it.Next()) { |
| if (*it != browser()) |
| other_browser = *it; |
| } |
| @@ -892,4 +892,56 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { |
| EXPECT_EQ(1U, |
| InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); |
| } |
| + |
| +class ManagedModeBrowserCreatorTest : public InProcessBrowserTest { |
| + protected: |
| + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| + InProcessBrowserTest::SetUpCommandLine(command_line); |
| + command_line->AppendSwitch(switches::kEnableManagedUsers); |
| + } |
| + |
| + // Check that there are two browsers. Find the one that is not |browser()|. |
| + void FindOneOtherBrowser(Browser** out_other_browser) { |
|
Bernhard Bauer
2013/04/03 16:41:23
This method is a copy of the one starting at line
Sergiu
2013/04/03 17:45:54
Moved it as a function in the anonymous namespace
|
| + // There should only be one other browser. |
| + ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), |
| + browser()->host_desktop_type())); |
| + |
| + // Find the new browser. |
| + Browser* other_browser = NULL; |
| + for (chrome::BrowserIterator it; !it.done() && !other_browser; it.Next()) { |
| + if (*it != browser()) |
| + other_browser = *it; |
| + } |
| + ASSERT_TRUE(other_browser); |
| + ASSERT_TRUE(other_browser != browser()); |
| + *out_other_browser = other_browser; |
| + } |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(ManagedModeBrowserCreatorTest, |
| + StartupManagedModeProfile) { |
| + // Make this a managed profile. |
| + browser()->profile()->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, true); |
| + StartupBrowserCreator browser_creator; |
| + |
| + // Do a simple non-process-startup browser launch. |
| + CommandLine dummy(CommandLine::NO_PROGRAM); |
| + StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, |
| + chrome::startup::IS_FIRST_RUN); |
| + ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); |
| + |
| + // This should have created a new browser window. |
| + Browser* new_browser = NULL; |
| + ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser)); |
| + |
| + TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| + // There should be only one tab. |
| + EXPECT_EQ(1, tab_strip->count()); |
| + |
| + // And it should point to the managed user settings page. |
| + content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); |
| + GURL expected(GURL(std::string(chrome::kChromeUISettingsURL) + |
| + chrome::kManagedUserSettingsSubPage)); |
| + EXPECT_EQ(GURL(expected), web_contents->GetURL()); |
| +} |
| #endif // !OS_CHROMEOS |