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

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

Issue 2379543002: installer and some misc files: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: regroup ifs 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 "chrome/installer/setup/install.h" 5 #include "chrome/installer/setup/install.h"
6 6
7 #include <objbase.h> 7 #include <objbase.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 expected_start_menu_properties_ = expected_properties_; 114 expected_start_menu_properties_ = expected_properties_;
115 expected_start_menu_properties_.set_dual_mode(false); 115 expected_start_menu_properties_.set_dual_mode(false);
116 116
117 prefs_.reset(GetFakeMasterPrefs(false, false)); 117 prefs_.reset(GetFakeMasterPrefs(false, false));
118 118
119 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir()); 119 ASSERT_TRUE(fake_user_desktop_.CreateUniqueTempDir());
120 ASSERT_TRUE(fake_common_desktop_.CreateUniqueTempDir()); 120 ASSERT_TRUE(fake_common_desktop_.CreateUniqueTempDir());
121 ASSERT_TRUE(fake_user_quick_launch_.CreateUniqueTempDir()); 121 ASSERT_TRUE(fake_user_quick_launch_.CreateUniqueTempDir());
122 ASSERT_TRUE(fake_start_menu_.CreateUniqueTempDir()); 122 ASSERT_TRUE(fake_start_menu_.CreateUniqueTempDir());
123 ASSERT_TRUE(fake_common_start_menu_.CreateUniqueTempDir()); 123 ASSERT_TRUE(fake_common_start_menu_.CreateUniqueTempDir());
124 user_desktop_override_.reset( 124 user_desktop_override_.reset(new base::ScopedPathOverride(
125 new base::ScopedPathOverride(base::DIR_USER_DESKTOP, 125 base::DIR_USER_DESKTOP, fake_user_desktop_.GetPath()));
126 fake_user_desktop_.path())); 126 common_desktop_override_.reset(new base::ScopedPathOverride(
127 common_desktop_override_.reset( 127 base::DIR_COMMON_DESKTOP, fake_common_desktop_.GetPath()));
128 new base::ScopedPathOverride(base::DIR_COMMON_DESKTOP, 128 user_quick_launch_override_.reset(new base::ScopedPathOverride(
129 fake_common_desktop_.path())); 129 base::DIR_USER_QUICK_LAUNCH, fake_user_quick_launch_.GetPath()));
130 user_quick_launch_override_.reset( 130 start_menu_override_.reset(new base::ScopedPathOverride(
131 new base::ScopedPathOverride(base::DIR_USER_QUICK_LAUNCH, 131 base::DIR_START_MENU, fake_start_menu_.GetPath()));
132 fake_user_quick_launch_.path())); 132 common_start_menu_override_.reset(new base::ScopedPathOverride(
133 start_menu_override_.reset( 133 base::DIR_COMMON_START_MENU, fake_common_start_menu_.GetPath()));
134 new base::ScopedPathOverride(base::DIR_START_MENU,
135 fake_start_menu_.path()));
136 common_start_menu_override_.reset(
137 new base::ScopedPathOverride(base::DIR_COMMON_START_MENU,
138 fake_common_start_menu_.path()));
139 134
140 base::string16 shortcut_name(dist_->GetShortcutName() + installer::kLnkExt); 135 base::string16 shortcut_name(dist_->GetShortcutName() + installer::kLnkExt);
141 136
142 user_desktop_shortcut_ = 137 user_desktop_shortcut_ = fake_user_desktop_.GetPath().Append(shortcut_name);
143 fake_user_desktop_.path().Append(shortcut_name);
144 user_quick_launch_shortcut_ = 138 user_quick_launch_shortcut_ =
145 fake_user_quick_launch_.path().Append(shortcut_name); 139 fake_user_quick_launch_.GetPath().Append(shortcut_name);
146 user_start_menu_shortcut_ = fake_start_menu_.path().Append(shortcut_name); 140 user_start_menu_shortcut_ =
141 fake_start_menu_.GetPath().Append(shortcut_name);
147 user_start_menu_subdir_shortcut_ = 142 user_start_menu_subdir_shortcut_ =
148 fake_start_menu_.path() 143 fake_start_menu_.GetPath()
149 .Append(dist_->GetStartMenuShortcutSubfolder( 144 .Append(dist_->GetStartMenuShortcutSubfolder(
150 BrowserDistribution::SUBFOLDER_CHROME)) 145 BrowserDistribution::SUBFOLDER_CHROME))
151 .Append(shortcut_name); 146 .Append(shortcut_name);
152 system_desktop_shortcut_ = 147 system_desktop_shortcut_ =
153 fake_common_desktop_.path().Append(shortcut_name); 148 fake_common_desktop_.GetPath().Append(shortcut_name);
154 system_start_menu_shortcut_ = 149 system_start_menu_shortcut_ =
155 fake_common_start_menu_.path().Append(shortcut_name); 150 fake_common_start_menu_.GetPath().Append(shortcut_name);
156 system_start_menu_subdir_shortcut_ = 151 system_start_menu_subdir_shortcut_ =
157 fake_common_start_menu_.path() 152 fake_common_start_menu_.GetPath()
158 .Append(dist_->GetStartMenuShortcutSubfolder( 153 .Append(dist_->GetStartMenuShortcutSubfolder(
159 BrowserDistribution::SUBFOLDER_CHROME)) 154 BrowserDistribution::SUBFOLDER_CHROME))
160 .Append(shortcut_name); 155 .Append(shortcut_name);
161 } 156 }
162 157
163 void TearDown() override { 158 void TearDown() override {
164 // Try to unpin potentially pinned shortcuts (although pinning isn't tested, 159 // Try to unpin potentially pinned shortcuts (although pinning isn't tested,
165 // the call itself might still have pinned the Start Menu shortcuts). 160 // the call itself might still have pinned the Start Menu shortcuts).
166 base::win::UnpinShortcutFromTaskbar(user_start_menu_shortcut_); 161 base::win::UnpinShortcutFromTaskbar(user_start_menu_shortcut_);
167 base::win::UnpinShortcutFromTaskbar(user_start_menu_subdir_shortcut_); 162 base::win::UnpinShortcutFromTaskbar(user_start_menu_subdir_shortcut_);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 base::win::ValidateShortcut(user_start_menu_shortcut_, 364 base::win::ValidateShortcut(user_start_menu_shortcut_,
370 expected_start_menu_properties_); 365 expected_start_menu_properties_);
371 } 366 }
372 367
373 TEST_F(InstallShortcutTest, ReplaceAll) { 368 TEST_F(InstallShortcutTest, ReplaceAll) {
374 base::win::ShortcutProperties dummy_properties; 369 base::win::ShortcutProperties dummy_properties;
375 base::FilePath dummy_target; 370 base::FilePath dummy_target;
376 ASSERT_TRUE( 371 ASSERT_TRUE(
377 base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &dummy_target)); 372 base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &dummy_target));
378 dummy_properties.set_target(dummy_target); 373 dummy_properties.set_target(dummy_target);
379 dummy_properties.set_working_dir(fake_user_desktop_.path()); 374 dummy_properties.set_working_dir(fake_user_desktop_.GetPath());
380 dummy_properties.set_arguments(L"--dummy --args"); 375 dummy_properties.set_arguments(L"--dummy --args");
381 dummy_properties.set_app_id(L"El.Dummiest"); 376 dummy_properties.set_app_id(L"El.Dummiest");
382 377
383 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 378 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
384 user_desktop_shortcut_, dummy_properties, 379 user_desktop_shortcut_, dummy_properties,
385 base::win::SHORTCUT_CREATE_ALWAYS)); 380 base::win::SHORTCUT_CREATE_ALWAYS));
386 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 381 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
387 user_quick_launch_shortcut_, dummy_properties, 382 user_quick_launch_shortcut_, dummy_properties,
388 base::win::SHORTCUT_CREATE_ALWAYS)); 383 base::win::SHORTCUT_CREATE_ALWAYS));
389 ASSERT_TRUE(base::CreateDirectory(user_start_menu_shortcut_.DirName())); 384 ASSERT_TRUE(base::CreateDirectory(user_start_menu_shortcut_.DirName()));
(...skipping 10 matching lines...) Expand all
400 base::win::ValidateShortcut(user_start_menu_shortcut_, 395 base::win::ValidateShortcut(user_start_menu_shortcut_,
401 expected_start_menu_properties_); 396 expected_start_menu_properties_);
402 } 397 }
403 398
404 TEST_F(InstallShortcutTest, ReplaceExisting) { 399 TEST_F(InstallShortcutTest, ReplaceExisting) {
405 base::win::ShortcutProperties dummy_properties; 400 base::win::ShortcutProperties dummy_properties;
406 base::FilePath dummy_target; 401 base::FilePath dummy_target;
407 ASSERT_TRUE( 402 ASSERT_TRUE(
408 base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &dummy_target)); 403 base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &dummy_target));
409 dummy_properties.set_target(dummy_target); 404 dummy_properties.set_target(dummy_target);
410 dummy_properties.set_working_dir(fake_user_desktop_.path()); 405 dummy_properties.set_working_dir(fake_user_desktop_.GetPath());
411 dummy_properties.set_arguments(L"--dummy --args"); 406 dummy_properties.set_arguments(L"--dummy --args");
412 dummy_properties.set_app_id(L"El.Dummiest"); 407 dummy_properties.set_app_id(L"El.Dummiest");
413 408
414 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink( 409 ASSERT_TRUE(base::win::CreateOrUpdateShortcutLink(
415 user_desktop_shortcut_, dummy_properties, 410 user_desktop_shortcut_, dummy_properties,
416 base::win::SHORTCUT_CREATE_ALWAYS)); 411 base::win::SHORTCUT_CREATE_ALWAYS));
417 ASSERT_TRUE(base::CreateDirectory(user_start_menu_shortcut_.DirName())); 412 ASSERT_TRUE(base::CreateDirectory(user_start_menu_shortcut_.DirName()));
418 413
419 installer::CreateOrUpdateShortcuts( 414 installer::CreateOrUpdateShortcuts(
420 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER, 415 chrome_exe_, *product_, *prefs_, installer::CURRENT_USER,
(...skipping 19 matching lines...) Expand all
440 private: 435 private:
441 DISALLOW_COPY_AND_ASSIGN(MigrateShortcutTest); 436 DISALLOW_COPY_AND_ASSIGN(MigrateShortcutTest);
442 }; 437 };
443 438
444 TEST_P(MigrateShortcutTest, MigrateAwayFromDeprecatedStartMenuTest) { 439 TEST_P(MigrateShortcutTest, MigrateAwayFromDeprecatedStartMenuTest) {
445 base::win::ShortcutProperties dummy_properties; 440 base::win::ShortcutProperties dummy_properties;
446 base::FilePath dummy_target; 441 base::FilePath dummy_target;
447 ASSERT_TRUE( 442 ASSERT_TRUE(
448 base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &dummy_target)); 443 base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &dummy_target));
449 dummy_properties.set_target(expected_properties_.target); 444 dummy_properties.set_target(expected_properties_.target);
450 dummy_properties.set_working_dir(fake_user_desktop_.path()); 445 dummy_properties.set_working_dir(fake_user_desktop_.GetPath());
451 dummy_properties.set_arguments(L"--dummy --args"); 446 dummy_properties.set_arguments(L"--dummy --args");
452 dummy_properties.set_app_id(L"El.Dummiest"); 447 dummy_properties.set_app_id(L"El.Dummiest");
453 448
454 base::FilePath start_menu_shortcut; 449 base::FilePath start_menu_shortcut;
455 base::FilePath start_menu_subdir_shortcut; 450 base::FilePath start_menu_subdir_shortcut;
456 if (shortcut_level_ == installer::CURRENT_USER) { 451 if (shortcut_level_ == installer::CURRENT_USER) {
457 start_menu_shortcut = user_start_menu_shortcut_; 452 start_menu_shortcut = user_start_menu_shortcut_;
458 start_menu_subdir_shortcut = user_start_menu_subdir_shortcut_; 453 start_menu_subdir_shortcut = user_start_menu_subdir_shortcut_;
459 } else { 454 } else {
460 start_menu_shortcut = system_start_menu_shortcut_; 455 start_menu_shortcut = system_start_menu_shortcut_;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 installer::EscapeXmlAttributeValueInSingleQuotes(&val); 815 installer::EscapeXmlAttributeValueInSingleQuotes(&val);
821 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); 816 ASSERT_STREQ(kExpectedEscapedVal, val.c_str());
822 } 817 }
823 818
824 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) { 819 TEST(EscapeXmlAttributeValueTest, DontEscapeNormalValue) {
825 base::string16 val(L"Google Chrome"); 820 base::string16 val(L"Google Chrome");
826 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome"; 821 static const wchar_t kExpectedEscapedVal[] = L"Google Chrome";
827 installer::EscapeXmlAttributeValueInSingleQuotes(&val); 822 installer::EscapeXmlAttributeValueInSingleQuotes(&val);
828 ASSERT_STREQ(kExpectedEscapedVal, val.c_str()); 823 ASSERT_STREQ(kExpectedEscapedVal, val.c_str());
829 } 824 }
OLDNEW
« no previous file with comments | « no previous file | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698