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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 | 58 |
| 59 using base::ASCIIToUTF16; | 59 using base::ASCIIToUTF16; |
| 60 using content::BrowserThread; | 60 using content::BrowserThread; |
| 61 | 61 |
| 62 namespace { | 62 namespace { |
| 63 | 63 |
| 64 // This global variable is used to check that value returned to different | 64 // This global variable is used to check that value returned to different |
| 65 // observers is the same. | 65 // observers is the same. |
| 66 Profile* g_created_profile; | 66 Profile* g_created_profile; |
| 67 | 67 |
| 68 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | |
| 69 void FailOnProfileCreation(Profile* profile, Profile::CreateStatus status) { | |
| 70 ADD_FAILURE(); | |
| 71 } | |
| 72 #endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | |
| 73 | |
| 68 class UnittestProfileManager : public ::ProfileManagerWithoutInit { | 74 class UnittestProfileManager : public ::ProfileManagerWithoutInit { |
| 69 public: | 75 public: |
| 70 explicit UnittestProfileManager(const base::FilePath& user_data_dir) | 76 explicit UnittestProfileManager(const base::FilePath& user_data_dir) |
| 71 : ::ProfileManagerWithoutInit(user_data_dir) {} | 77 : ::ProfileManagerWithoutInit(user_data_dir) {} |
| 72 | 78 |
| 73 protected: | 79 protected: |
| 74 Profile* CreateProfileHelper(const base::FilePath& file_path) override { | 80 Profile* CreateProfileHelper(const base::FilePath& file_path) override { |
| 75 if (!base::PathExists(file_path)) { | 81 if (!base::PathExists(file_path)) { |
| 76 if (!base::CreateDirectory(file_path)) | 82 if (!base::CreateDirectory(file_path)) |
| 77 return NULL; | 83 return NULL; |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 895 base::RunLoop().RunUntilIdle(); | 901 base::RunLoop().RunUntilIdle(); |
| 896 | 902 |
| 897 EXPECT_EQ(2u, profile_manager->GetLoadedProfiles().size()); | 903 EXPECT_EQ(2u, profile_manager->GetLoadedProfiles().size()); |
| 898 EXPECT_EQ(2u, profile_manager->GetProfileInfoCache().GetNumberOfProfiles()); | 904 EXPECT_EQ(2u, profile_manager->GetProfileInfoCache().GetNumberOfProfiles()); |
| 899 | 905 |
| 900 // Set the active profile. | 906 // Set the active profile. |
| 901 PrefService* local_state = g_browser_process->local_state(); | 907 PrefService* local_state = g_browser_process->local_state(); |
| 902 local_state->SetString(prefs::kProfileLastUsed, profile_name1); | 908 local_state->SetString(prefs::kProfileLastUsed, profile_name1); |
| 903 | 909 |
| 904 // Delete the active profile. | 910 // Delete the active profile. |
| 905 profile_manager->ScheduleProfileForDeletion(dest_path1, | 911 profile_manager->ScheduleProfileForDeletion( |
| 906 ProfileManager::CreateCallback()); | 912 dest_path1, false /* suppress_profile_creation */, |
| 913 ProfileManager::CreateCallback()); | |
| 907 // Spin the message loop so that all the callbacks can finish running. | 914 // Spin the message loop so that all the callbacks can finish running. |
| 908 base::RunLoop().RunUntilIdle(); | 915 base::RunLoop().RunUntilIdle(); |
| 909 | 916 |
| 910 EXPECT_EQ(dest_path2, profile_manager->GetLastUsedProfile()->GetPath()); | 917 EXPECT_EQ(dest_path2, profile_manager->GetLastUsedProfile()->GetPath()); |
| 911 EXPECT_EQ(profile_name2, local_state->GetString(prefs::kProfileLastUsed)); | 918 EXPECT_EQ(profile_name2, local_state->GetString(prefs::kProfileLastUsed)); |
| 912 } | 919 } |
| 913 | 920 |
| 914 TEST_F(ProfileManagerTest, LastProfileDeleted) { | 921 TEST_F(ProfileManagerTest, LastProfileDeleted) { |
| 915 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 922 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 916 ASSERT_TRUE(profile_manager); | 923 ASSERT_TRUE(profile_manager); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 927 base::RunLoop().RunUntilIdle(); | 934 base::RunLoop().RunUntilIdle(); |
| 928 | 935 |
| 929 EXPECT_EQ(1u, profile_manager->GetLoadedProfiles().size()); | 936 EXPECT_EQ(1u, profile_manager->GetLoadedProfiles().size()); |
| 930 EXPECT_EQ(1u, profile_manager->GetProfileInfoCache().GetNumberOfProfiles()); | 937 EXPECT_EQ(1u, profile_manager->GetProfileInfoCache().GetNumberOfProfiles()); |
| 931 | 938 |
| 932 // Set it as the active profile. | 939 // Set it as the active profile. |
| 933 PrefService* local_state = g_browser_process->local_state(); | 940 PrefService* local_state = g_browser_process->local_state(); |
| 934 local_state->SetString(prefs::kProfileLastUsed, profile_name1); | 941 local_state->SetString(prefs::kProfileLastUsed, profile_name1); |
| 935 | 942 |
| 936 // Delete the active profile. | 943 // Delete the active profile. |
| 937 profile_manager->ScheduleProfileForDeletion(dest_path1, | 944 profile_manager->ScheduleProfileForDeletion( |
| 938 ProfileManager::CreateCallback()); | 945 dest_path1, false /* suppress_profile_creation */, |
| 946 ProfileManager::CreateCallback()); | |
| 939 // Spin the message loop so that all the callbacks can finish running. | 947 // Spin the message loop so that all the callbacks can finish running. |
| 940 base::RunLoop().RunUntilIdle(); | 948 base::RunLoop().RunUntilIdle(); |
| 941 | 949 |
| 942 // A new profile should have been created | 950 // A new profile should have been created |
| 943 const std::string profile_name2 = "Profile 1"; | 951 const std::string profile_name2 = "Profile 1"; |
| 944 base::FilePath dest_path2 = temp_dir_.path().AppendASCII(profile_name2); | 952 base::FilePath dest_path2 = temp_dir_.path().AppendASCII(profile_name2); |
| 945 | 953 |
| 946 EXPECT_EQ(dest_path2, profile_manager->GetLastUsedProfile()->GetPath()); | 954 EXPECT_EQ(dest_path2, profile_manager->GetLastUsedProfile()->GetPath()); |
| 947 EXPECT_EQ(profile_name2, local_state->GetString(prefs::kProfileLastUsed)); | 955 EXPECT_EQ(profile_name2, local_state->GetString(prefs::kProfileLastUsed)); |
| 948 EXPECT_EQ(dest_path2, | 956 EXPECT_EQ(dest_path2, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 981 | 989 |
| 982 // The Guest profile does not get added to the ProfileInfoCache. | 990 // The Guest profile does not get added to the ProfileInfoCache. |
| 983 EXPECT_EQ(2u, profile_manager->GetLoadedProfiles().size()); | 991 EXPECT_EQ(2u, profile_manager->GetLoadedProfiles().size()); |
| 984 EXPECT_EQ(1u, profile_manager->GetProfileInfoCache().GetNumberOfProfiles()); | 992 EXPECT_EQ(1u, profile_manager->GetProfileInfoCache().GetNumberOfProfiles()); |
| 985 | 993 |
| 986 // Set the Guest profile as the active profile. | 994 // Set the Guest profile as the active profile. |
| 987 PrefService* local_state = g_browser_process->local_state(); | 995 PrefService* local_state = g_browser_process->local_state(); |
| 988 local_state->SetString(prefs::kProfileLastUsed, guest_profile_name); | 996 local_state->SetString(prefs::kProfileLastUsed, guest_profile_name); |
| 989 | 997 |
| 990 // Delete the other profile. | 998 // Delete the other profile. |
| 991 profile_manager->ScheduleProfileForDeletion(dest_path1, | 999 profile_manager->ScheduleProfileForDeletion( |
| 992 ProfileManager::CreateCallback()); | 1000 dest_path1, false /* suppress_profile_creation */, |
| 1001 ProfileManager::CreateCallback()); | |
| 993 // Spin the message loop so that all the callbacks can finish running. | 1002 // Spin the message loop so that all the callbacks can finish running. |
| 994 base::RunLoop().RunUntilIdle(); | 1003 base::RunLoop().RunUntilIdle(); |
| 995 | 1004 |
| 996 // A new profile should have been created. | 1005 // A new profile should have been created. |
| 997 const std::string profile_name2 = "Profile 1"; | 1006 const std::string profile_name2 = "Profile 1"; |
| 998 base::FilePath dest_path2 = temp_dir_.path().AppendASCII(profile_name2); | 1007 base::FilePath dest_path2 = temp_dir_.path().AppendASCII(profile_name2); |
| 999 | 1008 |
| 1000 EXPECT_EQ(3u, profile_manager->GetLoadedProfiles().size()); | 1009 EXPECT_EQ(3u, profile_manager->GetLoadedProfiles().size()); |
| 1001 EXPECT_EQ(1u, profile_manager->GetProfileInfoCache().GetNumberOfProfiles()); | 1010 ASSERT_EQ(1u, profile_manager->GetProfileInfoCache().GetNumberOfProfiles()); |
| 1002 EXPECT_EQ(dest_path2, | 1011 EXPECT_EQ(dest_path2, |
| 1003 profile_manager->GetProfileInfoCache().GetPathOfProfileAtIndex(0)); | 1012 profile_manager->GetProfileInfoCache().GetPathOfProfileAtIndex(0)); |
| 1004 } | 1013 } |
| 1005 | 1014 |
| 1015 TEST_F(ProfileManagerTest, DeleteStaleEphemeralProfile) { | |
| 1016 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 1017 ASSERT_TRUE(profile_manager); | |
| 1018 | |
| 1019 // Create a profile, don't load it yet. | |
| 1020 const std::string profile_name1 = "New Profile 1"; | |
| 1021 base::FilePath dest_path1 = temp_dir_.path().AppendASCII(profile_name1); | |
| 1022 | |
| 1023 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | |
| 1024 cache.AddProfileToCache(dest_path1, ASCIIToUTF16(profile_name1), | |
| 1025 ASCIIToUTF16(profile_name1), 0, std::string()); | |
| 1026 EXPECT_EQ(1u, cache.GetNumberOfProfiles()); | |
| 1027 EXPECT_EQ(0u, profile_manager->GetLoadedProfiles().size()); | |
| 1028 | |
| 1029 // Set it as the active profile. | |
| 1030 PrefService* local_state = g_browser_process->local_state(); | |
| 1031 local_state->SetString(prefs::kProfileLastUsed, profile_name1); | |
| 1032 | |
| 1033 // Delete the active profile. | |
| 1034 profile_manager->ScheduleProfileForDeletion( | |
| 1035 dest_path1, true /* suppress_profile_creation */, | |
| 1036 base::Bind(&FailOnProfileCreation)); | |
| 1037 // Spin the message loop so that all the callbacks can finish running. | |
| 1038 base::RunLoop().RunUntilIdle(); | |
| 1039 | |
| 1040 // A new profile should have been set as the last used profile, but not loaded | |
| 1041 // yet. | |
| 1042 const std::string profile_name2 = "Profile 1"; | |
|
Mike Lerman
2015/05/05 13:44:45
nit: variable is profile_name2, but the name is Pr
Bernhard Bauer
2015/05/05 14:33:22
Yes... except ProfileManager internally increases
| |
| 1043 base::FilePath dest_path2 = temp_dir_.path().AppendASCII(profile_name2); | |
| 1044 | |
| 1045 EXPECT_EQ(0u, profile_manager->GetLoadedProfiles().size()); | |
| 1046 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); | |
| 1047 EXPECT_EQ(profile_name2, local_state->GetString(prefs::kProfileLastUsed)); | |
| 1048 } | |
| 1049 | |
| 1006 TEST_F(ProfileManagerTest, ProfileDisplayNameResetsDefaultName) { | 1050 TEST_F(ProfileManagerTest, ProfileDisplayNameResetsDefaultName) { |
| 1007 if (!profiles::IsMultipleProfilesEnabled()) | 1051 if (!profiles::IsMultipleProfilesEnabled()) |
| 1008 return; | 1052 return; |
| 1009 | 1053 |
| 1010 // The command line is reset at the end of every test by the test suite. | 1054 // The command line is reset at the end of every test by the test suite. |
| 1011 switches::EnableNewAvatarMenuForTesting( | 1055 switches::EnableNewAvatarMenuForTesting( |
| 1012 base::CommandLine::ForCurrentProcess()); | 1056 base::CommandLine::ForCurrentProcess()); |
| 1013 | 1057 |
| 1014 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1058 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1015 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1059 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1027 // Multiple profiles means displaying the actual profile names. | 1071 // Multiple profiles means displaying the actual profile names. |
| 1028 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); | 1072 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); |
| 1029 Profile* profile2 = AddProfileToCache(profile_manager, | 1073 Profile* profile2 = AddProfileToCache(profile_manager, |
| 1030 "path_2", profile_name2); | 1074 "path_2", profile_name2); |
| 1031 EXPECT_EQ(profile_name1, | 1075 EXPECT_EQ(profile_name1, |
| 1032 profiles::GetAvatarNameForProfile(profile1->GetPath())); | 1076 profiles::GetAvatarNameForProfile(profile1->GetPath())); |
| 1033 EXPECT_EQ(profile_name2, | 1077 EXPECT_EQ(profile_name2, |
| 1034 profiles::GetAvatarNameForProfile(profile2->GetPath())); | 1078 profiles::GetAvatarNameForProfile(profile2->GetPath())); |
| 1035 | 1079 |
| 1036 // Deleting a profile means returning to the default name. | 1080 // Deleting a profile means returning to the default name. |
| 1037 profile_manager->ScheduleProfileForDeletion(profile2->GetPath(), | 1081 profile_manager->ScheduleProfileForDeletion( |
| 1038 ProfileManager::CreateCallback()); | 1082 profile2->GetPath(), false /* suppress_profile_creation */, |
| 1083 ProfileManager::CreateCallback()); | |
| 1039 // Spin the message loop so that all the callbacks can finish running. | 1084 // Spin the message loop so that all the callbacks can finish running. |
| 1040 base::RunLoop().RunUntilIdle(); | 1085 base::RunLoop().RunUntilIdle(); |
| 1041 EXPECT_EQ(default_profile_name, | 1086 EXPECT_EQ(default_profile_name, |
| 1042 profiles::GetAvatarNameForProfile(profile1->GetPath())); | 1087 profiles::GetAvatarNameForProfile(profile1->GetPath())); |
| 1043 } | 1088 } |
| 1044 | 1089 |
| 1045 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesCustomName) { | 1090 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesCustomName) { |
| 1046 if (!profiles::IsMultipleProfilesEnabled()) | 1091 if (!profiles::IsMultipleProfilesEnabled()) |
| 1047 return; | 1092 return; |
| 1048 | 1093 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1074 // Multiple profiles means displaying the actual profile names. | 1119 // Multiple profiles means displaying the actual profile names. |
| 1075 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); | 1120 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); |
| 1076 Profile* profile2 = AddProfileToCache(profile_manager, | 1121 Profile* profile2 = AddProfileToCache(profile_manager, |
| 1077 "path_2", profile_name2); | 1122 "path_2", profile_name2); |
| 1078 EXPECT_EQ(custom_profile_name, | 1123 EXPECT_EQ(custom_profile_name, |
| 1079 profiles::GetAvatarNameForProfile(profile1->GetPath())); | 1124 profiles::GetAvatarNameForProfile(profile1->GetPath())); |
| 1080 EXPECT_EQ(profile_name2, | 1125 EXPECT_EQ(profile_name2, |
| 1081 profiles::GetAvatarNameForProfile(profile2->GetPath())); | 1126 profiles::GetAvatarNameForProfile(profile2->GetPath())); |
| 1082 | 1127 |
| 1083 // Deleting a profile means returning to the original, custom name. | 1128 // Deleting a profile means returning to the original, custom name. |
| 1084 profile_manager->ScheduleProfileForDeletion(profile2->GetPath(), | 1129 profile_manager->ScheduleProfileForDeletion( |
| 1085 ProfileManager::CreateCallback()); | 1130 profile2->GetPath(), false /* suppress_profile_creation */, |
| 1131 ProfileManager::CreateCallback()); | |
| 1086 // Spin the message loop so that all the callbacks can finish running. | 1132 // Spin the message loop so that all the callbacks can finish running. |
| 1087 base::RunLoop().RunUntilIdle(); | 1133 base::RunLoop().RunUntilIdle(); |
| 1088 EXPECT_EQ(custom_profile_name, | 1134 EXPECT_EQ(custom_profile_name, |
| 1089 profiles::GetAvatarNameForProfile(profile1->GetPath())); | 1135 profiles::GetAvatarNameForProfile(profile1->GetPath())); |
| 1090 } | 1136 } |
| 1091 | 1137 |
| 1092 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesSignedInName) { | 1138 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesSignedInName) { |
| 1093 if (!profiles::IsMultipleProfilesEnabled()) | 1139 if (!profiles::IsMultipleProfilesEnabled()) |
| 1094 return; | 1140 return; |
| 1095 | 1141 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1129 // Multiple profiles means displaying the actual profile names. | 1175 // Multiple profiles means displaying the actual profile names. |
| 1130 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); | 1176 const base::string16 profile_name2 = cache.ChooseNameForNewProfile(1); |
| 1131 Profile* profile2 = AddProfileToCache(profile_manager, | 1177 Profile* profile2 = AddProfileToCache(profile_manager, |
| 1132 "path_2", profile_name2); | 1178 "path_2", profile_name2); |
| 1133 EXPECT_EQ(gaia_given_name, | 1179 EXPECT_EQ(gaia_given_name, |
| 1134 profiles::GetAvatarNameForProfile(profile1->GetPath())); | 1180 profiles::GetAvatarNameForProfile(profile1->GetPath())); |
| 1135 EXPECT_EQ(profile_name2, | 1181 EXPECT_EQ(profile_name2, |
| 1136 profiles::GetAvatarNameForProfile(profile2->GetPath())); | 1182 profiles::GetAvatarNameForProfile(profile2->GetPath())); |
| 1137 | 1183 |
| 1138 // Deleting a profile means returning to the original, actual profile name. | 1184 // Deleting a profile means returning to the original, actual profile name. |
| 1139 profile_manager->ScheduleProfileForDeletion(profile2->GetPath(), | 1185 profile_manager->ScheduleProfileForDeletion( |
| 1140 ProfileManager::CreateCallback()); | 1186 profile2->GetPath(), false /* suppress_profile_creation */, |
| 1187 ProfileManager::CreateCallback()); | |
| 1141 // Spin the message loop so that all the callbacks can finish running. | 1188 // Spin the message loop so that all the callbacks can finish running. |
| 1142 base::RunLoop().RunUntilIdle(); | 1189 base::RunLoop().RunUntilIdle(); |
| 1143 EXPECT_EQ(gaia_given_name, | 1190 EXPECT_EQ(gaia_given_name, |
| 1144 profiles::GetAvatarNameForProfile(profile1->GetPath())); | 1191 profiles::GetAvatarNameForProfile(profile1->GetPath())); |
| 1145 } | 1192 } |
| 1146 | 1193 |
| 1147 TEST_F(ProfileManagerTest, ProfileDisplayNameIsEmailIfDefaultName) { | 1194 TEST_F(ProfileManagerTest, ProfileDisplayNameIsEmailIfDefaultName) { |
| 1148 if (!profiles::IsMultipleProfilesEnabled()) | 1195 if (!profiles::IsMultipleProfilesEnabled()) |
| 1149 return; | 1196 return; |
| 1150 | 1197 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1234 EXPECT_EQ(1u, profile_manager->GetLoadedProfiles().size()); | 1281 EXPECT_EQ(1u, profile_manager->GetLoadedProfiles().size()); |
| 1235 EXPECT_EQ(2u, cache.GetNumberOfProfiles()); | 1282 EXPECT_EQ(2u, cache.GetNumberOfProfiles()); |
| 1236 | 1283 |
| 1237 // Set the active profile. | 1284 // Set the active profile. |
| 1238 PrefService* local_state = g_browser_process->local_state(); | 1285 PrefService* local_state = g_browser_process->local_state(); |
| 1239 local_state->SetString(prefs::kProfileLastUsed, | 1286 local_state->SetString(prefs::kProfileLastUsed, |
| 1240 dest_path1.BaseName().MaybeAsASCII()); | 1287 dest_path1.BaseName().MaybeAsASCII()); |
| 1241 | 1288 |
| 1242 // Delete the active profile. This should switch and load the unloaded | 1289 // Delete the active profile. This should switch and load the unloaded |
| 1243 // profile. | 1290 // profile. |
| 1244 profile_manager->ScheduleProfileForDeletion(dest_path1, | 1291 profile_manager->ScheduleProfileForDeletion( |
| 1245 ProfileManager::CreateCallback()); | 1292 dest_path1, false /* suppress_profile_creation */, |
| 1293 ProfileManager::CreateCallback()); | |
| 1246 | 1294 |
| 1247 // Spin the message loop so that all the callbacks can finish running. | 1295 // Spin the message loop so that all the callbacks can finish running. |
| 1248 base::RunLoop().RunUntilIdle(); | 1296 base::RunLoop().RunUntilIdle(); |
| 1249 | 1297 |
| 1250 EXPECT_EQ(dest_path2, profile_manager->GetLastUsedProfile()->GetPath()); | 1298 EXPECT_EQ(dest_path2, profile_manager->GetLastUsedProfile()->GetPath()); |
| 1251 EXPECT_EQ(profile_name2, local_state->GetString(prefs::kProfileLastUsed)); | 1299 EXPECT_EQ(profile_name2, local_state->GetString(prefs::kProfileLastUsed)); |
| 1252 } | 1300 } |
| 1253 | 1301 |
| 1254 // This tests the recursive call in ProfileManager::OnNewActiveProfileLoaded | 1302 // This tests the recursive call in ProfileManager::OnNewActiveProfileLoaded |
| 1255 // by simulating a scenario in which the profile that is being loaded as | 1303 // by simulating a scenario in which the profile that is being loaded as |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1292 local_state->SetString(prefs::kProfileLastUsed, | 1340 local_state->SetString(prefs::kProfileLastUsed, |
| 1293 dest_path1.BaseName().MaybeAsASCII()); | 1341 dest_path1.BaseName().MaybeAsASCII()); |
| 1294 | 1342 |
| 1295 // Delete the active profile, Profile1. | 1343 // Delete the active profile, Profile1. |
| 1296 // This will post a CreateProfileAsync message, that tries to load Profile2, | 1344 // This will post a CreateProfileAsync message, that tries to load Profile2, |
| 1297 // which checks that the profile is not being deleted, and then calls back | 1345 // which checks that the profile is not being deleted, and then calls back |
| 1298 // FinishDeletingProfile for Profile1. | 1346 // FinishDeletingProfile for Profile1. |
| 1299 // Try to break this flow by setting the active profile to Profile2 in the | 1347 // Try to break this flow by setting the active profile to Profile2 in the |
| 1300 // middle (so after the first posted message), and trying to delete Profile2, | 1348 // middle (so after the first posted message), and trying to delete Profile2, |
| 1301 // so that the ProfileManager has to look for a different profile to load. | 1349 // so that the ProfileManager has to look for a different profile to load. |
| 1302 profile_manager->ScheduleProfileForDeletion(dest_path1, | 1350 profile_manager->ScheduleProfileForDeletion( |
| 1303 ProfileManager::CreateCallback()); | 1351 dest_path1, false /* suppress_profile_creation */, |
| 1352 ProfileManager::CreateCallback()); | |
| 1304 local_state->SetString(prefs::kProfileLastUsed, | 1353 local_state->SetString(prefs::kProfileLastUsed, |
| 1305 dest_path2.BaseName().MaybeAsASCII()); | 1354 dest_path2.BaseName().MaybeAsASCII()); |
| 1306 profile_manager->ScheduleProfileForDeletion(dest_path2, | 1355 profile_manager->ScheduleProfileForDeletion( |
| 1307 ProfileManager::CreateCallback()); | 1356 dest_path2, false /* suppress_profile_creation */, |
| 1357 ProfileManager::CreateCallback()); | |
| 1308 // Spin the message loop so that all the callbacks can finish running. | 1358 // Spin the message loop so that all the callbacks can finish running. |
| 1309 base::RunLoop().RunUntilIdle(); | 1359 base::RunLoop().RunUntilIdle(); |
| 1310 | 1360 |
| 1311 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); | 1361 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); |
| 1312 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); | 1362 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); |
| 1313 } | 1363 } |
| 1314 #endif // !defined(OS_MACOSX) | 1364 #endif // !defined(OS_MACOSX) |
| OLD | NEW |