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

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

Issue 2507293005: Force migrate all clients from multi-install back to single-install. (Closed)
Patch Set: gab comments Created 4 years 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/installer_state.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 "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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 TEST_F(InstallerStateTest, InstallerResult) { 117 TEST_F(InstallerStateTest, InstallerResult) {
118 const bool system_level = true; 118 const bool system_level = true;
119 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 119 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
120 120
121 RegKey key; 121 RegKey key;
122 std::wstring launch_cmd = L"hey diddle diddle"; 122 std::wstring launch_cmd = L"hey diddle diddle";
123 std::wstring value; 123 std::wstring value;
124 DWORD dw_value; 124 DWORD dw_value;
125 125
126 // check results for a fresh install of single Chrome 126 // Check results for a fresh install of single Chrome and the same for an
127 { 127 // attempt at multi-install, which is now ignored.
128 static constexpr const wchar_t* kCommandLines[] = {
129 L"setup.exe --system-level",
130 L"setup.exe --system-level --multi-install --chrome",
131 };
132 for (const wchar_t* command_line : kCommandLines) {
128 RegistryOverrideManager override_manager; 133 RegistryOverrideManager override_manager;
129 override_manager.OverrideRegistry(root); 134 override_manager.OverrideRegistry(root);
130 base::CommandLine cmd_line = 135 base::CommandLine cmd_line = base::CommandLine::FromString(command_line);
131 base::CommandLine::FromString(L"setup.exe --system-level");
132 const MasterPreferences prefs(cmd_line); 136 const MasterPreferences prefs(cmd_line);
133 InstallationState machine_state; 137 InstallationState machine_state;
134 machine_state.Initialize(); 138 machine_state.Initialize();
135 InstallerState state; 139 InstallerState state;
136 state.Initialize(cmd_line, prefs, machine_state); 140 state.Initialize(cmd_line, prefs, machine_state);
137 state.WriteInstallerResult(installer::FIRST_INSTALL_SUCCESS, 141 state.WriteInstallerResult(installer::FIRST_INSTALL_SUCCESS,
138 IDS_INSTALL_OS_ERROR_BASE, &launch_cmd); 142 IDS_INSTALL_OS_ERROR_BASE, &launch_cmd);
139 BrowserDistribution* distribution = 143 BrowserDistribution* distribution =
140 BrowserDistribution::GetSpecificDistribution( 144 BrowserDistribution::GetSpecificDistribution(
141 BrowserDistribution::CHROME_BROWSER); 145 BrowserDistribution::CHROME_BROWSER);
142 EXPECT_EQ(ERROR_SUCCESS, 146 EXPECT_EQ(ERROR_SUCCESS,
143 key.Open(root, distribution->GetStateKey().c_str(), KEY_READ)); 147 key.Open(root, distribution->GetStateKey().c_str(), KEY_READ));
144 EXPECT_EQ(ERROR_SUCCESS, 148 EXPECT_EQ(ERROR_SUCCESS,
145 key.ReadValueDW(installer::kInstallerResult, &dw_value)); 149 key.ReadValueDW(installer::kInstallerResult, &dw_value));
146 EXPECT_EQ(static_cast<DWORD>(0), dw_value); 150 EXPECT_EQ(static_cast<DWORD>(0), dw_value);
147 EXPECT_EQ(ERROR_SUCCESS, 151 EXPECT_EQ(ERROR_SUCCESS,
148 key.ReadValueDW(installer::kInstallerError, &dw_value)); 152 key.ReadValueDW(installer::kInstallerError, &dw_value));
149 EXPECT_EQ(static_cast<DWORD>(installer::FIRST_INSTALL_SUCCESS), dw_value); 153 EXPECT_EQ(static_cast<DWORD>(installer::FIRST_INSTALL_SUCCESS), dw_value);
150 EXPECT_EQ(ERROR_SUCCESS, 154 EXPECT_EQ(ERROR_SUCCESS,
151 key.ReadValue(installer::kInstallerResultUIString, &value)); 155 key.ReadValue(installer::kInstallerResultUIString, &value));
152 EXPECT_FALSE(value.empty()); 156 EXPECT_FALSE(value.empty());
153 EXPECT_EQ(ERROR_SUCCESS, 157 EXPECT_EQ(ERROR_SUCCESS,
154 key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value)); 158 key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value));
155 EXPECT_EQ(launch_cmd, value); 159 EXPECT_EQ(launch_cmd, value);
156 } 160 }
157
158 // check results for a fresh install of multi Chrome
159 {
160 RegistryOverrideManager override_manager;
161 override_manager.OverrideRegistry(root);
162 base::CommandLine cmd_line = base::CommandLine::FromString(
163 L"setup.exe --system-level --multi-install --chrome");
164 const MasterPreferences prefs(cmd_line);
165 InstallationState machine_state;
166 machine_state.Initialize();
167 InstallerState state;
168 state.Initialize(cmd_line, prefs, machine_state);
169 state.WriteInstallerResult(installer::FIRST_INSTALL_SUCCESS, 0,
170 &launch_cmd);
171 BrowserDistribution* distribution =
172 BrowserDistribution::GetSpecificDistribution(
173 BrowserDistribution::CHROME_BROWSER);
174 BrowserDistribution* binaries =
175 BrowserDistribution::GetSpecificDistribution(
176 BrowserDistribution::CHROME_BINARIES);
177 EXPECT_EQ(ERROR_SUCCESS,
178 key.Open(root, distribution->GetStateKey().c_str(), KEY_READ));
179 EXPECT_EQ(ERROR_SUCCESS,
180 key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value));
181 EXPECT_EQ(launch_cmd, value);
182 EXPECT_EQ(ERROR_SUCCESS,
183 key.Open(root, binaries->GetStateKey().c_str(), KEY_READ));
184 EXPECT_EQ(ERROR_SUCCESS,
185 key.ReadValue(installer::kInstallerSuccessLaunchCmdLine, &value));
186 EXPECT_EQ(launch_cmd, value);
187 key.Close();
188 }
189 } 161 }
190 162
191 // Test GetCurrentVersion when migrating single Chrome to multi 163 // Test GetCurrentVersion when migrating single Chrome to multi
192 TEST_F(InstallerStateTest, GetCurrentVersionMigrateChrome) { 164 TEST_F(InstallerStateTest, GetCurrentVersionMigrateChrome) {
193 using installer::FakeInstallationState; 165 using installer::FakeInstallationState;
194 166
195 const bool system_install = false; 167 const bool system_install = false;
196 FakeInstallationState machine_state; 168 FakeInstallationState machine_state;
197 169
198 // Pretend that this version of single-install Chrome is already installed. 170 // Pretend that this version of single-install Chrome is already installed.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 temp); 224 temp);
253 registry_util::RegistryOverrideManager override_manager; 225 registry_util::RegistryOverrideManager override_manager;
254 override_manager.OverrideRegistry(HKEY_CURRENT_USER); 226 override_manager.OverrideRegistry(HKEY_CURRENT_USER);
255 override_manager.OverrideRegistry(HKEY_LOCAL_MACHINE); 227 override_manager.OverrideRegistry(HKEY_LOCAL_MACHINE);
256 228
257 InstallationState machine_state; 229 InstallationState machine_state;
258 machine_state.Initialize(); 230 machine_state.Initialize();
259 231
260 InstallerState installer_state; 232 InstallerState installer_state;
261 233
262 // Initialize the instance to install multi Chrome. 234 // Initialize the instance to install user-level Chrome.
263 { 235 {
264 base::CommandLine cmd_line( 236 base::CommandLine cmd_line(base::CommandLine::FromString(L"setup.exe"));
265 base::CommandLine::FromString(L"setup.exe --multi-install --chrome"));
266 MasterPreferences prefs(cmd_line); 237 MasterPreferences prefs(cmd_line);
267 installer_state.Initialize(cmd_line, prefs, machine_state); 238 installer_state.Initialize(cmd_line, prefs, machine_state);
268 } 239 }
269 // Confirm the expected state. 240 // Confirm the expected state.
270 EXPECT_EQ(InstallerState::USER_LEVEL, installer_state.level()); 241 EXPECT_EQ(InstallerState::USER_LEVEL, installer_state.level());
271 EXPECT_EQ(InstallerState::MULTI_PACKAGE, installer_state.package_type()); 242 EXPECT_EQ(InstallerState::SINGLE_PACKAGE, installer_state.package_type());
272 EXPECT_EQ(InstallerState::MULTI_INSTALL, installer_state.operation()); 243 EXPECT_EQ(InstallerState::SINGLE_INSTALL_OR_UPDATE,
244 installer_state.operation());
273 EXPECT_TRUE(wcsstr(installer_state.target_path().value().c_str(), 245 EXPECT_TRUE(wcsstr(installer_state.target_path().value().c_str(),
274 BrowserDistribution::GetSpecificDistribution( 246 BrowserDistribution::GetSpecificDistribution(
275 BrowserDistribution::CHROME_BINARIES)-> 247 BrowserDistribution::CHROME_BROWSER)
276 GetInstallSubDir().c_str())); 248 ->GetInstallSubDir()
249 .c_str()));
277 EXPECT_FALSE(installer_state.verbose_logging()); 250 EXPECT_FALSE(installer_state.verbose_logging());
278 EXPECT_EQ(installer_state.state_key(), 251 EXPECT_EQ(installer_state.state_key(),
279 BrowserDistribution::GetSpecificDistribution( 252 BrowserDistribution::GetSpecificDistribution(
280 BrowserDistribution::CHROME_BROWSER)->GetStateKey()); 253 BrowserDistribution::CHROME_BROWSER)->GetStateKey());
281 EXPECT_EQ(installer_state.state_type(), BrowserDistribution::CHROME_BROWSER); 254 EXPECT_EQ(installer_state.state_type(), BrowserDistribution::CHROME_BROWSER);
282 EXPECT_TRUE(installer_state.multi_package_binaries_distribution());
283 EXPECT_TRUE(installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER)); 255 EXPECT_TRUE(installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER));
284 256
285 // Now initialize it to install system-level single Chrome. 257 // Now initialize it to install system-level single Chrome.
286 { 258 {
287 base::CommandLine cmd_line(base::CommandLine::FromString( 259 base::CommandLine cmd_line(base::CommandLine::FromString(
288 L"setup.exe --system-level --verbose-logging")); 260 L"setup.exe --system-level --verbose-logging"));
289 MasterPreferences prefs(cmd_line); 261 MasterPreferences prefs(cmd_line);
290 installer_state.Initialize(cmd_line, prefs, machine_state); 262 installer_state.Initialize(cmd_line, prefs, machine_state);
291 } 263 }
292 264
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 // Critical update newer than the new version. 421 // Critical update newer than the new version.
450 EXPECT_FALSE( 422 EXPECT_FALSE(
451 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); 423 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid());
452 EXPECT_FALSE( 424 EXPECT_FALSE(
453 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) 425 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_)
454 .IsValid()); 426 .IsValid());
455 EXPECT_FALSE( 427 EXPECT_FALSE(
456 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) 428 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_)
457 .IsValid()); 429 .IsValid());
458 } 430 }
OLDNEW
« no previous file with comments | « chrome/installer/setup/installer_state.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698