| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/api/infobars/infobar_service.h" | 8 #include "chrome/browser/api/infobars/infobar_service.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/extensions/extension_browsertest.h" | 10 #include "chrome/browser/extensions/extension_browsertest.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
| 13 #include "chrome/browser/first_run/first_run.h" | 13 #include "chrome/browser/first_run/first_run.h" |
| 14 #include "chrome/browser/prefs/session_startup_pref.h" | 14 #include "chrome/browser/prefs/session_startup_pref.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/profiles/profile_impl.h" | 16 #include "chrome/browser/profiles/profile_impl.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/browser/sessions/session_restore.h" | 18 #include "chrome/browser/sessions/session_restore.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
| 21 #include "chrome/browser/ui/browser_iterator.h" | 21 #include "chrome/browser/ui/browser_iterator.h" |
| 22 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
| 23 #include "chrome/browser/ui/browser_list_observer.h" | 23 #include "chrome/browser/ui/browser_list_observer.h" |
| 24 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
| 25 #include "chrome/browser/ui/host_desktop.h" |
| 25 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 26 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 26 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 27 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 28 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" | 29 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" |
| 29 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
| 32 #include "chrome/test/base/in_process_browser_test.h" | 33 #include "chrome/test/base/in_process_browser_test.h" |
| 33 #include "chrome/test/base/ui_test_utils.h" | 34 #include "chrome/test/base/ui_test_utils.h" |
| 34 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 65 const Extension** out_app_extension) { | 66 const Extension** out_app_extension) { |
| 66 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(app_name.c_str()))); | 67 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII(app_name.c_str()))); |
| 67 | 68 |
| 68 ExtensionService* service = extensions::ExtensionSystem::Get( | 69 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 69 browser()->profile())->extension_service(); | 70 browser()->profile())->extension_service(); |
| 70 *out_app_extension = service->GetExtensionById( | 71 *out_app_extension = service->GetExtensionById( |
| 71 last_loaded_extension_id_, false); | 72 last_loaded_extension_id_, false); |
| 72 ASSERT_TRUE(*out_app_extension); | 73 ASSERT_TRUE(*out_app_extension); |
| 73 | 74 |
| 74 // Code that opens a new browser assumes we start with exactly one. | 75 // Code that opens a new browser assumes we start with exactly one. |
| 75 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); | 76 ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), |
| 77 browser()->host_desktop_type())); |
| 76 } | 78 } |
| 77 | 79 |
| 78 void SetAppLaunchPref(const std::string& app_id, | 80 void SetAppLaunchPref(const std::string& app_id, |
| 79 extensions::ExtensionPrefs::LaunchType launch_type) { | 81 extensions::ExtensionPrefs::LaunchType launch_type) { |
| 80 ExtensionService* service = extensions::ExtensionSystem::Get( | 82 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 81 browser()->profile())->extension_service(); | 83 browser()->profile())->extension_service(); |
| 82 service->extension_prefs()->SetLaunchType(app_id, launch_type); | 84 service->extension_prefs()->SetLaunchType(app_id, launch_type); |
| 83 } | 85 } |
| 84 | 86 |
| 85 // Check that there are two browsers. Find the one that is not |browser()|. | 87 // Check that there are two browsers. Find the one that is not |browser()|. |
| 86 void FindOneOtherBrowser(Browser** out_other_browser) { | 88 void FindOneOtherBrowser(Browser** out_other_browser) { |
| 87 // There should only be one other browser. | 89 // There should only be one other browser. |
| 88 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); | 90 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), |
| 91 browser()->host_desktop_type())); |
| 89 | 92 |
| 90 // Find the new browser. | 93 // Find the new browser. |
| 91 Browser* other_browser = NULL; | 94 Browser* other_browser = NULL; |
| 92 for (chrome::BrowserIterator it; !it.done() && !other_browser; it.Next()) { | 95 for (chrome::BrowserIterator it; !it.done() && !other_browser; it.Next()) { |
| 93 if (*it != browser()) | 96 if (*it != browser()) |
| 94 other_browser = *it; | 97 other_browser = *it; |
| 95 } | 98 } |
| 96 ASSERT_TRUE(other_browser); | 99 ASSERT_TRUE(other_browser); |
| 97 ASSERT_TRUE(other_browser != browser()); | 100 ASSERT_TRUE(other_browser != browser()); |
| 98 *out_other_browser = other_browser; | 101 *out_other_browser = other_browser; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 309 |
| 307 CommandLine command_line(CommandLine::NO_PROGRAM); | 310 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 308 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); | 311 command_line.AppendSwitchASCII(switches::kAppId, extension_app->id()); |
| 309 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? | 312 chrome::startup::IsFirstRun first_run = first_run::IsChromeFirstRun() ? |
| 310 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; | 313 chrome::startup::IS_FIRST_RUN : chrome::startup::IS_NOT_FIRST_RUN; |
| 311 StartupBrowserCreatorImpl launch(base::FilePath(), command_line, first_run); | 314 StartupBrowserCreatorImpl launch(base::FilePath(), command_line, first_run); |
| 312 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); | 315 ASSERT_TRUE(launch.Launch(browser()->profile(), std::vector<GURL>(), false)); |
| 313 | 316 |
| 314 // When an app shortcut is open and the pref indicates a tab should | 317 // When an app shortcut is open and the pref indicates a tab should |
| 315 // open, the tab is open in a new browser window. Expect a new window. | 318 // open, the tab is open in a new browser window. Expect a new window. |
| 316 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); | 319 ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), |
| 320 browser()->host_desktop_type())); |
| 317 | 321 |
| 318 Browser* new_browser = NULL; | 322 Browser* new_browser = NULL; |
| 319 ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser)); | 323 ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser)); |
| 320 | 324 |
| 321 // The tab should be in a tabbed window. | 325 // The tab should be in a tabbed window. |
| 322 EXPECT_TRUE(new_browser->is_type_tabbed()); | 326 EXPECT_TRUE(new_browser->is_type_tabbed()); |
| 323 | 327 |
| 324 // The browser's app_name should not include the app's ID: It is in a | 328 // The browser's app_name should not include the app's ID: It is in a |
| 325 // normal browser. | 329 // normal browser. |
| 326 EXPECT_EQ( | 330 EXPECT_EQ( |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 last_opened_profiles.push_back(default_profile); | 592 last_opened_profiles.push_back(default_profile); |
| 589 last_opened_profiles.push_back(other_profile); | 593 last_opened_profiles.push_back(other_profile); |
| 590 browser_creator.Start(dummy, profile_manager->user_data_dir(), | 594 browser_creator.Start(dummy, profile_manager->user_data_dir(), |
| 591 default_profile, last_opened_profiles, &return_code); | 595 default_profile, last_opened_profiles, &return_code); |
| 592 | 596 |
| 593 // urls1 were opened in a browser for default_profile, and urls2 were opened | 597 // urls1 were opened in a browser for default_profile, and urls2 were opened |
| 594 // in a browser for other_profile. | 598 // in a browser for other_profile. |
| 595 Browser* new_browser = NULL; | 599 Browser* new_browser = NULL; |
| 596 // |browser()| is still around at this point, even though we've closed its | 600 // |browser()| is still around at this point, even though we've closed its |
| 597 // window. Thus the browser count for default_profile is 2. | 601 // window. Thus the browser count for default_profile is 2. |
| 598 ASSERT_EQ(2u, chrome::GetBrowserCount(default_profile)); | 602 ASSERT_EQ(2u, chrome::GetBrowserCount(default_profile, |
| 603 browser()->host_desktop_type())); |
| 599 new_browser = FindOneOtherBrowserForProfile(default_profile, browser()); | 604 new_browser = FindOneOtherBrowserForProfile(default_profile, browser()); |
| 600 ASSERT_TRUE(new_browser); | 605 ASSERT_TRUE(new_browser); |
| 601 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 606 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 602 ASSERT_EQ(1, tab_strip->count()); | 607 ASSERT_EQ(1, tab_strip->count()); |
| 603 EXPECT_EQ(urls1[0], tab_strip->GetWebContentsAt(0)->GetURL()); | 608 EXPECT_EQ(urls1[0], tab_strip->GetWebContentsAt(0)->GetURL()); |
| 604 | 609 |
| 605 ASSERT_EQ(1u, chrome::GetBrowserCount(other_profile)); | 610 ASSERT_EQ(1u, chrome::GetBrowserCount(other_profile, |
| 611 browser()->host_desktop_type())); |
| 606 new_browser = FindOneOtherBrowserForProfile(other_profile, NULL); | 612 new_browser = FindOneOtherBrowserForProfile(other_profile, NULL); |
| 607 ASSERT_TRUE(new_browser); | 613 ASSERT_TRUE(new_browser); |
| 608 tab_strip = new_browser->tab_strip_model(); | 614 tab_strip = new_browser->tab_strip_model(); |
| 609 ASSERT_EQ(1, tab_strip->count()); | 615 ASSERT_EQ(1, tab_strip->count()); |
| 610 EXPECT_EQ(urls2[0], tab_strip->GetWebContentsAt(0)->GetURL()); | 616 EXPECT_EQ(urls2[0], tab_strip->GetWebContentsAt(0)->GetURL()); |
| 611 } | 617 } |
| 612 | 618 |
| 613 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, UpdateWithTwoProfiles) { | 619 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, UpdateWithTwoProfiles) { |
| 614 // Make StartupBrowserCreator::WasRestarted() return true. | 620 // Make StartupBrowserCreator::WasRestarted() return true. |
| 615 StartupBrowserCreator::was_restarted_read_ = false; | 621 StartupBrowserCreator::was_restarted_read_ = false; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 while (SessionRestore::IsRestoring(profile1) || | 666 while (SessionRestore::IsRestoring(profile1) || |
| 661 SessionRestore::IsRestoring(profile2)) | 667 SessionRestore::IsRestoring(profile2)) |
| 662 MessageLoop::current()->RunUntilIdle(); | 668 MessageLoop::current()->RunUntilIdle(); |
| 663 | 669 |
| 664 // The startup URLs are ignored, and instead the last open sessions are | 670 // The startup URLs are ignored, and instead the last open sessions are |
| 665 // restored. | 671 // restored. |
| 666 EXPECT_TRUE(profile1->restored_last_session()); | 672 EXPECT_TRUE(profile1->restored_last_session()); |
| 667 EXPECT_TRUE(profile2->restored_last_session()); | 673 EXPECT_TRUE(profile2->restored_last_session()); |
| 668 | 674 |
| 669 Browser* new_browser = NULL; | 675 Browser* new_browser = NULL; |
| 670 ASSERT_EQ(1u, chrome::GetBrowserCount(profile1)); | 676 ASSERT_EQ(1u, chrome::GetBrowserCount(profile1, |
| 677 browser()->host_desktop_type())); |
| 671 new_browser = FindOneOtherBrowserForProfile(profile1, NULL); | 678 new_browser = FindOneOtherBrowserForProfile(profile1, NULL); |
| 672 ASSERT_TRUE(new_browser); | 679 ASSERT_TRUE(new_browser); |
| 673 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 680 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 674 ASSERT_EQ(1, tab_strip->count()); | 681 ASSERT_EQ(1, tab_strip->count()); |
| 675 EXPECT_EQ(GURL(chrome::kAboutBlankURL), | 682 EXPECT_EQ(GURL(chrome::kAboutBlankURL), |
| 676 tab_strip->GetWebContentsAt(0)->GetURL()); | 683 tab_strip->GetWebContentsAt(0)->GetURL()); |
| 677 | 684 |
| 678 ASSERT_EQ(1u, chrome::GetBrowserCount(profile2)); | 685 ASSERT_EQ(1u, chrome::GetBrowserCount(profile2, |
| 686 browser()->host_desktop_type())); |
| 679 new_browser = FindOneOtherBrowserForProfile(profile2, NULL); | 687 new_browser = FindOneOtherBrowserForProfile(profile2, NULL); |
| 680 ASSERT_TRUE(new_browser); | 688 ASSERT_TRUE(new_browser); |
| 681 tab_strip = new_browser->tab_strip_model(); | 689 tab_strip = new_browser->tab_strip_model(); |
| 682 ASSERT_EQ(1, tab_strip->count()); | 690 ASSERT_EQ(1, tab_strip->count()); |
| 683 EXPECT_EQ(GURL(chrome::kAboutBlankURL), | 691 EXPECT_EQ(GURL(chrome::kAboutBlankURL), |
| 684 tab_strip->GetWebContentsAt(0)->GetURL()); | 692 tab_strip->GetWebContentsAt(0)->GetURL()); |
| 685 } | 693 } |
| 686 | 694 |
| 687 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, | 695 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, |
| 688 ProfilesWithoutPagesNotLaunched) { | 696 ProfilesWithoutPagesNotLaunched) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 std::vector<GURL> urls; | 729 std::vector<GURL> urls; |
| 722 urls.push_back(ui_test_utils::GetTestUrl( | 730 urls.push_back(ui_test_utils::GetTestUrl( |
| 723 base::FilePath(base::FilePath::kCurrentDirectory), | 731 base::FilePath(base::FilePath::kCurrentDirectory), |
| 724 base::FilePath(FILE_PATH_LITERAL("title1.html")))); | 732 base::FilePath(FILE_PATH_LITERAL("title1.html")))); |
| 725 | 733 |
| 726 SessionStartupPref pref_urls(SessionStartupPref::URLS); | 734 SessionStartupPref pref_urls(SessionStartupPref::URLS); |
| 727 pref_urls.urls = urls; | 735 pref_urls.urls = urls; |
| 728 SessionStartupPref::SetStartupPref(profile_urls, pref_urls); | 736 SessionStartupPref::SetStartupPref(profile_urls, pref_urls); |
| 729 | 737 |
| 730 // Close the browser. | 738 // Close the browser. |
| 739 chrome::HostDesktopType original_desktop_type = |
| 740 browser()->host_desktop_type(); |
| 731 browser()->window()->Close(); | 741 browser()->window()->Close(); |
| 732 | 742 |
| 733 // Do a simple non-process-startup browser launch. | 743 // Do a simple non-process-startup browser launch. |
| 734 CommandLine dummy(CommandLine::NO_PROGRAM); | 744 CommandLine dummy(CommandLine::NO_PROGRAM); |
| 735 | 745 |
| 736 int return_code; | 746 int return_code; |
| 737 StartupBrowserCreator browser_creator; | 747 StartupBrowserCreator browser_creator; |
| 738 std::vector<Profile*> last_opened_profiles; | 748 std::vector<Profile*> last_opened_profiles; |
| 739 last_opened_profiles.push_back(profile_home1); | 749 last_opened_profiles.push_back(profile_home1); |
| 740 last_opened_profiles.push_back(profile_home2); | 750 last_opened_profiles.push_back(profile_home2); |
| 741 last_opened_profiles.push_back(profile_last); | 751 last_opened_profiles.push_back(profile_last); |
| 742 last_opened_profiles.push_back(profile_urls); | 752 last_opened_profiles.push_back(profile_urls); |
| 743 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile_home1, | 753 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile_home1, |
| 744 last_opened_profiles, &return_code); | 754 last_opened_profiles, &return_code); |
| 745 | 755 |
| 746 while (SessionRestore::IsRestoring(default_profile) || | 756 while (SessionRestore::IsRestoring(default_profile) || |
| 747 SessionRestore::IsRestoring(profile_home1) || | 757 SessionRestore::IsRestoring(profile_home1) || |
| 748 SessionRestore::IsRestoring(profile_home2) || | 758 SessionRestore::IsRestoring(profile_home2) || |
| 749 SessionRestore::IsRestoring(profile_last) || | 759 SessionRestore::IsRestoring(profile_last) || |
| 750 SessionRestore::IsRestoring(profile_urls)) | 760 SessionRestore::IsRestoring(profile_urls)) |
| 751 MessageLoop::current()->RunUntilIdle(); | 761 MessageLoop::current()->RunUntilIdle(); |
| 752 | 762 |
| 753 Browser* new_browser = NULL; | 763 Browser* new_browser = NULL; |
| 754 // The last open profile (the profile_home1 in this case) will always be | 764 // The last open profile (the profile_home1 in this case) will always be |
| 755 // launched, even if it will open just the home page. | 765 // launched, even if it will open just the home page. |
| 756 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home1)); | 766 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home1, original_desktop_type)); |
| 757 new_browser = FindOneOtherBrowserForProfile(profile_home1, NULL); | 767 new_browser = FindOneOtherBrowserForProfile(profile_home1, NULL); |
| 758 ASSERT_TRUE(new_browser); | 768 ASSERT_TRUE(new_browser); |
| 759 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 769 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 760 ASSERT_EQ(1, tab_strip->count()); | 770 ASSERT_EQ(1, tab_strip->count()); |
| 761 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), | 771 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
| 762 tab_strip->GetWebContentsAt(0)->GetURL()); | 772 tab_strip->GetWebContentsAt(0)->GetURL()); |
| 763 | 773 |
| 764 // profile_urls opened the urls. | 774 // profile_urls opened the urls. |
| 765 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls)); | 775 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls, original_desktop_type)); |
| 766 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); | 776 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); |
| 767 ASSERT_TRUE(new_browser); | 777 ASSERT_TRUE(new_browser); |
| 768 tab_strip = new_browser->tab_strip_model(); | 778 tab_strip = new_browser->tab_strip_model(); |
| 769 ASSERT_EQ(1, tab_strip->count()); | 779 ASSERT_EQ(1, tab_strip->count()); |
| 770 EXPECT_EQ(urls[0], tab_strip->GetWebContentsAt(0)->GetURL()); | 780 EXPECT_EQ(urls[0], tab_strip->GetWebContentsAt(0)->GetURL()); |
| 771 | 781 |
| 772 // profile_last opened the last open pages. | 782 // profile_last opened the last open pages. |
| 773 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last)); | 783 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last, original_desktop_type)); |
| 774 new_browser = FindOneOtherBrowserForProfile(profile_last, NULL); | 784 new_browser = FindOneOtherBrowserForProfile(profile_last, NULL); |
| 775 ASSERT_TRUE(new_browser); | 785 ASSERT_TRUE(new_browser); |
| 776 tab_strip = new_browser->tab_strip_model(); | 786 tab_strip = new_browser->tab_strip_model(); |
| 777 ASSERT_EQ(1, tab_strip->count()); | 787 ASSERT_EQ(1, tab_strip->count()); |
| 778 EXPECT_EQ(GURL(chrome::kAboutBlankURL), | 788 EXPECT_EQ(GURL(chrome::kAboutBlankURL), |
| 779 tab_strip->GetWebContentsAt(0)->GetURL()); | 789 tab_strip->GetWebContentsAt(0)->GetURL()); |
| 780 | 790 |
| 781 // profile_home2 was not launched since it would've only opened the home page. | 791 // profile_home2 was not launched since it would've only opened the home page. |
| 782 ASSERT_EQ(0u, chrome::GetBrowserCount(profile_home2)); | 792 ASSERT_EQ(0u, chrome::GetBrowserCount(profile_home2, original_desktop_type)); |
| 783 } | 793 } |
| 784 | 794 |
| 785 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { | 795 IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { |
| 786 // After an unclean exit, all profiles will be launched. However, they won't | 796 // After an unclean exit, all profiles will be launched. However, they won't |
| 787 // open any pages automatically. | 797 // open any pages automatically. |
| 788 | 798 |
| 789 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 799 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 790 | 800 |
| 791 // Create 3 profiles. | 801 // Create 3 profiles. |
| 792 base::FilePath dest_path1 = profile_manager->user_data_dir().Append( | 802 base::FilePath dest_path1 = profile_manager->user_data_dir().Append( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 last_opened_profiles, &return_code); | 850 last_opened_profiles, &return_code); |
| 841 | 851 |
| 842 // No profiles are getting restored, since they all display the crash info | 852 // No profiles are getting restored, since they all display the crash info |
| 843 // bar. | 853 // bar. |
| 844 EXPECT_FALSE(SessionRestore::IsRestoring(profile_home)); | 854 EXPECT_FALSE(SessionRestore::IsRestoring(profile_home)); |
| 845 EXPECT_FALSE(SessionRestore::IsRestoring(profile_last)); | 855 EXPECT_FALSE(SessionRestore::IsRestoring(profile_last)); |
| 846 EXPECT_FALSE(SessionRestore::IsRestoring(profile_urls)); | 856 EXPECT_FALSE(SessionRestore::IsRestoring(profile_urls)); |
| 847 | 857 |
| 848 // The profile which normally opens the home page displays the new tab page. | 858 // The profile which normally opens the home page displays the new tab page. |
| 849 Browser* new_browser = NULL; | 859 Browser* new_browser = NULL; |
| 850 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home)); | 860 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home, |
| 861 browser()->host_desktop_type())); |
| 851 new_browser = FindOneOtherBrowserForProfile(profile_home, NULL); | 862 new_browser = FindOneOtherBrowserForProfile(profile_home, NULL); |
| 852 ASSERT_TRUE(new_browser); | 863 ASSERT_TRUE(new_browser); |
| 853 TabStripModel* tab_strip = new_browser->tab_strip_model(); | 864 TabStripModel* tab_strip = new_browser->tab_strip_model(); |
| 854 ASSERT_EQ(1, tab_strip->count()); | 865 ASSERT_EQ(1, tab_strip->count()); |
| 855 content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); | 866 content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); |
| 856 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); | 867 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); |
| 857 EXPECT_EQ(1U, | 868 EXPECT_EQ(1U, |
| 858 InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); | 869 InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); |
| 859 | 870 |
| 860 // The profile which normally opens last open pages displays the new tab page. | 871 // The profile which normally opens last open pages displays the new tab page. |
| 861 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last)); | 872 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last, |
| 873 browser()->host_desktop_type())); |
| 862 new_browser = FindOneOtherBrowserForProfile(profile_last, NULL); | 874 new_browser = FindOneOtherBrowserForProfile(profile_last, NULL); |
| 863 ASSERT_TRUE(new_browser); | 875 ASSERT_TRUE(new_browser); |
| 864 tab_strip = new_browser->tab_strip_model(); | 876 tab_strip = new_browser->tab_strip_model(); |
| 865 ASSERT_EQ(1, tab_strip->count()); | 877 ASSERT_EQ(1, tab_strip->count()); |
| 866 web_contents = tab_strip->GetWebContentsAt(0); | 878 web_contents = tab_strip->GetWebContentsAt(0); |
| 867 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); | 879 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); |
| 868 EXPECT_EQ(1U, | 880 EXPECT_EQ(1U, |
| 869 InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); | 881 InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); |
| 870 | 882 |
| 871 // The profile which normally opens URLs displays the new tab page. | 883 // The profile which normally opens URLs displays the new tab page. |
| 872 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls)); | 884 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls, |
| 885 browser()->host_desktop_type())); |
| 873 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); | 886 new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); |
| 874 ASSERT_TRUE(new_browser); | 887 ASSERT_TRUE(new_browser); |
| 875 tab_strip = new_browser->tab_strip_model(); | 888 tab_strip = new_browser->tab_strip_model(); |
| 876 ASSERT_EQ(1, tab_strip->count()); | 889 ASSERT_EQ(1, tab_strip->count()); |
| 877 web_contents = tab_strip->GetWebContentsAt(0); | 890 web_contents = tab_strip->GetWebContentsAt(0); |
| 878 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); | 891 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), web_contents->GetURL()); |
| 879 EXPECT_EQ(1U, | 892 EXPECT_EQ(1U, |
| 880 InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); | 893 InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); |
| 881 } | 894 } |
| 882 #endif // !OS_CHROMEOS | 895 #endif // !OS_CHROMEOS |
| OLD | NEW |