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..98ac07b408a13010a14cbbf5d6b72e6f10dbf3bc 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,104 @@ 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, UpdateChromeShortcut) { |
+ 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"); |
+ base::win::ShortcutProperties shortcut_properties; |
+ shortcut_properties.set_target(new_exe); |
+ shortcut_properties.set_working_dir(new_exe.DirName()); |
+ |
+ ASSERT_TRUE(ShellUtil::UpdateShortcuts( |
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, |
+ chrome_exe_, shortcut_properties)); |
+ base::FilePath target_path; |
+ ASSERT_TRUE(base::win::ResolveShortcut(shortcut_path, &target_path, NULL)); |
+ ASSERT_EQ(new_exe, target_path); |
+} |
+ |
+TEST_F(ShellUtilShortcutTest, UpdateSystemLevelChromeShortcut) { |
+ 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"); |
+ base::win::ShortcutProperties shortcut_properties; |
+ shortcut_properties.set_target(new_exe); |
+ shortcut_properties.set_working_dir(new_exe.DirName()); |
+ |
+ ASSERT_TRUE(ShellUtil::UpdateShortcuts( |
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::SYSTEM_LEVEL, |
+ chrome_exe_, shortcut_properties)); |
+ base::FilePath target_path; |
+ ASSERT_TRUE(base::win::ResolveShortcut(shortcut_path, &target_path, NULL)); |
+ ASSERT_EQ(new_exe, target_path); |
+} |
+ |
+TEST_F(ShellUtilShortcutTest, UpdateMultipleChromeShortcuts) { |
+ 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"); |
+ base::win::ShortcutProperties shortcut_properties; |
+ shortcut_properties.set_target(new_exe); |
+ shortcut_properties.set_working_dir(new_exe.DirName()); |
+ |
+ ASSERT_TRUE(ShellUtil::UpdateShortcuts( |
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, |
+ chrome_exe_, shortcut_properties)); |
+ |
+ 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 +540,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 +566,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())); |
} |