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 3d1c2ea2057a33bd6a014a07c2dc2518db9b3b4b..76cb4bb9c25885f8dce378755fb83b739febbc7e 100644 |
--- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc |
+++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc |
@@ -86,7 +86,6 @@ |
namespace { |
-#if !defined(OS_CHROMEOS) |
// Check that there are two browsers. Find the one that is not |browser|. |
Browser* FindOneOtherBrowser(Browser* browser) { |
// There should only be one other browser. |
@@ -108,7 +107,12 @@ |
return false; |
#endif |
} |
-#endif |
+ |
+GURL GetSigninPromoURL() { |
+ return signin::GetPromoURL( |
+ signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE, |
+ signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, false); |
+} |
} // namespace |
@@ -233,9 +237,6 @@ |
Profile* profile = browser()->profile(); |
- // Do not show Welcome Page this run. |
- profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
- |
// Set the startup preference to open these URLs. |
SessionStartupPref pref(SessionStartupPref::URLS); |
pref.urls = urls; |
@@ -488,6 +489,216 @@ |
EXPECT_FALSE(StartupBrowserCreator::WasRestarted()); |
} |
+// Fails on official builds. See http://crbug.com/313856 |
+#if defined(GOOGLE_CHROME_BUILD) |
+#define MAYBE_AddFirstRunTab DISABLED_AddFirstRunTab |
+#else |
+#define MAYBE_AddFirstRunTab AddFirstRunTab |
+#endif |
+IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, MAYBE_AddFirstRunTab) { |
+ ASSERT_TRUE(embedded_test_server()->Start()); |
+ StartupBrowserCreator browser_creator; |
+ browser_creator.AddFirstRunTab( |
+ embedded_test_server()->GetURL("/title1.html")); |
+ browser_creator.AddFirstRunTab( |
+ embedded_test_server()->GetURL("/title2.html")); |
+ |
+ // Do a simple non-process-startup browser launch. |
+ base::CommandLine dummy(base::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 = FindOneOtherBrowser(browser()); |
+ ASSERT_TRUE(new_browser); |
+ |
+ TabStripModel* tab_strip = new_browser->tab_strip_model(); |
+ EXPECT_EQ(2, tab_strip->count()); |
+ |
+ EXPECT_EQ("title1.html", |
+ tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
+ EXPECT_EQ("title2.html", |
+ tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName()); |
+} |
+ |
+// Test hard-coded special first run tabs (defined in |
+// StartupBrowserCreatorImpl::AddStartupURLs()). |
+// Fails on official builds. See http://crbug.com/313856 |
+#if defined(GOOGLE_CHROME_BUILD) |
+#define MAYBE_AddCustomFirstRunTab DISABLED_AddCustomFirstRunTab |
+#else |
+#define MAYBE_AddCustomFirstRunTab AddCustomFirstRunTab |
+#endif |
+IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, MAYBE_AddCustomFirstRunTab) { |
+ ASSERT_TRUE(embedded_test_server()->Start()); |
+ StartupBrowserCreator browser_creator; |
+ browser_creator.AddFirstRunTab( |
+ embedded_test_server()->GetURL("/title1.html")); |
+ browser_creator.AddFirstRunTab(GURL("http://new_tab_page")); |
+ browser_creator.AddFirstRunTab( |
+ embedded_test_server()->GetURL("/title2.html")); |
+ browser_creator.AddFirstRunTab(GURL("http://welcome_page")); |
+ |
+ // Do a simple non-process-startup browser launch. |
+ base::CommandLine dummy(base::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 = FindOneOtherBrowser(browser()); |
+ ASSERT_TRUE(new_browser); |
+ |
+ TabStripModel* tab_strip = new_browser->tab_strip_model(); |
+ EXPECT_EQ(4, tab_strip->count()); |
+ |
+ EXPECT_EQ("title1.html", |
+ tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
+ EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
+ tab_strip->GetWebContentsAt(1)->GetURL()); |
+ EXPECT_EQ("title2.html", |
+ tab_strip->GetWebContentsAt(2)->GetURL().ExtractFileName()); |
+ EXPECT_EQ(internals::GetWelcomePageURL(), |
+ tab_strip->GetWebContentsAt(3)->GetURL()); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoNoWelcomePage) { |
+ // Do a simple non-process-startup browser launch. |
+ base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
+ StartupBrowserCreatorImpl launch(base::FilePath(), dummy, |
+ 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 = FindOneOtherBrowser(browser()); |
+ ASSERT_TRUE(new_browser); |
+ |
+ TabStripModel* tab_strip = new_browser->tab_strip_model(); |
+ |
+ if (signin::ShouldShowPromoAtStartup(browser()->profile(), true)) { |
+ // The browser should show only the promo. |
+ ASSERT_EQ(1, tab_strip->count()); |
+ EXPECT_EQ(GetSigninPromoURL(), tab_strip->GetWebContentsAt(0)->GetURL()); |
+ } else if (IsWindows10OrNewer()) { |
+ // The browser should show the welcome page and the NTP. |
+ ASSERT_EQ(2, tab_strip->count()); |
+ EXPECT_EQ(GURL(internals::GetWelcomePageURL()), |
+ tab_strip->GetWebContentsAt(0)->GetURL()); |
+ EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
+ tab_strip->GetWebContentsAt(1)->GetURL()); |
+ } else { |
+ // The browser should show only the NTP. |
+ ASSERT_EQ(1, tab_strip->count()); |
+ EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
+ tab_strip->GetWebContentsAt(0)->GetURL()); |
+ } |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoWithWelcomePage) { |
+ first_run::SetShouldShowWelcomePage(); |
+ |
+ // Do a simple non-process-startup browser launch. |
+ base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
+ StartupBrowserCreatorImpl launch(base::FilePath(), dummy, |
+ 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 = FindOneOtherBrowser(browser()); |
+ ASSERT_TRUE(new_browser); |
+ |
+ TabStripModel* tab_strip = new_browser->tab_strip_model(); |
+ EXPECT_EQ(2, tab_strip->count()); |
+ |
+ if (IsWindows10OrNewer()) { |
+ EXPECT_EQ(internals::GetWelcomePageURL(), |
+ tab_strip->GetWebContentsAt(0)->GetURL()); |
+ EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
+ tab_strip->GetWebContentsAt(1)->GetURL()); |
+ } else { |
+ if (signin::ShouldShowPromoAtStartup(browser()->profile(), true)) { |
+ EXPECT_EQ(GetSigninPromoURL(), tab_strip->GetWebContentsAt(0)->GetURL()); |
+ } else { |
+ EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
+ tab_strip->GetWebContentsAt(0)->GetURL()); |
+ } |
+ EXPECT_EQ(internals::GetWelcomePageURL(), |
+ tab_strip->GetWebContentsAt(1)->GetURL()); |
+ } |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SyncPromoWithFirstRunTabs) { |
+ ASSERT_TRUE(embedded_test_server()->Start()); |
+ StartupBrowserCreator browser_creator; |
+ browser_creator.AddFirstRunTab( |
+ embedded_test_server()->GetURL("/title1.html")); |
+ |
+ // The welcome page should not be shown, even if |
+ // first_run::ShouldShowWelcomePage() says so, when there are already |
+ // more than 2 first run tabs. |
+ first_run::SetShouldShowWelcomePage(); |
+ |
+ // Do a simple non-process-startup browser launch. |
+ base::CommandLine dummy(base::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 = FindOneOtherBrowser(browser()); |
+ ASSERT_TRUE(new_browser); |
+ |
+ TabStripModel* tab_strip = new_browser->tab_strip_model(); |
+ if (signin::ShouldShowPromoAtStartup(browser()->profile(), true)) { |
+ EXPECT_EQ(2, tab_strip->count()); |
+ EXPECT_EQ(GetSigninPromoURL(), tab_strip->GetWebContentsAt(0)->GetURL()); |
+ EXPECT_EQ("title1.html", |
+ tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName()); |
+ } else { |
+ EXPECT_EQ(1, tab_strip->count()); |
+ EXPECT_EQ("title1.html", |
+ tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
+ } |
+} |
+ |
+// The welcome page should still be shown if there are more than 2 first run |
+// tabs, but the welcome page was explcitly added to the first run tabs. |
+IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, |
+ SyncPromoWithFirstRunTabsIncludingWelcomePage) { |
+ ASSERT_TRUE(embedded_test_server()->Start()); |
+ StartupBrowserCreator browser_creator; |
+ browser_creator.AddFirstRunTab( |
+ embedded_test_server()->GetURL("/title1.html")); |
+ browser_creator.AddFirstRunTab(GURL("http://welcome_page")); |
+ |
+ // Do a simple non-process-startup browser launch. |
+ base::CommandLine dummy(base::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 = FindOneOtherBrowser(browser()); |
+ ASSERT_TRUE(new_browser); |
+ |
+ TabStripModel* tab_strip = new_browser->tab_strip_model(); |
+ if (signin::ShouldShowPromoAtStartup(browser()->profile(), true)) { |
+ EXPECT_EQ(3, tab_strip->count()); |
+ EXPECT_EQ(GetSigninPromoURL(), tab_strip->GetWebContentsAt(0)->GetURL()); |
+ EXPECT_EQ("title1.html", |
+ tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName()); |
+ EXPECT_EQ(internals::GetWelcomePageURL(), |
+ tab_strip->GetWebContentsAt(2)->GetURL()); |
+ } else { |
+ EXPECT_EQ(2, tab_strip->count()); |
+ EXPECT_EQ("title1.html", |
+ tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
+ EXPECT_EQ(internals::GetWelcomePageURL(), |
+ tab_strip->GetWebContentsAt(1)->GetURL()); |
+ } |
+} |
+ |
#if !defined(OS_CHROMEOS) |
IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, StartupURLsForTwoProfiles) { |
Profile* default_profile = browser()->profile(); |
@@ -517,10 +728,6 @@ |
SessionStartupPref pref2(SessionStartupPref::URLS); |
pref2.urls = urls2; |
SessionStartupPref::SetStartupPref(other_profile, pref2); |
- |
- // Do not show the Welcome Page for either profile. |
- default_profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
- other_profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
// Close the browser. |
CloseBrowserAsynchronously(browser()); |
@@ -700,12 +907,6 @@ |
ASSERT_TRUE(profile_last); |
Profile* profile_urls = profile_manager->GetProfile(dest_path4); |
ASSERT_TRUE(profile_urls); |
- |
- // Avoid showing the Welcome page on all four profiles. |
- profile_home1->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
- profile_home2->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
- profile_last->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
- profile_urls->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
// Set the profiles to open urls, open last visited pages or display the home |
// page. |
@@ -963,6 +1164,11 @@ |
void SetUpCommandLine(base::CommandLine* command_line) override; |
void SetUpInProcessBrowserTestFixture() override; |
+ // Returns true if the platform supports showing the sync promo on first run. |
+ static bool PlatformSupportsSyncPromo() { |
+ return !IsWindows10OrNewer(); |
+ } |
+ |
policy::MockConfigurationPolicyProvider provider_; |
policy::PolicyMap policy_map_; |
}; |
@@ -987,33 +1193,327 @@ |
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); |
} |
-IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, AddFirstRunTab) { |
+#if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
+// http://crbug.com/314819 |
+#define MAYBE_SyncPromoForbidden DISABLED_SyncPromoForbidden |
+#else |
+#define MAYBE_SyncPromoForbidden SyncPromoForbidden |
+#endif |
+IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
+ MAYBE_SyncPromoForbidden) { |
+ // Consistently enable the welcome page on all platforms. |
+ first_run::SetShouldShowWelcomePage(); |
+ |
+ // Simulate the following master_preferences: |
+ // { |
+ // "sync_promo": { |
+ // "show_on_first_run_allowed": false |
+ // } |
+ // } |
+ StartupBrowserCreator browser_creator; |
+ browser()->profile()->GetPrefs()->SetBoolean( |
+ prefs::kSignInPromoShowOnFirstRunAllowed, false); |
+ |
+ // Do a process-startup browser launch. |
+ base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
+ StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, |
+ chrome::startup::IS_FIRST_RUN); |
+ ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), true)); |
+ |
+ // This should have created a new browser window. |
+ Browser* new_browser = FindOneOtherBrowser(browser()); |
+ ASSERT_TRUE(new_browser); |
+ |
+ // Verify that the NTP and the welcome page are shown. |
+ TabStripModel* tab_strip = new_browser->tab_strip_model(); |
+ ASSERT_EQ(2, tab_strip->count()); |
+ if (IsWindows10OrNewer()) { |
+ EXPECT_EQ(internals::GetWelcomePageURL(), |
+ tab_strip->GetWebContentsAt(0)->GetURL()); |
+ EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
+ tab_strip->GetWebContentsAt(1)->GetURL()); |
+ } else { |
+ EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
+ tab_strip->GetWebContentsAt(0)->GetURL()); |
+ EXPECT_EQ(internals::GetWelcomePageURL(), |
+ tab_strip->GetWebContentsAt(1)->GetURL()); |
+ } |
+} |
+ |
+#if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
+// http://crbug.com/314819 |
+#define MAYBE_SyncPromoAllowed DISABLED_SyncPromoAllowed |
+#else |
+#define MAYBE_SyncPromoAllowed SyncPromoAllowed |
+#endif |
+IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
+ MAYBE_SyncPromoAllowed) { |
+ if (!PlatformSupportsSyncPromo()) |
+ return; |
+ // Consistently enable the welcome page on all platforms. |
+ first_run::SetShouldShowWelcomePage(); |
+ |
+ // Simulate the following master_preferences: |
+ // { |
+ // "sync_promo": { |
+ // "show_on_first_run_allowed": true |
+ // } |
+ // } |
+ StartupBrowserCreator browser_creator; |
+ browser()->profile()->GetPrefs()->SetBoolean( |
+ prefs::kSignInPromoShowOnFirstRunAllowed, true); |
+ |
+ // Do a process-startup browser launch. |
+ base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
+ StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, |
+ chrome::startup::IS_FIRST_RUN); |
+ ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), true)); |
+ |
+ // This should have created a new browser window. |
+ Browser* new_browser = FindOneOtherBrowser(browser()); |
+ ASSERT_TRUE(new_browser); |
+ |
+ // Verify that the sync promo and the welcome page are shown. |
+ TabStripModel* tab_strip = new_browser->tab_strip_model(); |
+ ASSERT_EQ(2, tab_strip->count()); |
+ EXPECT_EQ(GetSigninPromoURL(), tab_strip->GetWebContentsAt(0)->GetURL()); |
+ EXPECT_EQ(internals::GetWelcomePageURL(), |
+ tab_strip->GetWebContentsAt(1)->GetURL()); |
+} |
+ |
+#if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
+// http://crbug.com/314819 |
+#define MAYBE_FirstRunTabsPromoAllowed DISABLED_FirstRunTabsPromoAllowed |
+#else |
+#define MAYBE_FirstRunTabsPromoAllowed FirstRunTabsPromoAllowed |
+#endif |
+IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
+ MAYBE_FirstRunTabsPromoAllowed) { |
+ if (!PlatformSupportsSyncPromo()) |
+ return; |
+ // Simulate the following master_preferences: |
+ // { |
+ // "first_run_tabs" : [ |
+ // "/title1.html" |
+ // ], |
+ // "sync_promo": { |
+ // "show_on_first_run_allowed": true |
+ // } |
+ // } |
ASSERT_TRUE(embedded_test_server()->Start()); |
StartupBrowserCreator browser_creator; |
browser_creator.AddFirstRunTab( |
embedded_test_server()->GetURL("/title1.html")); |
- browser_creator.AddFirstRunTab( |
- embedded_test_server()->GetURL("/title2.html")); |
- |
- // Do a simple non-process-startup browser launch. |
- base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
- |
+ browser()->profile()->GetPrefs()->SetBoolean( |
+ prefs::kSignInPromoShowOnFirstRunAllowed, true); |
+ |
+ // Do a process-startup browser launch. |
+ base::CommandLine dummy(base::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)); |
+ ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), true)); |
// This should have created a new browser window. |
Browser* new_browser = FindOneOtherBrowser(browser()); |
ASSERT_TRUE(new_browser); |
- TabStripModel* tab_strip = new_browser->tab_strip_model(); |
- |
- EXPECT_EQ(2, tab_strip->count()); |
- |
+ // Verify that the first-run tab is shown and the sync promo has been added. |
+ TabStripModel* tab_strip = new_browser->tab_strip_model(); |
+ ASSERT_EQ(2, tab_strip->count()); |
+ EXPECT_EQ(GetSigninPromoURL(), tab_strip->GetWebContentsAt(0)->GetURL()); |
+ EXPECT_EQ("title1.html", |
+ tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName()); |
+} |
+ |
+#if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
+// http://crbug.com/314819 |
+#define MAYBE_FirstRunTabsContainSyncPromo \ |
+ DISABLED_FirstRunTabsContainSyncPromo |
+#else |
+#define MAYBE_FirstRunTabsContainSyncPromo FirstRunTabsContainSyncPromo |
+#endif |
+IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
+ MAYBE_FirstRunTabsContainSyncPromo) { |
+ if (!PlatformSupportsSyncPromo()) |
+ return; |
+ // Simulate the following master_preferences: |
+ // { |
+ // "first_run_tabs" : [ |
+ // "/title1.html", |
+ // "chrome://signin/?source=0&next_page=chrome%3A%2F%2Fnewtab%2F" |
+ // ], |
+ // "sync_promo": { |
+ // "show_on_first_run_allowed": true |
+ // } |
+ // } |
+ ASSERT_TRUE(embedded_test_server()->Start()); |
+ StartupBrowserCreator browser_creator; |
+ browser_creator.AddFirstRunTab( |
+ embedded_test_server()->GetURL("/title1.html")); |
+ browser_creator.AddFirstRunTab(GetSigninPromoURL()); |
+ browser()->profile()->GetPrefs()->SetBoolean( |
+ prefs::kSignInPromoShowOnFirstRunAllowed, true); |
+ |
+ // Do a process-startup browser launch. |
+ base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
+ StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, |
+ chrome::startup::IS_FIRST_RUN); |
+ ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), true)); |
+ |
+ // This should have created a new browser window. |
+ Browser* new_browser = FindOneOtherBrowser(browser()); |
+ ASSERT_TRUE(new_browser); |
+ |
+ // Verify that the first-run tabs are shown and no sync promo has been added |
+ // as the first-run tabs contain it already. |
+ TabStripModel* tab_strip = new_browser->tab_strip_model(); |
+ ASSERT_EQ(2, tab_strip->count()); |
EXPECT_EQ("title1.html", |
tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
- EXPECT_EQ("title2.html", |
+ EXPECT_EQ(GetSigninPromoURL(), tab_strip->GetWebContentsAt(1)->GetURL()); |
+} |
+ |
+#if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
+// http://crbug.com/314819 |
+#define MAYBE_FirstRunTabsContainNTPSyncPromoAllowed \ |
+ DISABLED_FirstRunTabsContainNTPSyncPromoAllowed |
+#else |
+#define MAYBE_FirstRunTabsContainNTPSyncPromoAllowed \ |
+ FirstRunTabsContainNTPSyncPromoAllowed |
+#endif |
+IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
+ MAYBE_FirstRunTabsContainNTPSyncPromoAllowed) { |
+ if (!PlatformSupportsSyncPromo()) |
+ return; |
+ // Simulate the following master_preferences: |
+ // { |
+ // "first_run_tabs" : [ |
+ // "new_tab_page", |
+ // "/title1.html" |
+ // ], |
+ // "sync_promo": { |
+ // "show_on_first_run_allowed": true |
+ // } |
+ // } |
+ ASSERT_TRUE(embedded_test_server()->Start()); |
+ StartupBrowserCreator browser_creator; |
+ browser_creator.AddFirstRunTab(GURL("http://new_tab_page")); |
+ browser_creator.AddFirstRunTab( |
+ embedded_test_server()->GetURL("/title1.html")); |
+ browser()->profile()->GetPrefs()->SetBoolean( |
+ prefs::kSignInPromoShowOnFirstRunAllowed, true); |
+ |
+ // Do a process-startup browser launch. |
+ base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
+ StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, |
+ chrome::startup::IS_FIRST_RUN); |
+ ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), true)); |
+ |
+ // This should have created a new browser window. |
+ Browser* new_browser = FindOneOtherBrowser(browser()); |
+ ASSERT_TRUE(new_browser); |
+ |
+ // Verify that the first-run tabs are shown but the NTP that they contain has |
+ // been replaced by the sync promo. |
+ TabStripModel* tab_strip = new_browser->tab_strip_model(); |
+ ASSERT_EQ(2, tab_strip->count()); |
+ EXPECT_EQ(GetSigninPromoURL(), tab_strip->GetWebContentsAt(0)->GetURL()); |
+ EXPECT_EQ("title1.html", |
tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName()); |
+} |
+ |
+#if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
+// http://crbug.com/314819 |
+#define MAYBE_FirstRunTabsContainNTPSyncPromoForbidden \ |
+ DISABLED_FirstRunTabsContainNTPSyncPromoForbidden |
+#else |
+#define MAYBE_FirstRunTabsContainNTPSyncPromoForbidden \ |
+ FirstRunTabsContainNTPSyncPromoForbidden |
+#endif |
+IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
+ MAYBE_FirstRunTabsContainNTPSyncPromoForbidden) { |
+ if (!PlatformSupportsSyncPromo()) |
+ return; |
+ // Simulate the following master_preferences: |
+ // { |
+ // "first_run_tabs" : [ |
+ // "new_tab_page", |
+ // "/title1.html" |
+ // ], |
+ // "sync_promo": { |
+ // "show_on_first_run_allowed": false |
+ // } |
+ // } |
+ ASSERT_TRUE(embedded_test_server()->Start()); |
+ StartupBrowserCreator browser_creator; |
+ browser_creator.AddFirstRunTab(GURL("http://new_tab_page")); |
+ browser_creator.AddFirstRunTab( |
+ embedded_test_server()->GetURL("/title1.html")); |
+ browser()->profile()->GetPrefs()->SetBoolean( |
+ prefs::kSignInPromoShowOnFirstRunAllowed, false); |
+ |
+ // Do a process-startup browser launch. |
+ base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
+ StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, |
+ chrome::startup::IS_FIRST_RUN); |
+ ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), true)); |
+ |
+ // This should have created a new browser window. |
+ Browser* new_browser = FindOneOtherBrowser(browser()); |
+ ASSERT_TRUE(new_browser); |
+ |
+ // Verify that the first-run tabs are shown, the NTP that they contain has not |
+ // not been replaced by the sync promo and no sync promo has been added. |
+ TabStripModel* tab_strip = new_browser->tab_strip_model(); |
+ ASSERT_EQ(2, tab_strip->count()); |
+ EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
+ tab_strip->GetWebContentsAt(0)->GetURL()); |
+ EXPECT_EQ("title1.html", |
+ tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName()); |
+} |
+ |
+#if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
+// http://crbug.com/314819 |
+#define MAYBE_FirstRunTabsSyncPromoForbidden \ |
+ DISABLED_FirstRunTabsSyncPromoForbidden |
+#else |
+#define MAYBE_FirstRunTabsSyncPromoForbidden FirstRunTabsSyncPromoForbidden |
+#endif |
+IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
+ MAYBE_FirstRunTabsSyncPromoForbidden) { |
+ if (!PlatformSupportsSyncPromo()) |
+ return; |
+ // Simulate the following master_preferences: |
+ // { |
+ // "first_run_tabs" : [ |
+ // "/title1.html" |
+ // ], |
+ // "sync_promo": { |
+ // "show_on_first_run_allowed": false |
+ // } |
+ // } |
+ ASSERT_TRUE(embedded_test_server()->Start()); |
+ StartupBrowserCreator browser_creator; |
+ browser_creator.AddFirstRunTab( |
+ embedded_test_server()->GetURL("/title1.html")); |
+ browser()->profile()->GetPrefs()->SetBoolean( |
+ prefs::kSignInPromoShowOnFirstRunAllowed, false); |
+ |
+ // Do a process-startup browser launch. |
+ base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
+ StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator, |
+ chrome::startup::IS_FIRST_RUN); |
+ ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), true)); |
+ |
+ // This should have created a new browser window. |
+ Browser* new_browser = FindOneOtherBrowser(browser()); |
+ ASSERT_TRUE(new_browser); |
+ |
+ // Verify that the first-run tab is shown and no sync promo has been added. |
+ TabStripModel* tab_strip = new_browser->tab_strip_model(); |
+ ASSERT_EQ(1, tab_strip->count()); |
+ EXPECT_EQ("title1.html", |
+ tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
} |
#if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX) |
@@ -1026,12 +1526,18 @@ |
#endif |
IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, |
MAYBE_RestoreOnStartupURLsPolicySpecified) { |
+ if (!PlatformSupportsSyncPromo()) |
+ return; |
+ // Simulate the following master_preferences: |
+ // { |
+ // "sync_promo": { |
+ // "show_on_first_run_allowed": true |
+ // } |
+ // } |
ASSERT_TRUE(embedded_test_server()->Start()); |
StartupBrowserCreator browser_creator; |
- |
- // Avoid showing the Welcome page. |
- browser()->profile()->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, |
- true); |
+ browser()->profile()->GetPrefs()->SetBoolean( |
+ prefs::kSignInPromoShowOnFirstRunAllowed, true); |
// Set the following user policies: |
// * RestoreOnStartup = RestoreOnStartupIsURLs |
@@ -1051,9 +1557,6 @@ |
nullptr); |
provider_.UpdateChromePolicy(policy_map_); |
base::RunLoop().RunUntilIdle(); |
- |
- // Close the browser. |
- CloseBrowserAsynchronously(browser()); |
// Do a process-startup browser launch. |
base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |