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

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

Issue 2692843002: Fail tests fast if overriding the Windows registry fails. (Closed)
Patch Set: sync to position 450085 Created 3 years, 10 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
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/setup_util_unittest.h" 5 #include "chrome/installer/setup/setup_util_unittest.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shlobj.h> 8 #include <shlobj.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 ASSERT_FALSE(CurrentProcessHasPrivilege(kTestedPrivilege)); 190 ASSERT_FALSE(CurrentProcessHasPrivilege(kTestedPrivilege));
191 } 191 }
192 192
193 TEST(SetupUtilTest, GuidToSquid) { 193 TEST(SetupUtilTest, GuidToSquid) {
194 ASSERT_EQ(installer::GuidToSquid(L"EDA620E3-AA98-3846-B81E-3493CB2E0E02"), 194 ASSERT_EQ(installer::GuidToSquid(L"EDA620E3-AA98-3846-B81E-3493CB2E0E02"),
195 L"3E026ADE89AA64838BE14339BCE2E020"); 195 L"3E026ADE89AA64838BE14339BCE2E020");
196 } 196 }
197 197
198 TEST(SetupUtilTest, RegisterEventLogProvider) { 198 TEST(SetupUtilTest, RegisterEventLogProvider) {
199 registry_util::RegistryOverrideManager registry_override_manager; 199 registry_util::RegistryOverrideManager registry_override_manager;
200 registry_override_manager.OverrideRegistry(HKEY_LOCAL_MACHINE); 200 ASSERT_NO_FATAL_FAILURE(
201 registry_override_manager.OverrideRegistry(HKEY_LOCAL_MACHINE));
201 202
202 const base::Version version("1.2.3.4"); 203 const base::Version version("1.2.3.4");
203 const base::FilePath install_directory( 204 const base::FilePath install_directory(
204 FILE_PATH_LITERAL("c:\\some_path\\test")); 205 FILE_PATH_LITERAL("c:\\some_path\\test"));
205 installer::RegisterEventLogProvider(install_directory, version); 206 installer::RegisterEventLogProvider(install_directory, version);
206 207
207 // TODO(grt): use install_static::InstallDetails::Get().install_full_name() 208 // TODO(grt): use install_static::InstallDetails::Get().install_full_name()
208 // when InstallDetails is initialized in the installer. 209 // when InstallDetails is initialized in the installer.
209 base::string16 reg_path( 210 base::string16 reg_path(
210 L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\"); 211 L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\");
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 368
368 void set_uninstall_command(const base::CommandLine& uninstall_command) { 369 void set_uninstall_command(const base::CommandLine& uninstall_command) {
369 uninstall_command_ = uninstall_command; 370 uninstall_command_ = uninstall_command;
370 } 371 }
371 }; 372 };
372 373
373 FindArchiveToPatchTest() {} 374 FindArchiveToPatchTest() {}
374 375
375 void SetUp() override { 376 void SetUp() override {
376 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); 377 ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
377 registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER); 378 ASSERT_NO_FATAL_FAILURE(
378 registry_override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE); 379 registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER));
380 ASSERT_NO_FATAL_FAILURE(
381 registry_override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE));
379 product_version_ = base::Version("30.0.1559.0"); 382 product_version_ = base::Version("30.0.1559.0");
380 max_version_ = base::Version("47.0.1559.0"); 383 max_version_ = base::Version("47.0.1559.0");
381 384
382 // Install the product according to the version. 385 // Install the product according to the version.
383 original_state_.reset(new FakeInstallationState()); 386 original_state_.reset(new FakeInstallationState());
384 InstallProduct(); 387 InstallProduct();
385 388
386 // Prepare to update the product in the temp dir. 389 // Prepare to update the product in the temp dir.
387 installer_state_.reset(new installer::InstallerState( 390 installer_state_.reset(new installer::InstallerState(
388 kSystemInstall_ ? installer::InstallerState::SYSTEM_LEVEL : 391 kSystemInstall_ ? installer::InstallerState::SYSTEM_LEVEL :
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 base::CompareCase::SENSITIVE)); 526 base::CompareCase::SENSITIVE));
524 } 527 }
525 528
526 namespace installer { 529 namespace installer {
527 530
528 class DeleteRegistryKeyPartialTest : public ::testing::Test { 531 class DeleteRegistryKeyPartialTest : public ::testing::Test {
529 protected: 532 protected:
530 using RegKey = base::win::RegKey; 533 using RegKey = base::win::RegKey;
531 534
532 void SetUp() override { 535 void SetUp() override {
533 _registry_override_manager.OverrideRegistry(root_); 536 ASSERT_NO_FATAL_FAILURE(_registry_override_manager.OverrideRegistry(root_));
534 to_preserve_.push_back(L"preSERve1"); 537 to_preserve_.push_back(L"preSERve1");
535 to_preserve_.push_back(L"1evRESerp"); 538 to_preserve_.push_back(L"1evRESerp");
536 } 539 }
537 540
538 void CreateSubKeys(bool with_preserves) { 541 void CreateSubKeys(bool with_preserves) {
539 ASSERT_FALSE(RegKey(root_, path_.c_str(), KEY_READ).Valid()); 542 ASSERT_FALSE(RegKey(root_, path_.c_str(), KEY_READ).Valid());
540 // These subkeys are added such that 1) keys to preserve are intermixed with 543 // These subkeys are added such that 1) keys to preserve are intermixed with
541 // other keys, and 2) the case of the keys to preserve doesn't match the 544 // other keys, and 2) the case of the keys to preserve doesn't match the
542 // values in |to_preserve_|. 545 // values in |to_preserve_|.
543 ASSERT_EQ(ERROR_SUCCESS, RegKey(root_, path_.c_str(), KEY_WRITE) 546 ASSERT_EQ(ERROR_SUCCESS, RegKey(root_, path_.c_str(), KEY_WRITE)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 base::win::RegistryValueIterator it(root_, path_.c_str()); 637 base::win::RegistryValueIterator it(root_, path_.c_str());
635 ASSERT_EQ(0u, it.ValueCount()); 638 ASSERT_EQ(0u, it.ValueCount());
636 } 639 }
637 } 640 }
638 641
639 class LegacyCleanupsTest : public ::testing::Test { 642 class LegacyCleanupsTest : public ::testing::Test {
640 protected: 643 protected:
641 LegacyCleanupsTest() = default; 644 LegacyCleanupsTest() = default;
642 void SetUp() override { 645 void SetUp() override {
643 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 646 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
644 registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER); 647 ASSERT_NO_FATAL_FAILURE(
648 registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER));
645 installer_state_ = 649 installer_state_ =
646 base::MakeUnique<FakeInstallerState>(temp_dir_.GetPath()); 650 base::MakeUnique<FakeInstallerState>(temp_dir_.GetPath());
647 // Create the state to be cleared. 651 // Create the state to be cleared.
648 ASSERT_TRUE(base::win::RegKey(HKEY_CURRENT_USER, kBinariesClientsKeyPath, 652 ASSERT_TRUE(base::win::RegKey(HKEY_CURRENT_USER, kBinariesClientsKeyPath,
649 KEY_WRITE | KEY_WOW64_32KEY) 653 KEY_WRITE | KEY_WOW64_32KEY)
650 .Valid()); 654 .Valid());
651 #if defined(GOOGLE_CHROME_BUILD) 655 #if defined(GOOGLE_CHROME_BUILD)
652 ASSERT_TRUE(base::win::RegKey(HKEY_CURRENT_USER, kGCFClientsKeyPath, 656 ASSERT_TRUE(base::win::RegKey(HKEY_CURRENT_USER, kGCFClientsKeyPath,
653 KEY_WRITE | KEY_WOW64_32KEY) 657 KEY_WRITE | KEY_WOW64_32KEY)
654 .Valid()); 658 .Valid());
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 EXPECT_FALSE(HasBinariesVersionKey()); 771 EXPECT_FALSE(HasBinariesVersionKey());
768 #if defined(GOOGLE_CHROME_BUILD) 772 #if defined(GOOGLE_CHROME_BUILD)
769 EXPECT_FALSE(HasMultiGCFVersionKey()); 773 EXPECT_FALSE(HasMultiGCFVersionKey());
770 EXPECT_FALSE(HasAppLauncherVersionKey()); 774 EXPECT_FALSE(HasAppLauncherVersionKey());
771 EXPECT_FALSE(HasAppHostExe()); 775 EXPECT_FALSE(HasAppHostExe());
772 EXPECT_FALSE(HasInstallExtensionCommand()); 776 EXPECT_FALSE(HasInstallExtensionCommand());
773 #endif // GOOGLE_CHROME_BUILD 777 #endif // GOOGLE_CHROME_BUILD
774 } 778 }
775 779
776 } // namespace installer 780 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698