diff options
Diffstat (limited to 'chrome/installer/setup/install_unittest.cc')
-rw-r--r-- | chrome/installer/setup/install_unittest.cc | 84 |
1 files changed, 77 insertions, 7 deletions
diff --git a/chrome/installer/setup/install_unittest.cc b/chrome/installer/setup/install_unittest.cc index 6f8b9c0..0cb3e8f 100644 --- a/chrome/installer/setup/install_unittest.cc +++ b/chrome/installer/setup/install_unittest.cc @@ -125,18 +125,21 @@ class InstallShortcutTest : public testing::Test { fake_user_desktop_.path().Append(shortcut_name); user_quick_launch_shortcut_ = fake_user_quick_launch_.path().Append(shortcut_name); - user_start_menu_shortcut_ = - fake_start_menu_.path().Append( - dist_->GetStartMenuShortcutSubfolder( + user_start_menu_shortcut_ = fake_start_menu_.path().Append(shortcut_name); + user_start_menu_subdir_shortcut_ = + fake_start_menu_.path() + .Append(dist_->GetStartMenuShortcutSubfolder( BrowserDistribution::SUBFOLDER_CHROME)) - .Append(shortcut_name); + .Append(shortcut_name); system_desktop_shortcut_ = fake_common_desktop_.path().Append(shortcut_name); system_start_menu_shortcut_ = - fake_common_start_menu_.path().Append( - dist_->GetStartMenuShortcutSubfolder( + fake_common_start_menu_.path().Append(shortcut_name); + system_start_menu_subdir_shortcut_ = + fake_common_start_menu_.path() + .Append(dist_->GetStartMenuShortcutSubfolder( BrowserDistribution::SUBFOLDER_CHROME)) - .Append(shortcut_name); + .Append(shortcut_name); user_alternate_desktop_shortcut_ = fake_user_desktop_.path().Append(alternate_shortcut_name); } @@ -145,7 +148,9 @@ class InstallShortcutTest : public testing::Test { // Try to unpin potentially pinned shortcuts (although pinning isn't tested, // the call itself might still have pinned the Start Menu shortcuts). base::win::UnpinShortcutFromTaskbar(user_start_menu_shortcut_); + base::win::UnpinShortcutFromTaskbar(user_start_menu_subdir_shortcut_); base::win::UnpinShortcutFromTaskbar(system_start_menu_shortcut_); + base::win::UnpinShortcutFromTaskbar(system_start_menu_subdir_shortcut_); CoUninitialize(); } @@ -200,8 +205,10 @@ class InstallShortcutTest : public testing::Test { base::FilePath user_desktop_shortcut_; base::FilePath user_quick_launch_shortcut_; base::FilePath user_start_menu_shortcut_; + base::FilePath user_start_menu_subdir_shortcut_; base::FilePath system_desktop_shortcut_; base::FilePath system_start_menu_shortcut_; + base::FilePath system_start_menu_subdir_shortcut_; base::FilePath user_alternate_desktop_shortcut_; }; @@ -375,6 +382,69 @@ TEST_F(InstallShortcutTest, ReplaceExisting) { ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_)); } +class MigrateShortcutTest : public InstallShortcutTest, + public testing::WithParamInterface< + testing::tuple< + installer::InstallShortcutOperation, + installer::InstallShortcutLevel>> { + public: + MigrateShortcutTest() : shortcut_operation_(testing::get<0>(GetParam())), + shortcut_level_(testing::get<1>(GetParam())) {} + + protected: + const installer::InstallShortcutOperation shortcut_operation_; + const installer::InstallShortcutLevel shortcut_level_; + + private: + DISALLOW_COPY_AND_ASSIGN(MigrateShortcutTest); +}; + +TEST_P(MigrateShortcutTest, MigrateAwayFromDeprecatedStartMenuTest) { + base::win::ShortcutProperties dummy_properties; + base::FilePath dummy_target; + ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target)); + dummy_properties.set_target(expected_properties_.target); + dummy_properties.set_working_dir(fake_user_desktop_.path()); + dummy_properties.set_arguments(L"--dummy --args"); + dummy_properties.set_app_id(L"El.Dummiest"); + + base::FilePath start_menu_shortcut; + base::FilePath start_menu_subdir_shortcut; + if (shortcut_level_ == installer::CURRENT_USER) { + start_menu_shortcut = user_start_menu_shortcut_; + start_menu_subdir_shortcut = user_start_menu_subdir_shortcut_; + } else { + start_menu_shortcut = system_start_menu_shortcut_; + start_menu_subdir_shortcut = system_start_menu_subdir_shortcut_; + } + + ASSERT_TRUE(base::CreateDirectory(start_menu_subdir_shortcut.DirName())); + ASSERT_FALSE(base::PathExists(start_menu_subdir_shortcut)); + ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( + start_menu_subdir_shortcut, dummy_properties, + base::win::SHORTCUT_CREATE_ALWAYS)); + ASSERT_TRUE(base::PathExists(start_menu_subdir_shortcut)); + ASSERT_FALSE(base::PathExists(start_menu_shortcut)); + + installer::CreateOrUpdateShortcuts(chrome_exe_, *product_, *prefs_, + shortcut_level_, shortcut_operation_); + ASSERT_FALSE(base::PathExists(start_menu_subdir_shortcut)); + ASSERT_TRUE(base::PathExists(start_menu_shortcut)); +} + +// Verify that any installer operation for any installation level triggers +// the migration from sub-folder to root of start-menu. +INSTANTIATE_TEST_CASE_P( + MigrateShortcutTests, MigrateShortcutTest, + testing::Combine( + testing::Values( + installer::INSTALL_SHORTCUT_REPLACE_EXISTING, + installer::INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL, + installer::INSTALL_SHORTCUT_CREATE_ALL), + testing::Values( + installer::CURRENT_USER, + installer::ALL_USERS))); + TEST_F(InstallShortcutTest, CreateIfNoSystemLevelAllSystemShortcutsExist) { base::win::ShortcutProperties dummy_properties; base::FilePath dummy_target; |