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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 SessionStartupPref pref2(SessionStartupPref::URLS); | 652 SessionStartupPref pref2(SessionStartupPref::URLS); |
653 pref2.urls = urls2; | 653 pref2.urls = urls2; |
654 SessionStartupPref::SetStartupPref(other_profile, pref2); | 654 SessionStartupPref::SetStartupPref(other_profile, pref2); |
655 | 655 |
656 // Close the browser. | 656 // Close the browser. |
657 browser()->window()->Close(); | 657 browser()->window()->Close(); |
658 | 658 |
659 // Do a simple non-process-startup browser launch. | 659 // Do a simple non-process-startup browser launch. |
660 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); | 660 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
661 | 661 |
662 int return_code; | |
663 StartupBrowserCreator browser_creator; | 662 StartupBrowserCreator browser_creator; |
664 std::vector<Profile*> last_opened_profiles; | 663 std::vector<Profile*> last_opened_profiles; |
665 last_opened_profiles.push_back(default_profile); | 664 last_opened_profiles.push_back(default_profile); |
666 last_opened_profiles.push_back(other_profile); | 665 last_opened_profiles.push_back(other_profile); |
667 browser_creator.Start(dummy, profile_manager->user_data_dir(), | 666 browser_creator.Start(dummy, profile_manager->user_data_dir(), |
668 default_profile, last_opened_profiles, &return_code); | 667 default_profile, last_opened_profiles); |
669 | 668 |
670 // urls1 were opened in a browser for default_profile, and urls2 were opened | 669 // urls1 were opened in a browser for default_profile, and urls2 were opened |
671 // in a browser for other_profile. | 670 // in a browser for other_profile. |
672 Browser* new_browser = NULL; | 671 Browser* new_browser = NULL; |
673 // |browser()| is still around at this point, even though we've closed its | 672 // |browser()| is still around at this point, even though we've closed its |
674 // window. Thus the browser count for default_profile is 2. | 673 // window. Thus the browser count for default_profile is 2. |
675 ASSERT_EQ(2u, chrome::GetBrowserCount(default_profile, | 674 ASSERT_EQ(2u, chrome::GetBrowserCount(default_profile, |
676 browser()->host_desktop_type())); | 675 browser()->host_desktop_type())); |
677 new_browser = FindOneOtherBrowserForProfile(default_profile, browser()); | 676 new_browser = FindOneOtherBrowserForProfile(default_profile, browser()); |
678 ASSERT_TRUE(new_browser); | 677 ASSERT_TRUE(new_browser); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 Profile* profile1 = profile_manager->GetProfile( | 768 Profile* profile1 = profile_manager->GetProfile( |
770 dest_path.Append(FILE_PATH_LITERAL("New Profile 1"))); | 769 dest_path.Append(FILE_PATH_LITERAL("New Profile 1"))); |
771 ASSERT_TRUE(profile1); | 770 ASSERT_TRUE(profile1); |
772 | 771 |
773 Profile* profile2 = profile_manager->GetProfile( | 772 Profile* profile2 = profile_manager->GetProfile( |
774 dest_path.Append(FILE_PATH_LITERAL("New Profile 2"))); | 773 dest_path.Append(FILE_PATH_LITERAL("New Profile 2"))); |
775 ASSERT_TRUE(profile2); | 774 ASSERT_TRUE(profile2); |
776 | 775 |
777 // Simulate a launch after a browser update. | 776 // Simulate a launch after a browser update. |
778 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); | 777 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
779 int return_code; | |
780 StartupBrowserCreator browser_creator; | 778 StartupBrowserCreator browser_creator; |
781 std::vector<Profile*> last_opened_profiles; | 779 std::vector<Profile*> last_opened_profiles; |
782 last_opened_profiles.push_back(profile1); | 780 last_opened_profiles.push_back(profile1); |
783 last_opened_profiles.push_back(profile2); | 781 last_opened_profiles.push_back(profile2); |
784 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile1, | 782 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile1, |
785 last_opened_profiles, &return_code); | 783 last_opened_profiles); |
786 | 784 |
787 while (SessionRestore::IsRestoring(profile1) || | 785 while (SessionRestore::IsRestoring(profile1) || |
788 SessionRestore::IsRestoring(profile2)) | 786 SessionRestore::IsRestoring(profile2)) |
789 base::MessageLoop::current()->RunUntilIdle(); | 787 base::MessageLoop::current()->RunUntilIdle(); |
790 | 788 |
791 // The startup URLs are ignored, and instead the last open sessions are | 789 // The startup URLs are ignored, and instead the last open sessions are |
792 // restored. | 790 // restored. |
793 EXPECT_TRUE(profile1->restored_last_session()); | 791 EXPECT_TRUE(profile1->restored_last_session()); |
794 EXPECT_TRUE(profile2->restored_last_session()); | 792 EXPECT_TRUE(profile2->restored_last_session()); |
795 | 793 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 browser_last->window()->Close(); | 871 browser_last->window()->Close(); |
874 | 872 |
875 // Close the main browser. | 873 // Close the main browser. |
876 chrome::HostDesktopType original_desktop_type = | 874 chrome::HostDesktopType original_desktop_type = |
877 browser()->host_desktop_type(); | 875 browser()->host_desktop_type(); |
878 browser()->window()->Close(); | 876 browser()->window()->Close(); |
879 | 877 |
880 // Do a simple non-process-startup browser launch. | 878 // Do a simple non-process-startup browser launch. |
881 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); | 879 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
882 | 880 |
883 int return_code; | |
884 StartupBrowserCreator browser_creator; | 881 StartupBrowserCreator browser_creator; |
885 std::vector<Profile*> last_opened_profiles; | 882 std::vector<Profile*> last_opened_profiles; |
886 last_opened_profiles.push_back(profile_home1); | 883 last_opened_profiles.push_back(profile_home1); |
887 last_opened_profiles.push_back(profile_home2); | 884 last_opened_profiles.push_back(profile_home2); |
888 last_opened_profiles.push_back(profile_last); | 885 last_opened_profiles.push_back(profile_last); |
889 last_opened_profiles.push_back(profile_urls); | 886 last_opened_profiles.push_back(profile_urls); |
890 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile_home1, | 887 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile_home1, |
891 last_opened_profiles, &return_code); | 888 last_opened_profiles); |
892 | 889 |
893 while (SessionRestore::IsRestoring(default_profile) || | 890 while (SessionRestore::IsRestoring(default_profile) || |
894 SessionRestore::IsRestoring(profile_home1) || | 891 SessionRestore::IsRestoring(profile_home1) || |
895 SessionRestore::IsRestoring(profile_home2) || | 892 SessionRestore::IsRestoring(profile_home2) || |
896 SessionRestore::IsRestoring(profile_last) || | 893 SessionRestore::IsRestoring(profile_last) || |
897 SessionRestore::IsRestoring(profile_urls)) | 894 SessionRestore::IsRestoring(profile_urls)) |
898 base::MessageLoop::current()->RunUntilIdle(); | 895 base::MessageLoop::current()->RunUntilIdle(); |
899 | 896 |
900 Browser* new_browser = NULL; | 897 Browser* new_browser = NULL; |
901 // The last open profile (the profile_home1 in this case) will always be | 898 // The last open profile (the profile_home1 in this case) will always be |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 // is tested by function EnsureRestoreUIWasShown. | 987 // is tested by function EnsureRestoreUIWasShown. |
991 // | 988 // |
992 // Under a Google Chrome build, it is not tested because a task is posted to | 989 // Under a Google Chrome build, it is not tested because a task is posted to |
993 // the file thread before the bubble is shown. It is difficult to make sure | 990 // the file thread before the bubble is shown. It is difficult to make sure |
994 // that the histogram check runs after all threads have finished their tasks. | 991 // that the histogram check runs after all threads have finished their tasks. |
995 base::HistogramTester histogram_tester; | 992 base::HistogramTester histogram_tester; |
996 #endif // !defined(OS_MACOSX) && !defined(GOOGLE_CHROME_BUILD) | 993 #endif // !defined(OS_MACOSX) && !defined(GOOGLE_CHROME_BUILD) |
997 | 994 |
998 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); | 995 base::CommandLine dummy(base::CommandLine::NO_PROGRAM); |
999 dummy.AppendSwitchASCII(switches::kTestType, "browser"); | 996 dummy.AppendSwitchASCII(switches::kTestType, "browser"); |
1000 int return_code; | |
1001 StartupBrowserCreator browser_creator; | 997 StartupBrowserCreator browser_creator; |
1002 std::vector<Profile*> last_opened_profiles; | 998 std::vector<Profile*> last_opened_profiles; |
1003 last_opened_profiles.push_back(profile_home); | 999 last_opened_profiles.push_back(profile_home); |
1004 last_opened_profiles.push_back(profile_last); | 1000 last_opened_profiles.push_back(profile_last); |
1005 last_opened_profiles.push_back(profile_urls); | 1001 last_opened_profiles.push_back(profile_urls); |
1006 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile_home, | 1002 browser_creator.Start(dummy, profile_manager->user_data_dir(), profile_home, |
1007 last_opened_profiles, &return_code); | 1003 last_opened_profiles); |
1008 | 1004 |
1009 // No profiles are getting restored, since they all display the crash info | 1005 // No profiles are getting restored, since they all display the crash info |
1010 // bar. | 1006 // bar. |
1011 EXPECT_FALSE(SessionRestore::IsRestoring(profile_home)); | 1007 EXPECT_FALSE(SessionRestore::IsRestoring(profile_home)); |
1012 EXPECT_FALSE(SessionRestore::IsRestoring(profile_last)); | 1008 EXPECT_FALSE(SessionRestore::IsRestoring(profile_last)); |
1013 EXPECT_FALSE(SessionRestore::IsRestoring(profile_urls)); | 1009 EXPECT_FALSE(SessionRestore::IsRestoring(profile_urls)); |
1014 | 1010 |
1015 // The profile which normally opens the home page displays the new tab page. | 1011 // The profile which normally opens the home page displays the new tab page. |
1016 Browser* new_browser = NULL; | 1012 Browser* new_browser = NULL; |
1017 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home, | 1013 ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home, |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1492 ASSERT_EQ(1, tab_strip->count()); | 1488 ASSERT_EQ(1, tab_strip->count()); |
1493 EXPECT_EQ("title1.html", | 1489 EXPECT_EQ("title1.html", |
1494 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); | 1490 tab_strip->GetWebContentsAt(0)->GetURL().ExtractFileName()); |
1495 } | 1491 } |
1496 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 1492 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
1497 | 1493 |
1498 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || | 1494 #endif // !defined(OS_LINUX) || !defined(GOOGLE_CHROME_BUILD) || |
1499 // defined(ENABLE_CONFIGURATION_POLICY) | 1495 // defined(ENABLE_CONFIGURATION_POLICY) |
1500 | 1496 |
1501 #endif // !defined(OS_CHROMEOS) | 1497 #endif // !defined(OS_CHROMEOS) |
OLD | NEW |