| 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 76cb4bb9c25885f8dce378755fb83b739febbc7e..66ff44ce223dfc4a814983ce9e880376f362f4d9 100644
|
| --- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
|
| +++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
|
| @@ -86,6 +86,7 @@ using extensions::Extension;
|
|
|
| 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.
|
| @@ -107,12 +108,7 @@ bool IsWindows10OrNewer() {
|
| return false;
|
| #endif
|
| }
|
| -
|
| -GURL GetSigninPromoURL() {
|
| - return signin::GetPromoURL(
|
| - signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE,
|
| - signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, false);
|
| -}
|
| +#endif
|
|
|
| } // namespace
|
|
|
| @@ -237,6 +233,9 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest,
|
|
|
| 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;
|
| @@ -489,216 +488,6 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest,
|
| 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();
|
| @@ -729,6 +518,10 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, StartupURLsForTwoProfiles) {
|
| 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());
|
|
|
| @@ -908,6 +701,12 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest,
|
| 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.
|
| SessionStartupPref pref_home(SessionStartupPref::DEFAULT);
|
| @@ -1164,11 +963,6 @@ class StartupBrowserCreatorFirstRunTest : public InProcessBrowserTest {
|
| 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_;
|
| };
|
| @@ -1193,327 +987,33 @@ void StartupBrowserCreatorFirstRunTest::SetUpInProcessBrowserTestFixture() {
|
| policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
|
| }
|
|
|
| -#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
|
| - // }
|
| - // }
|
| +IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, AddFirstRunTab) {
|
| ASSERT_TRUE(embedded_test_server()->Start());
|
| StartupBrowserCreator browser_creator;
|
| 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 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(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);
|
| + embedded_test_server()->GetURL("/title2.html"));
|
|
|
| - // Do a process-startup browser launch.
|
| + // 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>(), 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));
|
| + 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);
|
|
|
| - // 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);
|
| + EXPECT_EQ(2, tab_strip->count());
|
|
|
| - // 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());
|
| + EXPECT_EQ("title2.html",
|
| + tab_strip->GetWebContentsAt(1)->GetURL().ExtractFileName());
|
| }
|
|
|
| #if defined(GOOGLE_CHROME_BUILD) && defined(OS_MACOSX)
|
| @@ -1526,18 +1026,15 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest,
|
| #endif
|
| IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest,
|
| MAYBE_RestoreOnStartupURLsPolicySpecified) {
|
| - if (!PlatformSupportsSyncPromo())
|
| + if (IsWindows10OrNewer())
|
| return;
|
| - // Simulate the following master_preferences:
|
| - // {
|
| - // "sync_promo": {
|
| - // "show_on_first_run_allowed": true
|
| - // }
|
| - // }
|
| +
|
| ASSERT_TRUE(embedded_test_server()->Start());
|
| StartupBrowserCreator browser_creator;
|
| - browser()->profile()->GetPrefs()->SetBoolean(
|
| - prefs::kSignInPromoShowOnFirstRunAllowed, true);
|
| +
|
| + // Avoid showing the Welcome page.
|
| + browser()->profile()->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage,
|
| + true);
|
|
|
| // Set the following user policies:
|
| // * RestoreOnStartup = RestoreOnStartupIsURLs
|
| @@ -1558,6 +1055,9 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest,
|
| 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);
|
| StartupBrowserCreatorImpl launch(base::FilePath(), dummy, &browser_creator,
|
|
|