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

Unified Diff: chrome/installer/setup/install_unittest.cc

Issue 1289333005: Change shortcut install location to non-subdir. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test improvements Created 5 years, 2 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
Index: chrome/installer/setup/install_unittest.cc
diff --git a/chrome/installer/setup/install_unittest.cc b/chrome/installer/setup/install_unittest.cc
index dc9f5d1c2197cc8299f19ba2e3a4c53ecdf33577..8b9f390bbbe283f6a113e16725985940e85290cf 100644
--- a/chrome/installer/setup/install_unittest.cc
+++ b/chrome/installer/setup/install_unittest.cc
@@ -126,6 +126,8 @@ class InstallShortcutTest : public testing::Test {
user_quick_launch_shortcut_ =
fake_user_quick_launch_.path().Append(shortcut_name);
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))
@@ -133,6 +135,8 @@ class InstallShortcutTest : public testing::Test {
system_desktop_shortcut_ =
fake_common_desktop_.path().Append(shortcut_name);
system_start_menu_shortcut_ =
+ fake_common_start_menu_.path().Append(shortcut_name);
+ system_start_menu_subdir_shortcut_ =
fake_common_start_menu_.path().Append(
dist_->GetStartMenuShortcutSubfolder(
BrowserDistribution::SUBFOLDER_CHROME))
@@ -145,9 +149,13 @@ 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_);
base::win::UnpinShortcutFromStart(user_start_menu_shortcut_);
+ base::win::UnpinShortcutFromStart(user_start_menu_subdir_shortcut_);
base::win::UnpinShortcutFromStart(system_start_menu_shortcut_);
+ base::win::UnpinShortcutFromStart(system_start_menu_subdir_shortcut_);
CoUninitialize();
}
@@ -202,8 +210,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_;
};
@@ -377,6 +387,65 @@ TEST_F(InstallShortcutTest, ReplaceExisting) {
ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_));
}
+class MigrateShortcutTest : public InstallShortcutTest,
+ public testing::WithParamInterface<
+ std::tr1::tuple<
grt (UTC plus 2) 2015/10/19 17:28:45 nit: use testing::tuple and testing::get<> rather
bcwhite 2015/10/20 16:02:13 Done.
+ installer::InstallShortcutOperation,
+ installer::InstallShortcutLevel>> {
+};
+
+TEST_P(MigrateShortcutTest, MigrateAwayFromDeprecatedStartMenuTest) {
+ installer::InstallShortcutOperation shortcut_operation =
+ std::tr1::get<0>(GetParam());
+ installer::InstallShortcutLevel shortcut_level =
+ std::tr1::get<1>(GetParam());
gab 2015/10/19 18:00:14 Make |shortcut_operation_| and |shortcut_level_| p
bcwhite 2015/10/20 16:02:13 Done.
+
+ 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;

Powered by Google App Engine
This is Rietveld 408576698