Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 ASSERT_TRUE(embedded_test_server()->Start()); | 229 ASSERT_TRUE(embedded_test_server()->Start()); |
| 230 std::vector<GURL> urls; | 230 std::vector<GURL> urls; |
| 231 urls.push_back(embedded_test_server()->GetURL("/title1.html")); | 231 urls.push_back(embedded_test_server()->GetURL("/title1.html")); |
| 232 urls.push_back(embedded_test_server()->GetURL("/title2.html")); | 232 urls.push_back(embedded_test_server()->GetURL("/title2.html")); |
| 233 | 233 |
| 234 Profile* profile = browser()->profile(); | 234 Profile* profile = browser()->profile(); |
| 235 | 235 |
| 236 // Do not show Welcome Page this run. | 236 // Do not show Welcome Page this run. |
| 237 profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); | 237 profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
| 238 | 238 |
| 239 #if defined(OS_WIN) | |
| 240 // Do not show the Windows 10 promo page. | |
| 241 g_browser_process->local_state()->SetBoolean( | |
| 242 prefs::kHasSeenWin10PromoPage, true); | |
| 243 #endif | |
|
Peter Kasting
2017/02/01 02:09:51
Lots of places in this file, and one place in anot
tmartino
2017/02/01 21:04:33
Done
| |
| 244 | |
| 239 // Set the startup preference to open these URLs. | 245 // Set the startup preference to open these URLs. |
| 240 SessionStartupPref pref(SessionStartupPref::URLS); | 246 SessionStartupPref pref(SessionStartupPref::URLS); |
| 241 pref.urls = urls; | 247 pref.urls = urls; |
| 242 SessionStartupPref::SetStartupPref(profile, pref); | 248 SessionStartupPref::SetStartupPref(profile, pref); |
| 243 | 249 |
| 244 // Keep the browser process running while browsers are closed. | 250 // Keep the browser process running while browsers are closed. |
| 245 ScopedKeepAlive keep_alive(KeepAliveOrigin::BROWSER, | 251 ScopedKeepAlive keep_alive(KeepAliveOrigin::BROWSER, |
| 246 KeepAliveRestartOption::DISABLED); | 252 KeepAliveRestartOption::DISABLED); |
| 247 | 253 |
| 248 // Close the browser. | 254 // Close the browser. |
| 249 CloseBrowserAsynchronously(browser()); | 255 CloseBrowserAsynchronously(browser()); |
| 250 | 256 |
| 251 // Do a simple non-process-startup browser launch. | 257 // Do a simple non-process-startup browser launch. |
| 252 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); | 258 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
| 253 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? | 259 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? |
| 254 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; | 260 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; |
| 255 { | 261 { |
| 256 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); | 262 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); |
| 257 ASSERT_TRUE(launch.Launch(profile, std::vector<GURL>(), false)); | 263 ASSERT_TRUE(launch.Launch(profile, std::vector<GURL>(), false)); |
| 258 } | 264 } |
| 259 | 265 |
| 260 // This should have created a new browser window. |browser()| is still | 266 // This should have created a new browser window. |browser()| is still |
| 261 // around at this point, even though we've closed its window. | 267 // around at this point, even though we've closed its window. |
| 262 Browser* new_browser = FindOneOtherBrowser(browser()); | 268 Browser* new_browser = FindOneOtherBrowser(browser()); |
| 263 ASSERT_TRUE(new_browser); | 269 ASSERT_TRUE(new_browser); |
| 264 | 270 |
| 265 std::vector<GURL> expected_urls(urls); | 271 std::vector<GURL> expected_urls(urls); |
| 266 if (IsWindows10OrNewer()) | |
| 267 expected_urls.insert(expected_urls.begin(), internals::GetWelcomePageURL()); | |
| 268 | 272 |
| 269 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 273 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 270 ASSERT_EQ(static_cast<int>(expected_urls.size()), tab_strip->count()); | 274 ASSERT_EQ(static_cast<int>(expected_urls.size()), tab_strip->count()); |
| 271 for (size_t i = 0; i < expected_urls.size(); i++) | 275 for (size_t i = 0; i < expected_urls.size(); i++) |
| 272 EXPECT_EQ(expected_urls[i], tab_strip->GetWebContentsAt(i)->GetURL()); | 276 EXPECT_EQ(expected_urls[i], tab_strip->GetWebContentsAt(i)->GetURL()); |
| 273 | 277 |
| 274 // The two test_server tabs, despite having the same site, should be in | 278 // The two test_server tabs, despite having the same site, should be in |
| 275 // different SiteInstances. | 279 // different SiteInstances. |
| 276 EXPECT_NE( | 280 EXPECT_NE( |
| 277 tab_strip->GetWebContentsAt(tab_strip->count() - 2)->GetSiteInstance(), | 281 tab_strip->GetWebContentsAt(tab_strip->count() - 2)->GetSiteInstance(), |
| 278 tab_strip->GetWebContentsAt(tab_strip->count() - 1)->GetSiteInstance()); | 282 tab_strip->GetWebContentsAt(tab_strip->count() - 1)->GetSiteInstance()); |
| 279 | 283 |
| 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 } | 284 } |
| 307 | 285 |
| 308 // Verify that startup URLs aren't used when the process already exists | 286 // 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 | 287 // and has other tabbed browser windows. This is the common case of starting a |
| 310 // new browser. | 288 // new browser. |
| 311 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, | 289 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, |
| 312 StartupURLsOnNewWindow) { | 290 StartupURLsOnNewWindow) { |
| 313 // Use a couple arbitrary URLs. | 291 // Use a couple arbitrary URLs. |
| 314 std::vector<GURL> urls; | 292 std::vector<GURL> urls; |
| 315 urls.push_back(ui_test_utils::GetTestUrl( | 293 urls.push_back(ui_test_utils::GetTestUrl( |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 331 { | 309 { |
| 332 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); | 310 StartupBrowserCreatorImpl launch(base::FilePath(), dummy, first_run); |
| 333 ASSERT_TRUE( | 311 ASSERT_TRUE( |
| 334 launch.Launch(browser()->profile(), std::vector<GURL>(), false)); | 312 launch.Launch(browser()->profile(), std::vector<GURL>(), false)); |
| 335 } | 313 } |
| 336 | 314 |
| 337 // This should have created a new browser window. | 315 // This should have created a new browser window. |
| 338 Browser* new_browser = FindOneOtherBrowser(browser()); | 316 Browser* new_browser = FindOneOtherBrowser(browser()); |
| 339 ASSERT_TRUE(new_browser); | 317 ASSERT_TRUE(new_browser); |
| 340 | 318 |
| 341 if (IsWindows10OrNewer()) { | 319 // The new browser should have exactly one tab (not the startup URLs). |
| 342 // The new browser should have two tabs (not the startup URLs). | 320 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 | 321 |
| 349 // Test that the welcome page is not shown the second time through if it was | 322 // Test that the welcome page is not shown the second time through if it was |
| 350 // above. | 323 // above. |
| 351 if (!IsWindows10OrNewer()) { | 324 if (!IsWindows10OrNewer()) { |
| 352 // Close the browser opened above. | 325 // Close the browser opened above. |
| 353 { | 326 { |
| 354 content::WindowedNotificationObserver observer( | 327 content::WindowedNotificationObserver observer( |
| 355 chrome::NOTIFICATION_BROWSER_CLOSED, | 328 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 356 content::Source<Browser>(new_browser)); | 329 content::Source<Browser>(new_browser)); |
| 357 new_browser->window()->Close(); | 330 new_browser->window()->Close(); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 pref1.urls = urls1; | 488 pref1.urls = urls1; |
| 516 SessionStartupPref::SetStartupPref(default_profile, pref1); | 489 SessionStartupPref::SetStartupPref(default_profile, pref1); |
| 517 SessionStartupPref pref2(SessionStartupPref::URLS); | 490 SessionStartupPref pref2(SessionStartupPref::URLS); |
| 518 pref2.urls = urls2; | 491 pref2.urls = urls2; |
| 519 SessionStartupPref::SetStartupPref(other_profile, pref2); | 492 SessionStartupPref::SetStartupPref(other_profile, pref2); |
| 520 | 493 |
| 521 // Do not show the Welcome Page for either profile. | 494 // Do not show the Welcome Page for either profile. |
| 522 default_profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); | 495 default_profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
| 523 other_profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); | 496 other_profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
| 524 | 497 |
| 498 #if defined(OS_WIN) | |
| 499 // Do not show the Windows 10 promo page for any profile. | |
| 500 g_browser_process->local_state()->SetBoolean( | |
| 501 prefs::kHasSeenWin10PromoPage, true); | |
| 502 #endif | |
| 503 | |
| 525 // Close the browser. | 504 // Close the browser. |
| 526 CloseBrowserAsynchronously(browser()); | 505 CloseBrowserAsynchronously(browser()); |
| 527 | 506 |
| 528 // Do a simple non-process-startup browser launch. | 507 // Do a simple non-process-startup browser launch. |
| 529 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); | 508 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
| 530 | 509 |
| 531 StartupBrowserCreator browser_creator; | 510 StartupBrowserCreator browser_creator; |
| 532 std::vector<Profile*> last_opened_profiles; | 511 std::vector<Profile*> last_opened_profiles; |
| 533 last_opened_profiles.push_back(default_profile); | 512 last_opened_profiles.push_back(default_profile); |
| 534 last_opened_profiles.push_back(other_profile); | 513 last_opened_profiles.push_back(other_profile); |
| 535 browser_creator.Start(dummy, profile_manager->user_data_dir(), | 514 browser_creator.Start(dummy, profile_manager->user_data_dir(), |
| 536 default_profile, last_opened_profiles); | 515 default_profile, last_opened_profiles); |
| 537 | 516 |
| 538 // urls1 were opened in a browser for default_profile, and urls2 were opened | 517 // urls1 were opened in a browser for default_profile, and urls2 were opened |
| 539 // in a browser for other_profile. | 518 // in a browser for other_profile. |
| 540 Browser* new_browser = NULL; | 519 Browser* new_browser = NULL; |
| 541 // |browser()| is still around at this point, even though we've closed its | 520 // |browser()| is still around at this point, even though we've closed its |
| 542 // window. Thus the browser count for default_profile is 2. | 521 // window. Thus the browser count for default_profile is 2. |
| 543 ASSERT_EQ(2u, chrome::GetBrowserCount(default_profile)); | 522 ASSERT_EQ(2u, chrome::GetBrowserCount(default_profile)); |
| 544 new_browser = FindOneOtherBrowserForProfile(default_profile, browser()); | 523 new_browser = FindOneOtherBrowserForProfile(default_profile, browser()); |
| 545 ASSERT_TRUE(new_browser); | 524 ASSERT_TRUE(new_browser); |
| 546 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 525 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 547 if (IsWindows10OrNewer()) { | 526 |
| 548 // The new browser should have the welcome tab and the URL for the profile. | 527 // The new browser should have only the desired URL for the profile. |
| 549 ASSERT_EQ(2, tab_strip->count()); | 528 ASSERT_EQ(1, tab_strip->count()); |
| 550 EXPECT_EQ(GURL(internals::GetWelcomePageURL()), | 529 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 | 530 |
| 559 ASSERT_EQ(1u, chrome::GetBrowserCount(other_profile)); | 531 ASSERT_EQ(1u, chrome::GetBrowserCount(other_profile)); |
| 560 new_browser = FindOneOtherBrowserForProfile(other_profile, NULL); | 532 new_browser = FindOneOtherBrowserForProfile(other_profile, NULL); |
| 561 ASSERT_TRUE(new_browser); | 533 ASSERT_TRUE(new_browser); |
| 562 tab_strip = new_browser->tab_strip_model(); | 534 tab_strip = new_browser->tab_strip_model(); |
| 563 ASSERT_EQ(1, tab_strip->count()); | 535 ASSERT_EQ(1, tab_strip->count()); |
| 564 EXPECT_EQ(urls2[0], tab_strip->GetWebContentsAt(0)->GetURL()); | 536 EXPECT_EQ(urls2[0], tab_strip->GetWebContentsAt(0)->GetURL()); |
| 565 } | 537 } |
| 566 | 538 |
| 567 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, PRE_UpdateWithTwoProfiles) { | 539 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, PRE_UpdateWithTwoProfiles) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 ASSERT_TRUE(profile_last); | 672 ASSERT_TRUE(profile_last); |
| 701 Profile* profile_urls = profile_manager->GetProfile(dest_path4); | 673 Profile* profile_urls = profile_manager->GetProfile(dest_path4); |
| 702 ASSERT_TRUE(profile_urls); | 674 ASSERT_TRUE(profile_urls); |
| 703 | 675 |
| 704 // Avoid showing the Welcome page on all four profiles. | 676 // Avoid showing the Welcome page on all four profiles. |
| 705 profile_home1->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); | 677 profile_home1->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
| 706 profile_home2->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); | 678 profile_home2->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
| 707 profile_last->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); | 679 profile_last->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
| 708 profile_urls->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); | 680 profile_urls->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); |
| 709 | 681 |
| 682 #if defined(OS_WIN) | |
| 683 // Do not show the Windows 10 promo page for any profile. | |
| 684 g_browser_process->local_state()->SetBoolean( | |
| 685 prefs::kHasSeenWin10PromoPage, true); | |
| 686 #endif | |
| 687 | |
| 710 // Set the profiles to open urls, open last visited pages or display the home | 688 // Set the profiles to open urls, open last visited pages or display the home |
| 711 // page. | 689 // page. |
| 712 SessionStartupPref pref_home(SessionStartupPref::DEFAULT); | 690 SessionStartupPref pref_home(SessionStartupPref::DEFAULT); |
| 713 SessionStartupPref::SetStartupPref(profile_home1, pref_home); | 691 SessionStartupPref::SetStartupPref(profile_home1, pref_home); |
| 714 SessionStartupPref::SetStartupPref(profile_home2, pref_home); | 692 SessionStartupPref::SetStartupPref(profile_home2, pref_home); |
| 715 | 693 |
| 716 SessionStartupPref pref_last(SessionStartupPref::LAST); | 694 SessionStartupPref pref_last(SessionStartupPref::LAST); |
| 717 SessionStartupPref::SetStartupPref(profile_last, pref_last); | 695 SessionStartupPref::SetStartupPref(profile_last, pref_last); |
| 718 | 696 |
| 719 std::vector<GURL> urls; | 697 std::vector<GURL> urls; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 756 base::RunLoop().RunUntilIdle(); | 734 base::RunLoop().RunUntilIdle(); |
| 757 | 735 |
| 758 Browser* new_browser = NULL; | 736 Browser* new_browser = NULL; |
| 759 // The last open profile (the profile_home1 in this case) will always be | 737 // 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 | 738 // launched, even if it will open just the NTP (and the welcome page on |
| 761 // relevant platforms). | 739 // relevant platforms). |
| 762 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home1)); | 740 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home1)); |
| 763 new_browser = FindOneOtherBrowserForProfile(profile_home1, NULL); | 741 new_browser = FindOneOtherBrowserForProfile(profile_home1, NULL); |
| 764 ASSERT_TRUE(new_browser); | 742 ASSERT_TRUE(new_browser); |
| 765 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 743 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 766 if (IsWindows10OrNewer()) { | 744 |
| 767 // The new browser should have the welcome tab and the NTP. | 745 // The new browser should have only the NTP. |
| 768 ASSERT_EQ(2, tab_strip->count()); | 746 ASSERT_EQ(1, tab_strip->count()); |
| 769 EXPECT_EQ(GURL(internals::GetWelcomePageURL()), | 747 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
| 770 tab_strip->GetWebContentsAt(0)->GetURL()); | 748 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 | 749 |
| 780 // profile_urls opened the urls. | 750 // profile_urls opened the urls. |
| 781 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls)); | 751 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls)); |
| 782 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); | 752 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); |
| 783 ASSERT_TRUE(new_browser); | 753 ASSERT_TRUE(new_browser); |
| 784 tab_strip = new_browser->tab_strip_model(); | 754 tab_strip = new_browser->tab_strip_model(); |
| 785 ASSERT_EQ(1, tab_strip->count()); | 755 ASSERT_EQ(1, tab_strip->count()); |
| 786 EXPECT_EQ(urls[0], tab_strip->GetWebContentsAt(0)->GetURL()); | 756 EXPECT_EQ(urls[0], tab_strip->GetWebContentsAt(0)->GetURL()); |
| 787 | 757 |
| 788 // profile_last opened the last open pages. | 758 // profile_last opened the last open pages. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 872 EXPECT_FALSE(SessionRestore::IsRestoring(profile_last)); | 842 EXPECT_FALSE(SessionRestore::IsRestoring(profile_last)); |
| 873 EXPECT_FALSE(SessionRestore::IsRestoring(profile_urls)); | 843 EXPECT_FALSE(SessionRestore::IsRestoring(profile_urls)); |
| 874 | 844 |
| 875 // The profile which normally opens the home page displays the new tab page. | 845 // The profile which normally opens the home page displays the new tab page. |
| 876 // The welcome page is also shown for relevant platforms. | 846 // The welcome page is also shown for relevant platforms. |
| 877 Browser* new_browser = NULL; | 847 Browser* new_browser = NULL; |
| 878 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home)); | 848 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home)); |
| 879 new_browser = FindOneOtherBrowserForProfile(profile_home, NULL); | 849 new_browser = FindOneOtherBrowserForProfile(profile_home, NULL); |
| 880 ASSERT_TRUE(new_browser); | 850 ASSERT_TRUE(new_browser); |
| 881 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 851 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 882 if (IsWindows10OrNewer()) { | 852 |
| 883 // The new browser should have the welcome tab and the NTP. | 853 // The new browser should have only the NTP. |
| 884 ASSERT_EQ(2, tab_strip->count()); | 854 ASSERT_EQ(1, tab_strip->count()); |
| 885 EXPECT_EQ(GURL(internals::GetWelcomePageURL()), | 855 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
| 886 tab_strip->GetWebContentsAt(0)->GetURL()); | 856 tab_strip->GetWebContentsAt(0)->GetURL()); |
| 887 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), | 857 |
| 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)); | 858 EnsureRestoreUIWasShown(tab_strip->GetWebContentsAt(0)); |
| 896 | 859 |
| 897 // The profile which normally opens last open pages displays the new tab page. | 860 // The profile which normally opens last open pages displays the new tab page. |
| 898 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last)); | 861 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last)); |
| 899 new_browser = FindOneOtherBrowserForProfile(profile_last, NULL); | 862 new_browser = FindOneOtherBrowserForProfile(profile_last, NULL); |
| 900 ASSERT_TRUE(new_browser); | 863 ASSERT_TRUE(new_browser); |
| 901 tab_strip = new_browser->tab_strip_model(); | 864 tab_strip = new_browser->tab_strip_model(); |
| 902 ASSERT_EQ(1, tab_strip->count()); | 865 ASSERT_EQ(1, tab_strip->count()); |
| 903 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), | 866 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
| 904 tab_strip->GetWebContentsAt(0)->GetURL()); | 867 tab_strip->GetWebContentsAt(0)->GetURL()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 940 content::WindowedNotificationObserver observer( | 903 content::WindowedNotificationObserver observer( |
| 941 content::NOTIFICATION_LOAD_STOP, | 904 content::NOTIFICATION_LOAD_STOP, |
| 942 content::NotificationService::AllSources()); | 905 content::NotificationService::AllSources()); |
| 943 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); | 906 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); |
| 944 | 907 |
| 945 // This should have created a new browser window. | 908 // This should have created a new browser window. |
| 946 Browser* new_browser = FindOneOtherBrowser(browser()); | 909 Browser* new_browser = FindOneOtherBrowser(browser()); |
| 947 ASSERT_TRUE(new_browser); | 910 ASSERT_TRUE(new_browser); |
| 948 | 911 |
| 949 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 912 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 950 // There should be only one tab, except on Windows 10. See crbug.com/505029. | 913 |
| 951 const int tab_count = IsWindows10OrNewer() ? 2 : 1; | 914 EXPECT_EQ(1, tab_strip->count()); |
| 952 EXPECT_EQ(tab_count, tab_strip->count()); | |
| 953 } | 915 } |
| 954 | 916 |
| 955 #endif // !defined(OS_CHROMEOS) | 917 #endif // !defined(OS_CHROMEOS) |
| 956 | 918 |
| 957 // These tests are not applicable to Chrome OS as neither master_preferences nor | 919 // These tests are not applicable to Chrome OS as neither master_preferences nor |
| 958 // the sync promo exist there. | 920 // the sync promo exist there. |
| 959 #if !defined(OS_CHROMEOS) | 921 #if !defined(OS_CHROMEOS) |
| 960 | 922 |
| 961 class StartupBrowserCreatorFirstRunTest : public InProcessBrowserTest { | 923 class StartupBrowserCreatorFirstRunTest : public InProcessBrowserTest { |
| 962 protected: | 924 protected: |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1119 ASSERT_TRUE(new_browser); | 1081 ASSERT_TRUE(new_browser); |
| 1120 | 1082 |
| 1121 // Verify that the first-run tab is shown and no other pages are present. | 1083 // Verify that the first-run tab is shown and no other pages are present. |
| 1122 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 1084 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 1123 ASSERT_EQ(1, tab_strip->count()); | 1085 ASSERT_EQ(1, tab_strip->count()); |
| 1124 EXPECT_EQ("title1.html", | 1086 EXPECT_EQ("title1.html", |
| 1125 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1087 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
| 1126 } | 1088 } |
| 1127 | 1089 |
| 1128 #endif // !defined(OS_CHROMEOS) | 1090 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |