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..7e36ee0cf7a583f430eca58d2394ed8d314817ee 100644 |
--- a/chrome/installer/util/shell_util_unittest.cc |
+++ b/chrome/installer/util/shell_util_unittest.cc |
@@ -357,8 +357,8 @@ TEST_F(ShellUtilShortcutTest, RemoveChromeShortcut) { |
ASSERT_TRUE(file_util::PathExists(shortcut_path)); |
ASSERT_TRUE(ShellUtil::RemoveShortcut( |
- ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, chrome_exe_, |
- ShellUtil::CURRENT_USER, NULL)); |
+ 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())); |
} |
@@ -376,8 +376,8 @@ TEST_F(ShellUtilShortcutTest, RemoveSystemLevelChromeShortcut) { |
ASSERT_TRUE(file_util::PathExists(shortcut_path)); |
ASSERT_TRUE(ShellUtil::RemoveShortcut( |
- ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, chrome_exe_, |
- ShellUtil::SYSTEM_LEVEL, NULL)); |
+ 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())); |
} |
@@ -394,9 +394,9 @@ TEST_F(ShellUtilShortcutTest, RemoveChromeShortcutWithSpecialName) { |
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_TRUE(ShellUtil::RemoveShortcutWithName( |
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, ShellUtil::CURRENT_USER, |
+ chrome_exe_, string16(kSpecialName))); |
ASSERT_FALSE(file_util::PathExists(shortcut_path)); |
ASSERT_TRUE(file_util::PathExists(shortcut_path.DirName())); |
} |
@@ -428,13 +428,91 @@ TEST_F(ShellUtilShortcutTest, RemoveMultipleChromeShortcuts) { |
ASSERT_TRUE(file_util::PathExists(shortcut2_path)); |
ASSERT_TRUE(ShellUtil::RemoveShortcut( |
- ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, chrome_exe_, |
- ShellUtil::CURRENT_USER, NULL)); |
+ 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, MigrateChromeShortcut) { |
+ 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::MigrateShortcut( |
+ 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, MigrateSystemLevelChromeShortcut) { |
+ 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::MigrateShortcut( |
+ 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, MigrateMultipleChromeShortcuts) { |
+ 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::MigrateShortcut( |
+ 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, |
@@ -457,8 +535,8 @@ TEST_F(ShellUtilShortcutTest, CreateMultipleStartMenuShortcutsAndRemoveFolder) { |
ASSERT_TRUE(file_util::PathExists(shortcut_folder)); |
ASSERT_TRUE(ShellUtil::RemoveShortcut( |
- ShellUtil::SHORTCUT_LOCATION_START_MENU, dist_, chrome_exe_, |
- ShellUtil::CURRENT_USER, NULL)); |
+ ShellUtil::SHORTCUT_LOCATION_START_MENU, dist_, ShellUtil::CURRENT_USER, |
+ chrome_exe_)); |
ASSERT_FALSE(file_util::PathExists(shortcut_folder)); |
} |
@@ -483,8 +561,8 @@ TEST_F(ShellUtilShortcutTest, DontRemoveChromeShortcutIfPointsToAnotherChrome) { |
// |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)); |
+ 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())); |
} |