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

Side by Side Diff: chrome/installer/setup/installer_state_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/installer_state.h" 5 #include "chrome/installer/setup/installer_state.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <fstream> 10 #include <fstream>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 EXPECT_EQ(system_level, installer_state.system_install()); 80 EXPECT_EQ(system_level, installer_state.system_install());
81 81
82 const char kCurrentVersion[] = "1.2.3.4"; 82 const char kCurrentVersion[] = "1.2.3.4";
83 base::Version current_version(kCurrentVersion); 83 base::Version current_version(kCurrentVersion);
84 84
85 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 85 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
86 EXPECT_EQ(root, installer_state.root_key()); 86 EXPECT_EQ(root, installer_state.root_key());
87 87
88 { 88 {
89 RegistryOverrideManager override_manager; 89 RegistryOverrideManager override_manager;
90 override_manager.OverrideRegistry(root); 90 ASSERT_NO_FATAL_FAILURE(override_manager.OverrideRegistry(root));
91 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 91 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
92 RegKey chrome_key(root, dist->GetVersionKey().c_str(), KEY_ALL_ACCESS); 92 RegKey chrome_key(root, dist->GetVersionKey().c_str(), KEY_ALL_ACCESS);
93 EXPECT_TRUE(chrome_key.Valid()); 93 EXPECT_TRUE(chrome_key.Valid());
94 if (chrome_key.Valid()) { 94 if (chrome_key.Valid()) {
95 chrome_key.WriteValue(google_update::kRegVersionField, 95 chrome_key.WriteValue(google_update::kRegVersionField,
96 base::UTF8ToWide( 96 base::UTF8ToWide(
97 current_version.GetString()).c_str()); 97 current_version.GetString()).c_str());
98 machine_state.Initialize(); 98 machine_state.Initialize();
99 // TODO(tommi): Also test for when there exists a new_chrome.exe. 99 // TODO(tommi): Also test for when there exists a new_chrome.exe.
100 base::Version found_version( 100 base::Version found_version(
(...skipping 15 matching lines...) Expand all
116 DWORD dw_value; 116 DWORD dw_value;
117 117
118 // Check results for a fresh install of Chrome and the same for an attempt at 118 // Check results for a fresh install of Chrome and the same for an attempt at
119 // multi-install, which is now ignored. 119 // multi-install, which is now ignored.
120 static constexpr const wchar_t* kCommandLines[] = { 120 static constexpr const wchar_t* kCommandLines[] = {
121 L"setup.exe --system-level", 121 L"setup.exe --system-level",
122 L"setup.exe --system-level --multi-install --chrome", 122 L"setup.exe --system-level --multi-install --chrome",
123 }; 123 };
124 for (const wchar_t* command_line : kCommandLines) { 124 for (const wchar_t* command_line : kCommandLines) {
125 RegistryOverrideManager override_manager; 125 RegistryOverrideManager override_manager;
126 override_manager.OverrideRegistry(root); 126 ASSERT_NO_FATAL_FAILURE(override_manager.OverrideRegistry(root));
127 base::CommandLine cmd_line = base::CommandLine::FromString(command_line); 127 base::CommandLine cmd_line = base::CommandLine::FromString(command_line);
128 const MasterPreferences prefs(cmd_line); 128 const MasterPreferences prefs(cmd_line);
129 InstallationState machine_state; 129 InstallationState machine_state;
130 machine_state.Initialize(); 130 machine_state.Initialize();
131 InstallerState state; 131 InstallerState state;
132 state.Initialize(cmd_line, prefs, machine_state); 132 state.Initialize(cmd_line, prefs, machine_state);
133 state.WriteInstallerResult(installer::FIRST_INSTALL_SUCCESS, 133 state.WriteInstallerResult(installer::FIRST_INSTALL_SUCCESS,
134 IDS_INSTALL_OS_ERROR_BASE, &launch_cmd); 134 IDS_INSTALL_OS_ERROR_BASE, &launch_cmd);
135 BrowserDistribution* distribution = BrowserDistribution::GetDistribution(); 135 BrowserDistribution* distribution = BrowserDistribution::GetDistribution();
136 EXPECT_EQ(ERROR_SUCCESS, 136 EXPECT_EQ(ERROR_SUCCESS,
(...skipping 20 matching lines...) Expand all
157 PathService::Get(base::DIR_PROGRAM_FILES, &temp); 157 PathService::Get(base::DIR_PROGRAM_FILES, &temp);
158 base::ScopedPathOverride program_files_override(base::DIR_PROGRAM_FILES, 158 base::ScopedPathOverride program_files_override(base::DIR_PROGRAM_FILES,
159 temp); 159 temp);
160 PathService::Get(base::DIR_PROGRAM_FILESX86, &temp); 160 PathService::Get(base::DIR_PROGRAM_FILESX86, &temp);
161 base::ScopedPathOverride program_filesx86_override(base::DIR_PROGRAM_FILESX86, 161 base::ScopedPathOverride program_filesx86_override(base::DIR_PROGRAM_FILESX86,
162 temp); 162 temp);
163 PathService::Get(base::DIR_LOCAL_APP_DATA, &temp); 163 PathService::Get(base::DIR_LOCAL_APP_DATA, &temp);
164 base::ScopedPathOverride local_app_data_override(base::DIR_LOCAL_APP_DATA, 164 base::ScopedPathOverride local_app_data_override(base::DIR_LOCAL_APP_DATA,
165 temp); 165 temp);
166 registry_util::RegistryOverrideManager override_manager; 166 registry_util::RegistryOverrideManager override_manager;
167 override_manager.OverrideRegistry(HKEY_CURRENT_USER); 167 ASSERT_NO_FATAL_FAILURE(override_manager.OverrideRegistry(HKEY_CURRENT_USER));
168 override_manager.OverrideRegistry(HKEY_LOCAL_MACHINE); 168 ASSERT_NO_FATAL_FAILURE(
169 override_manager.OverrideRegistry(HKEY_LOCAL_MACHINE));
169 170
170 InstallationState machine_state; 171 InstallationState machine_state;
171 machine_state.Initialize(); 172 machine_state.Initialize();
172 173
173 InstallerState installer_state; 174 InstallerState installer_state;
174 175
175 // Initialize the instance to install user-level Chrome. 176 // Initialize the instance to install user-level Chrome.
176 { 177 {
177 base::CommandLine cmd_line(base::CommandLine::FromString(L"setup.exe")); 178 base::CommandLine cmd_line(base::CommandLine::FromString(L"setup.exe"));
178 MasterPreferences prefs(cmd_line); 179 MasterPreferences prefs(cmd_line);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 // Critical update newer than the new version. 352 // Critical update newer than the new version.
352 EXPECT_FALSE( 353 EXPECT_FALSE(
353 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); 354 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid());
354 EXPECT_FALSE( 355 EXPECT_FALSE(
355 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) 356 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_)
356 .IsValid()); 357 .IsValid());
357 EXPECT_FALSE( 358 EXPECT_FALSE(
358 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) 359 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_)
359 .IsValid()); 360 .IsValid());
360 } 361 }
OLDNEW
« no previous file with comments | « chrome/installer/mini_installer/configuration_test.cc ('k') | chrome/installer/setup/setup_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698