summaryrefslogtreecommitdiffstats
path: root/chrome/installer/util/shell_util_unittest.cc
diff options
context:
space:
mode:
authorvasilii@chromium.org <vasilii@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-23 22:30:48 +0000
committervasilii@chromium.org <vasilii@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-23 22:30:48 +0000
commitf975324b71314a4c1766fe6e8ce4d811dad262d4 (patch)
tree13e45b14f92f6745c7e480c3a4e65c99a092995f /chrome/installer/util/shell_util_unittest.cc
parent01af2638cc5bc285f3fad3ec5b22714dcf890032 (diff)
downloadchromium_src-f975324b71314a4c1766fe6e8ce4d811dad262d4.zip
chromium_src-f975324b71314a4c1766fe6e8ce4d811dad262d4.tar.gz
chromium_src-f975324b71314a4c1766fe6e8ce4d811dad262d4.tar.bz2
This is a modified https://codereview.chromium.org/116143003/. The original patch was reverted (https://codereview.chromium.org/134873009) because enumerating shortcuts on the FILE thread was a huge task and it wasn't cancelled on browser shutdown. Now it's cancelable. The task is cancelled if the corresponding ResettableSettingsSnapshot destroyed. It happens if user closes chrome://settings tab.
BUG=324931 TBR=jyasskin@chromium.org Review URL: https://codereview.chromium.org/137533010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246705 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/shell_util_unittest.cc')
-rw-r--r--chrome/installer/util/shell_util_unittest.cc95
1 files changed, 95 insertions, 0 deletions
diff --git a/chrome/installer/util/shell_util_unittest.cc b/chrome/installer/util/shell_util_unittest.cc
index 76ed7de5..20d23b5 100644
--- a/chrome/installer/util/shell_util_unittest.cc
+++ b/chrome/installer/util/shell_util_unittest.cc
@@ -590,6 +590,101 @@ TEST_F(ShellUtilShortcutTest, RetargetChromeShortcutsWithArgsIcon) {
expected_properties3);
}
+TEST_F(ShellUtilShortcutTest, ClearShortcutArguments) {
+ // Shortcut 1: targets "chrome.exe"; no arguments.
+ test_properties_.set_shortcut_name(L"Chrome 1");
+ test_properties_.set_arguments(L"");
+ ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_,
+ ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS));
+ base::FilePath shortcut1_path = GetExpectedShortcutPath(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_);
+ ASSERT_TRUE(base::PathExists(shortcut1_path));
+ ShellUtil::ShortcutProperties expected_properties1(test_properties_);
+
+ // Shortcut 2: targets "chrome.exe"; has 1 whitelisted argument.
+ test_properties_.set_shortcut_name(L"Chrome 2");
+ test_properties_.set_arguments(L"--profile-directory=\"Profile 2\"");
+ ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_,
+ ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS));
+ base::FilePath shortcut2_path = GetExpectedShortcutPath(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_);
+ ASSERT_TRUE(base::PathExists(shortcut2_path));
+ ShellUtil::ShortcutProperties expected_properties2(test_properties_);
+
+ // Shortcut 3: targets "chrome.exe"; has an unknown argument.
+ test_properties_.set_shortcut_name(L"Chrome 3");
+ test_properties_.set_arguments(L"foo.com");
+ ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_,
+ ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS));
+ base::FilePath shortcut3_path = GetExpectedShortcutPath(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_);
+ ASSERT_TRUE(base::PathExists(shortcut3_path));
+ ShellUtil::ShortcutProperties expected_properties3(test_properties_);
+
+ // Shortcut 4: targets "chrome.exe"; has both unknown and known arguments.
+ test_properties_.set_shortcut_name(L"Chrome 4");
+ test_properties_.set_arguments(L"foo.com --show-app-list");
+ ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_,
+ ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS));
+ base::FilePath shortcut4_path = GetExpectedShortcutPath(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_, test_properties_);
+ ASSERT_TRUE(base::PathExists(shortcut4_path));
+ ShellUtil::ShortcutProperties expected_properties4(test_properties_);
+
+ // List the shortcuts.
+ std::vector<std::pair<base::FilePath, base::string16> > shortcuts;
+ EXPECT_TRUE(ShellUtil::ShortcutListMaybeRemoveUnknownArgs(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP,
+ dist_,
+ ShellUtil::CURRENT_USER,
+ chrome_exe_,
+ false,
+ &shortcuts));
+ ASSERT_EQ(2u, shortcuts.size());
+ std::pair<base::FilePath, base::string16> shortcut3 =
+ shortcuts[0].first == shortcut3_path ? shortcuts[0] : shortcuts[1];
+ std::pair<base::FilePath, base::string16> shortcut4 =
+ shortcuts[0].first == shortcut4_path ? shortcuts[0] : shortcuts[1];
+ EXPECT_EQ(shortcut3_path, shortcut3.first);
+ EXPECT_EQ(L"foo.com", shortcut3.second);
+ EXPECT_EQ(shortcut4_path, shortcut4.first);
+ EXPECT_EQ(L"foo.com --show-app-list", shortcut4.second);
+
+ // Clear shortcuts.
+ shortcuts.clear();
+ EXPECT_TRUE(ShellUtil::ShortcutListMaybeRemoveUnknownArgs(
+ ShellUtil::SHORTCUT_LOCATION_DESKTOP,
+ dist_,
+ ShellUtil::CURRENT_USER,
+ chrome_exe_,
+ true,
+ &shortcuts));
+ ASSERT_EQ(2u, shortcuts.size());
+ shortcut3 = shortcuts[0].first == shortcut3_path ? shortcuts[0] :
+ shortcuts[1];
+ shortcut4 = shortcuts[0].first == shortcut4_path ? shortcuts[0] :
+ shortcuts[1];
+ EXPECT_EQ(shortcut3_path, shortcut3.first);
+ EXPECT_EQ(L"foo.com", shortcut3.second);
+ EXPECT_EQ(shortcut4_path, shortcut4.first);
+ EXPECT_EQ(L"foo.com --show-app-list", shortcut4.second);
+
+ ValidateChromeShortcut(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_,
+ expected_properties1);
+ ValidateChromeShortcut(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_,
+ expected_properties2);
+ expected_properties3.set_arguments(base::string16());
+ ValidateChromeShortcut(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_,
+ expected_properties3);
+ expected_properties4.set_arguments(L"--show-app-list");
+ ValidateChromeShortcut(ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist_,
+ expected_properties4);
+}
+
TEST_F(ShellUtilShortcutTest, CreateMultipleStartMenuShortcutsAndRemoveFolder) {
ASSERT_TRUE(ShellUtil::CreateOrUpdateShortcut(
ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR,