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

Side by Side Diff: chrome/install_static/product_install_details_unittest.cc

Issue 2601443002: Remove multi-install from install_static. (Closed)
Patch Set: rebase onto position 442831 Created 3 years, 11 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 | « chrome/install_static/product_install_details.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/install_static/product_install_details.h" 5 #include "chrome/install_static/product_install_details.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 override_manager_.OverrideRegistry(root_key_, &path); 177 override_manager_.OverrideRegistry(root_key_, &path);
178 nt::SetTestingOverride(nt_root_key_, path); 178 nt::SetTestingOverride(nt_root_key_, path);
179 } 179 }
180 180
181 ~MakeProductDetailsTest() { 181 ~MakeProductDetailsTest() {
182 nt::SetTestingOverride(nt_root_key_, base::string16()); 182 nt::SetTestingOverride(nt_root_key_, base::string16());
183 } 183 }
184 184
185 const TestData& test_data() const { return test_data_; } 185 const TestData& test_data() const { return test_data_; }
186 186
187 void SetUninstallArguments(const wchar_t* value) { 187 void SetAp(const wchar_t* value) {
188 ASSERT_THAT( 188 ASSERT_THAT(base::win::RegKey(root_key_, GetClientStateKeyPath().c_str(),
189 base::win::RegKey(root_key_, GetClientStateKeyPath(false).c_str(), 189 KEY_WOW64_32KEY | KEY_SET_VALUE)
190 KEY_WOW64_32KEY | KEY_SET_VALUE) 190 .WriteValue(L"ap", value),
191 .WriteValue(L"UninstallArguments", value), 191 Eq(ERROR_SUCCESS));
192 Eq(ERROR_SUCCESS));
193 }
194
195 void SetAp(const wchar_t* value, bool binaries) {
196 ASSERT_TRUE(!binaries ||
197 kInstallModes[test_data().index].supports_multi_install);
198 ASSERT_THAT(
199 base::win::RegKey(root_key_, GetClientStateKeyPath(binaries).c_str(),
200 KEY_WOW64_32KEY | KEY_SET_VALUE)
201 .WriteValue(L"ap", value),
202 Eq(ERROR_SUCCESS));
203 } 192 }
204 193
205 private: 194 private:
206 // Returns the registry path for the product's ClientState key. 195 // Returns the registry path for the product's ClientState key.
207 std::wstring GetClientStateKeyPath(bool binaries) { 196 std::wstring GetClientStateKeyPath() {
208 EXPECT_TRUE(!binaries ||
209 kInstallModes[test_data().index].supports_multi_install);
210 std::wstring result(L"Software\\"); 197 std::wstring result(L"Software\\");
211 if (kUseGoogleUpdateIntegration) { 198 if (kUseGoogleUpdateIntegration) {
212 result.append(L"Google\\Update\\ClientState\\"); 199 result.append(L"Google\\Update\\ClientState\\");
213 if (binaries) 200 result.append(kInstallModes[test_data().index].app_guid);
214 result.append(kBinariesAppGuid);
215 else
216 result.append(kInstallModes[test_data().index].app_guid);
217 } else if (binaries) {
218 result.append(kBinariesPathName);
219 } else { 201 } else {
220 result.append(kProductPathName); 202 result.append(kProductPathName);
221 } 203 }
222 return result; 204 return result;
223 } 205 }
224 206
225 registry_util::RegistryOverrideManager override_manager_; 207 registry_util::RegistryOverrideManager override_manager_;
226 const TestData& test_data_; 208 const TestData& test_data_;
227 HKEY root_key_; 209 HKEY root_key_;
228 nt::ROOT_KEY nt_root_key_; 210 nt::ROOT_KEY nt_root_key_;
(...skipping 15 matching lines...) Expand all
244 EXPECT_THAT(details->system_level(), Eq(test_data().system_level)); 226 EXPECT_THAT(details->system_level(), Eq(test_data().system_level));
245 } 227 }
246 228
247 // Test that the default channel is sniffed properly based on the path. 229 // Test that the default channel is sniffed properly based on the path.
248 TEST_P(MakeProductDetailsTest, DefaultChannel) { 230 TEST_P(MakeProductDetailsTest, DefaultChannel) {
249 std::unique_ptr<PrimaryInstallDetails> details( 231 std::unique_ptr<PrimaryInstallDetails> details(
250 MakeProductDetails(test_data().path)); 232 MakeProductDetails(test_data().path));
251 EXPECT_THAT(details->channel(), StrEq(test_data().channel)); 233 EXPECT_THAT(details->channel(), StrEq(test_data().channel));
252 } 234 }
253 235
254 // Test that multi-install is properly parsed out of the registry.
255 TEST_P(MakeProductDetailsTest, MultiInstall) {
256 {
257 std::unique_ptr<PrimaryInstallDetails> details(
258 MakeProductDetails(test_data().path));
259 EXPECT_FALSE(details->multi_install());
260 }
261
262 {
263 SetUninstallArguments(L"--uninstall");
264 std::unique_ptr<PrimaryInstallDetails> details(
265 MakeProductDetails(test_data().path));
266 EXPECT_FALSE(details->multi_install());
267 }
268
269 if (!kInstallModes[test_data().index].supports_multi_install)
270 return;
271
272 {
273 SetUninstallArguments(L"--uninstall --multi-install --chrome");
274 std::unique_ptr<PrimaryInstallDetails> details(
275 MakeProductDetails(test_data().path));
276 EXPECT_TRUE(details->multi_install());
277 }
278 }
279
280 // Test that the channel name is properly parsed out of additional parameters. 236 // Test that the channel name is properly parsed out of additional parameters.
281 TEST_P(MakeProductDetailsTest, AdditionalParametersChannels) { 237 TEST_P(MakeProductDetailsTest, AdditionalParametersChannels) {
282 const std::pair<const wchar_t*, const wchar_t*> kApChannels[] = { 238 const std::pair<const wchar_t*, const wchar_t*> kApChannels[] = {
283 // stable 239 // stable
284 {L"", L""}, 240 {L"", L""},
285 {L"-full", L""}, 241 {L"-full", L""},
286 {L"x64-stable", L""}, 242 {L"x64-stable", L""},
287 {L"x64-stable-full", L""}, 243 {L"x64-stable-full", L""},
288 {L"baz-x64-stable", L""}, 244 {L"baz-x64-stable", L""},
289 {L"foo-1.1-beta", L""}, 245 {L"foo-1.1-beta", L""},
290 {L"2.0-beta", L""}, 246 {L"2.0-beta", L""},
291 {L"bar-2.0-dev", L""}, 247 {L"bar-2.0-dev", L""},
292 {L"1.0-dev", L""}, 248 {L"1.0-dev", L""},
293 {L"fuzzy", L""}, 249 {L"fuzzy", L""},
294 {L"foo", L""}, 250 {L"foo", L""},
295 {L"-multi-chrome", L""}, 251 {L"-multi-chrome", L""}, // Legacy.
296 {L"x64-stable-multi-chrome", L""}, 252 {L"x64-stable-multi-chrome", L""}, // Legacy.
297 {L"-stage:ensemble_patching-multi-chrome-full", L""}, 253 {L"-stage:ensemble_patching-multi-chrome-full", L""}, // Legacy.
298 {L"-multi-chrome-full", L""}, 254 {L"-multi-chrome-full", L""}, // Legacy.
299 // beta 255 // beta
300 {L"1.1-beta", L"beta"}, 256 {L"1.1-beta", L"beta"},
301 {L"1.1-beta-full", L"beta"}, 257 {L"1.1-beta-full", L"beta"},
302 {L"x64-beta", L"beta"}, 258 {L"x64-beta", L"beta"},
303 {L"x64-beta-full", L"beta"}, 259 {L"x64-beta-full", L"beta"},
304 {L"1.1-bar", L"beta"}, 260 {L"1.1-bar", L"beta"},
305 {L"1n1-foobar", L"beta"}, 261 {L"1n1-foobar", L"beta"},
306 {L"x64-Beta", L"beta"}, 262 {L"x64-Beta", L"beta"},
307 {L"bar-x64-beta", L"beta"}, 263 {L"bar-x64-beta", L"beta"},
308 // dev 264 // dev
309 {L"2.0-dev", L"dev"}, 265 {L"2.0-dev", L"dev"},
310 {L"2.0-dev-full", L"dev"}, 266 {L"2.0-dev-full", L"dev"},
311 {L"x64-dev", L"dev"}, 267 {L"x64-dev", L"dev"},
312 {L"x64-dev-full", L"dev"}, 268 {L"x64-dev-full", L"dev"},
313 {L"2.0-DEV", L"dev"}, 269 {L"2.0-DEV", L"dev"},
314 {L"2.0-dev-eloper", L"dev"}, 270 {L"2.0-dev-eloper", L"dev"},
315 {L"2.0-doom", L"dev"}, 271 {L"2.0-doom", L"dev"},
316 {L"250-doom", L"dev"}, 272 {L"250-doom", L"dev"},
317 }; 273 };
318 274
319 for (const auto& ap_and_channel : kApChannels) { 275 for (const auto& ap_and_channel : kApChannels) {
320 SetAp(ap_and_channel.first, false); 276 SetAp(ap_and_channel.first);
321 std::unique_ptr<PrimaryInstallDetails> details( 277 std::unique_ptr<PrimaryInstallDetails> details(
322 MakeProductDetails(test_data().path)); 278 MakeProductDetails(test_data().path));
323 if (kInstallModes[test_data().index].channel_strategy == 279 if (kInstallModes[test_data().index].channel_strategy ==
324 ChannelStrategy::ADDITIONAL_PARAMETERS) {
325 EXPECT_THAT(details->channel(), StrEq(ap_and_channel.second));
326 } else {
327 // "ap" is ignored for this mode.
328 EXPECT_THAT(details->channel(), StrEq(test_data().channel));
329 }
330 }
331
332 if (!kInstallModes[test_data().index].supports_multi_install)
333 return;
334
335 // For multi-install modes, "ap" is pulled from the binaries' key.
336 for (const auto& ap_and_channel : kApChannels) {
337 SetAp(ap_and_channel.first, true);
338 SetUninstallArguments(L"--uninstall --multi-install --chrome");
339 std::unique_ptr<PrimaryInstallDetails> details(
340 MakeProductDetails(test_data().path));
341 if (kInstallModes[test_data().index].channel_strategy ==
342 ChannelStrategy::ADDITIONAL_PARAMETERS) { 280 ChannelStrategy::ADDITIONAL_PARAMETERS) {
343 EXPECT_THAT(details->channel(), StrEq(ap_and_channel.second)); 281 EXPECT_THAT(details->channel(), StrEq(ap_and_channel.second));
344 } else { 282 } else {
345 // "ap" is ignored for this mode. 283 // "ap" is ignored for this mode.
346 EXPECT_THAT(details->channel(), StrEq(test_data().channel)); 284 EXPECT_THAT(details->channel(), StrEq(test_data().channel));
347 } 285 }
348 } 286 }
349 } 287 }
350 288
351 INSTANTIATE_TEST_CASE_P(All, 289 INSTANTIATE_TEST_CASE_P(All,
352 MakeProductDetailsTest, 290 MakeProductDetailsTest,
353 testing::ValuesIn(kTestData)); 291 testing::ValuesIn(kTestData));
354 292
355 } // namespace install_static 293 } // namespace install_static
OLDNEW
« no previous file with comments | « chrome/install_static/product_install_details.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698