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

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

Issue 1213913002: Update Chrome's Active Setup version per component instead of as a single string. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@active_setup_onosup_addCB_API
Patch Set: Created 5 years, 6 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 "base/test/test_reg_util_win.h"
8 #include "base/version.h"
7 #include "base/win/registry.h" 9 #include "base/win/registry.h"
8 #include "base/version.h"
9 #include "chrome/common/chrome_constants.h" 10 #include "chrome/common/chrome_constants.h"
10 #include "chrome/installer/setup/setup_util.h" 11 #include "chrome/installer/setup/setup_util.h"
12 #include "chrome/installer/util/create_reg_key_work_item.h"
11 #include "chrome/installer/util/delete_reg_key_work_item.h" 13 #include "chrome/installer/util/delete_reg_key_work_item.h"
12 #include "chrome/installer/util/create_reg_key_work_item.h" 14 #include "chrome/installer/util/google_update_constants.h"
13 #include "chrome/installer/util/helper.h" 15 #include "chrome/installer/util/helper.h"
14 #include "chrome/installer/util/google_update_constants.h" 16 #include "chrome/installer/util/install_util.h"
15 #include "chrome/installer/util/installation_state.h" 17 #include "chrome/installer/util/installation_state.h"
16 #include "chrome/installer/util/installer_state.h" 18 #include "chrome/installer/util/installer_state.h"
17 #include "chrome/installer/util/set_reg_value_work_item.h" 19 #include "chrome/installer/util/set_reg_value_work_item.h"
18 #include "chrome/installer/util/util_constants.h" 20 #include "chrome/installer/util/util_constants.h"
21 #include "chrome/installer/util/work_item.h"
19 #include "chrome/installer/util/work_item_list.h" 22 #include "chrome/installer/util/work_item_list.h"
20 23 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
22 #include "testing/gmock/include/gmock/gmock.h"
23 25
24 using base::win::RegKey; 26 using base::win::RegKey;
25 using installer::InstallationState; 27 using installer::InstallationState;
26 using installer::InstallerState; 28 using installer::InstallerState;
27 using installer::Product; 29 using installer::Product;
28 using installer::ProductState; 30 using installer::ProductState;
29 31
30 using ::testing::_; 32 using ::testing::_;
31 using ::testing::AtLeast; 33 using ::testing::AtLeast;
32 using ::testing::AtMost; 34 using ::testing::AtMost;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 void set_package_type(PackageType type) { 161 void set_package_type(PackageType type) {
160 InstallerState::set_package_type(type); 162 InstallerState::set_package_type(type);
161 } 163 }
162 }; 164 };
163 165
164 // The test fixture 166 // The test fixture
165 //------------------------------------------------------------------------------ 167 //------------------------------------------------------------------------------
166 168
167 class InstallWorkerTest : public testing::Test { 169 class InstallWorkerTest : public testing::Test {
168 public: 170 public:
171 InstallWorkerTest() {}
172
169 void SetUp() override { 173 void SetUp() override {
174 registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER);
175 registry_override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE);
176
170 current_version_.reset(new Version("1.0.0.0")); 177 current_version_.reset(new Version("1.0.0.0"));
171 new_version_.reset(new Version("42.0.0.0")); 178 new_version_.reset(new Version("42.0.0.0"));
172 179
173 // Don't bother ensuring that these paths exist. Since we're just 180 // Don't bother ensuring that these paths exist. Since we're just
174 // building the work item lists and not running them, they shouldn't 181 // building the work item lists and not running them, they shouldn't
175 // actually be touched. 182 // actually be touched.
176 archive_path_ = 183 archive_path_ =
177 base::FilePath(L"C:\\UnlikelyPath\\Temp\\chrome_123\\chrome.7z"); 184 base::FilePath(L"C:\\UnlikelyPath\\Temp\\chrome_123\\chrome.7z");
178 // TODO(robertshield): Take this from the BrowserDistribution once that 185 // TODO(robertshield): Take this from the BrowserDistribution once that
179 // no longer depends on MasterPreferences. 186 // no longer depends on MasterPreferences.
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 } 424 }
418 425
419 protected: 426 protected:
420 scoped_ptr<Version> current_version_; 427 scoped_ptr<Version> current_version_;
421 scoped_ptr<Version> new_version_; 428 scoped_ptr<Version> new_version_;
422 base::FilePath archive_path_; 429 base::FilePath archive_path_;
423 base::FilePath installation_path_; 430 base::FilePath installation_path_;
424 base::FilePath setup_path_; 431 base::FilePath setup_path_;
425 base::FilePath src_path_; 432 base::FilePath src_path_;
426 base::FilePath temp_dir_; 433 base::FilePath temp_dir_;
434
435 private:
436 registry_util::RegistryOverrideManager registry_override_manager_;
437
438 DISALLOW_COPY_AND_ASSIGN(InstallWorkerTest);
427 }; 439 };
428 440
429 // Tests 441 // Tests
430 //------------------------------------------------------------------------------ 442 //------------------------------------------------------------------------------
431 443
432 TEST_F(InstallWorkerTest, TestInstallChromeSingleSystem) { 444 TEST_F(InstallWorkerTest, TestInstallChromeSingleSystem) {
433 const bool system_level = true; 445 const bool system_level = true;
434 const bool multi_install = false; 446 const bool multi_install = false;
435 MockWorkItemList work_item_list; 447 MockWorkItemList work_item_list;
436 448
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 AddDeleteRegValueWorkItem( 676 AddDeleteRegValueWorkItem(
665 Eq(installer_state->root_key()), 677 Eq(installer_state->root_key()),
666 StrEq(chrome_dist->GetStateKey()), 678 StrEq(chrome_dist->GetStateKey()),
667 StrEq(google_update::kRegUsageStatsField))).Times(1); 679 StrEq(google_update::kRegUsageStatsField))).Times(1);
668 680
669 AddUsageStatsWorkItems(*installation_state.get(), 681 AddUsageStatsWorkItems(*installation_state.get(),
670 *installer_state.get(), 682 *installer_state.get(),
671 &work_item_list); 683 &work_item_list);
672 } 684 }
673 685
686 // Test that active setup version installing/updating is handled property.
687 TEST_F(InstallWorkerTest, AddAndRunActiveSetupWorkItems) {
688 // Active Setup only makes sense at system-level.
689 const bool system_level = true;
690 const bool multi_install = false;
691
692 scoped_ptr<MockInstallationState> installation_state(
693 BuildChromeInstallationState(system_level, multi_install));
694
695 MockProductState chrome_state;
696 chrome_state.set_version(new Version(*current_version_));
697 chrome_state.set_multi_install(multi_install);
698
699 installation_state->SetProductState(
700 system_level, BrowserDistribution::CHROME_BROWSER, chrome_state);
701
702 scoped_ptr<MockInstallerState> installer_state(
703 BuildChromeInstallerState(system_level, multi_install,
704 *installation_state,
705 InstallerState::MULTI_INSTALL));
706
707 const HKEY kRoot = HKEY_LOCAL_MACHINE;
708 const std::wstring active_setup_path(InstallUtil::GetActiveSetupPath(
709 BrowserDistribution::GetSpecificDistribution(
710 BrowserDistribution::CHROME_BROWSER)));
711 RegKey test_key;
712
713 EXPECT_NE(ERROR_SUCCESS,
714 test_key.Open(kRoot, active_setup_path.c_str(), KEY_READ));
715
716 // Execute the work items twice, once to confirm it works initially when
717 // nothing it there and a second time to confirm the no-op update works as
718 // intended.
719 for (size_t i = 0; i < 2; ++i) {
720 // Note: This performs real operations, it's *not* a MockWorkItemList like
721 // in the other tests (the registry itself is mocked in the fixture however
722 // so this is okay).
723 scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList());
724 AddActiveSetupWorkItems(
725 *installer_state,
726 *current_version_,
727 *installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER),
728 work_item_list.get());
729 work_item_list->Do();
730
731 std::wstring version_out;
732 EXPECT_EQ(ERROR_SUCCESS,
733 test_key.Open(kRoot, active_setup_path.c_str(), KEY_READ));
734 EXPECT_EQ(ERROR_SUCCESS, test_key.ReadValue(L"Version", &version_out));
735 EXPECT_EQ(L"43,0,0,0", version_out);
736 }
737
738 // Write a bogus value to the key and confirm that executing the work items
grt (UTC plus 2) 2015/06/29 17:41:49 I think "bogus" is the wrong word here; I expect a
gab 2015/06/30 18:40:39 Refactored the test to make testing all of these v
739 // only updates the major version.
740 EXPECT_EQ(ERROR_SUCCESS, test_key.Open(kRoot, active_setup_path.c_str(),
741 KEY_READ | KEY_SET_VALUE));
742 EXPECT_EQ(ERROR_SUCCESS, test_key.WriteValue(L"Version", L"24,1,2,3"));
743
744 scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList());
745 AddActiveSetupWorkItems(
746 *installer_state,
747 *current_version_,
748 *installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER),
749 work_item_list.get());
750 work_item_list->Do();
751
752 std::wstring version_out;
753 EXPECT_EQ(ERROR_SUCCESS, test_key.ReadValue(L"Version", &version_out));
754 EXPECT_EQ(L"43,1,2,3", version_out);
755 }
756
674 // The Quick Enable tests only make sense for the Google Chrome build as it 757 // 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. 758 // interacts with registry values that are specific to Google Update.
676 #if defined(GOOGLE_CHROME_BUILD) 759 #if defined(GOOGLE_CHROME_BUILD)
677 760
678 // Test scenarios under which the quick-enable-cf command should not exist after 761 // 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 762 // the run. We're permissive in that we allow the DeleteRegKeyWorkItem even if
680 // it isn't strictly needed. 763 // it isn't strictly needed.
681 class QuickEnableAbsentTest : public InstallWorkerTest { 764 class QuickEnableAbsentTest : public InstallWorkerTest {
682 public: 765 public:
683 virtual void SetUp() { 766 virtual void SetUp() {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 prod_type_list[i_type_check]); 880 prod_type_list[i_type_check]);
798 bool prod_expect = (mach_after & (1 << i_type_check)) != 0; 881 bool prod_expect = (mach_after & (1 << i_type_check)) != 0;
799 EXPECT_EQ(prod_expect, prod_res); 882 EXPECT_EQ(prod_expect, prod_res);
800 } 883 }
801 } 884 }
802 } 885 }
803 } 886 }
804 } 887 }
805 888
806 #endif // defined(GOOGLE_CHROME_BUILD) 889 #endif // defined(GOOGLE_CHROME_BUILD)
OLDNEW
« chrome/installer/setup/install_worker.cc ('K') | « chrome/installer/setup/install_worker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698