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

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

Issue 1614943004: Revert of Uniquify profile shortcut name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | chrome/browser/profiles/profile_shortcut_manager_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5d512c30dfedae9e411144c930950ab16c447773..644a88376a4a5059d2f2fd3b90fd84aeab1b8e68 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc
@@ -238,7 +238,7 @@
const base::FilePath& profile_path,
const base::string16& new_profile_name) {
const size_t profile_index =
- profile_info_cache_->GetIndexOfProfileWithPath(profile_path);
+ profile_info_cache_->GetIndexOfProfileWithPath(profile_2_path_);
ASSERT_NE(std::string::npos, profile_index);
ASSERT_NE(profile_info_cache_->GetNameOfProfileAtIndex(profile_index),
new_profile_name);
@@ -877,146 +877,3 @@
EXPECT_TRUE(base::ReadFileToString(icon_path_1, &unbadged_icon_1_a));
EXPECT_EQ(unbadged_icon_1, unbadged_icon_1_a);
}
-
-TEST_F(ProfileShortcutManagerTest, ShortcutFilenameUniquified) {
- const auto suffix =
- GetDistribution()->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME);
- std::set<base::FilePath> excludes;
-
- auto shortcut_filename =
- profiles::internal::GetUniqueShortcutFilenameForProfile(
- L"Carrie", excludes, GetDistribution());
- EXPECT_EQ(L"Carrie - " + suffix + L".lnk", shortcut_filename);
- excludes.insert(GetUserShortcutsDirectory().Append(shortcut_filename));
-
- shortcut_filename = profiles::internal::GetUniqueShortcutFilenameForProfile(
- L"Carrie", excludes, GetDistribution());
- EXPECT_EQ(L"Carrie - " + suffix + L" (1).lnk", shortcut_filename);
- excludes.insert(GetUserShortcutsDirectory().Append(shortcut_filename));
-
- shortcut_filename = profiles::internal::GetUniqueShortcutFilenameForProfile(
- L"Carrie", excludes, GetDistribution());
- EXPECT_EQ(L"Carrie - " + suffix + L" (2).lnk", shortcut_filename);
- excludes.insert(GetUserShortcutsDirectory().Append(shortcut_filename));
-
- shortcut_filename = profiles::internal::GetUniqueShortcutFilenameForProfile(
- L"Steven", excludes, GetDistribution());
- EXPECT_EQ(L"Steven - " + suffix + L".lnk", shortcut_filename);
- excludes.insert(GetUserShortcutsDirectory().Append(shortcut_filename));
-
- shortcut_filename = profiles::internal::GetUniqueShortcutFilenameForProfile(
- L"Steven", excludes, GetDistribution());
- EXPECT_EQ(L"Steven - " + suffix + L" (1).lnk", shortcut_filename);
- excludes.insert(GetUserShortcutsDirectory().Append(shortcut_filename));
-
- shortcut_filename = profiles::internal::GetUniqueShortcutFilenameForProfile(
- L"Carrie", excludes, GetDistribution());
- EXPECT_EQ(L"Carrie - " + suffix + L" (3).lnk", shortcut_filename);
- excludes.insert(GetUserShortcutsDirectory().Append(shortcut_filename));
-
- excludes.erase(
- GetUserShortcutsDirectory().Append(L"Carrie - " + suffix + L".lnk"));
- shortcut_filename = profiles::internal::GetUniqueShortcutFilenameForProfile(
- L"Carrie", excludes, GetDistribution());
- EXPECT_EQ(L"Carrie - " + suffix + L".lnk", shortcut_filename);
-}
-
-TEST_F(ProfileShortcutManagerTest, ShortcutFilenameMatcher) {
- profiles::internal::ShortcutFilenameMatcher matcher(L"Carrie",
- GetDistribution());
- const auto suffix =
- GetDistribution()->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME);
- EXPECT_TRUE(matcher.IsCanonical(L"Carrie - " + suffix + L" (2).lnk"));
- EXPECT_FALSE(matcher.IsCanonical(L"Carrie - " + suffix + L"(2).lnk"));
- EXPECT_FALSE(matcher.IsCanonical(L"Carrie - " + suffix + L" 2.lnk"));
- EXPECT_FALSE(matcher.IsCanonical(L"Carrie - " + suffix + L"2.lnk"));
- EXPECT_FALSE(matcher.IsCanonical(L"Carrie - " + suffix + L" - 2.lnk"));
- EXPECT_FALSE(matcher.IsCanonical(L"Carrie - " + suffix + L" (a).lnk"));
- EXPECT_TRUE(matcher.IsCanonical(L"Carrie - " + suffix + L" (11).lnk"));
- EXPECT_TRUE(matcher.IsCanonical(L"Carrie - " + suffix + L" (03).lnk"));
- EXPECT_TRUE(matcher.IsCanonical(L"Carrie - " + suffix + L" (999).lnk"));
- EXPECT_FALSE(matcher.IsCanonical(L"Carrie - " + suffix + L" (999).lin"));
- EXPECT_FALSE(matcher.IsCanonical(L"ABC Carrie - " + suffix + L" DEF.lnk"));
- EXPECT_FALSE(matcher.IsCanonical(L"ABC Carrie DEF.lnk"));
- EXPECT_FALSE(matcher.IsCanonical(L"Carrie.lnk"));
-}
-
-TEST_F(ProfileShortcutManagerTest, ShortcutsForProfilesWithIdenticalNames) {
- SetupDefaultProfileShortcut(FROM_HERE);
-
- // Create new profile - profile2.
- CreateProfileWithShortcut(FROM_HERE, profile_2_name_, profile_2_path_);
- // Check that nothing is changed for profile1.
- ValidateProfileShortcut(FROM_HERE, profile_1_name_, profile_1_path_);
-
- // Give to profile1 the same name as profile2.
- base::string16 new_profile_1_name = profile_2_name_;
- RenameProfile(FROM_HERE, profile_1_path_, new_profile_1_name);
- const auto profile_1_shortcut_name = new_profile_1_name + L" - " +
- GetDistribution()->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) +
- L" (1)";
- const auto profile_1_shortcut_path = GetUserShortcutsDirectory()
- .Append(profile_1_shortcut_name + installer::kLnkExt);
- ValidateProfileShortcutAtPath(FROM_HERE,
- profile_1_shortcut_path,
- profile_1_path_);
- // Check that nothing is changed for profile2.
- ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_);
-
- // Create new profile - profile3.
- CreateProfileWithShortcut(FROM_HERE, profile_3_name_, profile_3_path_);
- // Check that nothing is changed for profile1 and profile2.
- ValidateProfileShortcutAtPath(FROM_HERE,
- profile_1_shortcut_path,
- profile_1_path_);
- ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_);
-
- // Give to profile3 the same name as profile2.
- const base::string16 new_profile_3_name = profile_2_name_;
- RenameProfile(FROM_HERE, profile_3_path_, new_profile_3_name);
- const auto profile_3_shortcut_name = new_profile_3_name + L" - " +
- GetDistribution()->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) +
- L" (2)";
- const auto profile_3_shortcut_path = GetUserShortcutsDirectory()
- .Append(profile_3_shortcut_name + installer::kLnkExt);
- ValidateProfileShortcutAtPath(FROM_HERE,
- profile_3_shortcut_path,
- profile_3_path_);
- // Check that nothing is changed for profile1 and profile2.
- ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_);
- ValidateProfileShortcutAtPath(FROM_HERE,
- profile_1_shortcut_path,
- profile_1_path_);
-
- // Rename profile1 again.
- new_profile_1_name = L"Carrie";
- RenameProfile(FROM_HERE, profile_1_path_, new_profile_1_name);
- ValidateProfileShortcut(FROM_HERE, new_profile_1_name, profile_1_path_);
- // Check that nothing is changed for profile2 and profile3.
- ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_);
- ValidateProfileShortcutAtPath(FROM_HERE,
- profile_3_shortcut_path,
- profile_3_path_);
-
- // Delete profile1.
- profile_info_cache_->DeleteProfileFromCache(profile_1_path_);
- RunPendingTasks();
- EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(new_profile_1_name));
- // Check that nothing is changed for profile2 and profile3.
- ValidateProfileShortcut(FROM_HERE, profile_2_name_, profile_2_path_);
- ValidateProfileShortcutAtPath(FROM_HERE,
- profile_3_shortcut_path,
- profile_3_path_);
-
- // Delete profile2.
- EXPECT_TRUE(base::PathExists(
- GetDefaultShortcutPathForProfile(profile_2_name_)));
- EXPECT_TRUE(base::PathExists(profile_3_shortcut_path));
- profile_info_cache_->DeleteProfileFromCache(profile_2_path_);
- RunPendingTasks();
- EXPECT_FALSE(base::PathExists(
- GetDefaultShortcutPathForProfile(profile_2_name_)));
- // Only profile3 exists. There should be non-profile shortcut only.
- EXPECT_FALSE(base::PathExists(profile_3_shortcut_path));
- ValidateNonProfileShortcut(FROM_HERE);
-}
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_shortcut_manager_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698