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

Side by Side Diff: chrome/browser/ui/startup/startup_browser_creator_browsertest.cc

Issue 2687573004: Enabling new FRE and launch flow by default on Win 10. (Closed)
Patch Set: Created 3 years, 10 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
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return other_browser; 101 return other_browser;
102 } 102 }
103 103
104 bool IsWindows10OrNewer() { 104 bool IsWindows10OrNewer() {
105 #if defined(OS_WIN) 105 #if defined(OS_WIN)
106 return base::win::GetVersion() >= base::win::VERSION_WIN10; 106 return base::win::GetVersion() >= base::win::VERSION_WIN10;
107 #else 107 #else
108 return false; 108 return false;
109 #endif 109 #endif
110 } 110 }
111
112
113 void DisableWelcomePages(const std::vector<Profile*>& profiles) {
114 for (Profile* profile : profiles)
115 profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true);
116
117 #if defined(OS_WIN)
118 g_browser_process->local_state()->SetBoolean(prefs::kHasSeenWin10PromoPage,
119 true);
120 #endif
121 }
111 #endif 122 #endif
112 123
113 } // namespace 124 } // namespace
114 125
115 class StartupBrowserCreatorTest : public ExtensionBrowserTest { 126 class StartupBrowserCreatorTest : public ExtensionBrowserTest {
116 protected: 127 protected:
117 StartupBrowserCreatorTest() {} 128 StartupBrowserCreatorTest() {}
118 129
119 bool SetUpUserDataDirectory() override { 130 bool SetUpUserDataDirectory() override {
120 return ExtensionBrowserTest::SetUpUserDataDirectory(); 131 return ExtensionBrowserTest::SetUpUserDataDirectory();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, 237 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest,
227 StartupURLsOnNewWindowWithNoTabbedBrowsers) { 238 StartupURLsOnNewWindowWithNoTabbedBrowsers) {
228 // Use a couple same-site HTTP URLs. 239 // Use a couple same-site HTTP URLs.
229 ASSERT_TRUE(embedded_test_server()->Start()); 240 ASSERT_TRUE(embedded_test_server()->Start());
230 std::vector<GURL> urls; 241 std::vector<GURL> urls;
231 urls.push_back(embedded_test_server()->GetURL("/title1.html")); 242 urls.push_back(embedded_test_server()->GetURL("/title1.html"));
232 urls.push_back(embedded_test_server()->GetURL("/title2.html")); 243 urls.push_back(embedded_test_server()->GetURL("/title2.html"));
233 244
234 Profile* profile = browser()->profile(); 245 Profile* profile = browser()->profile();
235 246
236 // Do not show Welcome Page this run. 247 DisableWelcomePages({profile});
237 profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true);
238 248
239 // Set the startup preference to open these URLs. 249 // Set the startup preference to open these URLs.
240 SessionStartupPref pref(SessionStartupPref::URLS); 250 SessionStartupPref pref(SessionStartupPref::URLS);
241 pref.urls = urls; 251 pref.urls = urls;
242 SessionStartupPref::SetStartupPref(profile, pref); 252 SessionStartupPref::SetStartupPref(profile, pref);
243 253
244 // Keep the browser process running while browsers are closed. 254 // Keep the browser process running while browsers are closed.
245 ScopedKeepAlive keep_alive(KeepAliveOrigin::BROWSER, 255 ScopedKeepAlive keep_alive(KeepAliveOrigin::BROWSER,
246 KeepAliveRestartOption::DISABLED); 256 KeepAliveRestartOption::DISABLED);
247 257
248 // Close the browser. 258 // Close the browser.
249 CloseBrowserAsynchronously(browser()); 259 CloseBrowserAsynchronously(browser());
250 260
251 // Do a simple non-process-startup browser launch. 261 // Do a simple non-process-startup browser launch.
252 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); 262 base::CommandLine dummy(base::CommandLine::NO_PROGRAM);
253 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? 263 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ?
254 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; 264 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN;
255 { 265 {
256 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); 266 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run);
257 ASSERT_TRUE(launch.Launch(profile, std::vector<GURL>(), false)); 267 ASSERT_TRUE(launch.Launch(profile, std::vector<GURL>(), false));
258 } 268 }
259 269
260 // This should have created a new browser window. |browser()| is still 270 // This should have created a new browser window. |browser()| is still
261 // around at this point, even though we've closed its window. 271 // around at this point, even though we've closed its window.
262 Browser* new_browser = FindOneOtherBrowser(browser()); 272 Browser* new_browser = FindOneOtherBrowser(browser());
263 ASSERT_TRUE(new_browser); 273 ASSERT_TRUE(new_browser);
264 274
265 std::vector<GURL> expected_urls(urls); 275 std::vector<GURL> expected_urls(urls);
266 if (IsWindows10OrNewer())
267 expected_urls.insert(expected_urls.begin(), internals::GetWelcomePageURL());
268 276
269 TabStripModel* tab_strip = new_browser->tab_strip_model(); 277 TabStripModel* tab_strip = new_browser->tab_strip_model();
270 ASSERT_EQ(static_cast<int>(expected_urls.size()), tab_strip->count()); 278 ASSERT_EQ(static_cast<int>(expected_urls.size()), tab_strip->count());
271 for (size_t i = 0; i < expected_urls.size(); i++) 279 for (size_t i = 0; i < expected_urls.size(); i++)
272 EXPECT_EQ(expected_urls[i], tab_strip->GetWebContentsAt(i)->GetURL()); 280 EXPECT_EQ(expected_urls[i], tab_strip->GetWebContentsAt(i)->GetURL());
273 281
274 // The two test_server tabs, despite having the same site, should be in 282 // The two test_server tabs, despite having the same site, should be in
275 // different SiteInstances. 283 // different SiteInstances.
276 EXPECT_NE( 284 EXPECT_NE(
277 tab_strip->GetWebContentsAt(tab_strip->count() - 2)->GetSiteInstance(), 285 tab_strip->GetWebContentsAt(tab_strip->count() - 2)->GetSiteInstance(),
278 tab_strip->GetWebContentsAt(tab_strip->count() - 1)->GetSiteInstance()); 286 tab_strip->GetWebContentsAt(tab_strip->count() - 1)->GetSiteInstance());
279 287
280 // Test that the welcome page is not shown the second time through if it was
281 // above.
282 if (IsWindows10OrNewer()) {
283 // Close the browser opened above.
284 {
285 content::WindowedNotificationObserver observer(
286 chrome::NOTIFICATION_BROWSER_CLOSED,
287 content::Source<Browser>(new_browser));
288 new_browser->window()->Close();
289 observer.Wait();
290 }
291
292 {
293 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run);
294 ASSERT_TRUE(launch.Launch(profile, std::vector<GURL>(), false));
295 }
296
297 // Find the new browser and ensure that it has only the specified URLs this
298 // time. Both the original browser created by the fixture and the one
299 // created above have been closed, so the new browser is the only one
300 // remaining.
301 new_browser = chrome::FindTabbedBrowser(profile, true);
302 ASSERT_TRUE(new_browser);
303 ASSERT_EQ(static_cast<int>(urls.size()),
304 new_browser->tab_strip_model()->count());
305 }
306 } 288 }
307 289
308 // Verify that startup URLs aren't used when the process already exists 290 // Verify that startup URLs aren't used when the process already exists
309 // and has other tabbed browser windows. This is the common case of starting a 291 // and has other tabbed browser windows. This is the common case of starting a
310 // new browser. 292 // new browser.
311 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, 293 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest,
312 StartupURLsOnNewWindow) { 294 StartupURLsOnNewWindow) {
313 // Use a couple arbitrary URLs. 295 // Use a couple arbitrary URLs.
314 std::vector<GURL> urls; 296 std::vector<GURL> urls;
315 urls.push_back(ui_test_utils::GetTestUrl( 297 urls.push_back(ui_test_utils::GetTestUrl(
(...skipping 15 matching lines...) Expand all
331 { 313 {
332 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); 314 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run);
333 ASSERT_TRUE( 315 ASSERT_TRUE(
334 launch.Launch(browser()->profile(), std::vector<GURL>(), false)); 316 launch.Launch(browser()->profile(), std::vector<GURL>(), false));
335 } 317 }
336 318
337 // This should have created a new browser window. 319 // This should have created a new browser window.
338 Browser* new_browser = FindOneOtherBrowser(browser()); 320 Browser* new_browser = FindOneOtherBrowser(browser());
339 ASSERT_TRUE(new_browser); 321 ASSERT_TRUE(new_browser);
340 322
341 if (IsWindows10OrNewer()) { 323 // The new browser should have exactly one tab (not the startup URLs).
342 // The new browser should have two tabs (not the startup URLs). 324 ASSERT_EQ(1, new_browser->tab_strip_model()->count());
343 ASSERT_EQ(2, new_browser->tab_strip_model()->count());
344 } else {
345 // The new browser should have exactly one tab (not the startup URLs).
346 ASSERT_EQ(1, new_browser->tab_strip_model()->count());
347 }
348 325
349 // Test that the welcome page is not shown the second time through if it was 326 // Test that the welcome page is not shown the second time through if it was
350 // above. 327 // above.
351 if (!IsWindows10OrNewer()) { 328 if (!IsWindows10OrNewer()) {
352 // Close the browser opened above. 329 // Close the browser opened above.
353 { 330 {
354 content::WindowedNotificationObserver observer( 331 content::WindowedNotificationObserver observer(
355 chrome::NOTIFICATION_BROWSER_CLOSED, 332 chrome::NOTIFICATION_BROWSER_CLOSED,
356 content::Source<Browser>(new_browser)); 333 content::Source<Browser>(new_browser));
357 new_browser->window()->Close(); 334 new_browser->window()->Close();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 base::FilePath(FILE_PATH_LITERAL("title2.html")))); 488 base::FilePath(FILE_PATH_LITERAL("title2.html"))));
512 489
513 // Set different startup preferences for the 2 profiles. 490 // Set different startup preferences for the 2 profiles.
514 SessionStartupPref pref1(SessionStartupPref::URLS); 491 SessionStartupPref pref1(SessionStartupPref::URLS);
515 pref1.urls = urls1; 492 pref1.urls = urls1;
516 SessionStartupPref::SetStartupPref(default_profile, pref1); 493 SessionStartupPref::SetStartupPref(default_profile, pref1);
517 SessionStartupPref pref2(SessionStartupPref::URLS); 494 SessionStartupPref pref2(SessionStartupPref::URLS);
518 pref2.urls = urls2; 495 pref2.urls = urls2;
519 SessionStartupPref::SetStartupPref(other_profile, pref2); 496 SessionStartupPref::SetStartupPref(other_profile, pref2);
520 497
521 // Do not show the Welcome Page for either profile. 498 DisableWelcomePages({default_profile, other_profile});
522 default_profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true);
523 other_profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true);
524 499
525 // Close the browser. 500 // Close the browser.
526 CloseBrowserAsynchronously(browser()); 501 CloseBrowserAsynchronously(browser());
527 502
528 // Do a simple non-process-startup browser launch. 503 // Do a simple non-process-startup browser launch.
529 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); 504 base::CommandLine dummy(base::CommandLine::NO_PROGRAM);
530 505
531 StartupBrowserCreator browser_creator; 506 StartupBrowserCreator browser_creator;
532 std::vector<Profile*> last_opened_profiles; 507 std::vector<Profile*> last_opened_profiles;
533 last_opened_profiles.push_back(default_profile); 508 last_opened_profiles.push_back(default_profile);
534 last_opened_profiles.push_back(other_profile); 509 last_opened_profiles.push_back(other_profile);
535 browser_creator.Start(dummy, profile_manager->user_data_dir(), 510 browser_creator.Start(dummy, profile_manager->user_data_dir(),
536 default_profile, last_opened_profiles); 511 default_profile, last_opened_profiles);
537 512
538 // urls1 were opened in a browser for default_profile, and urls2 were opened 513 // urls1 were opened in a browser for default_profile, and urls2 were opened
539 // in a browser for other_profile. 514 // in a browser for other_profile.
540 Browser* new_browser = NULL; 515 Browser* new_browser = NULL;
541 // |browser()| is still around at this point, even though we've closed its 516 // |browser()| is still around at this point, even though we've closed its
542 // window. Thus the browser count for default_profile is 2. 517 // window. Thus the browser count for default_profile is 2.
543 ASSERT_EQ(2u, chrome::GetBrowserCount(default_profile)); 518 ASSERT_EQ(2u, chrome::GetBrowserCount(default_profile));
544 new_browser = FindOneOtherBrowserForProfile(default_profile, browser()); 519 new_browser = FindOneOtherBrowserForProfile(default_profile, browser());
545 ASSERT_TRUE(new_browser); 520 ASSERT_TRUE(new_browser);
546 TabStripModel* tab_strip = new_browser->tab_strip_model(); 521 TabStripModel* tab_strip = new_browser->tab_strip_model();
547 if (IsWindows10OrNewer()) { 522
548 // The new browser should have the welcome tab and the URL for the profile. 523 // The new browser should have only the desired URL for the profile.
549 ASSERT_EQ(2, tab_strip->count()); 524 ASSERT_EQ(1, tab_strip->count());
550 EXPECT_EQ(GURL(internals::GetWelcomePageURL()), 525 EXPECT_EQ(urls1[0], tab_strip->GetWebContentsAt(0)->GetURL());
551 tab_strip->GetWebContentsAt(0)->GetURL());
552 EXPECT_EQ(urls1[0], tab_strip->GetWebContentsAt(1)->GetURL());
553 } else {
554 // The new browser should have only the desired URL for the profile.
555 ASSERT_EQ(1, tab_strip->count());
556 EXPECT_EQ(urls1[0], tab_strip->GetWebContentsAt(0)->GetURL());
557 }
558 526
559 ASSERT_EQ(1u, chrome::GetBrowserCount(other_profile)); 527 ASSERT_EQ(1u, chrome::GetBrowserCount(other_profile));
560 new_browser = FindOneOtherBrowserForProfile(other_profile, NULL); 528 new_browser = FindOneOtherBrowserForProfile(other_profile, NULL);
561 ASSERT_TRUE(new_browser); 529 ASSERT_TRUE(new_browser);
562 tab_strip = new_browser->tab_strip_model(); 530 tab_strip = new_browser->tab_strip_model();
563 ASSERT_EQ(1, tab_strip->count()); 531 ASSERT_EQ(1, tab_strip->count());
564 EXPECT_EQ(urls2[0], tab_strip->GetWebContentsAt(0)->GetURL()); 532 EXPECT_EQ(urls2[0], tab_strip->GetWebContentsAt(0)->GetURL());
565 } 533 }
566 534
567 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, PRE_UpdateWithTwoProfiles) { 535 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, PRE_UpdateWithTwoProfiles) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 662
695 Profile* profile_home1 = profile_manager->GetProfile(dest_path1); 663 Profile* profile_home1 = profile_manager->GetProfile(dest_path1);
696 ASSERT_TRUE(profile_home1); 664 ASSERT_TRUE(profile_home1);
697 Profile* profile_home2 = profile_manager->GetProfile(dest_path2); 665 Profile* profile_home2 = profile_manager->GetProfile(dest_path2);
698 ASSERT_TRUE(profile_home2); 666 ASSERT_TRUE(profile_home2);
699 Profile* profile_last = profile_manager->GetProfile(dest_path3); 667 Profile* profile_last = profile_manager->GetProfile(dest_path3);
700 ASSERT_TRUE(profile_last); 668 ASSERT_TRUE(profile_last);
701 Profile* profile_urls = profile_manager->GetProfile(dest_path4); 669 Profile* profile_urls = profile_manager->GetProfile(dest_path4);
702 ASSERT_TRUE(profile_urls); 670 ASSERT_TRUE(profile_urls);
703 671
704 // Avoid showing the Welcome page on all four profiles. 672 DisableWelcomePages(
705 profile_home1->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); 673 {profile_home1, profile_home2, profile_last, profile_urls});
706 profile_home2->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true);
707 profile_last->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true);
708 profile_urls->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true);
709 674
710 // Set the profiles to open urls, open last visited pages or display the home 675 // Set the profiles to open urls, open last visited pages or display the home
711 // page. 676 // page.
712 SessionStartupPref pref_home(SessionStartupPref::DEFAULT); 677 SessionStartupPref pref_home(SessionStartupPref::DEFAULT);
713 SessionStartupPref::SetStartupPref(profile_home1, pref_home); 678 SessionStartupPref::SetStartupPref(profile_home1, pref_home);
714 SessionStartupPref::SetStartupPref(profile_home2, pref_home); 679 SessionStartupPref::SetStartupPref(profile_home2, pref_home);
715 680
716 SessionStartupPref pref_last(SessionStartupPref::LAST); 681 SessionStartupPref pref_last(SessionStartupPref::LAST);
717 SessionStartupPref::SetStartupPref(profile_last, pref_last); 682 SessionStartupPref::SetStartupPref(profile_last, pref_last);
718 683
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 base::RunLoop().RunUntilIdle(); 721 base::RunLoop().RunUntilIdle();
757 722
758 Browser* new_browser = NULL; 723 Browser* new_browser = NULL;
759 // The last open profile (the profile_home1 in this case) will always be 724 // The last open profile (the profile_home1 in this case) will always be
760 // launched, even if it will open just the NTP (and the welcome page on 725 // launched, even if it will open just the NTP (and the welcome page on
761 // relevant platforms). 726 // relevant platforms).
762 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home1)); 727 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home1));
763 new_browser = FindOneOtherBrowserForProfile(profile_home1, NULL); 728 new_browser = FindOneOtherBrowserForProfile(profile_home1, NULL);
764 ASSERT_TRUE(new_browser); 729 ASSERT_TRUE(new_browser);
765 TabStripModel* tab_strip = new_browser->tab_strip_model(); 730 TabStripModel* tab_strip = new_browser->tab_strip_model();
766 if (IsWindows10OrNewer()) { 731
767 // The new browser should have the welcome tab and the NTP. 732 // The new browser should have only the NTP.
768 ASSERT_EQ(2, tab_strip->count()); 733 ASSERT_EQ(1, tab_strip->count());
769 EXPECT_EQ(GURL(internals::GetWelcomePageURL()), 734 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
770 tab_strip->GetWebContentsAt(0)->GetURL()); 735 tab_strip->GetWebContentsAt(0)->GetURL());
771 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
772 tab_strip->GetWebContentsAt(1)->GetURL());
773 } else {
774 // The new browser should have only the NTP.
775 ASSERT_EQ(1, tab_strip->count());
776 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
777 tab_strip->GetWebContentsAt(0)->GetURL());
778 }
779 736
780 // profile_urls opened the urls. 737 // profile_urls opened the urls.
781 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls)); 738 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls));
782 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); 739 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL);
783 ASSERT_TRUE(new_browser); 740 ASSERT_TRUE(new_browser);
784 tab_strip = new_browser->tab_strip_model(); 741 tab_strip = new_browser->tab_strip_model();
785 ASSERT_EQ(1, tab_strip->count()); 742 ASSERT_EQ(1, tab_strip->count());
786 EXPECT_EQ(urls[0], tab_strip->GetWebContentsAt(0)->GetURL()); 743 EXPECT_EQ(urls[0], tab_strip->GetWebContentsAt(0)->GetURL());
787 744
788 // profile_last opened the last open pages. 745 // profile_last opened the last open pages.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 EXPECT_FALSE(SessionRestore::IsRestoring(profile_last)); 829 EXPECT_FALSE(SessionRestore::IsRestoring(profile_last));
873 EXPECT_FALSE(SessionRestore::IsRestoring(profile_urls)); 830 EXPECT_FALSE(SessionRestore::IsRestoring(profile_urls));
874 831
875 // The profile which normally opens the home page displays the new tab page. 832 // The profile which normally opens the home page displays the new tab page.
876 // The welcome page is also shown for relevant platforms. 833 // The welcome page is also shown for relevant platforms.
877 Browser* new_browser = NULL; 834 Browser* new_browser = NULL;
878 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home)); 835 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home));
879 new_browser = FindOneOtherBrowserForProfile(profile_home, NULL); 836 new_browser = FindOneOtherBrowserForProfile(profile_home, NULL);
880 ASSERT_TRUE(new_browser); 837 ASSERT_TRUE(new_browser);
881 TabStripModel* tab_strip = new_browser->tab_strip_model(); 838 TabStripModel* tab_strip = new_browser->tab_strip_model();
882 if (IsWindows10OrNewer()) { 839
883 // The new browser should have the welcome tab and the NTP. 840 // The new browser should have only the NTP.
884 ASSERT_EQ(2, tab_strip->count()); 841 ASSERT_EQ(1, tab_strip->count());
885 EXPECT_EQ(GURL(internals::GetWelcomePageURL()), 842 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
886 tab_strip->GetWebContentsAt(0)->GetURL()); 843 tab_strip->GetWebContentsAt(0)->GetURL());
887 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), 844
888 tab_strip->GetWebContentsAt(1)->GetURL());
889 } else {
890 // The new browser should have only the NTP.
891 ASSERT_EQ(1, tab_strip->count());
892 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
893 tab_strip->GetWebContentsAt(0)->GetURL());
894 }
895 EnsureRestoreUIWasShown(tab_strip->GetWebContentsAt(0)); 845 EnsureRestoreUIWasShown(tab_strip->GetWebContentsAt(0));
896 846
897 // The profile which normally opens last open pages displays the new tab page. 847 // The profile which normally opens last open pages displays the new tab page.
898 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last)); 848 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last));
899 new_browser = FindOneOtherBrowserForProfile(profile_last, NULL); 849 new_browser = FindOneOtherBrowserForProfile(profile_last, NULL);
900 ASSERT_TRUE(new_browser); 850 ASSERT_TRUE(new_browser);
901 tab_strip = new_browser->tab_strip_model(); 851 tab_strip = new_browser->tab_strip_model();
902 ASSERT_EQ(1, tab_strip->count()); 852 ASSERT_EQ(1, tab_strip->count());
903 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), 853 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
904 tab_strip->GetWebContentsAt(0)->GetURL()); 854 tab_strip->GetWebContentsAt(0)->GetURL());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 content::WindowedNotificationObserver observer( 890 content::WindowedNotificationObserver observer(
941 content::NOTIFICATION_LOAD_STOP, 891 content::NOTIFICATION_LOAD_STOP,
942 content::NotificationService::AllSources()); 892 content::NotificationService::AllSources());
943 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); 893 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false));
944 894
945 // This should have created a new browser window. 895 // This should have created a new browser window.
946 Browser* new_browser = FindOneOtherBrowser(browser()); 896 Browser* new_browser = FindOneOtherBrowser(browser());
947 ASSERT_TRUE(new_browser); 897 ASSERT_TRUE(new_browser);
948 898
949 TabStripModel* tab_strip = new_browser->tab_strip_model(); 899 TabStripModel* tab_strip = new_browser->tab_strip_model();
950 // There should be only one tab, except on Windows 10. See crbug.com/505029. 900
951 const int tab_count = IsWindows10OrNewer() ? 2 : 1; 901 EXPECT_EQ(1, tab_strip->count());
952 EXPECT_EQ(tab_count, tab_strip->count());
953 } 902 }
954 903
955 #endif // !defined(OS_CHROMEOS) 904 #endif // !defined(OS_CHROMEOS)
956 905
957 // These tests are not applicable to Chrome OS as neither master_preferences nor 906 // These tests are not applicable to Chrome OS as neither master_preferences nor
958 // the sync promo exist there. 907 // the sync promo exist there.
959 #if !defined(OS_CHROMEOS) 908 #if !defined(OS_CHROMEOS)
960 909
961 class StartupBrowserCreatorFirstRunTest : public InProcessBrowserTest { 910 class StartupBrowserCreatorFirstRunTest : public InProcessBrowserTest {
962 protected: 911 protected:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 RestoreOnStartupURLsPolicySpecified 974 RestoreOnStartupURLsPolicySpecified
1026 #endif 975 #endif
1027 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest, 976 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorFirstRunTest,
1028 MAYBE_RestoreOnStartupURLsPolicySpecified) { 977 MAYBE_RestoreOnStartupURLsPolicySpecified) {
1029 if (IsWindows10OrNewer()) 978 if (IsWindows10OrNewer())
1030 return; 979 return;
1031 980
1032 ASSERT_TRUE(embedded_test_server()->Start()); 981 ASSERT_TRUE(embedded_test_server()->Start());
1033 StartupBrowserCreator browser_creator; 982 StartupBrowserCreator browser_creator;
1034 983
1035 // Avoid showing the Welcome page. 984 DisableWelcomePages({browser()->profile()});
1036 browser()->profile()->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage,
1037 true);
1038 985
1039 // Set the following user policies: 986 // Set the following user policies:
1040 // * RestoreOnStartup = RestoreOnStartupIsURLs 987 // * RestoreOnStartup = RestoreOnStartupIsURLs
1041 // * RestoreOnStartupURLs = [ "/title1.html" ] 988 // * RestoreOnStartupURLs = [ "/title1.html" ]
1042 policy_map_.Set( 989 policy_map_.Set(
1043 policy::key::kRestoreOnStartup, policy::POLICY_LEVEL_MANDATORY, 990 policy::key::kRestoreOnStartup, policy::POLICY_LEVEL_MANDATORY,
1044 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, 991 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
1045 base::WrapUnique( 992 base::WrapUnique(
1046 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs)), 993 new base::FundamentalValue(SessionStartupPref::kPrefValueURLs)),
1047 nullptr); 994 nullptr);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 ASSERT_TRUE(new_browser); 1066 ASSERT_TRUE(new_browser);
1120 1067
1121 // Verify that the first-run tab is shown and no other pages are present. 1068 // Verify that the first-run tab is shown and no other pages are present.
1122 TabStripModel* tab_strip = new_browser->tab_strip_model(); 1069 TabStripModel* tab_strip = new_browser->tab_strip_model();
1123 ASSERT_EQ(1, tab_strip->count()); 1070 ASSERT_EQ(1, tab_strip->count());
1124 EXPECT_EQ("title1.html", 1071 EXPECT_EQ("title1.html",
1125 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); 1072 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName());
1126 } 1073 }
1127 1074
1128 #endif // !defined(OS_CHROMEOS) 1075 #endif // !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | chrome/browser/ui/startup/startup_browser_creator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698