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

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

Issue 1878313003: Convert //chrome/installer from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert decompress.cc in mini_installer. Created 4 years, 8 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/install_worker.h" 5 #include "chrome/installer/setup/install_worker.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/version.h" 10 #include "base/version.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 if (multi_install) 294 if (multi_install)
295 product_state.AddUninstallSwitch(installer::switches::kMultiInstall); 295 product_state.AddUninstallSwitch(installer::switches::kMultiInstall);
296 296
297 installation_state->SetProductState(system_level, 297 installation_state->SetProductState(system_level,
298 BrowserDistribution::CHROME_FRAME, 298 BrowserDistribution::CHROME_FRAME,
299 product_state); 299 product_state);
300 } 300 }
301 301
302 MockInstallationState* BuildChromeInstallationState(bool system_level, 302 MockInstallationState* BuildChromeInstallationState(bool system_level,
303 bool multi_install) { 303 bool multi_install) {
304 scoped_ptr<MockInstallationState> installation_state( 304 std::unique_ptr<MockInstallationState> installation_state(
305 new MockInstallationState()); 305 new MockInstallationState());
306 AddChromeToInstallationState(system_level, multi_install, 306 AddChromeToInstallationState(system_level, multi_install,
307 installation_state.get()); 307 installation_state.get());
308 return installation_state.release(); 308 return installation_state.release();
309 } 309 }
310 310
311 static MockInstallerState* BuildBasicInstallerState( 311 static MockInstallerState* BuildBasicInstallerState(
312 bool system_install, 312 bool system_install,
313 bool multi_install, 313 bool multi_install,
314 const InstallationState& machine_state, 314 const InstallationState& machine_state,
315 InstallerState::Operation operation) { 315 InstallerState::Operation operation) {
316 scoped_ptr<MockInstallerState> installer_state(new MockInstallerState()); 316 std::unique_ptr<MockInstallerState> installer_state(
317 new MockInstallerState());
317 318
318 InstallerState::Level level = system_install ? 319 InstallerState::Level level = system_install ?
319 InstallerState::SYSTEM_LEVEL : InstallerState::USER_LEVEL; 320 InstallerState::SYSTEM_LEVEL : InstallerState::USER_LEVEL;
320 installer_state->set_level(level); 321 installer_state->set_level(level);
321 installer_state->set_operation(operation); 322 installer_state->set_operation(operation);
322 // Hope this next one isn't checked for now. 323 // Hope this next one isn't checked for now.
323 installer_state->set_state_key(L"PROBABLY_INVALID_REG_PATH"); 324 installer_state->set_state_key(L"PROBABLY_INVALID_REG_PATH");
324 installer_state->set_state_type(BrowserDistribution::CHROME_BROWSER); 325 installer_state->set_state_type(BrowserDistribution::CHROME_BROWSER);
325 installer_state->set_package_type(multi_install ? 326 installer_state->set_package_type(multi_install ?
326 InstallerState::MULTI_PACKAGE : 327 InstallerState::MULTI_PACKAGE :
(...skipping 15 matching lines...) Expand all
342 const ProductState* chrome_binaries = 343 const ProductState* chrome_binaries =
343 machine_state.GetProductState(installer_state->system_install(), 344 machine_state.GetProductState(installer_state->system_install(),
344 BrowserDistribution::CHROME_BINARIES); 345 BrowserDistribution::CHROME_BINARIES);
345 if (chrome_binaries != NULL) { 346 if (chrome_binaries != NULL) {
346 installer_state->AddProductFromState(BrowserDistribution::CHROME_BINARIES, 347 installer_state->AddProductFromState(BrowserDistribution::CHROME_BINARIES,
347 *chrome_binaries); 348 *chrome_binaries);
348 } else { 349 } else {
349 BrowserDistribution* dist = 350 BrowserDistribution* dist =
350 BrowserDistribution::GetSpecificDistribution( 351 BrowserDistribution::GetSpecificDistribution(
351 BrowserDistribution::CHROME_BINARIES); 352 BrowserDistribution::CHROME_BINARIES);
352 scoped_ptr<Product> product(new Product(dist)); 353 std::unique_ptr<Product> product(new Product(dist));
353 product->SetOption(installer::kOptionMultiInstall, true); 354 product->SetOption(installer::kOptionMultiInstall, true);
354 installer_state->AddProduct(&product); 355 installer_state->AddProduct(&product);
355 } 356 }
356 } 357 }
357 358
358 static void AddChromeToInstallerState( 359 static void AddChromeToInstallerState(
359 const InstallationState& machine_state, 360 const InstallationState& machine_state,
360 MockInstallerState* installer_state) { 361 MockInstallerState* installer_state) {
361 // Fresh install or upgrade? 362 // Fresh install or upgrade?
362 const ProductState* chrome = 363 const ProductState* chrome =
363 machine_state.GetProductState(installer_state->system_install(), 364 machine_state.GetProductState(installer_state->system_install(),
364 BrowserDistribution::CHROME_BROWSER); 365 BrowserDistribution::CHROME_BROWSER);
365 if (chrome != NULL && 366 if (chrome != NULL &&
366 chrome->is_multi_install() == installer_state->is_multi_install()) { 367 chrome->is_multi_install() == installer_state->is_multi_install()) {
367 installer_state->AddProductFromState(BrowserDistribution::CHROME_BROWSER, 368 installer_state->AddProductFromState(BrowserDistribution::CHROME_BROWSER,
368 *chrome); 369 *chrome);
369 } else { 370 } else {
370 BrowserDistribution* dist = 371 BrowserDistribution* dist =
371 BrowserDistribution::GetSpecificDistribution( 372 BrowserDistribution::GetSpecificDistribution(
372 BrowserDistribution::CHROME_BROWSER); 373 BrowserDistribution::CHROME_BROWSER);
373 scoped_ptr<Product> product(new Product(dist)); 374 std::unique_ptr<Product> product(new Product(dist));
374 if (installer_state->is_multi_install()) 375 if (installer_state->is_multi_install())
375 product->SetOption(installer::kOptionMultiInstall, true); 376 product->SetOption(installer::kOptionMultiInstall, true);
376 installer_state->AddProduct(&product); 377 installer_state->AddProduct(&product);
377 } 378 }
378 } 379 }
379 380
380 static void AddChromeFrameToInstallerState( 381 static void AddChromeFrameToInstallerState(
381 const InstallationState& machine_state, 382 const InstallationState& machine_state,
382 MockInstallerState* installer_state) { 383 MockInstallerState* installer_state) {
383 // Fresh install or upgrade? 384 // Fresh install or upgrade?
384 const ProductState* cf = 385 const ProductState* cf =
385 machine_state.GetProductState(installer_state->system_install(), 386 machine_state.GetProductState(installer_state->system_install(),
386 BrowserDistribution::CHROME_FRAME); 387 BrowserDistribution::CHROME_FRAME);
387 if (cf != NULL) { 388 if (cf != NULL) {
388 installer_state->AddProductFromState(BrowserDistribution::CHROME_FRAME, 389 installer_state->AddProductFromState(BrowserDistribution::CHROME_FRAME,
389 *cf); 390 *cf);
390 } else { 391 } else {
391 BrowserDistribution* dist = 392 BrowserDistribution* dist =
392 BrowserDistribution::GetSpecificDistribution( 393 BrowserDistribution::GetSpecificDistribution(
393 BrowserDistribution::CHROME_FRAME); 394 BrowserDistribution::CHROME_FRAME);
394 scoped_ptr<Product> product(new Product(dist)); 395 std::unique_ptr<Product> product(new Product(dist));
395 if (installer_state->is_multi_install()) 396 if (installer_state->is_multi_install())
396 product->SetOption(installer::kOptionMultiInstall, true); 397 product->SetOption(installer::kOptionMultiInstall, true);
397 installer_state->AddProduct(&product); 398 installer_state->AddProduct(&product);
398 } 399 }
399 } 400 }
400 401
401 static MockInstallerState* BuildChromeInstallerState( 402 static MockInstallerState* BuildChromeInstallerState(
402 bool system_install, 403 bool system_install,
403 bool multi_install, 404 bool multi_install,
404 const InstallationState& machine_state, 405 const InstallationState& machine_state,
405 InstallerState::Operation operation) { 406 InstallerState::Operation operation) {
406 scoped_ptr<MockInstallerState> installer_state( 407 std::unique_ptr<MockInstallerState> installer_state(
407 BuildBasicInstallerState(system_install, multi_install, machine_state, 408 BuildBasicInstallerState(system_install, multi_install, machine_state,
408 operation)); 409 operation));
409 if (multi_install) { 410 if (multi_install) {
410 // We don't want to include Chrome Binaries for uninstall if the machine 411 // We don't want to include Chrome Binaries for uninstall if the machine
411 // has other products. For simplicity, we check Chrome Frame only. 412 // has other products. For simplicity, we check Chrome Frame only.
412 bool machine_has_other_products = 413 bool machine_has_other_products =
413 machine_state.GetProductState(system_install, 414 machine_state.GetProductState(system_install,
414 BrowserDistribution::CHROME_FRAME) != NULL; 415 BrowserDistribution::CHROME_FRAME) != NULL;
415 if (operation != InstallerState::UNINSTALL || !machine_has_other_products) 416 if (operation != InstallerState::UNINSTALL || !machine_has_other_products)
416 AddChromeBinariesToInstallerState(machine_state, installer_state.get()); 417 AddChromeBinariesToInstallerState(machine_state, installer_state.get());
417 } 418 }
418 AddChromeToInstallerState(machine_state, installer_state.get()); 419 AddChromeToInstallerState(machine_state, installer_state.get());
419 return installer_state.release(); 420 return installer_state.release();
420 } 421 }
421 422
422 static MockInstallerState* BuildChromeFrameInstallerState( 423 static MockInstallerState* BuildChromeFrameInstallerState(
423 bool system_install, 424 bool system_install,
424 bool multi_install, 425 bool multi_install,
425 const InstallationState& machine_state, 426 const InstallationState& machine_state,
426 InstallerState::Operation operation) { 427 InstallerState::Operation operation) {
427 // This method only works for installation/upgrade. 428 // This method only works for installation/upgrade.
428 DCHECK(operation != InstallerState::UNINSTALL); 429 DCHECK(operation != InstallerState::UNINSTALL);
429 scoped_ptr<MockInstallerState> installer_state( 430 std::unique_ptr<MockInstallerState> installer_state(
430 BuildBasicInstallerState(system_install, multi_install, machine_state, 431 BuildBasicInstallerState(system_install, multi_install, machine_state,
431 operation)); 432 operation));
432 if (multi_install) 433 if (multi_install)
433 AddChromeBinariesToInstallerState(machine_state, installer_state.get()); 434 AddChromeBinariesToInstallerState(machine_state, installer_state.get());
434 AddChromeFrameToInstallerState(machine_state, installer_state.get()); 435 AddChromeFrameToInstallerState(machine_state, installer_state.get());
435 return installer_state.release(); 436 return installer_state.release();
436 } 437 }
437 438
438 protected: 439 protected:
439 scoped_ptr<Version> current_version_; 440 std::unique_ptr<Version> current_version_;
440 scoped_ptr<Version> new_version_; 441 std::unique_ptr<Version> new_version_;
441 base::FilePath archive_path_; 442 base::FilePath archive_path_;
442 base::FilePath installation_path_; 443 base::FilePath installation_path_;
443 base::FilePath setup_path_; 444 base::FilePath setup_path_;
444 base::FilePath src_path_; 445 base::FilePath src_path_;
445 base::FilePath temp_dir_; 446 base::FilePath temp_dir_;
446 }; 447 };
447 448
448 // Tests 449 // Tests
449 //------------------------------------------------------------------------------ 450 //------------------------------------------------------------------------------
450 451
451 TEST_F(InstallWorkerTest, TestInstallChromeSingleSystem) { 452 TEST_F(InstallWorkerTest, TestInstallChromeSingleSystem) {
452 const bool system_level = true; 453 const bool system_level = true;
453 const bool multi_install = false; 454 const bool multi_install = false;
454 NiceMock<MockWorkItemList> work_item_list; 455 NiceMock<MockWorkItemList> work_item_list;
455 456
456 const HKEY kRegRoot = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 457 const HKEY kRegRoot = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
457 static const wchar_t kRegKeyPath[] = L"Software\\Chromium\\test"; 458 static const wchar_t kRegKeyPath[] = L"Software\\Chromium\\test";
458 scoped_ptr<CreateRegKeyWorkItem> create_reg_key_work_item( 459 std::unique_ptr<CreateRegKeyWorkItem> create_reg_key_work_item(
459 WorkItem::CreateCreateRegKeyWorkItem( 460 WorkItem::CreateCreateRegKeyWorkItem(kRegRoot, kRegKeyPath,
460 kRegRoot, kRegKeyPath, WorkItem::kWow64Default)); 461 WorkItem::kWow64Default));
461 scoped_ptr<SetRegValueWorkItem> set_reg_value_work_item( 462 std::unique_ptr<SetRegValueWorkItem> set_reg_value_work_item(
462 WorkItem::CreateSetRegValueWorkItem( 463 WorkItem::CreateSetRegValueWorkItem(
463 kRegRoot, kRegKeyPath, WorkItem::kWow64Default, L"", L"", false)); 464 kRegRoot, kRegKeyPath, WorkItem::kWow64Default, L"", L"", false));
464 scoped_ptr<DeleteTreeWorkItem> delete_tree_work_item( 465 std::unique_ptr<DeleteTreeWorkItem> delete_tree_work_item(
465 WorkItem::CreateDeleteTreeWorkItem(base::FilePath(), base::FilePath(), 466 WorkItem::CreateDeleteTreeWorkItem(base::FilePath(), base::FilePath(),
466 std::vector<base::FilePath>())); 467 std::vector<base::FilePath>()));
467 scoped_ptr<DeleteRegKeyWorkItem> delete_reg_key_work_item( 468 std::unique_ptr<DeleteRegKeyWorkItem> delete_reg_key_work_item(
468 WorkItem::CreateDeleteRegKeyWorkItem(kRegRoot, kRegKeyPath, 469 WorkItem::CreateDeleteRegKeyWorkItem(kRegRoot, kRegKeyPath,
469 WorkItem::kWow64Default)); 470 WorkItem::kWow64Default));
470 471
471 scoped_ptr<InstallationState> installation_state( 472 std::unique_ptr<InstallationState> installation_state(
472 BuildChromeInstallationState(system_level, multi_install)); 473 BuildChromeInstallationState(system_level, multi_install));
473 474
474 scoped_ptr<InstallerState> installer_state( 475 std::unique_ptr<InstallerState> installer_state(BuildChromeInstallerState(
475 BuildChromeInstallerState(system_level, multi_install, 476 system_level, multi_install, *installation_state,
476 *installation_state, 477 InstallerState::SINGLE_INSTALL_OR_UPDATE));
477 InstallerState::SINGLE_INSTALL_OR_UPDATE));
478 478
479 // Set up some expectations. 479 // Set up some expectations.
480 // TODO(robertshield): Set up some real expectations. 480 // TODO(robertshield): Set up some real expectations.
481 EXPECT_CALL(work_item_list, AddCopyTreeWorkItem(_, _, _, _, _)) 481 EXPECT_CALL(work_item_list, AddCopyTreeWorkItem(_, _, _, _, _))
482 .Times(AtLeast(1)); 482 .Times(AtLeast(1));
483 EXPECT_CALL(work_item_list, AddCreateRegKeyWorkItem(_, _, _)) 483 EXPECT_CALL(work_item_list, AddCreateRegKeyWorkItem(_, _, _))
484 .WillRepeatedly(Return(create_reg_key_work_item.get())); 484 .WillRepeatedly(Return(create_reg_key_work_item.get()));
485 EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(_, _, _, _, _, _)) 485 EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(_, _, _, _, _, _))
486 .WillRepeatedly(Return(set_reg_value_work_item.get())); 486 .WillRepeatedly(Return(set_reg_value_work_item.get()));
487 EXPECT_CALL(work_item_list, AddDeleteTreeWorkItem(_, _)) 487 EXPECT_CALL(work_item_list, AddDeleteTreeWorkItem(_, _))
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 system_level_, multi_install_, *installation_state_, 531 system_level_, multi_install_, *installation_state_,
532 multi_install_ ? InstallerState::MULTI_UPDATE : 532 multi_install_ ? InstallerState::MULTI_UPDATE :
533 InstallerState::SINGLE_INSTALL_OR_UPDATE)); 533 InstallerState::SINGLE_INSTALL_OR_UPDATE));
534 if (multi_install_) 534 if (multi_install_)
535 AddChromeBinariesToInstallerState(*installation_state_, 535 AddChromeBinariesToInstallerState(*installation_state_,
536 installer_state_.get()); 536 installer_state_.get());
537 AddChromeFrameToInstallerState(*installation_state_, 537 AddChromeFrameToInstallerState(*installation_state_,
538 installer_state_.get()); 538 installer_state_.get());
539 } 539 }
540 540
541 scoped_ptr<MockInstallationState> installation_state_; 541 std::unique_ptr<MockInstallationState> installation_state_;
542 scoped_ptr<MockInstallerState> installer_state_; 542 std::unique_ptr<MockInstallerState> installer_state_;
543 bool system_level_; 543 bool system_level_;
544 bool multi_install_; 544 bool multi_install_;
545 HKEY root_key_; 545 HKEY root_key_;
546 }; 546 };
547 547
548 TEST_P(OldIELowRightsTests, AddDeleteOldIELowRightsPolicyWorkItems) { 548 TEST_P(OldIELowRightsTests, AddDeleteOldIELowRightsPolicyWorkItems) {
549 StrictMock<MockWorkItemList> work_item_list; 549 StrictMock<MockWorkItemList> work_item_list;
550 550
551 EXPECT_CALL(work_item_list, 551 EXPECT_CALL(work_item_list,
552 AddDeleteRegKeyWorkItem(root_key_, StrEq(old_elevation_key), _)) 552 AddDeleteRegKeyWorkItem(root_key_, StrEq(old_elevation_key), _))
553 .Times(1); 553 .Times(1);
554 554
555 AddDeleteOldIELowRightsPolicyWorkItems(*installer_state_.get(), 555 AddDeleteOldIELowRightsPolicyWorkItems(*installer_state_.get(),
556 &work_item_list); 556 &work_item_list);
557 } 557 }
558 558
559 INSTANTIATE_TEST_CASE_P(Variations, OldIELowRightsTests, 559 INSTANTIATE_TEST_CASE_P(Variations, OldIELowRightsTests,
560 Combine(Bool(), Bool())); 560 Combine(Bool(), Bool()));
561 561
562 TEST_F(InstallWorkerTest, GoogleUpdateWorkItemsTest) { 562 TEST_F(InstallWorkerTest, GoogleUpdateWorkItemsTest) {
563 const bool system_level = true; 563 const bool system_level = true;
564 const bool multi_install = true; 564 const bool multi_install = true;
565 MockWorkItemList work_item_list; 565 MockWorkItemList work_item_list;
566 566
567 // Per-machine single-install Chrome is installed. 567 // Per-machine single-install Chrome is installed.
568 scoped_ptr<MockInstallationState> installation_state( 568 std::unique_ptr<MockInstallationState> installation_state(
569 BuildChromeInstallationState(system_level, false)); 569 BuildChromeInstallationState(system_level, false));
570 570
571 MockProductState cf_state; 571 MockProductState cf_state;
572 cf_state.set_version(new Version(*current_version_)); 572 cf_state.set_version(new Version(*current_version_));
573 cf_state.set_multi_install(false); 573 cf_state.set_multi_install(false);
574 574
575 // Per-machine single-install Chrome Frame is installed. 575 // Per-machine single-install Chrome Frame is installed.
576 installation_state->SetProductState(system_level, 576 installation_state->SetProductState(system_level,
577 BrowserDistribution::CHROME_FRAME, cf_state); 577 BrowserDistribution::CHROME_FRAME, cf_state);
578 578
579 // Prepare per-machine multi-install Chrome for installation. 579 // Prepare per-machine multi-install Chrome for installation.
580 scoped_ptr<MockInstallerState> installer_state( 580 std::unique_ptr<MockInstallerState> installer_state(BuildChromeInstallerState(
581 BuildChromeInstallerState(system_level, multi_install, 581 system_level, multi_install, *installation_state,
582 *installation_state, 582 InstallerState::MULTI_INSTALL));
583 InstallerState::MULTI_INSTALL));
584 583
585 // Expect the multi Client State key to be created for the binaries. 584 // Expect the multi Client State key to be created for the binaries.
586 #if defined(GOOGLE_CHROME_BUILD) 585 #if defined(GOOGLE_CHROME_BUILD)
587 BrowserDistribution* multi_dist = 586 BrowserDistribution* multi_dist =
588 BrowserDistribution::GetSpecificDistribution( 587 BrowserDistribution::GetSpecificDistribution(
589 BrowserDistribution::CHROME_BINARIES); 588 BrowserDistribution::CHROME_BINARIES);
590 std::wstring multi_app_guid(multi_dist->GetAppGuid()); 589 std::wstring multi_app_guid(multi_dist->GetAppGuid());
591 std::wstring multi_client_state_suffix(L"ClientState\\" + multi_app_guid); 590 std::wstring multi_client_state_suffix(L"ClientState\\" + multi_app_guid);
592 std::wstring multi_medium_suffix(L"ClientStateMedium\\" + multi_app_guid); 591 std::wstring multi_medium_suffix(L"ClientStateMedium\\" + multi_app_guid);
593 592
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 *installer_state.get(), 629 *installer_state.get(),
631 &work_item_list); 630 &work_item_list);
632 } 631 }
633 632
634 // Test that usagestats values are migrated properly. 633 // Test that usagestats values are migrated properly.
635 TEST_F(InstallWorkerTest, AddUsageStatsWorkItems) { 634 TEST_F(InstallWorkerTest, AddUsageStatsWorkItems) {
636 const bool system_level = true; 635 const bool system_level = true;
637 const bool multi_install = true; 636 const bool multi_install = true;
638 MockWorkItemList work_item_list; 637 MockWorkItemList work_item_list;
639 638
640 scoped_ptr<MockInstallationState> installation_state( 639 std::unique_ptr<MockInstallationState> installation_state(
641 BuildChromeInstallationState(system_level, multi_install)); 640 BuildChromeInstallationState(system_level, multi_install));
642 641
643 MockProductState chrome_state; 642 MockProductState chrome_state;
644 chrome_state.set_version(new Version(*current_version_)); 643 chrome_state.set_version(new Version(*current_version_));
645 chrome_state.set_multi_install(false); 644 chrome_state.set_multi_install(false);
646 chrome_state.set_usagestats(1); 645 chrome_state.set_usagestats(1);
647 646
648 installation_state->SetProductState(system_level, 647 installation_state->SetProductState(system_level,
649 BrowserDistribution::CHROME_BROWSER, chrome_state); 648 BrowserDistribution::CHROME_BROWSER, chrome_state);
650 649
651 scoped_ptr<MockInstallerState> installer_state( 650 std::unique_ptr<MockInstallerState> installer_state(BuildChromeInstallerState(
652 BuildChromeInstallerState(system_level, multi_install, 651 system_level, multi_install, *installation_state,
653 *installation_state, 652 InstallerState::MULTI_INSTALL));
654 InstallerState::MULTI_INSTALL));
655 653
656 // Expect the multi Client State key to be created. 654 // Expect the multi Client State key to be created.
657 BrowserDistribution* multi_dist = 655 BrowserDistribution* multi_dist =
658 BrowserDistribution::GetSpecificDistribution( 656 BrowserDistribution::GetSpecificDistribution(
659 BrowserDistribution::CHROME_BINARIES); 657 BrowserDistribution::CHROME_BINARIES);
660 std::wstring multi_app_guid(multi_dist->GetAppGuid()); 658 std::wstring multi_app_guid(multi_dist->GetAppGuid());
661 EXPECT_CALL(work_item_list, AddCreateRegKeyWorkItem( 659 EXPECT_CALL(work_item_list, AddCreateRegKeyWorkItem(
662 _, HasSubstr(multi_app_guid), _)).Times(1); 660 _, HasSubstr(multi_app_guid), _)).Times(1);
663 661
664 // Expect to see a set value for the usagestats in the multi Client State key. 662 // Expect to see a set value for the usagestats in the multi Client State key.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 virtual void TearDown() { 723 virtual void TearDown() {
726 machine_state_.reset(); 724 machine_state_.reset();
727 delete_reg_key_item_.reset(); 725 delete_reg_key_item_.reset();
728 root_key_ = NULL; 726 root_key_ = NULL;
729 InstallWorkerTest::TearDown(); 727 InstallWorkerTest::TearDown();
730 } 728 }
731 protected: 729 protected:
732 static const bool system_level_ = false; 730 static const bool system_level_ = false;
733 static const wchar_t kRegKeyPath[]; 731 static const wchar_t kRegKeyPath[];
734 HKEY root_key_; 732 HKEY root_key_;
735 scoped_ptr<DeleteRegKeyWorkItem> delete_reg_key_item_; 733 std::unique_ptr<DeleteRegKeyWorkItem> delete_reg_key_item_;
736 scoped_ptr<MockInstallationState> machine_state_; 734 std::unique_ptr<MockInstallationState> machine_state_;
737 StrictMock<MockWorkItemList> work_item_list_; 735 StrictMock<MockWorkItemList> work_item_list_;
738 }; 736 };
739 737
740 const wchar_t QuickEnableAbsentTest::kRegKeyPath[] = 738 const wchar_t QuickEnableAbsentTest::kRegKeyPath[] =
741 L"Software\\Google\\Update\\Clients\\" 739 L"Software\\Google\\Update\\Clients\\"
742 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}\\Commands\\quick-enable-cf"; 740 L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}\\Commands\\quick-enable-cf";
743 741
744 TEST_F(QuickEnableAbsentTest, CleanInstallSingleChrome) { 742 TEST_F(QuickEnableAbsentTest, CleanInstallSingleChrome) {
745 // Install single Chrome on a clean system. 743 // Install single Chrome on a clean system.
746 scoped_ptr<MockInstallerState> installer_state( 744 std::unique_ptr<MockInstallerState> installer_state(BuildBasicInstallerState(
747 BuildBasicInstallerState(system_level_, true, *machine_state_, 745 system_level_, true, *machine_state_, InstallerState::MULTI_UPDATE));
748 InstallerState::MULTI_UPDATE));
749 AddQuickEnableChromeFrameWorkItems(*installer_state, &work_item_list_); 746 AddQuickEnableChromeFrameWorkItems(*installer_state, &work_item_list_);
750 } 747 }
751 748
752 TEST_F(InstallWorkerTest, WillProductBePresentAfterSetup) { 749 TEST_F(InstallWorkerTest, WillProductBePresentAfterSetup) {
753 BrowserDistribution::Type prod_type_list[] = { 750 BrowserDistribution::Type prod_type_list[] = {
754 BrowserDistribution::CHROME_BROWSER, 751 BrowserDistribution::CHROME_BROWSER,
755 BrowserDistribution::CHROME_FRAME, 752 BrowserDistribution::CHROME_FRAME,
756 // Excluding BrowserDistribution::CHROME_BINARIES, since it is installed 753 // Excluding BrowserDistribution::CHROME_BINARIES, since it is installed
757 // along with other products. 754 // along with other products.
758 }; 755 };
759 enum { // Index into prod_type_list[]. 756 enum { // Index into prod_type_list[].
760 TYPE_BROWSER = 0, 757 TYPE_BROWSER = 0,
761 TYPE_CF, 758 TYPE_CF,
762 NUM_TYPE // This must appear last. 759 NUM_TYPE // This must appear last.
763 }; 760 };
764 DCHECK(arraysize(prod_type_list) == NUM_TYPE); 761 DCHECK(arraysize(prod_type_list) == NUM_TYPE);
765 InstallerState::Operation op_list[] = { 762 InstallerState::Operation op_list[] = {
766 InstallerState::UNINSTALL, 763 InstallerState::UNINSTALL,
767 InstallerState::SINGLE_INSTALL_OR_UPDATE 764 InstallerState::SINGLE_INSTALL_OR_UPDATE
768 }; 765 };
769 766
770 const bool system_level = false; 767 const bool system_level = false;
771 const bool multi_install = true; 768 const bool multi_install = true;
772 769
773 // Loop over machine states: {No product, Chrome, CF, Chrome + CF}. 770 // Loop over machine states: {No product, Chrome, CF, Chrome + CF}.
774 for (int i_mach = 0; i_mach < (1 << NUM_TYPE); ++i_mach) { 771 for (int i_mach = 0; i_mach < (1 << NUM_TYPE); ++i_mach) {
775 // i_mach is the machine state before operation, as bit mask. 772 // i_mach is the machine state before operation, as bit mask.
776 scoped_ptr<MockInstallationState> machine_state( 773 std::unique_ptr<MockInstallationState> machine_state(
777 new MockInstallationState()); 774 new MockInstallationState());
778 if ((i_mach & (1 << TYPE_BROWSER)) != 0) { // Add Chrome. 775 if ((i_mach & (1 << TYPE_BROWSER)) != 0) { // Add Chrome.
779 AddChromeToInstallationState(system_level, multi_install, 776 AddChromeToInstallationState(system_level, multi_install,
780 machine_state.get()); 777 machine_state.get());
781 } 778 }
782 if ((i_mach & (1 << TYPE_CF)) != 0) { // Add Chrome Frame. 779 if ((i_mach & (1 << TYPE_CF)) != 0) { // Add Chrome Frame.
783 AddChromeFrameToInstallationState(system_level, multi_install, 780 AddChromeFrameToInstallationState(system_level, multi_install,
784 machine_state.get()); 781 machine_state.get());
785 } 782 }
786 783
787 // Loop over operations: {uninstall, install/update}. 784 // Loop over operations: {uninstall, install/update}.
788 for (InstallerState::Operation op : op_list) { 785 for (InstallerState::Operation op : op_list) {
789 786
790 // Loop over product types to operate on: {TYPE_BROWSER, TYPE_CF}. 787 // Loop over product types to operate on: {TYPE_BROWSER, TYPE_CF}.
791 for (int i_type_op = 0; i_type_op < NUM_TYPE; ++i_type_op) { 788 for (int i_type_op = 0; i_type_op < NUM_TYPE; ++i_type_op) {
792 scoped_ptr<InstallerState> installer_state; 789 std::unique_ptr<InstallerState> installer_state;
793 if (i_type_op == TYPE_BROWSER) { 790 if (i_type_op == TYPE_BROWSER) {
794 installer_state.reset(BuildChromeInstallerState( 791 installer_state.reset(BuildChromeInstallerState(
795 system_level, multi_install, *machine_state, op)); 792 system_level, multi_install, *machine_state, op));
796 } else if (i_type_op == TYPE_CF) { 793 } else if (i_type_op == TYPE_CF) {
797 // Skip the CF uninstall case due to limitations in 794 // Skip the CF uninstall case due to limitations in
798 // BuildChromeFrameInstallerState(). 795 // BuildChromeFrameInstallerState().
799 if (op == InstallerState::UNINSTALL) 796 if (op == InstallerState::UNINSTALL)
800 continue; 797 continue;
801 798
802 installer_state.reset(BuildChromeFrameInstallerState( 799 installer_state.reset(BuildChromeFrameInstallerState(
(...skipping 26 matching lines...) Expand all
829 prod_type_list[i_type_check]); 826 prod_type_list[i_type_check]);
830 bool prod_expect = (mach_after & (1 << i_type_check)) != 0; 827 bool prod_expect = (mach_after & (1 << i_type_check)) != 0;
831 EXPECT_EQ(prod_expect, prod_res); 828 EXPECT_EQ(prod_expect, prod_res);
832 } 829 }
833 } 830 }
834 } 831 }
835 } 832 }
836 } 833 }
837 834
838 #endif // defined(GOOGLE_CHROME_BUILD) 835 #endif // defined(GOOGLE_CHROME_BUILD)
OLDNEW
« no previous file with comments | « chrome/installer/setup/install_worker.cc ('k') | chrome/installer/setup/installer_crash_reporter_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698