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

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

Issue 2456853002: Remove shortcut path fixups introduced to repair breakages caused by r378802. (Closed)
Patch Set: Created 4 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/util/install_util.h » ('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 a97f20eeea31baf2d4d299fdb9acbeae9211dd68..c9667854595f15629d8ff2b8c2516981fb70a3d2 100644
--- a/chrome/installer/setup/install_unittest.cc
+++ b/chrome/installer/setup/install_unittest.cc
@@ -15,9 +15,7 @@
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
-#include "base/path_service.h"
#include "base/strings/string16.h"
-#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_path_override.h"
#include "base/test/test_shortcut_win.h"
@@ -37,12 +35,6 @@
namespace {
-base::FilePath GetNormalizedFilePath(const base::FilePath& path) {
- base::FilePath normalized_path;
- EXPECT_TRUE(base::NormalizeFilePath(path, &normalized_path));
- return normalized_path;
-}
-
class CreateVisualElementsManifestTest : public testing::Test {
protected:
void SetUp() override {
@@ -78,19 +70,6 @@ class CreateVisualElementsManifestTest : public testing::Test {
class InstallShortcutTest : public testing::Test {
protected:
- struct UpdateShortcutsTestCase {
- // Shortcut target path, relative to |temp_dir_|.
- const base::FilePath::CharType* target_path;
-
- // Shortcut icon path, relative to |temp_dir_|. Can be null to create a
- // shortcut without an icon.
- const base::FilePath::CharType* icon_path;
-
- // Whether the shortcut's target path should be updated by
- // UpdatePerUserShortcutsInLocation().
- bool should_update;
- };
-
void SetUp() override {
EXPECT_EQ(S_OK, CoInitialize(NULL));
@@ -190,67 +169,6 @@ class InstallShortcutTest : public testing::Test {
return new installer::MasterPreferences(master_prefs);
}
- // Creates the shortcuts defined by |test_cases|. Tries to update the target
- // path of these shortcuts to |new_target_path_relative| using
- // UpdatePerUserShortcutsInLocation(). Verifies that the right shortcuts have
- // been updated.
- void TestUpdateShortcuts(const UpdateShortcutsTestCase* test_cases,
- size_t num_test_cases,
- const base::FilePath& new_target_path_relative) {
- // Create shortcuts.
- for (size_t i = 0; i < num_test_cases; ++i) {
- // Make sure that the target exists.
- const base::FilePath target_path =
- temp_dir_.GetPath().Append(test_cases[i].target_path);
- if (!base::PathExists(target_path)) {
- ASSERT_TRUE(base::CreateDirectory(target_path.DirName()));
- base::File file(target_path, base::File::FLAG_CREATE_ALWAYS |
- base::File::FLAG_WRITE);
- ASSERT_TRUE(file.IsValid());
- static const char kDummyData[] = "dummy";
- ASSERT_EQ(arraysize(kDummyData),
- static_cast<size_t>(file.WriteAtCurrentPos(
- kDummyData, arraysize(kDummyData))));
- }
-
- // Create the shortcut.
- base::win::ShortcutProperties properties;
- properties.set_target(target_path);
- properties.set_icon(temp_dir_.GetPath().Append(test_cases[i].icon_path),
- 1);
- ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
- user_desktop_shortcut_.InsertBeforeExtension(
- base::SizeTToString16(i)),
- properties, base::win::SHORTCUT_CREATE_ALWAYS));
- }
-
- // Update shortcuts.
- const base::FilePath new_target_path =
- temp_dir_.GetPath().Append(new_target_path_relative);
- installer::UpdatePerUserShortcutsInLocation(
- ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_,
- new_target_path.DirName().DirName(), new_target_path.BaseName(),
- new_target_path);
-
- // Verify that shortcuts were updated correctly.
- for (size_t i = 0; i < num_test_cases; ++i) {
- base::FilePath target_path;
- ASSERT_TRUE(base::win::ResolveShortcut(
- user_desktop_shortcut_.InsertBeforeExtension(
- base::SizeTToString16(i)),
- &target_path, nullptr));
-
- if (test_cases[i].should_update) {
- EXPECT_EQ(GetNormalizedFilePath(new_target_path),
- GetNormalizedFilePath(target_path));
- } else {
- EXPECT_EQ(GetNormalizedFilePath(
- temp_dir_.GetPath().Append(test_cases[i].target_path)),
- GetNormalizedFilePath(target_path));
- }
- }
- }
-
base::win::ShortcutProperties expected_properties_;
base::win::ShortcutProperties expected_start_menu_properties_;
@@ -541,273 +459,6 @@ TEST_F(InstallShortcutTest, CreateIfNoSystemLevelSomeSystemShortcutsExist) {
expected_start_menu_properties_);
}
-TEST_F(InstallShortcutTest, UpdatePerUserChromeUserLevelShortcuts) {
- static const UpdateShortcutsTestCase kTestCases[] = {
- // Shortcut target in the Chrome Canary install directory. No icon.
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Temp\\scoped_dir\\new_chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Temp\\scoped_dir\\chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Application\\chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Application\\something_else.exe"),
- nullptr, false},
-
- // Shortcut target in the user-level Chrome install directory. No icon.
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Temp\\scope"
- "d_dir\\new_chrome.exe"),
- nullptr, true},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Temp\\scope"
- "d_dir\\chrome.exe"),
- nullptr, true},
- {FILE_PATH_LITERAL(
- "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
- nullptr, true},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Application"
- "\\something_else.exe"),
- nullptr, false},
-
- // Shortcut target in the system-level Chrome install directory. No icon.
- {FILE_PATH_LITERAL("Program Files "
- "(x86)\\Google\\Chrome\\Temp\\scoped_dir\\new_chrome."
- "exe"),
- nullptr, false},
- {FILE_PATH_LITERAL(
- "Program Files (x86)\\Google\\Chrome\\Temp\\scoped_dir\\chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL(
- "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL("Program Files "
- "(x86)\\Google\\Chrome\\Application\\something_else."
- "exe"),
- nullptr, false},
-
- // Dummy shortcut target. Icon in the Chrome Canary install directory.
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Application\\chrome.exe"),
- false},
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Application\\User Data\\Profile 1\\Google "
- "Profile.ico"),
- false},
-
- // Dummy shortcut target. Icon in the user-level Chrome install directory.
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL(
- "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
- true},
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL(
- "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\User "
- "Data\\Profile 1\\Google Profile.ico"),
- true},
-
- // Dummy shortcut target. Icon in the system-level Chrome install
- // directory.
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL(
- "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"),
- false},
-
- // Shortcuts that don't belong to Chrome.
- {FILE_PATH_LITERAL("something_else.exe"), nullptr, false},
- {FILE_PATH_LITERAL("something_else.exe"),
- FILE_PATH_LITERAL(
- "Users\\x\\AppData\\Local\\Google\\Something Else.ico"),
- false},
- };
-
- TestUpdateShortcuts(
- kTestCases, arraysize(kTestCases),
- base::FilePath(FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrom"
- "e\\Application\\chrome.exe")));
-}
-
-TEST_F(InstallShortcutTest, UpdatePerUserCanaryShortcuts) {
- static const UpdateShortcutsTestCase kTestCases[] = {
- // Shortcut target in the Chrome Canary install directory. No icon.
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Temp\\scoped_dir\\new_chrome.exe"),
- nullptr, true},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Temp\\scoped_dir\\chrome.exe"),
- nullptr, true},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Application\\chrome.exe"),
- nullptr, true},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Application\\something_else.exe"),
- nullptr, false},
-
- // Shortcut target in the user-level Chrome install directory. No icon.
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Temp\\scope"
- "d_dir\\new_chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Temp\\scope"
- "d_dir\\chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL(
- "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Application"
- "\\something_else.exe"),
- nullptr, false},
-
- // Shortcut target in the system-level Chrome install directory. No icon.
- {FILE_PATH_LITERAL("Program Files "
- "(x86)\\Google\\Chrome\\Temp\\scoped_dir\\new_chrome."
- "exe"),
- nullptr, false},
- {FILE_PATH_LITERAL(
- "Program Files (x86)\\Google\\Chrome\\Temp\\scoped_dir\\chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL(
- "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL("Program Files "
- "(x86)\\Google\\Chrome\\Application\\something_else."
- "exe"),
- nullptr, false},
-
- // Dummy shortcut target. Icon in the Chrome Canary install directory.
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Application\\chrome.exe"),
- true},
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Application\\User Data\\Profile 1\\Google "
- "Profile.ico"),
- true},
-
- // Dummy shortcut target. Icon in the user-level Chrome install directory.
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL(
- "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
- false},
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL(
- "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\User "
- "Data\\Profile 1\\Google Profile.ico"),
- false},
-
- // Dummy shortcut target. Icon in the system-level Chrome install
- // directory.
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL(
- "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"),
- false},
-
- // Shortcuts that don't belong to Chrome.
- {FILE_PATH_LITERAL("something_else.exe"), nullptr, false},
- {FILE_PATH_LITERAL("something_else.exe"),
- FILE_PATH_LITERAL(
- "Users\\x\\AppData\\Local\\Google\\Something Else.ico"),
- false},
- };
-
- TestUpdateShortcuts(
- kTestCases, arraysize(kTestCases),
- base::FilePath(FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrom"
- "e SxS\\Application\\chrome.exe")));
-}
-
-TEST_F(InstallShortcutTest, UpdatePerUserChromeSystemLevelShortcuts) {
- static const UpdateShortcutsTestCase kTestCases[] = {
- // Shortcut target in the Chrome Canary install directory. No icon.
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Temp\\scoped_dir\\new_chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Temp\\scoped_dir\\chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Application\\chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Application\\something_else.exe"),
- nullptr, false},
-
- // Shortcut target in the user-level Chrome install directory. No icon.
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Temp\\scope"
- "d_dir\\new_chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Temp\\scope"
- "d_dir\\chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL(
- "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
- nullptr, false},
- {FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome\\Application"
- "\\something_else.exe"),
- nullptr, false},
-
- // Shortcut target in the system-level Chrome install directory. No icon.
- {FILE_PATH_LITERAL("Program Files "
- "(x86)\\Google\\Chrome\\Temp\\scoped_dir\\new_chrome."
- "exe"),
- nullptr, true},
- {FILE_PATH_LITERAL(
- "Program Files (x86)\\Google\\Chrome\\Temp\\scoped_dir\\chrome.exe"),
- nullptr, true},
- {FILE_PATH_LITERAL(
- "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"),
- nullptr, true},
- {FILE_PATH_LITERAL("Program Files "
- "(x86)\\Google\\Chrome\\Application\\something_else."
- "exe"),
- nullptr, false},
-
- // Dummy shortcut target. Icon in the Chrome Canary install directory.
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Application\\chrome.exe"),
- false},
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL("Users\\x\\AppData\\Local\\Google\\Chrome "
- "SxS\\Application\\User Data\\Profile 1\\Google "
- "Profile.ico"),
- false},
-
- // Dummy shortcut target. Icon in the user-level Chrome install directory.
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL(
- "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
- false},
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL(
- "Users\\x\\AppData\\Local\\Google\\Chrome\\Application\\User "
- "Data\\Profile 1\\Google Profile.ico"),
- false},
-
- // Dummy shortcut target. Icon in the system-level Chrome install
- // directory.
- {FILE_PATH_LITERAL("dummy.exe"),
- FILE_PATH_LITERAL(
- "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"),
- true},
-
- // Shortcuts that don't belong to Chrome.
- {FILE_PATH_LITERAL("something_else.exe"), nullptr, false},
- {FILE_PATH_LITERAL("something_else.exe"),
- FILE_PATH_LITERAL(
- "Users\\x\\AppData\\Local\\Google\\Something Else.ico"),
- false},
- };
-
- TestUpdateShortcuts(
- kTestCases, arraysize(kTestCases),
- base::FilePath(FILE_PATH_LITERAL(
- "Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe")));
-}
-
TEST(EscapeXmlAttributeValueTest, EscapeCrazyValue) {
base::string16 val(L"This has 'crazy' \"chars\" && < and > signs.");
static const wchar_t kExpectedEscapedVal[] =
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | chrome/installer/util/install_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698