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

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: addressed review comments; re-ordered some params 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
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0538669934625b989bba5d088daa05176eb529d3 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))
@@ -147,7 +151,9 @@ class InstallShortcutTest : public testing::Test {
base::win::UnpinShortcutFromTaskbar(user_start_menu_shortcut_);
base::win::UnpinShortcutFromTaskbar(system_start_menu_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_);
gab 2015/10/15 18:55:06 Also need to add matching UnpinShortcutFromTaskbar
bcwhite 2015/10/15 20:12:19 Done.
CoUninitialize();
}
@@ -202,8 +208,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 +385,68 @@ TEST_F(InstallShortcutTest, ReplaceExisting) {
ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_));
}
+struct ShortcutParams {
+ installer::InstallShortcutOperation operation;
+ installer::InstallShortcutLevel level;
+
+ ShortcutParams(
gab 2015/10/15 18:55:06 Constructor goes before members (https://google-st
bcwhite 2015/10/15 20:12:19 Done.
+ installer::InstallShortcutOperation op,
+ installer::InstallShortcutLevel lev)
+ : operation(op), level(lev) {}
+};
+
+class MigrateShortcutTest : public InstallShortcutTest,
+ public testing::WithParamInterface<
+ ShortcutParams> {
+};
+
+TEST_P(MigrateShortcutTest, MigrateAwayFromDeprecatedStartMenuTest) {
+ installer::InstallShortcutOperation shortcut_operation = GetParam().operation;
+ installer::InstallShortcutLevel shortcut_level = GetParam().level;
+ 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));
+}
+
+INSTANTIATE_TEST_CASE_P(
gab 2015/10/15 18:55:06 Add a comment like: // Verify that any installer
bcwhite 2015/10/15 20:12:19 Done.
+ MigrateShortcutTests, MigrateShortcutTest,
+ testing::Values(ShortcutParams(installer::INSTALL_SHORTCUT_REPLACE_EXISTING,
+ installer::CURRENT_USER),
+ ShortcutParams(installer::INSTALL_SHORTCUT_CREATE_ALL,
+ installer::CURRENT_USER),
+ ShortcutParams(installer::INSTALL_SHORTCUT_REPLACE_EXISTING,
+ installer::ALL_USERS),
+ ShortcutParams(installer::INSTALL_SHORTCUT_CREATE_ALL,
gab 2015/10/15 18:55:06 Instead of using a custom struct, make your test a
bcwhite 2015/10/15 20:12:19 Nice. Done.
+ installer::ALL_USERS)));
+
TEST_F(InstallShortcutTest, CreateIfNoSystemLevelAllSystemShortcutsExist) {
base::win::ShortcutProperties dummy_properties;
base::FilePath dummy_target;
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698