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

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