Chromium Code Reviews| Index: chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc | 
| diff --git a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc | 
| index e4eb340ad26449cedb78c2df3324afa91d514c37..417335e80c4a601d06a163f58ee2b7764be48823 100644 | 
| --- a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc | 
| +++ b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc | 
| @@ -72,8 +72,10 @@ class ProfileShortcutManagerTest : public testing::Test { | 
| RunPendingTasks(); | 
| ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_name)); | 
| const base::FilePath icon_path = | 
| - profile_path.AppendASCII(profiles::internal::kProfileIconFileName); | 
| - ASSERT_FALSE(file_util::PathExists(icon_path)); | 
| + profiles::internal::GetProfileIconPath(profile_path); | 
| + // The icon file should not be deleted on shortcut deletion. | 
| 
 
gab
2013/07/11 12:30:16
Wait, this is wrong, no? It is true that the icon
 
calamity
2013/07/12 07:55:08
Profile directories are not cleaned up on the file
 
gab
2013/07/12 11:47:45
Hmm, okay, so then why is the directory absent in
 
gab
2013/07/16 14:10:38
Ok, then the comment above should state that, not
 
gab
2013/07/16 14:10:38
Ah okay I see, so it's not that it's deleted too e
 
calamity
2013/07/18 08:39:08
This test is fine. It's others that are failing. T
 
 | 
