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

Unified Diff: base/win/shortcut_unittest.cc

Issue 108193019: Installer: adding ResolveShortcutProperties(); updating shortcut icons during shortcut migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing path comparison in ShortcutTest. Created 6 years, 11 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: base/win/shortcut_unittest.cc
diff --git a/base/win/shortcut_unittest.cc b/base/win/shortcut_unittest.cc
index eaf152eb9dcbd328716cf71a1aab5e63074c4d81..2247eceee98fabac381b890679daa0e904da201a 100644
--- a/base/win/shortcut_unittest.cc
+++ b/base/win/shortcut_unittest.cc
@@ -12,6 +12,7 @@
#include "base/test/test_file_util.h"
#include "base/test/test_shortcut_win.h"
#include "base/win/scoped_com_initializer.h"
+#include "base/win/windows_version.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base {
@@ -80,6 +81,61 @@ class ShortcutTest : public testing::Test {
} // namespace
+TEST_F(ShortcutTest, CreateAndResolveShortcutProperties) {
+ uint32 valid_properties = ShortcutProperties::PROPERTIES_BASIC;
+ if (GetVersion() >= VERSION_WIN7)
+ valid_properties |= ShortcutProperties::PROPERTIES_WIN7;
+
+ // Test all properties.
+ FilePath file_1(temp_dir_.path().Append(L"Link1.lnk"));
+ ASSERT_TRUE(CreateOrUpdateShortcutLink(
+ file_1, link_properties_, SHORTCUT_CREATE_ALWAYS));
+
+ ShortcutProperties properties_read_1;
+ ASSERT_TRUE(ResolveShortcutProperties(
+ file_1, ShortcutProperties::PROPERTIES_ALL, &properties_read_1));
+ EXPECT_EQ(link_properties_.options, valid_properties);
+ EXPECT_TRUE(FilePath::CompareEqualIgnoreCase(
+ link_properties_.target.value(), properties_read_1.target.value()));
+ EXPECT_TRUE(FilePath::CompareEqualIgnoreCase(
+ link_properties_.working_dir.value(),
+ properties_read_1.working_dir.value()));
+ EXPECT_EQ(link_properties_.arguments, properties_read_1.arguments);
+ EXPECT_EQ(link_properties_.description, properties_read_1.description);
+ EXPECT_TRUE(FilePath::CompareEqualIgnoreCase(
+ link_properties_.icon.value(), properties_read_1.icon.value()));
+ EXPECT_EQ(link_properties_.icon_index, properties_read_1.icon_index);
+ if (GetVersion() >= VERSION_WIN7) {
+ EXPECT_EQ(link_properties_.app_id, properties_read_1.app_id);
+ EXPECT_EQ(link_properties_.dual_mode, properties_read_1.dual_mode);
+ }
+
+ // Test simple shortcut with no special properties set.
+ FilePath file_2(temp_dir_.path().Append(L"Link2.lnk"));
+ ShortcutProperties only_target_properties;
+ only_target_properties.set_target(link_properties_.target);
+ ASSERT_TRUE(CreateOrUpdateShortcutLink(
+ file_2, only_target_properties, SHORTCUT_CREATE_ALWAYS));
+
+ ShortcutProperties properties_read_2;
+ ASSERT_TRUE(ResolveShortcutProperties(
+ file_2, ShortcutProperties::PROPERTIES_ALL, &properties_read_2));
+ EXPECT_EQ(valid_properties, properties_read_2.options);
+ EXPECT_TRUE(FilePath::CompareEqualIgnoreCase(
+ only_target_properties.target.value(), properties_read_2.target.value()));
+ EXPECT_TRUE(FilePath::CompareEqualIgnoreCase(
+ FilePath().value(), properties_read_2.working_dir.value()));
+ EXPECT_EQ(L"", properties_read_2.arguments);
+ EXPECT_EQ(L"", properties_read_2.description);
+ EXPECT_TRUE(FilePath::CompareEqualIgnoreCase(
+ FilePath().value(), properties_read_2.icon.value()));
+ EXPECT_EQ(0, properties_read_2.icon_index);
+ if (GetVersion() >= VERSION_WIN7) {
+ EXPECT_EQ(L"", properties_read_2.app_id);
+ EXPECT_FALSE(properties_read_2.dual_mode);
+ }
+}
+
TEST_F(ShortcutTest, CreateAndResolveShortcut) {
ShortcutProperties only_target_properties;
only_target_properties.set_target(link_properties_.target);

Powered by Google App Engine
This is Rietveld 408576698