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

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

Issue 1214343003: Fix broken unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 5 years, 5 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 | « no previous file | 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 (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>
8
7 #include "base/win/registry.h" 9 #include "base/win/registry.h"
8 #include "base/version.h" 10 #include "base/version.h"
9 #include "chrome/common/chrome_constants.h" 11 #include "chrome/common/chrome_constants.h"
10 #include "chrome/installer/setup/setup_util.h" 12 #include "chrome/installer/setup/setup_util.h"
13 #include "chrome/installer/util/create_reg_key_work_item.h"
11 #include "chrome/installer/util/delete_reg_key_work_item.h" 14 #include "chrome/installer/util/delete_reg_key_work_item.h"
12 #include "chrome/installer/util/create_reg_key_work_item.h" 15 #include "chrome/installer/util/delete_tree_work_item.h"
13 #include "chrome/installer/util/helper.h" 16 #include "chrome/installer/util/helper.h"
14 #include "chrome/installer/util/google_update_constants.h" 17 #include "chrome/installer/util/google_update_constants.h"
15 #include "chrome/installer/util/installation_state.h" 18 #include "chrome/installer/util/installation_state.h"
16 #include "chrome/installer/util/installer_state.h" 19 #include "chrome/installer/util/installer_state.h"
17 #include "chrome/installer/util/set_reg_value_work_item.h" 20 #include "chrome/installer/util/set_reg_value_work_item.h"
18 #include "chrome/installer/util/util_constants.h" 21 #include "chrome/installer/util/util_constants.h"
19 #include "chrome/installer/util/work_item_list.h" 22 #include "chrome/installer/util/work_item_list.h"
20 23
21 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
22 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
23 26
24 using base::win::RegKey; 27 using base::win::RegKey;
25 using installer::InstallationState; 28 using installer::InstallationState;
26 using installer::InstallerState; 29 using installer::InstallerState;
27 using installer::Product; 30 using installer::Product;
28 using installer::ProductState; 31 using installer::ProductState;
29 32
30 using ::testing::_; 33 using ::testing::_;
34 using ::testing::AnyNumber;
31 using ::testing::AtLeast; 35 using ::testing::AtLeast;
32 using ::testing::AtMost; 36 using ::testing::AtMost;
33 using ::testing::Bool; 37 using ::testing::Bool;
34 using ::testing::Combine; 38 using ::testing::Combine;
39 using ::testing::Eq;
35 using ::testing::HasSubstr; 40 using ::testing::HasSubstr;
36 using ::testing::Eq; 41 using ::testing::NiceMock;
37 using ::testing::Return; 42 using ::testing::Return;
38 using ::testing::StrCaseEq; 43 using ::testing::StrCaseEq;
39 using ::testing::StrEq; 44 using ::testing::StrEq;
40 using ::testing::StrictMock; 45 using ::testing::StrictMock;
41 using ::testing::Values; 46 using ::testing::Values;
42 47
43 // Mock classes to help with testing 48 // Mock classes to help with testing
44 //------------------------------------------------------------------------------ 49 //------------------------------------------------------------------------------
45 50
46 class MockWorkItemList : public WorkItemList { 51 class MockWorkItemList : public WorkItemList {
47 public: 52 public:
48 MockWorkItemList() {} 53 MockWorkItemList() {}
49 54
50 MOCK_METHOD4(AddCopyRegKeyWorkItem, WorkItem* (HKEY, 55 MOCK_METHOD5(AddCopyTreeWorkItem,
51 const std::wstring&, 56 WorkItem*(const std::wstring&,
52 const std::wstring&, 57 const std::wstring&,
53 CopyOverWriteOption)); 58 const std::wstring&,
54 MOCK_METHOD5(AddCopyTreeWorkItem, WorkItem*(const std::wstring&, 59 CopyOverWriteOption,
55 const std::wstring&, 60 const std::wstring&));
56 const std::wstring&,
57 CopyOverWriteOption,
58 const std::wstring&));
59 MOCK_METHOD1(AddCreateDirWorkItem, WorkItem* (const base::FilePath&)); 61 MOCK_METHOD1(AddCreateDirWorkItem, WorkItem* (const base::FilePath&));
60 MOCK_METHOD2(AddCreateRegKeyWorkItem, WorkItem* (HKEY, const std::wstring&)); 62 MOCK_METHOD3(AddCreateRegKeyWorkItem,
61 MOCK_METHOD2(AddDeleteRegKeyWorkItem, WorkItem* (HKEY, const std::wstring&)); 63 WorkItem*(HKEY, const std::wstring&, REGSAM));
62 MOCK_METHOD3(AddDeleteRegValueWorkItem, WorkItem* (HKEY, 64 MOCK_METHOD3(AddDeleteRegKeyWorkItem,
63 const std::wstring&, 65 WorkItem*(HKEY, const std::wstring&, REGSAM));
64 const std::wstring&)); 66 MOCK_METHOD4(
65 MOCK_METHOD2(AddDeleteTreeWorkItem, WorkItem* ( 67 AddDeleteRegValueWorkItem,
66 const base::FilePath&, 68 WorkItem*(HKEY, const std::wstring&, REGSAM, const std::wstring&));
67 const std::vector<base::FilePath>&)); 69 MOCK_METHOD3(AddDeleteTreeWorkItem,
68 MOCK_METHOD1(AddDeleteTreeWorkItem, WorkItem* (const base::FilePath&)); 70 WorkItem*(const base::FilePath&,
69 MOCK_METHOD3(AddMoveTreeWorkItem, WorkItem* (const std::wstring&, 71 const base::FilePath&,
70 const std::wstring&, 72 const std::vector<base::FilePath>&));
71 const std::wstring&)); 73 MOCK_METHOD2(AddDeleteTreeWorkItem,
74 WorkItem*(const base::FilePath&, const base::FilePath&));
75 MOCK_METHOD4(AddMoveTreeWorkItem,
76 WorkItem*(const std::wstring&,
77 const std::wstring&,
78 const std::wstring&,
79 MoveTreeOption));
72 // Workaround for gmock problems with disambiguating between string pointers 80 // Workaround for gmock problems with disambiguating between string pointers
73 // and DWORD. 81 // and DWORD.
74 virtual WorkItem* AddSetRegValueWorkItem(HKEY a1, const std::wstring& a2, 82 virtual WorkItem* AddSetRegValueWorkItem(HKEY a1,
75 const std::wstring& a3, const std::wstring& a4, bool a5) { 83 const std::wstring& a2,
76 return AddSetRegStringValueWorkItem(a1, a2, a3, a4, a5); 84 REGSAM a3,
85 const std::wstring& a4,
86 const std::wstring& a5,
87 bool a6) {
88 return AddSetRegStringValueWorkItem(a1, a2, a3, a4, a5, a6);
77 } 89 }
78 90
79 virtual WorkItem* AddSetRegValueWorkItem(HKEY a1, const std::wstring& a2, 91 virtual WorkItem* AddSetRegValueWorkItem(HKEY a1,
80 const std::wstring& a3, 92 const std::wstring& a2,
81 DWORD a4, bool a5) { 93 REGSAM a3,
82 return AddSetRegDwordValueWorkItem(a1, a2, a3, a4, a5); 94 const std::wstring& a4,
95 DWORD a5,
96 bool a6) {
97 return AddSetRegDwordValueWorkItem(a1, a2, a3, a4, a5, a6);
83 } 98 }
84 99
85 MOCK_METHOD5(AddSetRegStringValueWorkItem, WorkItem*(HKEY, 100 MOCK_METHOD6(AddSetRegStringValueWorkItem,
86 const std::wstring&, 101 WorkItem*(HKEY,
87 const std::wstring&, 102 const std::wstring&,
88 const std::wstring&, 103 REGSAM,
89 bool)); 104 const std::wstring&,
90 MOCK_METHOD5(AddSetRegDwordValueWorkItem, WorkItem* (HKEY, 105 const std::wstring&,
91 const std::wstring&, 106 bool));
92 const std::wstring&, 107 MOCK_METHOD6(AddSetRegDwordValueWorkItem,
93 DWORD, 108 WorkItem*(HKEY,
94 bool)); 109 const std::wstring&,
110 REGSAM,
111 const std::wstring&,
112 DWORD,
113 bool));
95 MOCK_METHOD3(AddSelfRegWorkItem, WorkItem* (const std::wstring&, 114 MOCK_METHOD3(AddSelfRegWorkItem, WorkItem* (const std::wstring&,
96 bool, 115 bool,
97 bool)); 116 bool));
98 }; 117 };
99 118
100 class MockProductState : public ProductState { 119 class MockProductState : public ProductState {
101 public: 120 public:
102 // Takes ownership of |version|. 121 // Takes ownership of |version|.
103 void set_version(Version* version) { version_.reset(version); } 122 void set_version(Version* version) { version_.reset(version); }
104 void set_multi_install(bool multi) { multi_install_ = multi; } 123 void set_multi_install(bool multi) { multi_install_ = multi; }
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 base::FilePath src_path_; 444 base::FilePath src_path_;
426 base::FilePath temp_dir_; 445 base::FilePath temp_dir_;
427 }; 446 };
428 447
429 // Tests 448 // Tests
430 //------------------------------------------------------------------------------ 449 //------------------------------------------------------------------------------
431 450
432 TEST_F(InstallWorkerTest, TestInstallChromeSingleSystem) { 451 TEST_F(InstallWorkerTest, TestInstallChromeSingleSystem) {
433 const bool system_level = true; 452 const bool system_level = true;
434 const bool multi_install = false; 453 const bool multi_install = false;
435 MockWorkItemList work_item_list; 454 NiceMock<MockWorkItemList> work_item_list;
436 455
437 const HKEY kRegRoot = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 456 const HKEY kRegRoot = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
438 static const wchar_t kRegKeyPath[] = L"Software\\Chromium\\test"; 457 static const wchar_t kRegKeyPath[] = L"Software\\Chromium\\test";
439 scoped_ptr<CreateRegKeyWorkItem> create_reg_key_work_item( 458 scoped_ptr<CreateRegKeyWorkItem> create_reg_key_work_item(
440 WorkItem::CreateCreateRegKeyWorkItem( 459 WorkItem::CreateCreateRegKeyWorkItem(
441 kRegRoot, kRegKeyPath, WorkItem::kWow64Default)); 460 kRegRoot, kRegKeyPath, WorkItem::kWow64Default));
442 scoped_ptr<SetRegValueWorkItem> set_reg_value_work_item( 461 scoped_ptr<SetRegValueWorkItem> set_reg_value_work_item(
443 WorkItem::CreateSetRegValueWorkItem( 462 WorkItem::CreateSetRegValueWorkItem(
444 kRegRoot, kRegKeyPath, WorkItem::kWow64Default, L"", L"", false)); 463 kRegRoot, kRegKeyPath, WorkItem::kWow64Default, L"", L"", false));
464 scoped_ptr<DeleteTreeWorkItem> delete_tree_work_item(
465 WorkItem::CreateDeleteTreeWorkItem(base::FilePath(), base::FilePath(),
466 std::vector<base::FilePath>()));
467 scoped_ptr<DeleteRegKeyWorkItem> delete_reg_key_work_item(
468 WorkItem::CreateDeleteRegKeyWorkItem(kRegRoot, kRegKeyPath,
469 WorkItem::kWow64Default));
445 470
446 scoped_ptr<InstallationState> installation_state( 471 scoped_ptr<InstallationState> installation_state(
447 BuildChromeInstallationState(system_level, multi_install)); 472 BuildChromeInstallationState(system_level, multi_install));
448 473
449 scoped_ptr<InstallerState> installer_state( 474 scoped_ptr<InstallerState> installer_state(
450 BuildChromeInstallerState(system_level, multi_install, 475 BuildChromeInstallerState(system_level, multi_install,
451 *installation_state, 476 *installation_state,
452 InstallerState::SINGLE_INSTALL_OR_UPDATE)); 477 InstallerState::SINGLE_INSTALL_OR_UPDATE));
453 478
454 // Set up some expectations. 479 // Set up some expectations.
455 // TODO(robertshield): Set up some real expectations. 480 // TODO(robertshield): Set up some real expectations.
456 EXPECT_CALL(work_item_list, AddCopyTreeWorkItem(_, _, _, _, _)) 481 EXPECT_CALL(work_item_list, AddCopyTreeWorkItem(_, _, _, _, _))
457 .Times(AtLeast(1)); 482 .Times(AtLeast(1));
458 EXPECT_CALL(work_item_list, AddCreateRegKeyWorkItem(_, _)) 483 EXPECT_CALL(work_item_list, AddCreateRegKeyWorkItem(_, _, _))
459 .WillRepeatedly(Return(create_reg_key_work_item.get())); 484 .WillRepeatedly(Return(create_reg_key_work_item.get()));
460 EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(_, _, _, _, _)) 485 EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(_, _, _, _, _, _))
461 .WillRepeatedly(Return(set_reg_value_work_item.get())); 486 .WillRepeatedly(Return(set_reg_value_work_item.get()));
487 EXPECT_CALL(work_item_list, AddDeleteTreeWorkItem(_, _))
488 .WillRepeatedly(Return(delete_tree_work_item.get()));
489 EXPECT_CALL(work_item_list, AddDeleteRegKeyWorkItem(_, _, _))
490 .WillRepeatedly(Return(delete_reg_key_work_item.get()));
462 491
463 AddInstallWorkItems(*installation_state.get(), 492 AddInstallWorkItems(*installation_state.get(),
464 *installer_state.get(), 493 *installer_state.get(),
465 setup_path_, 494 setup_path_,
466 archive_path_, 495 archive_path_,
467 src_path_, 496 src_path_,
468 temp_dir_, 497 temp_dir_,
469 current_version_.get(), 498 current_version_.get(),
470 *new_version_.get(), 499 *new_version_.get(),
471 &work_item_list); 500 &work_item_list);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 scoped_ptr<MockInstallerState> installer_state_; 545 scoped_ptr<MockInstallerState> installer_state_;
517 bool system_level_; 546 bool system_level_;
518 bool multi_install_; 547 bool multi_install_;
519 HKEY root_key_; 548 HKEY root_key_;
520 }; 549 };
521 550
522 TEST_P(OldIELowRightsTests, AddDeleteOldIELowRightsPolicyWorkItems) { 551 TEST_P(OldIELowRightsTests, AddDeleteOldIELowRightsPolicyWorkItems) {
523 StrictMock<MockWorkItemList> work_item_list; 552 StrictMock<MockWorkItemList> work_item_list;
524 553
525 EXPECT_CALL(work_item_list, 554 EXPECT_CALL(work_item_list,
526 AddDeleteRegKeyWorkItem(root_key_, StrEq(old_elevation_key))) 555 AddDeleteRegKeyWorkItem(root_key_, StrEq(old_elevation_key), _))
527 .Times(1); 556 .Times(1);
528 557
529 AddDeleteOldIELowRightsPolicyWorkItems(*installer_state_.get(), 558 AddDeleteOldIELowRightsPolicyWorkItems(*installer_state_.get(),
530 &work_item_list); 559 &work_item_list);
531 } 560 }
532 561
533 INSTANTIATE_TEST_CASE_P(Variations, OldIELowRightsTests, 562 INSTANTIATE_TEST_CASE_P(Variations, OldIELowRightsTests,
534 Combine(Bool(), Bool())); 563 Combine(Bool(), Bool()));
535 564
536 TEST_F(InstallWorkerTest, GoogleUpdateWorkItemsTest) { 565 TEST_F(InstallWorkerTest, GoogleUpdateWorkItemsTest) {
537 const bool system_level = true; 566 const bool system_level = true;
538 const bool multi_install = true; 567 const bool multi_install = true;
539 MockWorkItemList work_item_list; 568 MockWorkItemList work_item_list;
540 569
570 // Per-machine single-install Chrome is installed.
541 scoped_ptr<MockInstallationState> installation_state( 571 scoped_ptr<MockInstallationState> installation_state(
542 BuildChromeInstallationState(system_level, false)); 572 BuildChromeInstallationState(system_level, false));
543 573
544 MockProductState cf_state; 574 MockProductState cf_state;
545 cf_state.set_version(new Version(*current_version_)); 575 cf_state.set_version(new Version(*current_version_));
546 cf_state.set_multi_install(false); 576 cf_state.set_multi_install(false);
547 577
578 // Per-machine single-install Chrome Frame is installed.
548 installation_state->SetProductState(system_level, 579 installation_state->SetProductState(system_level,
549 BrowserDistribution::CHROME_FRAME, cf_state); 580 BrowserDistribution::CHROME_FRAME, cf_state);
550 581
582 // Prepare per-machine multi-install Chrome for installation.
551 scoped_ptr<MockInstallerState> installer_state( 583 scoped_ptr<MockInstallerState> installer_state(
552 BuildChromeInstallerState(system_level, multi_install, 584 BuildChromeInstallerState(system_level, multi_install,
553 *installation_state, 585 *installation_state,
554 InstallerState::MULTI_INSTALL)); 586 InstallerState::MULTI_INSTALL));
555 587
556 // Expect the multi Client State key to be created. 588 // Expect the multi Client State key to be created for the binaries.
557 BrowserDistribution* multi_dist = 589 BrowserDistribution* multi_dist =
558 BrowserDistribution::GetSpecificDistribution( 590 BrowserDistribution::GetSpecificDistribution(
559 BrowserDistribution::CHROME_BINARIES); 591 BrowserDistribution::CHROME_BINARIES);
560 std::wstring multi_app_guid(multi_dist->GetAppGuid()); 592 std::wstring multi_app_guid(multi_dist->GetAppGuid());
561 std::wstring multi_client_state_suffix(L"ClientState\\" + multi_app_guid); 593 std::wstring multi_client_state_suffix(L"ClientState\\" + multi_app_guid);
562 EXPECT_CALL(work_item_list, 594 EXPECT_CALL(work_item_list, AddCreateRegKeyWorkItem(
563 AddCreateRegKeyWorkItem(_, HasSubstr(multi_client_state_suffix))) 595 _, HasSubstr(multi_client_state_suffix), _))
564 .Times(testing::AnyNumber()); 596 .Times(AnyNumber());
565 597
566 // Expect ClientStateMedium to be created for system-level installs. 598 // Expect ClientStateMedium to be created for system-level installs.
567 EXPECT_CALL(work_item_list, 599 EXPECT_CALL(work_item_list,
568 AddCreateRegKeyWorkItem(_, HasSubstr(L"ClientStateMedium\\" + 600 AddCreateRegKeyWorkItem(
569 multi_app_guid))) 601 _, HasSubstr(L"ClientStateMedium\\" + multi_app_guid), _))
570 .Times(system_level ? 1 : 0); 602 .Times(system_level ? 1 : 0);
571 603
572 // Expect to see a set value for the "TEST" brand code in the multi Client 604 // Expect to see a set value for the "TEST" brand code in the multi Client
573 // State key. 605 // State key.
574 EXPECT_CALL(work_item_list, 606 EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(
575 AddSetRegStringValueWorkItem(_, 607 _, HasSubstr(multi_client_state_suffix), _,
576 HasSubstr(multi_client_state_suffix), 608 StrEq(google_update::kRegBrandField),
577 StrEq(google_update::kRegBrandField), 609 StrEq(L"TEST"), _)).Times(1);
578 StrEq(L"TEST"),
579 _)).Times(1);
580 610
581 // There may also be some calls to set 'ap' values. 611 // There may also be some calls to set 'ap' values.
582 EXPECT_CALL(work_item_list, 612 EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(
583 AddSetRegStringValueWorkItem(_, _, 613 _, _, _, StrEq(google_update::kRegApField), _,
584 StrEq(google_update::kRegApField), 614 _)).Times(AnyNumber());
585 _, _)).Times(testing::AnyNumber());
586 615
587 // Expect "oeminstall" to be cleared. 616 // Expect "oeminstall" to be cleared.
588 EXPECT_CALL(work_item_list, 617 EXPECT_CALL(work_item_list, AddDeleteRegValueWorkItem(
589 AddDeleteRegValueWorkItem( 618 _, HasSubstr(multi_client_state_suffix), _,
590 _, 619 StrEq(google_update::kRegOemInstallField)))
591 HasSubstr(multi_client_state_suffix), 620 .Times(1);
592 StrEq(google_update::kRegOemInstallField))).Times(1);
593 621
594 // Expect "eulaaccepted" to set. 622 // Expect "eulaaccepted" to set.
595 EXPECT_CALL(work_item_list, 623 EXPECT_CALL(work_item_list, AddSetRegDwordValueWorkItem(
596 AddSetRegDwordValueWorkItem( 624 _, HasSubstr(multi_client_state_suffix), _,
597 _, 625 StrEq(google_update::kRegEULAAceptedField),
598 HasSubstr(multi_client_state_suffix), 626 Eq(static_cast<DWORD>(1)), _)).Times(1);
599 StrEq(google_update::kRegEULAAceptedField),
600 Eq(static_cast<DWORD>(1)),
601 _)).Times(1);
602 627
603 AddGoogleUpdateWorkItems(*installation_state.get(), 628 AddGoogleUpdateWorkItems(*installation_state.get(),
604 *installer_state.get(), 629 *installer_state.get(),
605 &work_item_list); 630 &work_item_list);
606 } 631 }
607 632
608 // Test that usagestats values are migrated properly. 633 // Test that usagestats values are migrated properly.
609 TEST_F(InstallWorkerTest, AddUsageStatsWorkItems) { 634 TEST_F(InstallWorkerTest, AddUsageStatsWorkItems) {
610 const bool system_level = true; 635 const bool system_level = true;
611 const bool multi_install = true; 636 const bool multi_install = true;
(...skipping 13 matching lines...) Expand all
625 scoped_ptr<MockInstallerState> installer_state( 650 scoped_ptr<MockInstallerState> installer_state(
626 BuildChromeInstallerState(system_level, multi_install, 651 BuildChromeInstallerState(system_level, multi_install,
627 *installation_state, 652 *installation_state,
628 InstallerState::MULTI_INSTALL)); 653 InstallerState::MULTI_INSTALL));
629 654
630 // Expect the multi Client State key to be created. 655 // Expect the multi Client State key to be created.
631 BrowserDistribution* multi_dist = 656 BrowserDistribution* multi_dist =
632 BrowserDistribution::GetSpecificDistribution( 657 BrowserDistribution::GetSpecificDistribution(
633 BrowserDistribution::CHROME_BINARIES); 658 BrowserDistribution::CHROME_BINARIES);
634 std::wstring multi_app_guid(multi_dist->GetAppGuid()); 659 std::wstring multi_app_guid(multi_dist->GetAppGuid());
635 EXPECT_CALL(work_item_list, 660 EXPECT_CALL(work_item_list, AddCreateRegKeyWorkItem(
636 AddCreateRegKeyWorkItem(_, HasSubstr(multi_app_guid))).Times(1); 661 _, HasSubstr(multi_app_guid), _)).Times(1);
637 662
638 // Expect to see a set value for the usagestats in the multi Client State key. 663 // Expect to see a set value for the usagestats in the multi Client State key.
639 EXPECT_CALL(work_item_list, 664 EXPECT_CALL(work_item_list, AddSetRegDwordValueWorkItem(
640 AddSetRegDwordValueWorkItem( 665 _, HasSubstr(multi_app_guid), _,
641 _, 666 StrEq(google_update::kRegUsageStatsField),
642 HasSubstr(multi_app_guid), 667 Eq(static_cast<DWORD>(1)), Eq(true)))
643 StrEq(google_update::kRegUsageStatsField), 668 .Times(1);
644 Eq(static_cast<DWORD>(1)),
645 Eq(true))).Times(1);
646 669
647 // Expect to see some values cleaned up from Chrome's keys. 670 // Expect to see some values cleaned up from Chrome's keys.
648 BrowserDistribution* chrome_dist = 671 BrowserDistribution* chrome_dist =
649 BrowserDistribution::GetSpecificDistribution( 672 BrowserDistribution::GetSpecificDistribution(
650 BrowserDistribution::CHROME_BROWSER); 673 BrowserDistribution::CHROME_BROWSER);
651 if (system_level) { 674 if (system_level) {
652 EXPECT_CALL(work_item_list, 675 EXPECT_CALL(work_item_list,
653 AddDeleteRegValueWorkItem( 676 AddDeleteRegValueWorkItem(
654 _, 677 _, StrEq(chrome_dist->GetStateMediumKey()), _,
655 StrEq(chrome_dist->GetStateMediumKey()),
656 StrEq(google_update::kRegUsageStatsField))).Times(1); 678 StrEq(google_update::kRegUsageStatsField))).Times(1);
657 EXPECT_CALL(work_item_list, 679 EXPECT_CALL(work_item_list,
658 AddDeleteRegValueWorkItem( 680 AddDeleteRegValueWorkItem(
659 Eq(HKEY_CURRENT_USER), 681 Eq(HKEY_CURRENT_USER), StrEq(chrome_dist->GetStateKey()), _,
660 StrEq(chrome_dist->GetStateKey()),
661 StrEq(google_update::kRegUsageStatsField))).Times(1); 682 StrEq(google_update::kRegUsageStatsField))).Times(1);
662 } 683 }
663 EXPECT_CALL(work_item_list, 684 EXPECT_CALL(
664 AddDeleteRegValueWorkItem( 685 work_item_list,
665 Eq(installer_state->root_key()), 686 AddDeleteRegValueWorkItem(
666 StrEq(chrome_dist->GetStateKey()), 687 Eq(installer_state->root_key()), StrEq(chrome_dist->GetStateKey()), _,
667 StrEq(google_update::kRegUsageStatsField))).Times(1); 688 StrEq(google_update::kRegUsageStatsField))).Times(1);
668 689
669 AddUsageStatsWorkItems(*installation_state.get(), 690 AddUsageStatsWorkItems(*installation_state.get(),
670 *installer_state.get(), 691 *installer_state.get(),
671 &work_item_list); 692 &work_item_list);
672 } 693 }
673 694
674 // The Quick Enable tests only make sense for the Google Chrome build as it 695 // The Quick Enable tests only make sense for the Google Chrome build as it
675 // interacts with registry values that are specific to Google Update. 696 // interacts with registry values that are specific to Google Update.
676 #if defined(GOOGLE_CHROME_BUILD) 697 #if defined(GOOGLE_CHROME_BUILD)
677 698
678 // Test scenarios under which the quick-enable-cf command should not exist after 699 // Test scenarios under which the quick-enable-cf command should not exist after
679 // the run. We're permissive in that we allow the DeleteRegKeyWorkItem even if 700 // the run. We're permissive in that we allow the DeleteRegKeyWorkItem even if
680 // it isn't strictly needed. 701 // it isn't strictly needed.
681 class QuickEnableAbsentTest : public InstallWorkerTest { 702 class QuickEnableAbsentTest : public InstallWorkerTest {
682 public: 703 public:
683 virtual void SetUp() { 704 virtual void SetUp() {
684 InstallWorkerTest::SetUp(); 705 InstallWorkerTest::SetUp();
685 root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 706 root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
686 delete_reg_key_item_.reset(WorkItem::CreateDeleteRegKeyWorkItem( 707 delete_reg_key_item_.reset(WorkItem::CreateDeleteRegKeyWorkItem(
687 root_key_, kRegKeyPath, WorkItem::kWow64Default)); 708 root_key_, kRegKeyPath, WorkItem::kWow64Default));
688 machine_state_.reset(new MockInstallationState()); 709 machine_state_.reset(new MockInstallationState());
689 EXPECT_CALL(work_item_list_, 710 EXPECT_CALL(work_item_list_, AddDeleteRegKeyWorkItem(
690 AddDeleteRegKeyWorkItem(Eq(root_key_), StrCaseEq(kRegKeyPath))) 711 Eq(root_key_), StrCaseEq(kRegKeyPath), _))
691 .Times(AtMost(1)) 712 .Times(AtMost(1))
692 .WillRepeatedly(Return(delete_reg_key_item_.get())); 713 .WillRepeatedly(Return(delete_reg_key_item_.get()));
693 } 714 }
694 virtual void TearDown() { 715 virtual void TearDown() {
695 machine_state_.reset(); 716 machine_state_.reset();
696 delete_reg_key_item_.reset(); 717 delete_reg_key_item_.reset();
697 root_key_ = NULL; 718 root_key_ = NULL;
698 InstallWorkerTest::TearDown(); 719 InstallWorkerTest::TearDown();
699 } 720 }
700 protected: 721 protected:
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 prod_type_list[i_type_check]); 818 prod_type_list[i_type_check]);
798 bool prod_expect = (mach_after & (1 << i_type_check)) != 0; 819 bool prod_expect = (mach_after & (1 << i_type_check)) != 0;
799 EXPECT_EQ(prod_expect, prod_res); 820 EXPECT_EQ(prod_expect, prod_res);
800 } 821 }
801 } 822 }
802 } 823 }
803 } 824 }
804 } 825 }
805 826
806 #endif // defined(GOOGLE_CHROME_BUILD) 827 #endif // defined(GOOGLE_CHROME_BUILD)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698