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

Unified Diff: chrome/installer/util/shell_util_unittest.cc

Issue 14287008: Refactoring installer shortcut deletion; adding dedicated shortcut update feature. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment fixes; reduced RemoveShortcuts() to a single interface. Created 7 years, 8 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
« chrome/installer/util/shell_util.cc ('K') | « chrome/installer/util/shell_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/shell_util_unittest.cc
diff --git a/chrome/installer/util/shell_util_unittest.cc b/chrome/installer/util/shell_util_unittest.cc
index 25dff4c1f3129af5df37d7b57a35d2034b1823dc..492e8b37cc3967acd1b3aa4eb11cc9237fb44166 100644
--- a/chrome/installer/util/shell_util_unittest.cc
+++ b/chrome/installer/util/shell_util_unittest.cc
@@ -356,9 +356,9 @@ TEST_F(ShellUtilShortcutTest, RemoveChromeShortcut) {
base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name));
ASSERT_TRUE(file_util::PathExists(shortcut_path));
- ASSERT_TRUE(ShellUtil::RemoveShortcut(
- ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, chrome_exe_,
- ShellUtil::CURRENT_USER, NULL));
+ ASSERT_TRUE(ShellUtil::RemoveShortcuts(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER,
+ chrome_exe_));
ASSERT_FALSE(file_util::PathExists(shortcut_path));
ASSERT_TRUE(file_util::PathExists(shortcut_path.DirName()));
}
@@ -375,9 +375,9 @@ TEST_F(ShellUtilShortcutTest, RemoveSystemLevelChromeShortcut) {
fake_common_desktop_.path().Append(shortcut_name));
ASSERT_TRUE(file_util::PathExists(shortcut_path));
- ASSERT_TRUE(ShellUtil::RemoveShortcut(
- ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, chrome_exe_,
- ShellUtil::SYSTEM_LEVEL, NULL));
+ ASSERT_TRUE(ShellUtil::RemoveShortcuts(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::SYSTEM_LEVEL,
+ chrome_exe_));
ASSERT_FALSE(file_util::PathExists(shortcut_path));
ASSERT_TRUE(file_util::PathExists(shortcut_path.DirName()));
}
@@ -393,12 +393,6 @@ TEST_F(ShellUtilShortcutTest, RemoveChromeShortcutWithSpecialName) {
string16 shortcut_name(string16(kSpecialName).append(installer::kLnkExt));
base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name));
ASSERT_TRUE(file_util::PathExists(shortcut_path));
-
- ASSERT_TRUE(ShellUtil::RemoveShortcut(
- ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, chrome_exe_,
- ShellUtil::CURRENT_USER, &string16(kSpecialName)));
- ASSERT_FALSE(file_util::PathExists(shortcut_path));
- ASSERT_TRUE(file_util::PathExists(shortcut_path.DirName()));
}
TEST_F(ShellUtilShortcutTest, RemoveMultipleChromeShortcuts) {
@@ -427,14 +421,92 @@ TEST_F(ShellUtilShortcutTest, RemoveMultipleChromeShortcuts) {
fake_user_desktop_.path().Append(shortcut2_name));
ASSERT_TRUE(file_util::PathExists(shortcut2_path));
- ASSERT_TRUE(ShellUtil::RemoveShortcut(
- ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, chrome_exe_,
- ShellUtil::CURRENT_USER, NULL));
+ ASSERT_TRUE(ShellUtil::RemoveShortcuts(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER,
+ chrome_exe_));
ASSERT_FALSE(file_util::PathExists(shortcut1_path));
ASSERT_FALSE(file_util::PathExists(shortcut2_path));
ASSERT_TRUE(file_util::PathExists(shortcut1_path.DirName()));
}
+TEST_F(ShellUtilShortcutTest, RetargetChromeShortcut) {
+ ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_,
+ *test_properties_,
+ ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS));
+
+ string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt);
+ base::FilePath shortcut_path(fake_user_desktop_.path().Append(shortcut_name));
+ ASSERT_TRUE(file_util::PathExists(shortcut_path));
+
+ base::FilePath new_exe = temp_dir_.path().Append(L"manganese.exe");
+ ASSERT_TRUE(ShellUtil::RetargetShortcuts(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER,
+ chrome_exe_, new_exe));
+ base::FilePath target_path;
+ ASSERT_TRUE(base::win::ResolveShortcut(shortcut_path, &target_path, NULL));
+ ASSERT_EQ(new_exe, target_path);
+}
+
+TEST_F(ShellUtilShortcutTest, RetargetSystemLevelChromeShortcut) {
+ test_properties_->level = ShellUtil::SYSTEM_LEVEL;
+ ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_,
+ *test_properties_,
+ ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS));
+
+ string16 shortcut_name(dist_->GetAppShortCutName() + installer::kLnkExt);
+ base::FilePath shortcut_path(
+ fake_common_desktop_.path().Append(shortcut_name));
+ ASSERT_TRUE(file_util::PathExists(shortcut_path));
+
+ base::FilePath new_exe = temp_dir_.path().Append(L"manganese.exe");
+ ASSERT_TRUE(ShellUtil::RetargetShortcuts(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::SYSTEM_LEVEL,
+ chrome_exe_, new_exe));
+ base::FilePath target_path;
+ ASSERT_TRUE(base::win::ResolveShortcut(shortcut_path, &target_path, NULL));
+ ASSERT_EQ(new_exe, target_path);
+}
+
+TEST_F(ShellUtilShortcutTest, RetargetMultipleChromeShortcuts) {
+ const wchar_t kShortcutName1[] = L"Chrome 1";
+ const wchar_t kShortcutName2[] = L"Chrome 2";
+
+ test_properties_->set_shortcut_name(kShortcutName1);
+ ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_,
+ *test_properties_,
+ ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS));
+ string16 shortcut1_name(
+ string16(kShortcutName1).append(installer::kLnkExt));
+ base::FilePath shortcut1_path(
+ fake_user_desktop_.path().Append(shortcut1_name));
+
+ test_properties_->set_shortcut_name(kShortcutName2);
+ test_properties_->set_arguments(L"--profile-directory=\"Profile 2\"");
+ ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_,
+ *test_properties_,
+ ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS));
+ string16 shortcut2_name(string16(kShortcutName2).append(installer::kLnkExt));
+ base::FilePath shortcut2_path(
+ fake_user_desktop_.path().Append(shortcut2_name));
+ ASSERT_TRUE(file_util::PathExists(shortcut2_path));
+
+ base::FilePath new_exe = temp_dir_.path().Append(L"manganese.exe");
+ ASSERT_TRUE(ShellUtil::RetargetShortcuts(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER,
+ chrome_exe_, new_exe));
+
+ base::FilePath target_path1;
+ ASSERT_TRUE(base::win::ResolveShortcut(shortcut1_path, &target_path1, NULL));
+ ASSERT_EQ(new_exe, target_path1);
+ base::FilePath target_path2;
+ ASSERT_TRUE(base::win::ResolveShortcut(shortcut2_path, &target_path2, NULL));
+ ASSERT_EQ(new_exe, target_path2);
+}
+
TEST_F(ShellUtilShortcutTest, CreateMultipleStartMenuShortcutsAndRemoveFolder) {
ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut(
ShellUtil::SHORTCUT_LOCATION_START_MENU,
@@ -456,9 +528,9 @@ TEST_F(ShellUtilShortcutTest, CreateMultipleStartMenuShortcutsAndRemoveFolder) {
EXPECT_EQ(2, count);
ASSERT_TRUE(file_util::PathExists(shortcut_folder));
- ASSERT_TRUE(ShellUtil::RemoveShortcut(
- ShellUtil::SHORTCUT_LOCATION_START_MENU, dist_, chrome_exe_,
- ShellUtil::CURRENT_USER, NULL));
+ ASSERT_TRUE(ShellUtil::RemoveShortcuts(
+ ShellUtil::SHORTCUT_LOCATION_START_MENU, dist_, ShellUtil::CURRENT_USER,
+ chrome_exe_));
ASSERT_FALSE(file_util::PathExists(shortcut_folder));
}
@@ -482,9 +554,9 @@ TEST_F(ShellUtilShortcutTest, DontRemoveChromeShortcutIfPointsToAnotherChrome) {
// The shortcut shouldn't be removed as it was installed pointing to
// |other_chrome_exe| and RemoveChromeShortcut() is being told that the
// removed shortcut should point to |chrome_exe_|.
- ASSERT_TRUE(ShellUtil::RemoveShortcut(
- ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, chrome_exe_,
- ShellUtil::CURRENT_USER, NULL));
+ ASSERT_TRUE(ShellUtil::RemoveShortcuts(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER,
+ chrome_exe_));
ASSERT_TRUE(file_util::PathExists(shortcut_path));
ASSERT_TRUE(file_util::PathExists(shortcut_path.DirName()));
}
« chrome/installer/util/shell_util.cc ('K') | « chrome/installer/util/shell_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698