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

Side by Side 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: Remove extra line Created 7 years, 8 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) 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 86
87 // Check that there are two browsers. Find the one that is not |browser()|. 87 // Check that there are two browsers. Find the one that is not |browser()|.
88 void FindOneOtherBrowser(Browser** out_other_browser) { 88 void FindOneOtherBrowser(Browser** out_other_browser) {
89 // There should only be one other browser. 89 // There should only be one other browser.
90 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), 90 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(),
91 browser()->host_desktop_type())); 91 browser()->host_desktop_type()));
92 92
93 // Find the new browser. 93 // Find the new browser.
94 Browser* other_browser = NULL; 94 Browser* other_browser = NULL;
95 for (chrome::BrowserIterator it; !it.done() && !other_browser; it.Next()) { 95 for (chrome::BrowserIterator it; !it.done() && !other_browser; it.Next()) {
96 if (*it != browser()) 96 if (*it != browser())
97 other_browser = *it; 97 other_browser = *it;
98 } 98 }
99 ASSERT_TRUE(other_browser); 99 ASSERT_TRUE(other_browser);
100 ASSERT_TRUE(other_browser != browser()); 100 ASSERT_TRUE(other_browser != browser());
101 *out_other_browser = other_browser; 101 *out_other_browser = other_browser;
102 } 102 }
103 103
104 Browser* FindOneOtherBrowserForProfile(Profile* profile, 104 Browser* FindOneOtherBrowserForProfile(Profile* profile,
105 Browser* not_this_browser) { 105 Browser* not_this_browser) {
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 browser()->host_desktop_type())); 885 browser()->host_desktop_type()));
886 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); 886 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL);
887 ASSERT_TRUE(new_browser); 887 ASSERT_TRUE(new_browser);
888 tab_strip = new_browser->tab_strip_model(); 888 tab_strip = new_browser->tab_strip_model();
889 ASSERT_EQ(1, tab_strip->count()); 889 ASSERT_EQ(1, tab_strip->count());
890 web_contents = tab_strip->GetWebContentsAt(0); 890 web_contents = tab_strip->GetWebContentsAt(0);
891 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); 891 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL());
892 EXPECT_EQ(1U, 892 EXPECT_EQ(1U,
893 InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); 893 InfoBarService::FromWebContents(web_contents)->GetInfoBarCount());
894 } 894 }
895
896 class ManagedModeBrowserCreatorTest : public InProcessBrowserTest {
897 protected:
898 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
899 InProcessBrowserTest::SetUpCommandLine(command_line);
900 command_line->AppendSwitch(switches::kEnableManagedUsers);
901 }
902
903 // Check that there are two browsers. Find the one that is not |browser()|.
904 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
905 // There should only be one other browser.
906 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(),
907 browser()->host_desktop_type()));
908
909 // Find the new browser.
910 Browser* other_browser = NULL;
911 for (chrome::BrowserIterator it; !it.done() && !other_browser; it.Next()) {
912 if (*it != browser())
913 other_browser = *it;
914 }
915 ASSERT_TRUE(other_browser);
916 ASSERT_TRUE(other_browser != browser());
917 *out_other_browser = other_browser;
918 }
919 };
920
921 IN_PROC_BROWSER_TEST_F(ManagedModeBrowserCreatorTest,
922 StartupManagedModeProfile) {
923 // Make this a managed profile.
924 browser()->profile()->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, true);
925 StartupBrowserCreator browser_creator;
926
927 // Do a simple non-process-startup browser launch.
928 CommandLine dummy(CommandLine::NO_PROGRAM);
929 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator,
930 chrome::startup::IS_FIRST_RUN);
931 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false));
932
933 // This should have created a new browser window.
934 Browser* new_browser = NULL;
935 ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser));
936
937 TabStripModel* tab_strip = new_browser->tab_strip_model();
938 // There should be only one tab.
939 EXPECT_EQ(1, tab_strip->count());
940
941 // And it should point to the managed user settings page.
942 content::WebContents* web_contents = tab_strip->GetWebContentsAt(0);
943 GURL expected(GURL(std::string(chrome::kChromeUISettingsURL) +
944 chrome::kManagedUserSettingsSubPage));
945 EXPECT_EQ(GURL(expected), web_contents->GetURL());
946 }
895 #endif // !OS_CHROMEOS 947 #endif // !OS_CHROMEOS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698