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

Unified Diff: chrome/browser/ui/startup/startup_browser_creator_browsertest.cc

Issue 13468005: Show only the settings pages for new managed users (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
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..d787b33ec3cde4693ff81307c1f208b05f3611b7 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
@@ -37,6 +37,27 @@
using extensions::Extension;
+namespace {
+
+// Check that there are two browsers. Find the one that is not |browser|.
+void FindOneOtherBrowser(Browser* browser, Browser** out_other_browser) {
Bernhard Bauer 2013/04/03 17:55:20 Could you simply return the other browser here?
Sergiu 2013/04/04 09:02:55 Well, there is a comment below that says: // Hel
Bernhard Bauer 2013/04/04 09:08:40 Well, yeah, an ASSERT expands to something that re
+ // 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);
Bernhard Bauer 2013/04/03 17:55:20 This check isn't really necessary (that's the exac
Sergiu 2013/04/04 09:02:55 Done.
+ *out_other_browser = other_browser;
+}
+
+} // namespace
+
class StartupBrowserCreatorTest : public ExtensionBrowserTest {
protected:
virtual bool SetUpUserDataDirectory() OVERRIDE {
@@ -84,23 +105,6 @@ class StartupBrowserCreatorTest : public ExtensionBrowserTest {
service->extension_prefs()->SetLaunchType(app_id, launch_type);
}
- // Check that there are two browsers. Find the one that is not |browser()|.
- void FindOneOtherBrowser(Browser** out_other_browser) {
- // 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;
- }
-
Browser* FindOneOtherBrowserForProfile(Profile* profile,
Browser* not_this_browser) {
for (chrome::BrowserIterator it; !it.done(); it.Next()) {
@@ -189,7 +193,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest,
// This should have created a new browser window. |browser()| is still
// around at this point, even though we've closed its window.
Browser* new_browser = NULL;
- ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser));
+ ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(browser(), &new_browser));
// The new browser should have one tab for each URL.
TabStripModel* tab_strip = new_browser->tab_strip_model();
@@ -232,7 +236,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest,
// This should have created a new browser window.
Browser* new_browser = NULL;
- ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser));
+ ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(browser(), &new_browser));
// The new browser should have exactly one tab (not the startup URLs).
ASSERT_EQ(1, new_browser->tab_strip_model()->count());
@@ -257,7 +261,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenAppShortcutNoPref) {
// No pref was set, so the app should have opened in a window.
// The launch should have created a new browser.
Browser* new_browser = NULL;
- ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser));
+ ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(browser(), &new_browser));
// Expect an app window.
EXPECT_TRUE(new_browser->is_app());
@@ -287,7 +291,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenAppShortcutWindowPref) {
// window. The launch should have created a new browser. Find the new
// browser.
Browser* new_browser = NULL;
- ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser));
+ ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(browser(), &new_browser));
// Expect an app window.
EXPECT_TRUE(new_browser->is_app());
@@ -320,7 +324,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenAppShortcutTabPref) {
browser()->host_desktop_type()));
Browser* new_browser = NULL;
- ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser));
+ ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(browser(), &new_browser));
// The tab should be in a tabbed window.
EXPECT_TRUE(new_browser->is_type_tabbed());
@@ -373,7 +377,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, AddFirstRunTab) {
// This should have created a new browser window.
Browser* new_browser = NULL;
- ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser));
+ ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(browser(), &new_browser));
TabStripModel* tab_strip = new_browser->tab_strip_model();
EXPECT_EQ(2, tab_strip->count());
@@ -401,7 +405,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, AddCustomFirstRunTab) {
// This should have created a new browser window.
Browser* new_browser = NULL;
- ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser));
+ ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(browser(), &new_browser));
TabStripModel* tab_strip = new_browser->tab_strip_model();
EXPECT_EQ(4, tab_strip->count());
@@ -430,7 +434,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoNoWelcomePage) {
// This should have created a new browser window.
Browser* new_browser = NULL;
- ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser));
+ ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(browser(), &new_browser));
TabStripModel* tab_strip = new_browser->tab_strip_model();
EXPECT_EQ(1, tab_strip->count());
@@ -458,7 +462,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoWithWelcomePage) {
// This should have created a new browser window.
Browser* new_browser = NULL;
- ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser));
+ ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(browser(), &new_browser));
TabStripModel* tab_strip = new_browser->tab_strip_model();
EXPECT_EQ(2, tab_strip->count());
@@ -495,7 +499,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoWithFirstRunTabs) {
// This should have created a new browser window.
Browser* new_browser = NULL;
- ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser));
+ ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(browser(), &new_browser));
TabStripModel* tab_strip = new_browser->tab_strip_model();
if (SyncPromoUI::ShouldShowSyncPromoAtStartup(browser()->profile(), true)) {
@@ -531,7 +535,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest,
// This should have created a new browser window.
Browser* new_browser = NULL;
- ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser));
+ ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(browser(), &new_browser));
TabStripModel* tab_strip = new_browser->tab_strip_model();
if (SyncPromoUI::ShouldShowSyncPromoAtStartup(browser()->profile(), true)) {
@@ -892,4 +896,39 @@ 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);
+ }
+};
+
+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(browser(), &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());
+}
Bernhard Bauer 2013/04/03 17:55:20 Nit: a newline after this line would be nice.
Sergiu 2013/04/04 09:02:55 Done.
#endif // !OS_CHROMEOS

Powered by Google App Engine
This is Rietveld 408576698