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

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: review comments 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
« no previous file with comments | « chrome/browser/profiles/profile_info_cache.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9fa123c6d968fe37bb401001d9c2cbf05b99a1e9 100644
--- a/chrome/browser/profiles/profile_info_cache_unittest.cc
+++ b/chrome/browser/profiles/profile_info_cache_unittest.cc
@@ -590,4 +590,85 @@ 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());
+ base::string16 name_5 = ASCIIToUTF16("Person 2");
+ base::FilePath path_5 = GetProfilePath("path_5");
+ GetCache()->AddProfileToCache(path_5, name_5,
+ base::string16(), 2, std::string());
+
+ EXPECT_EQ(5U, GetCache()->GetNumberOfProfiles());
+
+
+ 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 3"), 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)));
+ EXPECT_EQ(name_5, GetCache()->GetNameOfProfileAtIndex(
+ GetCache()->GetIndexOfProfileWithPath(path_5)));
+}
#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)));
+}
+
« no previous file with comments | « chrome/browser/profiles/profile_info_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698