diff options
author | grt <grt@chromium.org> | 2014-08-31 17:34:28 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-01 00:36:40 +0000 |
commit | 4b1d16a9cbc61817d584c16fe2b3cc79dc0febc2 (patch) | |
tree | 0fc33d82f3fbf5d0814a639d3b05c3af5db80837 /chrome/installer | |
parent | f49fcfbf0db909f48d245f06240f184d473ec55d (diff) | |
download | chromium_src-4b1d16a9cbc61817d584c16fe2b3cc79dc0febc2.zip chromium_src-4b1d16a9cbc61817d584c16fe2b3cc79dc0febc2.tar.gz chromium_src-4b1d16a9cbc61817d584c16fe2b3cc79dc0febc2.tar.bz2 |
Fix ProductTest.ProductInstallBasic and InstallerStateTest.InitializeTwice flakes.
Use registry virtualization so that stale data on the test machines
don't interfere with the tests.
BUG=375739
Committed: https://chromium.googlesource.com/chromium/src/+/6d6ac988d6a7a311876f3b0d0257086ac58c8181
Review URL: https://codereview.chromium.org/521703002
Cr-Commit-Position: refs/heads/master@{#292822}
Diffstat (limited to 'chrome/installer')
-rw-r--r-- | chrome/installer/util/installer_state_unittest.cc | 17 | ||||
-rw-r--r-- | chrome/installer/util/product_unittest.cc | 10 |
2 files changed, 22 insertions, 5 deletions
diff --git a/chrome/installer/util/installer_state_unittest.cc b/chrome/installer/util/installer_state_unittest.cc index b3db8b3..1c8fd65 100644 --- a/chrome/installer/util/installer_state_unittest.cc +++ b/chrome/installer/util/installer_state_unittest.cc @@ -15,6 +15,7 @@ #include "base/path_service.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "base/test/scoped_path_override.h" #include "base/test/test_reg_util_win.h" #include "base/version.h" #include "base/win/registry.h" @@ -603,6 +604,22 @@ TEST_F(InstallerStateTest, RemoveOldVersionDirs) { } TEST_F(InstallerStateTest, InitializeTwice) { + // Override these paths so that they can be found after the registry override + // manager is in place. + base::FilePath temp; + PathService::Get(base::DIR_PROGRAM_FILES, &temp); + base::ScopedPathOverride program_files_override(base::DIR_PROGRAM_FILES, + temp); + PathService::Get(base::DIR_PROGRAM_FILESX86, &temp); + base::ScopedPathOverride program_filesx86_override(base::DIR_PROGRAM_FILESX86, + temp); + PathService::Get(base::DIR_LOCAL_APP_DATA, &temp); + base::ScopedPathOverride local_app_data_override(base::DIR_LOCAL_APP_DATA, + temp); + registry_util::RegistryOverrideManager override_manager; + override_manager.OverrideRegistry(HKEY_CURRENT_USER, base::string16()); + override_manager.OverrideRegistry(HKEY_LOCAL_MACHINE, base::string16()); + InstallationState machine_state; machine_state.Initialize(); diff --git a/chrome/installer/util/product_unittest.cc b/chrome/installer/util/product_unittest.cc index eabade7..ea69d6e 100644 --- a/chrome/installer/util/product_unittest.cc +++ b/chrome/installer/util/product_unittest.cc @@ -76,16 +76,16 @@ TEST_F(ProductTest, ProductInstallBasic) { EXPECT_EQ(std::wstring::npos, user_data_dir.value().find(program_files.value())); - // There should be no installed version in the registry. - machine_state.Initialize(); - EXPECT_TRUE(machine_state.GetProductState( - system_level, distribution->GetType()) == NULL); - HKEY root = installer_state.root_key(); { RegistryOverrideManager override_manager; override_manager.OverrideRegistry(root, L"root_pit"); + // There should be no installed version in the registry. + machine_state.Initialize(); + EXPECT_TRUE(machine_state.GetProductState( + system_level, distribution->GetType()) == NULL); + // Let's pretend chrome is installed. RegKey version_key(root, distribution->GetVersionKey().c_str(), KEY_ALL_ACCESS); |