Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2376)

Unified Diff: chrome/browser/profiles/profile_info_cache_unittest.cc

Issue 490363002: [Profiles] Update legacy default profile names. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_info_cache_unittest.cc
diff --git a/chrome/browser/profiles/profile_info_cache_unittest.cc b/chrome/browser/profiles/profile_info_cache_unittest.cc
index ab253578132871594c3074c3975973406860d221..64cfdb956ec3d92c752bb83a76c72c9f4a34cf3a 100644
--- a/chrome/browser/profiles/profile_info_cache_unittest.cc
+++ b/chrome/browser/profiles/profile_info_cache_unittest.cc
@@ -590,4 +590,77 @@ TEST_F(ProfileInfoCacheTest, DownloadHighResAvatarTest) {
EXPECT_TRUE(base::DeleteFile(icon_path, true));
EXPECT_FALSE(base::PathExists(icon_path));
}
+
+TEST_F(ProfileInfoCacheTest, MigrateLegacyProfileNamesWithNewAvatarMenu) {
+ switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess());
+ EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles());
+
+ base::FilePath path_1 = GetProfilePath("path_1");
+ GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("Default Profile"),
+ base::string16(), 0, std::string());
+ base::FilePath path_2 = GetProfilePath("path_2");
+ GetCache()->AddProfileToCache(path_2, ASCIIToUTF16("First user"),
+ base::string16(), 1, std::string());
+ base::string16 name_3 = ASCIIToUTF16("Lemonade");
+ base::FilePath path_3 = GetProfilePath("path_3");
+ GetCache()->AddProfileToCache(path_3, name_3,
+ base::string16(), 2, std::string());
+ base::string16 name_4 = ASCIIToUTF16("Batman");
+ base::FilePath path_4 = GetProfilePath("path_4");
+ GetCache()->AddProfileToCache(path_4, name_4,
+ base::string16(), 3, std::string());
+ EXPECT_EQ(4U, GetCache()->GetNumberOfProfiles());
rpetterson 2014/08/22 20:36:10 You could also add a fifth person whose name is "P
noms (inactive) 2014/08/22 20:44:35 Oh, that's a great idea. Thanks!
+
+ ResetCache();
+
+ // Legacy profile names like "Default Profile" and "First user" should be
+ // migrated to "Person %n" type names.
+ EXPECT_EQ(ASCIIToUTF16("Person 1"), GetCache()->GetNameOfProfileAtIndex(
+ GetCache()->GetIndexOfProfileWithPath(path_1)));
+ EXPECT_EQ(ASCIIToUTF16("Person 2"), GetCache()->GetNameOfProfileAtIndex(
+ GetCache()->GetIndexOfProfileWithPath(path_2)));
+
+ // Other profile names should not be migrated even if they're the old
+ // default cartoon profile names.
+ EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex(
+ GetCache()->GetIndexOfProfileWithPath(path_3)));
+ EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex(
+ GetCache()->GetIndexOfProfileWithPath(path_4)));
+}
#endif
+
+TEST_F(ProfileInfoCacheTest,
+ DontMigrateLegacyProfileNamesWithoutNewAvatarMenu) {
+ EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles());
+
+ base::string16 name_1 = ASCIIToUTF16("Default Profile");
+ base::FilePath path_1 = GetProfilePath("path_1");
+ GetCache()->AddProfileToCache(path_1, name_1,
+ base::string16(), 0, std::string());
+ base::string16 name_2 = ASCIIToUTF16("First user");
+ base::FilePath path_2 = GetProfilePath("path_2");
+ GetCache()->AddProfileToCache(path_2, name_2,
+ base::string16(), 1, std::string());
+ base::string16 name_3 = ASCIIToUTF16("Lemonade");
+ base::FilePath path_3 = GetProfilePath("path_3");
+ GetCache()->AddProfileToCache(path_3, name_3,
+ base::string16(), 2, std::string());
+ base::string16 name_4 = ASCIIToUTF16("Batman");
+ base::FilePath path_4 = GetProfilePath("path_4");
+ GetCache()->AddProfileToCache(path_4, name_4,
+ base::string16(), 3, std::string());
+ EXPECT_EQ(4U, GetCache()->GetNumberOfProfiles());
+
+ ResetCache();
+
+ // Profile names should have been preserved.
+ EXPECT_EQ(name_1, GetCache()->GetNameOfProfileAtIndex(
+ GetCache()->GetIndexOfProfileWithPath(path_1)));
+ EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex(
+ GetCache()->GetIndexOfProfileWithPath(path_2)));
+ EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex(
+ GetCache()->GetIndexOfProfileWithPath(path_3)));
+ EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex(
+ GetCache()->GetIndexOfProfileWithPath(path_4)));
+}
+

Powered by Google App Engine
This is Rietveld 408576698