Commit dad8147d authored by David Bienvenu's avatar David Bienvenu Committed by Commit Bot

Make shortcut target file name comparison case-insensitive.

When running ShellIntegrationWinMigrateShortcutTest.*, I got errors
because the shortcut target path was all lower-case, but the passed-in
target was mixed-case. I'm not sure why this was, but the file name
comparisons should be case-insensitive anyway.

Change-Id: I857b1c78030a8278507b19071c3ac765b20f1f5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2284086Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#785730}
parent 987446ef
...@@ -45,7 +45,8 @@ void ValidatePathsAreEqual(const FilePath& expected_path, ...@@ -45,7 +45,8 @@ void ValidatePathsAreEqual(const FilePath& expected_path,
EXPECT_FALSE(long_expected_path.empty()); EXPECT_FALSE(long_expected_path.empty());
EXPECT_FALSE(long_actual_path.empty()); EXPECT_FALSE(long_actual_path.empty());
EXPECT_EQ(long_expected_path, long_actual_path); EXPECT_TRUE(base::FilePath::CompareEqualIgnoreCase(long_expected_path.value(),
long_actual_path.value()));
} }
void ValidateShortcut(const FilePath& shortcut_path, void ValidateShortcut(const FilePath& shortcut_path,
......
...@@ -813,7 +813,8 @@ int MigrateShortcutsInPathInternal(const base::FilePath& chrome_exe, ...@@ -813,7 +813,8 @@ int MigrateShortcutsInPathInternal(const base::FilePath& chrome_exe,
// TODO(gab): Use ProgramCompare instead of comparing FilePaths below once // TODO(gab): Use ProgramCompare instead of comparing FilePaths below once
// it is fixed to work with FilePaths with spaces. // it is fixed to work with FilePaths with spaces.
if (!base::win::ResolveShortcut(shortcut, &target_path, &arguments) || if (!base::win::ResolveShortcut(shortcut, &target_path, &arguments) ||
chrome_exe != target_path) { !base::FilePath::CompareEqualIgnoreCase(chrome_exe.value(),
target_path.value())) {
continue; continue;
} }
base::CommandLine command_line( base::CommandLine command_line(
......
...@@ -332,6 +332,24 @@ TEST_F(ShellIntegrationWinMigrateShortcutTest, MigrateChromeProxyTest) { ...@@ -332,6 +332,24 @@ TEST_F(ShellIntegrationWinMigrateShortcutTest, MigrateChromeProxyTest) {
base::win::ValidateShortcut(shortcuts_[1].path, shortcuts_[1].properties); base::win::ValidateShortcut(shortcuts_[1].path, shortcuts_[1].properties);
} }
// This test verifies that MigrateTaskbarPins does a case-insensitive
// comparison when comparing the shortcut target with the chrome exe path.
TEST_F(ShellIntegrationWinMigrateShortcutTest, MigrateMixedCaseDirTest) {
base::win::ShortcutProperties temp_properties;
base::FilePath chrome_proxy_path(web_app::GetChromeProxyPath());
ASSERT_EQ(chrome_proxy_path.Extension(), FILE_PATH_LITERAL(".exe"));
temp_properties.set_target(
chrome_proxy_path.ReplaceExtension(FILE_PATH_LITERAL("EXE")));
temp_properties.set_app_id(L"Dumbo.Default");
ASSERT_NO_FATAL_FAILURE(
AddTestShortcutAndResetProperties(temp_dir_.GetPath(), &temp_properties));
MigrateTaskbarPinsCallback(temp_dir_.GetPath(), temp_dir_.GetPath());
// Verify that the shortcut was migrated, i.e., its app_id does not contain
// the default profile name.
shortcuts_[0].properties.set_app_id(chrome_app_id_);
base::win::ValidateShortcut(shortcuts_[0].path, shortcuts_[0].properties);
}
TEST(ShellIntegrationWinTest, GetAppModelIdForProfileTest) { TEST(ShellIntegrationWinTest, GetAppModelIdForProfileTest) {
const base::string16 base_app_id(install_static::GetBaseAppId()); const base::string16 base_app_id(install_static::GetBaseAppId());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment