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

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

Issue 14137032: Create profile .ico file on profile creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test, fix nits Created 7 years, 6 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_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 aedcfb21d33573d41755960b3f30c464b06eba73..7b56c2c07a787414e6431809bf26bc665c0d8c0d 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
@@ -73,8 +73,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.
+ ASSERT_TRUE(file_util::PathExists(icon_path));
+ ASSERT_TRUE(file_util::Delete(icon_path, false));
}
}
@@ -135,7 +137,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;
@@ -761,7 +763,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();
@@ -773,3 +775,53 @@ 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(file_util::Delete(icon_path, false));
+ EXPECT_FALSE(file_util::PathExists(icon_path));
+
+ profile_shortcut_manager_->CreateProfileIcon(profile_1_path_,
+ base::Closure());
+ RunPendingTasks();
+ EXPECT_TRUE(file_util::PathExists(icon_path));
+}
+
+TEST_F(ProfileShortcutManagerTest, UnbadgeProfileIconOnDeletion) {
Alexei Svitkine (slow) 2013/06/13 13:16:05 Sweet test! Can you also test the avatar change sc
calamity 2013/06/14 04:09:05 Done.
+ 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);
+}

Powered by Google App Engine
This is Rietveld 408576698