summaryrefslogtreecommitdiffstats
path: root/base/win/shortcut_unittest.cc
diff options
context:
space:
mode:
authorgab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-03 20:57:36 +0000
committergab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-03 20:57:36 +0000
commitffd6f26f00d35d389ec660ca7eafc47549dcedc7 (patch)
tree285f71f66181a0646ba8aef5a46fe809029ced4c /base/win/shortcut_unittest.cc
parent16580b7aeaeab7ace066588912aead634ea0c1af (diff)
downloadchromium_src-ffd6f26f00d35d389ec660ca7eafc47549dcedc7.zip
chromium_src-ffd6f26f00d35d389ec660ca7eafc47549dcedc7.tar.gz
chromium_src-ffd6f26f00d35d389ec660ca7eafc47549dcedc7.tar.bz2
[Fixit-Dec-2012] Keep old shortcut's arguments when replacing an existing shortcut and not specifying any arguments for the new shortcut.
R=robertshield@chromium.org BUG=146471 TEST=base_unittests --gtest_filter=ShortcutTest.* (hard to test locally as an over-install of the same version triggers a repair install which uses SHORTCUT_CREATE_ALWAYS -- I'll setup an old dev-channel and wait for it to autoupdate to the new one once this lands...). Review URL: https://chromiumcodereview.appspot.com/11740014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175008 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/win/shortcut_unittest.cc')
-rw-r--r--base/win/shortcut_unittest.cc27
1 files changed, 22 insertions, 5 deletions
diff --git a/base/win/shortcut_unittest.cc b/base/win/shortcut_unittest.cc
index 26b22be..70cc852 100644
--- a/base/win/shortcut_unittest.cc
+++ b/base/win/shortcut_unittest.cc
@@ -212,7 +212,7 @@ TEST_F(ShortcutTest, FailUpdateShortcutThatDoesNotExist) {
ASSERT_FALSE(file_util::PathExists(link_file_));
}
-TEST_F(ShortcutTest, TruncateShortcutAllProperties) {
+TEST_F(ShortcutTest, ReplaceShortcutAllProperties) {
ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
link_file_, link_properties_, base::win::SHORTCUT_CREATE_ALWAYS));
@@ -222,29 +222,46 @@ TEST_F(ShortcutTest, TruncateShortcutAllProperties) {
base::win::ValidateShortcut(link_file_, link_properties_2_);
}
-TEST_F(ShortcutTest, TruncateShortcutSomeProperties) {
+TEST_F(ShortcutTest, ReplaceShortcutSomeProperties) {
ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
link_file_, link_properties_, base::win::SHORTCUT_CREATE_ALWAYS));
base::win::ShortcutProperties new_properties;
new_properties.set_target(link_properties_2_.target);
+ new_properties.set_arguments(link_properties_2_.arguments);
new_properties.set_description(link_properties_2_.description);
ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
link_file_, new_properties, base::win::SHORTCUT_REPLACE_EXISTING));
// Expect only properties in |new_properties| to be set, all other properties
// should have been overwritten.
- base::win::ShortcutProperties expected_properties = new_properties;
+ base::win::ShortcutProperties expected_properties(new_properties);
expected_properties.set_working_dir(FilePath());
- expected_properties.set_arguments(string16());
expected_properties.set_icon(FilePath(), 0);
expected_properties.set_app_id(string16());
expected_properties.set_dual_mode(false);
base::win::ValidateShortcut(link_file_, expected_properties);
}
-TEST_F(ShortcutTest, FailTruncateShortcutThatDoesNotExist) {
+TEST_F(ShortcutTest, FailReplaceShortcutThatDoesNotExist) {
ASSERT_FALSE(base::win::CreateOrUpdateShortcutLink(
link_file_, link_properties_, base::win::SHORTCUT_REPLACE_EXISTING));
ASSERT_FALSE(file_util::PathExists(link_file_));
}
+
+// Test that the old arguments remain on the replaced shortcut when not
+// otherwise specified.
+TEST_F(ShortcutTest, ReplaceShortcutKeepOldArguments) {
+ ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
+ link_file_, link_properties_, base::win::SHORTCUT_CREATE_ALWAYS));
+
+ // Do not explicitly set the arguments.
+ link_properties_2_.options &=
+ ~base::win::ShortcutProperties::PROPERTIES_ARGUMENTS;
+ ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
+ link_file_, link_properties_2_, base::win::SHORTCUT_REPLACE_EXISTING));
+
+ base::win::ShortcutProperties expected_properties(link_properties_2_);
+ expected_properties.set_arguments(link_properties_.arguments);
+ base::win::ValidateShortcut(link_file_, expected_properties);
+}