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

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

Issue 1803383002: Don't update Canary shortcuts from Dev/Beta/Stable installer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« chrome/installer/setup/install.h ('K') | « chrome/installer/setup/install.cc ('k') | no next file » | 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 3f2a75d74ebdd418e0b357fee7436f6592271bae..1a8f5d7163c367d63ce2f8e26fcf258037d77e4d 100644
--- a/chrome/installer/setup/install_unittest.cc
+++ b/chrome/installer/setup/install_unittest.cc
@@ -14,6 +14,7 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.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"
@@ -459,6 +460,166 @@ TEST_F(InstallShortcutTest, CreateIfNoSystemLevelSomeSystemShortcutsExist) {
expected_start_menu_properties_);
}
+TEST_F(InstallShortcutTest, UpdatePerUserShortcuts) {
+ base::FilePath shortcut_path_template;
+ ASSERT_TRUE(ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_DESKTOP,
+ dist_, ShellUtil::CURRENT_USER,
+ &shortcut_path_template));
+ shortcut_path_template =
+ shortcut_path_template.Append(FILE_PATH_LITERAL("shortcut.lnk"));
gab 2016/03/16 21:57:31 You can use the fixture's |user_desktop_shortcut_|
fdoray 2016/03/17 00:50:34 Done.
+
+ static const struct TestData {
gab 2016/03/16 21:57:30 s/TestData/TestCase/
fdoray 2016/03/17 00:50:34 Done.
+ const base::FilePath::CharType* relative_target_path;
+ bool should_update;
+ } kTargetPathsToUpdate[] = {
+ {FILE_PATH_LITERAL("AppData\\Local\\Google\\Chrome "
+ "SxS\\Temp\\scoped_dir\\new_chrome.exe"),
+ false},
+ {FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome SxS\\Temp\\scoped_dir\\chrome.exe"),
+ false},
+ {FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe"),
+ false},
+ {FILE_PATH_LITERAL("AppData\\Local\\Google\\Chrome "
+ "SxS\\Application\\something_else.exe"),
+ false},
+ {FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome\\Temp\\scoped_dir\\new_chrome.exe"),
+ true},
+ {FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome\\Temp\\scoped_dir\\chrome.exe"),
+ true},
+ {FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
+ true},
+ {FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome\\Application\\something_else.exe"),
+ false},
+ {FILE_PATH_LITERAL("something_else.exe"), false},
+ };
+
+ // Create shortcuts.
+ for (size_t i = 0; i < arraysize(kTargetPathsToUpdate); ++i) {
+ const base::FilePath target_path =
+ temp_dir_.path().Append(kTargetPathsToUpdate[i].relative_target_path);
+ ASSERT_TRUE(base::CreateDirectory(target_path.DirName()));
+ base::File file(target_path, base::File::FLAG_CREATE);
+ ASSERT_TRUE(file.IsValid());
+
+ base::win::ShortcutProperties properties;
+ properties.set_target(target_path);
+ ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
+ shortcut_path_template.InsertBeforeExtension(base::SizeTToString16(i)),
+ properties, base::win::SHORTCUT_CREATE_ALWAYS));
+ }
+
+ // Update shortcuts.
+ const base::FilePath new_target_path =
+ temp_dir_.path().Append(FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"));
+ installer::UpdatePerUserShortcutsInLocation(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_,
+ new_target_path.DirName().DirName(), new_target_path.BaseName(),
+ new_target_path);
+
+ // Check if shortcuts were updated correctly.
gab 2016/03/16 21:57:31 s/Check if/Verify that/
fdoray 2016/03/17 00:50:34 Done.
+ for (size_t i = 0; i < arraysize(kTargetPathsToUpdate); ++i) {
+ base::FilePath target_path;
+ ASSERT_TRUE(base::win::ResolveShortcut(
+ shortcut_path_template.InsertBeforeExtension(base::SizeTToString16(i)),
+ &target_path, nullptr));
+
+ if (kTargetPathsToUpdate[i].should_update) {
+ EXPECT_EQ(new_target_path, target_path);
+ } else {
+ EXPECT_EQ(
+ temp_dir_.path().Append(kTargetPathsToUpdate[i].relative_target_path),
+ target_path);
+ }
+ }
+}
+
+TEST_F(InstallShortcutTest, UpdatePerUserShortcutsCanary) {
+ base::FilePath shortcut_path_template;
+ ASSERT_TRUE(ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_LOCATION_DESKTOP,
+ dist_, ShellUtil::CURRENT_USER,
+ &shortcut_path_template));
+ shortcut_path_template =
+ shortcut_path_template.Append(FILE_PATH_LITERAL("shortcut.lnk"));
+
+ static const struct TestData {
+ const base::FilePath::CharType* relative_target_path;
+ bool should_update;
+ } kTargetPathsToUpdate[] = {
+ {FILE_PATH_LITERAL("AppData\\Local\\Google\\Chrome "
+ "SxS\\Temp\\scoped_dir\\new_chrome.exe"),
+ true},
+ {FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome SxS\\Temp\\scoped_dir\\chrome.exe"),
+ true},
+ {FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe"),
+ true},
+ {FILE_PATH_LITERAL("AppData\\Local\\Google\\Chrome "
+ "SxS\\Application\\something_else.exe"),
+ false},
+ {FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome\\Temp\\scoped_dir\\new_chrome.exe"),
+ false},
+ {FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome\\Temp\\scoped_dir\\chrome.exe"),
+ false},
+ {FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),
+ false},
+ {FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome\\Application\\something_else.exe"),
+ false},
+ {FILE_PATH_LITERAL("something_else.exe"), false},
+ };
+
+ // Create shortcuts.
+ for (size_t i = 0; i < arraysize(kTargetPathsToUpdate); ++i) {
+ const base::FilePath target_path =
+ temp_dir_.path().Append(kTargetPathsToUpdate[i].relative_target_path);
+ ASSERT_TRUE(base::CreateDirectory(target_path.DirName()));
+ base::File file(target_path, base::File::FLAG_CREATE);
+ ASSERT_TRUE(file.IsValid());
+
+ base::win::ShortcutProperties properties;
+ properties.set_target(target_path);
+ ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
+ shortcut_path_template.InsertBeforeExtension(base::SizeTToString16(i)),
+ properties, base::win::SHORTCUT_CREATE_ALWAYS));
+ }
+
+ // Update shortcuts.
+ const base::FilePath new_target_path =
+ temp_dir_.path().Append(FILE_PATH_LITERAL(
+ "AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe"));
+ installer::UpdatePerUserShortcutsInLocation(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_,
+ new_target_path.DirName().DirName(), new_target_path.BaseName(),
+ new_target_path);
+
+ // Check if shortcuts were updated correctly.
+ for (size_t i = 0; i < arraysize(kTargetPathsToUpdate); ++i) {
+ base::FilePath target_path;
+ ASSERT_TRUE(base::win::ResolveShortcut(
+ shortcut_path_template.InsertBeforeExtension(base::SizeTToString16(i)),
+ &target_path, nullptr));
+
+ if (kTargetPathsToUpdate[i].should_update) {
+ EXPECT_EQ(new_target_path, target_path);
+ } else {
+ EXPECT_EQ(
+ temp_dir_.path().Append(kTargetPathsToUpdate[i].relative_target_path),
+ target_path);
+ }
+ }
+}
+
TEST(EscapeXmlAttributeValueTest, EscapeCrazyValue) {
base::string16 val(L"This has 'crazy' \"chars\" && < and > signs.");
static const wchar_t kExpectedEscapedVal[] =
« chrome/installer/setup/install.h ('K') | « chrome/installer/setup/install.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698