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 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 EXPECT_EQ(3u, profile_manager->GetLoadedProfiles().size()); | 1047 EXPECT_EQ(3u, profile_manager->GetLoadedProfiles().size()); |
1048 EXPECT_EQ(1u, profile_manager->GetProfileInfoCache().GetNumberOfProfiles()); | 1048 EXPECT_EQ(1u, profile_manager->GetProfileInfoCache().GetNumberOfProfiles()); |
1049 EXPECT_EQ(dest_path2, | 1049 EXPECT_EQ(dest_path2, |
1050 profile_manager->GetProfileInfoCache().GetPathOfProfileAtIndex(0)); | 1050 profile_manager->GetProfileInfoCache().GetPathOfProfileAtIndex(0)); |
1051 } | 1051 } |
1052 | 1052 |
1053 TEST_F(ProfileManagerTest, ProfileDisplayNameResetsDefaultName) { | 1053 TEST_F(ProfileManagerTest, ProfileDisplayNameResetsDefaultName) { |
1054 if (!profiles::IsMultipleProfilesEnabled()) | 1054 if (!profiles::IsMultipleProfilesEnabled()) |
1055 return; | 1055 return; |
1056 | 1056 |
1057 // The command line is reset at the end of every test by the test suite. | |
1058 switches::EnableNewAvatarMenuForTesting( | |
1059 base::CommandLine::ForCurrentProcess()); | |
1060 | |
1061 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1057 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1062 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1058 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
1063 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); | 1059 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); |
1064 | 1060 |
1065 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. | 1061 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. |
1066 const base::string16 default_profile_name = | 1062 const base::string16 default_profile_name = |
1067 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); | 1063 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); |
1068 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); | 1064 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); |
1069 Profile* profile1 = AddProfileToCache(profile_manager, | 1065 Profile* profile1 = AddProfileToCache(profile_manager, |
1070 "path_1", profile_name1); | 1066 "path_1", profile_name1); |
(...skipping 15 matching lines...) Expand all Loading... |
1086 // Spin the message loop so that all the callbacks can finish running. | 1082 // Spin the message loop so that all the callbacks can finish running. |
1087 base::RunLoop().RunUntilIdle(); | 1083 base::RunLoop().RunUntilIdle(); |
1088 EXPECT_EQ(default_profile_name, | 1084 EXPECT_EQ(default_profile_name, |
1089 profiles::GetAvatarNameForProfile(profile1->GetPath())); | 1085 profiles::GetAvatarNameForProfile(profile1->GetPath())); |
1090 } | 1086 } |
1091 | 1087 |
1092 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesCustomName) { | 1088 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesCustomName) { |
1093 if (!profiles::IsMultipleProfilesEnabled()) | 1089 if (!profiles::IsMultipleProfilesEnabled()) |
1094 return; | 1090 return; |
1095 | 1091 |
1096 // The command line is reset at the end of every test by the test suite. | |
1097 switches::EnableNewAvatarMenuForTesting( | |
1098 base::CommandLine::ForCurrentProcess()); | |
1099 | |
1100 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1092 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1101 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1093 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
1102 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); | 1094 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); |
1103 | 1095 |
1104 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. | 1096 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. |
1105 const base::string16 default_profile_name = | 1097 const base::string16 default_profile_name = |
1106 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); | 1098 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); |
1107 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); | 1099 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); |
1108 Profile* profile1 = AddProfileToCache(profile_manager, | 1100 Profile* profile1 = AddProfileToCache(profile_manager, |
1109 "path_1", profile_name1); | 1101 "path_1", profile_name1); |
(...skipping 23 matching lines...) Expand all Loading... |
1133 // Spin the message loop so that all the callbacks can finish running. | 1125 // Spin the message loop so that all the callbacks can finish running. |
1134 base::RunLoop().RunUntilIdle(); | 1126 base::RunLoop().RunUntilIdle(); |
1135 EXPECT_EQ(custom_profile_name, | 1127 EXPECT_EQ(custom_profile_name, |
1136 profiles::GetAvatarNameForProfile(profile1->GetPath())); | 1128 profiles::GetAvatarNameForProfile(profile1->GetPath())); |
1137 } | 1129 } |
1138 | 1130 |
1139 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesSignedInName) { | 1131 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesSignedInName) { |
1140 if (!profiles::IsMultipleProfilesEnabled()) | 1132 if (!profiles::IsMultipleProfilesEnabled()) |
1141 return; | 1133 return; |
1142 | 1134 |
1143 // The command line is reset at the end of every test by the test suite. | |
1144 switches::EnableNewAvatarMenuForTesting( | |
1145 base::CommandLine::ForCurrentProcess()); | |
1146 | |
1147 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1135 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1148 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1136 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
1149 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); | 1137 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); |
1150 | 1138 |
1151 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. | 1139 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. |
1152 const base::string16 default_profile_name = | 1140 const base::string16 default_profile_name = |
1153 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); | 1141 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); |
1154 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); | 1142 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); |
1155 Profile* profile1 = AddProfileToCache(profile_manager, | 1143 Profile* profile1 = AddProfileToCache(profile_manager, |
1156 "path_1", profile_name1); | 1144 "path_1", profile_name1); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 // Spin the message loop so that all the callbacks can finish running. | 1176 // Spin the message loop so that all the callbacks can finish running. |
1189 base::RunLoop().RunUntilIdle(); | 1177 base::RunLoop().RunUntilIdle(); |
1190 EXPECT_EQ(gaia_given_name, | 1178 EXPECT_EQ(gaia_given_name, |
1191 profiles::GetAvatarNameForProfile(profile1->GetPath())); | 1179 profiles::GetAvatarNameForProfile(profile1->GetPath())); |
1192 } | 1180 } |
1193 | 1181 |
1194 TEST_F(ProfileManagerTest, ProfileDisplayNameIsEmailIfDefaultName) { | 1182 TEST_F(ProfileManagerTest, ProfileDisplayNameIsEmailIfDefaultName) { |
1195 if (!profiles::IsMultipleProfilesEnabled()) | 1183 if (!profiles::IsMultipleProfilesEnabled()) |
1196 return; | 1184 return; |
1197 | 1185 |
1198 // The command line is reset at the end of every test by the test suite. | |
1199 switches::EnableNewAvatarMenuForTesting( | |
1200 base::CommandLine::ForCurrentProcess()); | |
1201 | |
1202 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1186 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1203 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1187 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
1204 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); | 1188 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); |
1205 | 1189 |
1206 // Create two signed in profiles, with both new and legacy default names, and | 1190 // Create two signed in profiles, with both new and legacy default names, and |
1207 // a profile with a custom name. | 1191 // a profile with a custom name. |
1208 Profile* profile1 = AddProfileToCache( | 1192 Profile* profile1 = AddProfileToCache( |
1209 profile_manager, "path_1", ASCIIToUTF16("Person 1")); | 1193 profile_manager, "path_1", ASCIIToUTF16("Person 1")); |
1210 Profile* profile2 = AddProfileToCache( | 1194 Profile* profile2 = AddProfileToCache( |
1211 profile_manager, "path_2", ASCIIToUTF16("Default Profile")); | 1195 profile_manager, "path_2", ASCIIToUTF16("Default Profile")); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 dest_path2.BaseName().MaybeAsASCII()); | 1338 dest_path2.BaseName().MaybeAsASCII()); |
1355 profile_manager->ScheduleProfileForDeletion(dest_path2, | 1339 profile_manager->ScheduleProfileForDeletion(dest_path2, |
1356 ProfileManager::CreateCallback()); | 1340 ProfileManager::CreateCallback()); |
1357 // Spin the message loop so that all the callbacks can finish running. | 1341 // Spin the message loop so that all the callbacks can finish running. |
1358 base::RunLoop().RunUntilIdle(); | 1342 base::RunLoop().RunUntilIdle(); |
1359 | 1343 |
1360 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); | 1344 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); |
1361 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); | 1345 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); |
1362 } | 1346 } |
1363 #endif // !defined(OS_MACOSX) | 1347 #endif // !defined(OS_MACOSX) |
OLD | NEW |