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

Side by Side Diff: chrome/installer/setup/install_unittest.cc

Issue 1405993006: Revert of Change shortcut install location to non-subdir. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <objbase.h> 5 #include <objbase.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) + 118 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME) +
119 installer::kLnkExt); 119 installer::kLnkExt);
120 base::string16 alternate_shortcut_name( 120 base::string16 alternate_shortcut_name(
121 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME_ALTERNATE) + 121 dist_->GetShortcutName(BrowserDistribution::SHORTCUT_CHROME_ALTERNATE) +
122 installer::kLnkExt); 122 installer::kLnkExt);
123 123
124 user_desktop_shortcut_ = 124 user_desktop_shortcut_ =
125 fake_user_desktop_.path().Append(shortcut_name); 125 fake_user_desktop_.path().Append(shortcut_name);
126 user_quick_launch_shortcut_ = 126 user_quick_launch_shortcut_ =
127 fake_user_quick_launch_.path().Append(shortcut_name); 127 fake_user_quick_launch_.path().Append(shortcut_name);
128 user_start_menu_shortcut_ = fake_start_menu_.path().Append(shortcut_name); 128 user_start_menu_shortcut_ =
129 user_start_menu_subdir_shortcut_ = 129 fake_start_menu_.path().Append(
130 fake_start_menu_.path() 130 dist_->GetStartMenuShortcutSubfolder(
131 .Append(dist_->GetStartMenuShortcutSubfolder(
132 BrowserDistribution::SUBFOLDER_CHROME)) 131 BrowserDistribution::SUBFOLDER_CHROME))
133 .Append(shortcut_name); 132 .Append(shortcut_name);
134 system_desktop_shortcut_ = 133 system_desktop_shortcut_ =
135 fake_common_desktop_.path().Append(shortcut_name); 134 fake_common_desktop_.path().Append(shortcut_name);
136 system_start_menu_shortcut_ = 135 system_start_menu_shortcut_ =
137 fake_common_start_menu_.path().Append(shortcut_name); 136 fake_common_start_menu_.path().Append(
138 system_start_menu_subdir_shortcut_ = 137 dist_->GetStartMenuShortcutSubfolder(
139 fake_common_start_menu_.path()
140 .Append(dist_->GetStartMenuShortcutSubfolder(
141 BrowserDistribution::SUBFOLDER_CHROME)) 138 BrowserDistribution::SUBFOLDER_CHROME))
142 .Append(shortcut_name); 139 .Append(shortcut_name);
143 user_alternate_desktop_shortcut_ = 140 user_alternate_desktop_shortcut_ =
144 fake_user_desktop_.path().Append(alternate_shortcut_name); 141 fake_user_desktop_.path().Append(alternate_shortcut_name);
145 } 142 }
146 143
147 void TearDown() override { 144 void TearDown() override {
148 // Try to unpin potentially pinned shortcuts (although pinning isn't tested, 145 // Try to unpin potentially pinned shortcuts (although pinning isn't tested,
149 // the call itself might still have pinned the Start Menu shortcuts). 146 // the call itself might still have pinned the Start Menu shortcuts).
150 base::win::UnpinShortcutFromTaskbar(user_start_menu_shortcut_); 147 base::win::UnpinShortcutFromTaskbar(user_start_menu_shortcut_);
151 base::win::UnpinShortcutFromTaskbar(user_start_menu_subdir_shortcut_);
152 base::win::UnpinShortcutFromTaskbar(system_start_menu_shortcut_); 148 base::win::UnpinShortcutFromTaskbar(system_start_menu_shortcut_);
153 base::win::UnpinShortcutFromTaskbar(system_start_menu_subdir_shortcut_);
154 CoUninitialize(); 149 CoUninitialize();
155 } 150 }
156 151
157 installer::MasterPreferences* GetFakeMasterPrefs( 152 installer::MasterPreferences* GetFakeMasterPrefs(
158 bool do_not_create_desktop_shortcut, 153 bool do_not_create_desktop_shortcut,
159 bool do_not_create_quick_launch_shortcut, 154 bool do_not_create_quick_launch_shortcut,
160 bool alternate_desktop_shortcut) { 155 bool alternate_desktop_shortcut) {
161 const struct { 156 const struct {
162 const char* pref_name; 157 const char* pref_name;
163 bool is_desired; 158 bool is_desired;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 base::ScopedTempDir fake_common_start_menu_; 193 base::ScopedTempDir fake_common_start_menu_;
199 scoped_ptr<base::ScopedPathOverride> user_desktop_override_; 194 scoped_ptr<base::ScopedPathOverride> user_desktop_override_;
200 scoped_ptr<base::ScopedPathOverride> common_desktop_override_; 195 scoped_ptr<base::ScopedPathOverride> common_desktop_override_;
201 scoped_ptr<base::ScopedPathOverride> user_quick_launch_override_; 196 scoped_ptr<base::ScopedPathOverride> user_quick_launch_override_;
202 scoped_ptr<base::ScopedPathOverride> start_menu_override_; 197 scoped_ptr<base::ScopedPathOverride> start_menu_override_;
203 scoped_ptr<base::ScopedPathOverride> common_start_menu_override_; 198 scoped_ptr<base::ScopedPathOverride> common_start_menu_override_;
204 199
205 base::FilePath user_desktop_shortcut_; 200 base::FilePath user_desktop_shortcut_;
206 base::FilePath user_quick_launch_shortcut_; 201 base::FilePath user_quick_launch_shortcut_;
207 base::FilePath user_start_menu_shortcut_; 202 base::FilePath user_start_menu_shortcut_;
208 base::FilePath user_start_menu_subdir_shortcut_;
209 base::FilePath system_desktop_shortcut_; 203 base::FilePath system_desktop_shortcut_;
210 base::FilePath system_start_menu_shortcut_; 204 base::FilePath system_start_menu_shortcut_;
211 base::FilePath system_start_menu_subdir_shortcut_;
212 base::FilePath user_alternate_desktop_shortcut_; 205 base::FilePath user_alternate_desktop_shortcut_;
213 }; 206 };
214 207
215 } // namespace 208 } // namespace
216 209
217 // Test that VisualElementsManifest.xml is not created when VisualElements are 210 // Test that VisualElementsManifest.xml is not created when VisualElements are
218 // not present. 211 // not present.
219 TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestNotCreated) { 212 TEST_F(CreateVisualElementsManifestTest, VisualElementsManifestNotCreated) {
220 ASSERT_TRUE( 213 ASSERT_TRUE(
221 installer::CreateVisualElementsManifest(test_dir_.path(), version_)); 214 installer::CreateVisualElementsManifest(test_dir_.path(), version_));
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 ASSERT_TRUE(base::CreateDirectory(user_start_menu_shortcut_.DirName())); 368 ASSERT_TRUE(base::CreateDirectory(user_start_menu_shortcut_.DirName()));
376 369
377 installer::CreateOrUpdateShortcuts( 370 installer::CreateOrUpdateShortcuts(
378 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, 371 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER,
379 installer::INSTALL_SHORTCUT_REPLACE_EXISTING); 372 installer::INSTALL_SHORTCUT_REPLACE_EXISTING);
380 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_); 373 base::win::ValidateShortcut(user_desktop_shortcut_, expected_properties_);
381 ASSERT_FALSE(base::PathExists(user_quick_launch_shortcut_)); 374 ASSERT_FALSE(base::PathExists(user_quick_launch_shortcut_));
382 ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_)); 375 ASSERT_FALSE(base::PathExists(user_start_menu_shortcut_));
383 } 376 }
384 377
385 class MigrateShortcutTest : public InstallShortcutTest,
386 public testing::WithParamInterface<
387 testing::tuple<
388 installer::InstallShortcutOperation,
389 installer::InstallShortcutLevel>> {
390 public:
391 MigrateShortcutTest() : shortcut_operation_(testing::get<0>(GetParam())),
392 shortcut_level_(testing::get<1>(GetParam())) {}
393
394 protected:
395 const installer::InstallShortcutOperation shortcut_operation_;
396 const installer::InstallShortcutLevel shortcut_level_;
397
398 private:
399 DISALLOW_COPY_AND_ASSIGN(MigrateShortcutTest);
400 };
401
402 TEST_P(MigrateShortcutTest, MigrateAwayFromDeprecatedStartMenuTest) {
403 base::win::ShortcutProperties dummy_properties;
404 base::FilePath dummy_target;
405 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target));
406 dummy_properties.set_target(expected_properties_.target);
407 dummy_properties.set_working_dir(fake_user_desktop_.path());
408 dummy_properties.set_arguments(L"--dummy --args");
409 dummy_properties.set_app_id(L"El.Dummiest");
410
411 base::FilePath start_menu_shortcut;
412 base::FilePath start_menu_subdir_shortcut;
413 if (shortcut_level_ == installer::CURRENT_USER) {
414 start_menu_shortcut = user_start_menu_shortcut_;
415 start_menu_subdir_shortcut = user_start_menu_subdir_shortcut_;
416 } else {
417 start_menu_shortcut = system_start_menu_shortcut_;
418 start_menu_subdir_shortcut = system_start_menu_subdir_shortcut_;
419 }
420
421 ASSERT_TRUE(base::CreateDirectory(start_menu_subdir_shortcut.DirName()));
422 ASSERT_FALSE(base::PathExists(start_menu_subdir_shortcut));
423 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
424 start_menu_subdir_shortcut, dummy_properties,
425 base::win::SHORTCUT_CREATE_ALWAYS));
426 ASSERT_TRUE(base::PathExists(start_menu_subdir_shortcut));
427 ASSERT_FALSE(base::PathExists(start_menu_shortcut));
428
429 installer::CreateOrUpdateShortcuts(chrome_exe_, *product_, *prefs_,
430 shortcut_level_, shortcut_operation_);
431 ASSERT_FALSE(base::PathExists(start_menu_subdir_shortcut));
432 ASSERT_TRUE(base::PathExists(start_menu_shortcut));
433 }
434
435 // Verify that any installer operation for any installation level triggers
436 // the migration from sub-folder to root of start-menu.
437 INSTANTIATE_TEST_CASE_P(
438 MigrateShortcutTests, MigrateShortcutTest,
439 testing::Combine(
440 testing::Values(
441 installer::INSTALL_SHORTCUT_REPLACE_EXISTING,
442 installer::INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL,
443 installer::INSTALL_SHORTCUT_CREATE_ALL),
444 testing::Values(
445 installer::CURRENT_USER,
446 installer::ALL_USERS)));
447
448 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelAllSystemShortcutsExist) { 378 TEST_F(InstallShortcutTest, CreateIfNoSystemLevelAllSystemShortcutsExist) {
449 base::win::ShortcutProperties dummy_properties; 379 base::win::ShortcutProperties dummy_properties;
450 base::FilePath dummy_target; 380 base::FilePath dummy_target;
451 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target)); 381 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &dummy_target));
452 dummy_properties.set_target(dummy_target); 382 dummy_properties.set_target(dummy_target);
453 383
454 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 384 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
455 system_desktop_shortcut_, dummy_properties, 385 system_desktop_shortcut_, dummy_properties,
456 base::win::SHORTCUT_CREATE_ALWAYS)); 386 base::win::SHORTCUT_CREATE_ALWAYS));
457 ASSERT_TRUE(base::CreateDirectory( 387 ASSERT_TRUE(base::CreateDirectory(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 installer::EscapeXmlAttributeValueInSingleQuotes(&val); 438 installer::EscapeXmlAttributeValueInSingleQuotes(&val);
509 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); 439 ASSERT_STREQ(kExpectedEscapedVal, val.c_str());
510 } 440 }
511 441
512 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) { 442 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) {
513 base::string16 val(L"Google Chrome"); 443 base::string16 val(L"Google Chrome");
514 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome"; 444 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome";
515 installer::EscapeXmlAttributeValueInSingleQuotes(&val); 445 installer::EscapeXmlAttributeValueInSingleQuotes(&val);
516 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); 446 ASSERT_STREQ(kExpectedEscapedVal, val.c_str());
517 } 447 }
OLDNEW
« no previous file with comments | « chrome/installer/setup/install.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698