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

Unified 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: review:grt 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/setup/install_worker.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c4861f463617a9c798e9eea184394b9e75ef638a 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,120 @@ 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));
+
+ enum class TestCaseStep {
grt (UTC plus 2) 2015/06/30 18:54:49 this all seems pretty complicated. does it all boi
gab 2015/07/02 03:12:33 Good point, at first I didn't like having to go th
+ // Executes the Active Setup work items.
+ EXECUTE,
+ // Expect a given value for the Active Setup version in the registry.
+ EXPECT_VERSION,
+ // Set a specific value for the Active Setup version in the registry.
+ SET_VERSION,
+ };
+
+ struct TestCaseSteps {
+ TestCaseStep step;
+ const wchar_t* step_value;
+ } static const kTestCaseSteps[] = {
+ // Execute the work items twice, once to confirm it works initially when
+ // nothing is there and a second time to confirm the no-op update works as
+ // intended.
+ {TestCaseStep::EXECUTE},
+ {TestCaseStep::EXPECT_VERSION, L"43,0,0,0"},
+
+ {TestCaseStep::EXECUTE},
+ {TestCaseStep::EXPECT_VERSION, L"43,0,0,0"},
+
+ // Write a different version and expect that only the major component of
+ // the version gets updated.
+ {TestCaseStep::SET_VERSION, L"24,1,2,3"},
+ {TestCaseStep::EXECUTE},
+ {TestCaseStep::EXPECT_VERSION, L"43,1,2,3"},
+
+ // Try a few invalid Version entries, expect them all to be reset to the
+ // default version.
+ {TestCaseStep::SET_VERSION, L"zzz"},
+ {TestCaseStep::EXECUTE},
+ {TestCaseStep::EXPECT_VERSION, L"43,0,0,0"},
+
+ {TestCaseStep::SET_VERSION, L"1,2"},
+ {TestCaseStep::EXECUTE},
+ {TestCaseStep::EXPECT_VERSION, L"43,0,0,0"},
+
+ {TestCaseStep::SET_VERSION, L"43,1,2,3,10"},
+ {TestCaseStep::EXECUTE},
+ {TestCaseStep::EXPECT_VERSION, L"43,0,0,0"},
+
+ {TestCaseStep::SET_VERSION, L""},
+ {TestCaseStep::EXECUTE},
+ {TestCaseStep::EXPECT_VERSION, L"43,0,0,0"},
+ };
+
+ 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));
+
+ for (size_t i = 0; i < arraysize(kTestCaseSteps); ++i) {
+ SCOPED_TRACE(i);
grt (UTC plus 2) 2015/06/30 18:54:49 kewl
gab 2015/07/02 03:12:33 Yep :-)
+
+ switch (kTestCaseSteps[i].step) {
+ case TestCaseStep::EXECUTE: {
+ // 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();
+ break;
+ }
+
+ case TestCaseStep::EXPECT_VERSION: {
+ 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(kTestCaseSteps[i].step_value, version_out);
+ break;
+ }
+
+ case TestCaseStep::SET_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", kTestCaseSteps[i].step_value));
+ break;
+ }
+ }
+ }
+}
+
// 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)
« no previous file with comments | « chrome/installer/setup/install_worker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698