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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 | 706 |
707 TestingProfile* profile2 = | 707 TestingProfile* profile2 = |
708 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path2)); | 708 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path2)); |
709 ASSERT_TRUE(profile2); | 709 ASSERT_TRUE(profile2); |
710 | 710 |
711 std::vector<Profile*> last_opened_profiles = | 711 std::vector<Profile*> last_opened_profiles = |
712 profile_manager->GetLastOpenedProfiles(); | 712 profile_manager->GetLastOpenedProfiles(); |
713 ASSERT_EQ(0U, last_opened_profiles.size()); | 713 ASSERT_EQ(0U, last_opened_profiles.size()); |
714 | 714 |
715 // Create a browser for profile1. | 715 // Create a browser for profile1. |
716 Browser::CreateParams profile1_params(profile1); | 716 Browser::CreateParams profile1_params(profile1, true); |
717 std::unique_ptr<Browser> browser1a( | 717 std::unique_ptr<Browser> browser1a( |
718 chrome::CreateBrowserWithTestWindowForParams(&profile1_params)); | 718 chrome::CreateBrowserWithTestWindowForParams(&profile1_params)); |
719 | 719 |
720 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 720 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
721 ASSERT_EQ(1U, last_opened_profiles.size()); | 721 ASSERT_EQ(1U, last_opened_profiles.size()); |
722 EXPECT_EQ(profile1, last_opened_profiles[0]); | 722 EXPECT_EQ(profile1, last_opened_profiles[0]); |
723 | 723 |
724 // And for profile2. | 724 // And for profile2. |
725 Browser::CreateParams profile2_params(profile2); | 725 Browser::CreateParams profile2_params(profile2, true); |
726 std::unique_ptr<Browser> browser2( | 726 std::unique_ptr<Browser> browser2( |
727 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); | 727 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); |
728 | 728 |
729 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 729 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
730 ASSERT_EQ(2U, last_opened_profiles.size()); | 730 ASSERT_EQ(2U, last_opened_profiles.size()); |
731 EXPECT_EQ(profile1, last_opened_profiles[0]); | 731 EXPECT_EQ(profile1, last_opened_profiles[0]); |
732 EXPECT_EQ(profile2, last_opened_profiles[1]); | 732 EXPECT_EQ(profile2, last_opened_profiles[1]); |
733 | 733 |
734 // Adding more browsers doesn't change anything. | 734 // Adding more browsers doesn't change anything. |
735 std::unique_ptr<Browser> browser1b( | 735 std::unique_ptr<Browser> browser1b( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 // Successfully create the profiles. | 768 // Successfully create the profiles. |
769 TestingProfile* profile1 = | 769 TestingProfile* profile1 = |
770 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path1)); | 770 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path1)); |
771 ASSERT_TRUE(profile1); | 771 ASSERT_TRUE(profile1); |
772 | 772 |
773 TestingProfile* profile2 = | 773 TestingProfile* profile2 = |
774 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path2)); | 774 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path2)); |
775 ASSERT_TRUE(profile2); | 775 ASSERT_TRUE(profile2); |
776 | 776 |
777 // Create a browser for profile1. | 777 // Create a browser for profile1. |
778 Browser::CreateParams profile1_params(profile1); | 778 Browser::CreateParams profile1_params(profile1, true); |
779 std::unique_ptr<Browser> browser1( | 779 std::unique_ptr<Browser> browser1( |
780 chrome::CreateBrowserWithTestWindowForParams(&profile1_params)); | 780 chrome::CreateBrowserWithTestWindowForParams(&profile1_params)); |
781 | 781 |
782 // And for profile2. | 782 // And for profile2. |
783 Browser::CreateParams profile2_params(profile2); | 783 Browser::CreateParams profile2_params(profile2, true); |
784 std::unique_ptr<Browser> browser2( | 784 std::unique_ptr<Browser> browser2( |
785 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); | 785 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); |
786 | 786 |
787 std::vector<Profile*> last_opened_profiles = | 787 std::vector<Profile*> last_opened_profiles = |
788 profile_manager->GetLastOpenedProfiles(); | 788 profile_manager->GetLastOpenedProfiles(); |
789 ASSERT_EQ(2U, last_opened_profiles.size()); | 789 ASSERT_EQ(2U, last_opened_profiles.size()); |
790 EXPECT_EQ(profile1, last_opened_profiles[0]); | 790 EXPECT_EQ(profile1, last_opened_profiles[0]); |
791 EXPECT_EQ(profile2, last_opened_profiles[1]); | 791 EXPECT_EQ(profile2, last_opened_profiles[1]); |
792 | 792 |
793 // Simulate a shutdown. | 793 // Simulate a shutdown. |
(...skipping 24 matching lines...) Expand all Loading... |
818 // Successfully create the profiles. | 818 // Successfully create the profiles. |
819 TestingProfile* profile1 = | 819 TestingProfile* profile1 = |
820 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path1)); | 820 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path1)); |
821 ASSERT_TRUE(profile1); | 821 ASSERT_TRUE(profile1); |
822 | 822 |
823 std::vector<Profile*> last_opened_profiles = | 823 std::vector<Profile*> last_opened_profiles = |
824 profile_manager->GetLastOpenedProfiles(); | 824 profile_manager->GetLastOpenedProfiles(); |
825 ASSERT_EQ(0U, last_opened_profiles.size()); | 825 ASSERT_EQ(0U, last_opened_profiles.size()); |
826 | 826 |
827 // Create a browser for profile1. | 827 // Create a browser for profile1. |
828 Browser::CreateParams profile1_params(profile1); | 828 Browser::CreateParams profile1_params(profile1, true); |
829 std::unique_ptr<Browser> browser1( | 829 std::unique_ptr<Browser> browser1( |
830 chrome::CreateBrowserWithTestWindowForParams(&profile1_params)); | 830 chrome::CreateBrowserWithTestWindowForParams(&profile1_params)); |
831 | 831 |
832 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 832 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
833 ASSERT_EQ(1U, last_opened_profiles.size()); | 833 ASSERT_EQ(1U, last_opened_profiles.size()); |
834 EXPECT_EQ(profile1, last_opened_profiles[0]); | 834 EXPECT_EQ(profile1, last_opened_profiles[0]); |
835 | 835 |
836 // And for profile2. | 836 // And for profile2. |
837 Browser::CreateParams profile2_params(profile1->GetOffTheRecordProfile()); | 837 Browser::CreateParams profile2_params(profile1->GetOffTheRecordProfile(), |
| 838 true); |
838 std::unique_ptr<Browser> browser2a( | 839 std::unique_ptr<Browser> browser2a( |
839 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); | 840 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); |
840 | 841 |
841 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); | 842 last_opened_profiles = profile_manager->GetLastOpenedProfiles(); |
842 ASSERT_EQ(1U, last_opened_profiles.size()); | 843 ASSERT_EQ(1U, last_opened_profiles.size()); |
843 EXPECT_EQ(profile1, last_opened_profiles[0]); | 844 EXPECT_EQ(profile1, last_opened_profiles[0]); |
844 | 845 |
845 // Adding more browsers doesn't change anything. | 846 // Adding more browsers doesn't change anything. |
846 std::unique_ptr<Browser> browser2b( | 847 std::unique_ptr<Browser> browser2b( |
847 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); | 848 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); |
(...skipping 29 matching lines...) Expand all Loading... |
877 TestingProfile* profile = | 878 TestingProfile* profile = |
878 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path)); | 879 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path)); |
879 ASSERT_TRUE(profile); | 880 ASSERT_TRUE(profile); |
880 profile->GetPrefs()->SetBoolean(prefs::kForceEphemeralProfiles, true); | 881 profile->GetPrefs()->SetBoolean(prefs::kForceEphemeralProfiles, true); |
881 | 882 |
882 // Here the last used profile is still the "Default" profile. | 883 // Here the last used profile is still the "Default" profile. |
883 Profile* last_used_profile = profile_manager->GetLastUsedProfile(); | 884 Profile* last_used_profile = profile_manager->GetLastUsedProfile(); |
884 EXPECT_NE(profile, last_used_profile); | 885 EXPECT_NE(profile, last_used_profile); |
885 | 886 |
886 // Create a browser for the profile. | 887 // Create a browser for the profile. |
887 Browser::CreateParams profile_params(profile); | 888 Browser::CreateParams profile_params(profile, true); |
888 std::unique_ptr<Browser> browser( | 889 std::unique_ptr<Browser> browser( |
889 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); | 890 chrome::CreateBrowserWithTestWindowForParams(&profile_params)); |
890 last_used_profile = profile_manager->GetLastUsedProfile(); | 891 last_used_profile = profile_manager->GetLastUsedProfile(); |
891 EXPECT_NE(profile, last_used_profile); | 892 EXPECT_NE(profile, last_used_profile); |
892 | 893 |
893 // Close the browser. | 894 // Close the browser. |
894 browser.reset(); | 895 browser.reset(); |
895 last_used_profile = profile_manager->GetLastUsedProfile(); | 896 last_used_profile = profile_manager->GetLastUsedProfile(); |
896 EXPECT_NE(profile, last_used_profile); | 897 EXPECT_NE(profile, last_used_profile); |
897 } | 898 } |
(...skipping 21 matching lines...) Expand all Loading... |
919 ASSERT_TRUE(ephemeral_profile1); | 920 ASSERT_TRUE(ephemeral_profile1); |
920 ephemeral_profile1->GetPrefs()->SetBoolean(prefs::kForceEphemeralProfiles, | 921 ephemeral_profile1->GetPrefs()->SetBoolean(prefs::kForceEphemeralProfiles, |
921 true); | 922 true); |
922 | 923 |
923 // Add second ephemeral profile but don't mark it as such yet. | 924 // Add second ephemeral profile but don't mark it as such yet. |
924 TestingProfile* ephemeral_profile2 = | 925 TestingProfile* ephemeral_profile2 = |
925 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path3)); | 926 static_cast<TestingProfile*>(profile_manager->GetProfile(dest_path3)); |
926 ASSERT_TRUE(ephemeral_profile2); | 927 ASSERT_TRUE(ephemeral_profile2); |
927 | 928 |
928 // Create a browser for profile1. | 929 // Create a browser for profile1. |
929 Browser::CreateParams profile1_params(normal_profile); | 930 Browser::CreateParams profile1_params(normal_profile, true); |
930 std::unique_ptr<Browser> browser1( | 931 std::unique_ptr<Browser> browser1( |
931 chrome::CreateBrowserWithTestWindowForParams(&profile1_params)); | 932 chrome::CreateBrowserWithTestWindowForParams(&profile1_params)); |
932 | 933 |
933 // Create browsers for the ephemeral profile. | 934 // Create browsers for the ephemeral profile. |
934 Browser::CreateParams profile2_params(ephemeral_profile1); | 935 Browser::CreateParams profile2_params(ephemeral_profile1, true); |
935 std::unique_ptr<Browser> browser2( | 936 std::unique_ptr<Browser> browser2( |
936 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); | 937 chrome::CreateBrowserWithTestWindowForParams(&profile2_params)); |
937 | 938 |
938 Browser::CreateParams profile3_params(ephemeral_profile2); | 939 Browser::CreateParams profile3_params(ephemeral_profile2, true); |
939 std::unique_ptr<Browser> browser3( | 940 std::unique_ptr<Browser> browser3( |
940 chrome::CreateBrowserWithTestWindowForParams(&profile3_params)); | 941 chrome::CreateBrowserWithTestWindowForParams(&profile3_params)); |
941 | 942 |
942 std::vector<Profile*> last_opened_profiles = | 943 std::vector<Profile*> last_opened_profiles = |
943 profile_manager->GetLastOpenedProfiles(); | 944 profile_manager->GetLastOpenedProfiles(); |
944 ASSERT_EQ(2U, last_opened_profiles.size()); | 945 ASSERT_EQ(2U, last_opened_profiles.size()); |
945 EXPECT_EQ(normal_profile, last_opened_profiles[0]); | 946 EXPECT_EQ(normal_profile, last_opened_profiles[0]); |
946 EXPECT_EQ(ephemeral_profile2, last_opened_profiles[1]); | 947 EXPECT_EQ(ephemeral_profile2, last_opened_profiles[1]); |
947 | 948 |
948 // Mark the second profile ephemeral. | 949 // Mark the second profile ephemeral. |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 dest_path2.BaseName().MaybeAsASCII()); | 1443 dest_path2.BaseName().MaybeAsASCII()); |
1443 profile_manager->ScheduleProfileForDeletion(dest_path2, | 1444 profile_manager->ScheduleProfileForDeletion(dest_path2, |
1444 ProfileManager::CreateCallback()); | 1445 ProfileManager::CreateCallback()); |
1445 // Spin the message loop so that all the callbacks can finish running. | 1446 // Spin the message loop so that all the callbacks can finish running. |
1446 base::RunLoop().RunUntilIdle(); | 1447 base::RunLoop().RunUntilIdle(); |
1447 | 1448 |
1448 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); | 1449 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); |
1449 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); | 1450 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); |
1450 } | 1451 } |
1451 #endif // !defined(OS_MACOSX) | 1452 #endif // !defined(OS_MACOSX) |
OLD | NEW |