| + ASSERT_TRUE(file_util::PathExists(icon_path)); | 
| + ASSERT_TRUE(base::Delete(icon_path, false)); | 
| } | 
| } | 
| @@ -134,7 +136,7 @@ class ProfileShortcutManagerTest : public testing::Test { | 
| // Ensure that the corresponding icon exists. | 
| const base::FilePath icon_path = | 
| - profile_path.AppendASCII(profiles::internal::kProfileIconFileName); | 
| + profiles::internal::GetProfileIconPath(profile_path); | 
| EXPECT_TRUE(file_util::PathExists(icon_path)) << location.ToString(); | 
| base::win::ShortcutProperties expected_properties; | 
| @@ -760,7 +762,7 @@ TEST_F(ProfileShortcutManagerTest, | 
| CreateRegularSystemLevelShortcut(FROM_HERE); | 
| // Delete the profile that has a shortcut, which will exercise the non-profile | 
| - // shortcut creation path in |DeleteDesktopShortcutsAndIconFile()|, which is | 
| + // shortcut creation path in |DeleteDesktopShortcuts()|, which is | 
| // not covered by the |DeleteSecondToLastProfileWithSystemLevelShortcut| test. | 
| profile_info_cache_->DeleteProfileFromCache(profile_2_path_); | 
| RunPendingTasks(); | 
| @@ -772,3 +774,95 @@ TEST_F(ProfileShortcutManagerTest, | 
| EXPECT_FALSE(file_util::PathExists(profile_1_shortcut_path)); | 
| EXPECT_FALSE(file_util::PathExists(profile_2_shortcut_path)); | 
| } | 
| + | 
| +TEST_F(ProfileShortcutManagerTest, CreateProfileIcon) { | 
| + SetupDefaultProfileShortcut(FROM_HERE); | 
| + | 
| + const base::FilePath icon_path = | 
| + profiles::internal::GetProfileIconPath(profile_1_path_); | 
| + | 
| + EXPECT_TRUE(file_util::PathExists(icon_path)); | 
| + EXPECT_TRUE(base::Delete(icon_path, false)); | 
| + EXPECT_FALSE(file_util::PathExists(icon_path)); | 
| + | 
| + profile_shortcut_manager_->CreateOrUpdateProfileIcon(profile_1_path_, | 
| + base::Closure()); | 
| + RunPendingTasks(); | 
| + EXPECT_TRUE(file_util::PathExists(icon_path)); | 
| +} | 
| + | 
| +TEST_F(ProfileShortcutManagerTest, UnbadgeProfileIconOnDeletion) { | 
| + SetupDefaultProfileShortcut(FROM_HERE); | 
| + const base::FilePath icon_path_1 = | 
| + profiles::internal::GetProfileIconPath(profile_1_path_); | 
| + const base::FilePath icon_path_2 = | 
| + profiles::internal::GetProfileIconPath(profile_2_path_); | 
| + | 
| + // Default profile has unbadged icon to start. | 
| + std::string unbadged_icon_1; | 
| + EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &unbadged_icon_1)); | 
| + | 
| + // Creating a new profile adds a badge to both the new profile icon and the | 
| + // default profile icon. Since they use the same icon index, the icon files | 
| + // should be the same. | 
| + CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_); | 
| + | 
| + std::string badged_icon_1; | 
| + EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &badged_icon_1)); | 
| + std::string badged_icon_2; | 
| + EXPECT_TRUE(file_util::ReadFileToString(icon_path_2, &badged_icon_2)); | 
| + | 
| + EXPECT_NE(badged_icon_1, unbadged_icon_1); | 
| + EXPECT_EQ(badged_icon_1, badged_icon_2); | 
| + | 
| + // Deleting the default profile will unbadge the new profile's icon and should | 
| + // result in an icon that is identical to the unbadged default profile icon. | 
| + profile_info_cache_->DeleteProfileFromCache(profile_1_path_); | 
| + RunPendingTasks(); | 
| + | 
| + std::string unbadged_icon_2; | 
| + EXPECT_TRUE(file_util::ReadFileToString(icon_path_2, &unbadged_icon_2)); | 
| + EXPECT_EQ(unbadged_icon_1, unbadged_icon_2); | 
| +} | 
| + | 
| +TEST_F(ProfileShortcutManagerTest, ProfileIconOnAvatarChange) { | 
| + SetupAndCreateTwoShortcuts(FROM_HERE); | 
| + const base::FilePath icon_path_1 = | 
| + profiles::internal::GetProfileIconPath(profile_1_path_); | 
| + const base::FilePath icon_path_2 = | 
| + profiles::internal::GetProfileIconPath(profile_2_path_); | 
| + const size_t profile_index_1 = | 
| + profile_info_cache_->GetIndexOfProfileWithPath(profile_1_path_); | 
| + | 
| + std::string badged_icon_1; | 
| + EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &badged_icon_1)); | 
| + std::string badged_icon_2; | 
| + EXPECT_TRUE(file_util::ReadFileToString(icon_path_2, &badged_icon_2)); | 
| + | 
| + // Profile 1 and 2 are created with the same icon. | 
| + EXPECT_EQ(badged_icon_1, badged_icon_2); | 
| + | 
| + // Change profile 1's icon. | 
| + profile_info_cache_->SetAvatarIconOfProfileAtIndex(profile_index_1, 1); | 
| + RunPendingTasks(); | 
| + | 
| + std::string new_badged_icon_1; | 
| + EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &new_badged_icon_1)); | 
| + EXPECT_NE(new_badged_icon_1, badged_icon_1); | 
| + | 
| + // Ensure the new icon is not the unbadged icon. | 
| + profile_info_cache_->DeleteProfileFromCache(profile_2_path_); | 
| + RunPendingTasks(); | 
| + | 
| + std::string unbadged_icon_1; | 
| + EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &unbadged_icon_1)); | 
| + EXPECT_NE(unbadged_icon_1, new_badged_icon_1); | 
| + | 
| + // Ensure the icon doesn't change on avatar change without 2 profiles. | 
| + profile_info_cache_->SetAvatarIconOfProfileAtIndex(profile_index_1, 1); | 
| + RunPendingTasks(); | 
| + | 
| + std::string unbadged_icon_1_a; | 
| + EXPECT_TRUE(file_util::ReadFileToString(icon_path_1, &unbadged_icon_1_a)); | 
| + EXPECT_EQ(unbadged_icon_1, unbadged_icon_1_a); | 
| +} |