Index: chrome/installer/setup/install_worker_unittest.cc |
diff --git a/chrome/installer/setup/install_worker_unittest.cc b/chrome/installer/setup/install_worker_unittest.cc |
index 9cd28f086d8db0137ec9b6c6e623c343b4d516e7..1ae567037ad34d402d8924807d6d547e132cdd14 100644 |
--- a/chrome/installer/setup/install_worker_unittest.cc |
+++ b/chrome/installer/setup/install_worker_unittest.cc |
@@ -4,22 +4,24 @@ |
#include "chrome/installer/setup/install_worker.h" |
-#include "base/win/registry.h" |
+#include "base/test/test_reg_util_win.h" |
#include "base/version.h" |
+#include "base/win/registry.h" |
#include "chrome/common/chrome_constants.h" |
#include "chrome/installer/setup/setup_util.h" |
-#include "chrome/installer/util/delete_reg_key_work_item.h" |
#include "chrome/installer/util/create_reg_key_work_item.h" |
-#include "chrome/installer/util/helper.h" |
+#include "chrome/installer/util/delete_reg_key_work_item.h" |
#include "chrome/installer/util/google_update_constants.h" |
+#include "chrome/installer/util/helper.h" |
+#include "chrome/installer/util/install_util.h" |
#include "chrome/installer/util/installation_state.h" |
#include "chrome/installer/util/installer_state.h" |
#include "chrome/installer/util/set_reg_value_work_item.h" |
#include "chrome/installer/util/util_constants.h" |
+#include "chrome/installer/util/work_item.h" |
#include "chrome/installer/util/work_item_list.h" |
- |
-#include "testing/gtest/include/gtest/gtest.h" |
#include "testing/gmock/include/gmock/gmock.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
using base::win::RegKey; |
using installer::InstallationState; |
@@ -166,7 +168,12 @@ class MockInstallerState : public InstallerState { |
class InstallWorkerTest : public testing::Test { |
public: |
+ InstallWorkerTest() {} |
+ |
void SetUp() override { |
+ registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER); |
+ registry_override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE); |
+ |
current_version_.reset(new Version("1.0.0.0")); |
new_version_.reset(new Version("42.0.0.0")); |
@@ -424,6 +431,11 @@ class InstallWorkerTest : public testing::Test { |
base::FilePath setup_path_; |
base::FilePath src_path_; |
base::FilePath temp_dir_; |
+ |
+ private: |
+ registry_util::RegistryOverrideManager registry_override_manager_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(InstallWorkerTest); |
}; |
// Tests |
@@ -671,6 +683,77 @@ TEST_F(InstallWorkerTest, AddUsageStatsWorkItems) { |
&work_item_list); |
} |
+// Test that active setup version installing/updating is handled property. |
+TEST_F(InstallWorkerTest, AddAndRunActiveSetupWorkItems) { |
+ // Active Setup only makes sense at system-level. |
+ const bool system_level = true; |
+ const bool multi_install = false; |
+ |
+ scoped_ptr<MockInstallationState> installation_state( |
+ BuildChromeInstallationState(system_level, multi_install)); |
+ |
+ MockProductState chrome_state; |
+ chrome_state.set_version(new Version(*current_version_)); |
+ chrome_state.set_multi_install(multi_install); |
+ |
+ installation_state->SetProductState( |
+ system_level, BrowserDistribution::CHROME_BROWSER, chrome_state); |
+ |
+ scoped_ptr<MockInstallerState> installer_state( |
+ BuildChromeInstallerState(system_level, multi_install, |
+ *installation_state, |
+ InstallerState::MULTI_INSTALL)); |
+ |
+ const HKEY kRoot = HKEY_LOCAL_MACHINE; |
+ const std::wstring active_setup_path(InstallUtil::GetActiveSetupPath( |
+ BrowserDistribution::GetSpecificDistribution( |
+ BrowserDistribution::CHROME_BROWSER))); |
+ RegKey test_key; |
+ |
+ EXPECT_NE(ERROR_SUCCESS, |
+ test_key.Open(kRoot, active_setup_path.c_str(), KEY_READ)); |
+ |
+ // Execute the work items twice, once to confirm it works initially when |
+ // nothing it there and a second time to confirm the no-op update works as |
+ // intended. |
+ for (size_t i = 0; i < 2; ++i) { |
+ // Note: This performs real operations, it's *not* a MockWorkItemList like |
+ // in the other tests (the registry itself is mocked in the fixture however |
+ // so this is okay). |
+ scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList()); |
+ AddActiveSetupWorkItems( |
+ *installer_state, |
+ *current_version_, |
+ *installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER), |
+ work_item_list.get()); |
+ work_item_list->Do(); |
+ |
+ std::wstring version_out; |
+ EXPECT_EQ(ERROR_SUCCESS, |
+ test_key.Open(kRoot, active_setup_path.c_str(), KEY_READ)); |
+ EXPECT_EQ(ERROR_SUCCESS, test_key.ReadValue(L"Version", &version_out)); |
+ EXPECT_EQ(L"43,0,0,0", version_out); |
+ } |
+ |
+ // 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
|
+ // only updates the major version. |
+ EXPECT_EQ(ERROR_SUCCESS, test_key.Open(kRoot, active_setup_path.c_str(), |
+ KEY_READ | KEY_SET_VALUE)); |
+ EXPECT_EQ(ERROR_SUCCESS, test_key.WriteValue(L"Version", L"24,1,2,3")); |
+ |
+ scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList()); |
+ AddActiveSetupWorkItems( |
+ *installer_state, |
+ *current_version_, |
+ *installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER), |
+ work_item_list.get()); |
+ work_item_list->Do(); |
+ |
+ std::wstring version_out; |
+ EXPECT_EQ(ERROR_SUCCESS, test_key.ReadValue(L"Version", &version_out)); |
+ EXPECT_EQ(L"43,1,2,3", version_out); |
+} |
+ |
// The Quick Enable tests only make sense for the Google Chrome build as it |
// interacts with registry values that are specific to Google Update. |
#if defined(GOOGLE_CHROME_BUILD) |