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

Unified Diff: chrome/installer/setup/install_worker_unittest.cc

Issue 7976045: Fix in-use updates for Chrome Frame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sanity check before dcommit Created 9 years, 3 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') | chrome/installer/setup/setup_main.cc » ('j') | 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 67ef806c18e159708b0cb8329a97560b66fa5c48..e5936df72421bbcb771c0824109d34e0a15b7b8b 100644
--- a/chrome/installer/setup/install_worker_unittest.cc
+++ b/chrome/installer/setup/install_worker_unittest.cc
@@ -20,6 +20,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gmock/include/gmock/gmock.h"
+using base::win::RegKey;
using installer::InstallationState;
using installer::InstallerState;
using installer::Product;
@@ -27,13 +28,16 @@ using installer::ProductState;
using ::testing::_;
using ::testing::AtLeast;
-using ::testing::HasSubstr;
using ::testing::AtMost;
+using ::testing::Bool;
+using ::testing::Combine;
+using ::testing::HasSubstr;
using ::testing::Eq;
using ::testing::Return;
using ::testing::StrCaseEq;
using ::testing::StrEq;
using ::testing::StrictMock;
+using ::testing::Values;
// Mock classes to help with testing
//------------------------------------------------------------------------------
@@ -42,6 +46,10 @@ class MockWorkItemList : public WorkItemList {
public:
MockWorkItemList() {}
+ MOCK_METHOD4(AddCopyRegKeyWorkItem, WorkItem* (HKEY,
+ const std::wstring&,
+ const std::wstring&,
+ CopyOverWriteOption));
MOCK_METHOD5(AddCopyTreeWorkItem, WorkItem*(const std::wstring&,
const std::wstring&,
const std::wstring&,
@@ -176,11 +184,26 @@ class InstallWorkerTest : public testing::Test {
virtual void TearDown() {
}
+ void MaybeAddBinariesToInstallationState(
+ bool system_level,
+ MockInstallationState* installation_state) {
+ if (installation_state->GetProductState(
+ system_level, BrowserDistribution::CHROME_BINARIES) == NULL) {
+ MockProductState product_state;
+ product_state.set_version(current_version_->Clone());
+ installation_state->SetProductState(system_level,
+ BrowserDistribution::CHROME_BINARIES,
+ product_state);
+ }
+ }
+
void AddChromeToInstallationState(
bool system_level,
bool multi_install,
bool with_chrome_frame_ready_mode,
MockInstallationState* installation_state) {
+ if (multi_install)
+ MaybeAddBinariesToInstallationState(system_level, installation_state);
MockProductState product_state;
product_state.set_version(current_version_->Clone());
product_state.set_multi_install(multi_install);
@@ -192,7 +215,9 @@ class InstallWorkerTest : public testing::Test {
FilePath install_path =
installer::GetChromeInstallPath(system_level, dist);
product_state.SetUninstallProgram(
- install_path.Append(installer::kSetupExe));
+ install_path.AppendASCII(current_version_->GetString())
+ .Append(installer::kInstallerDir)
+ .Append(installer::kSetupExe));
product_state.AddUninstallSwitch(installer::switches::kUninstall);
if (system_level)
product_state.AddUninstallSwitch(installer::switches::kSystemLevel);
@@ -216,6 +241,8 @@ class InstallWorkerTest : public testing::Test {
bool multi_install,
bool ready_mode,
MockInstallationState* installation_state) {
+ if (multi_install)
+ MaybeAddBinariesToInstallationState(system_level, installation_state);
MockProductState product_state;
product_state.set_version(current_version_->Clone());
product_state.set_multi_install(multi_install);
@@ -226,7 +253,9 @@ class InstallWorkerTest : public testing::Test {
FilePath install_path =
installer::GetChromeInstallPath(system_level, dist);
product_state.SetUninstallProgram(
- install_path.Append(installer::kSetupExe));
+ install_path.AppendASCII(current_version_->GetString())
+ .Append(installer::kInstallerDir)
+ .Append(installer::kSetupExe));
product_state.AddUninstallSwitch(installer::switches::kUninstall);
product_state.AddUninstallSwitch(installer::switches::kChromeFrame);
if (system_level)
@@ -393,141 +422,72 @@ namespace {
const wchar_t elevation_key[] =
L"SOFTWARE\\Microsoft\\Internet Explorer\\Low Rights\\ElevationPolicy\\"
L"{E0A900DF-9611-4446-86BD-4B1D47E7DB2A}";
-const wchar_t dragdrop_key[] =
- L"SOFTWARE\\Microsoft\\Internet Explorer\\Low Rights\\DragDrop\\"
- L"{E0A900DF-9611-4446-86BD-4B1D47E7DB2A}";
+const wchar_t old_elevation_key[] =
+ L"SOFTWARE\\Microsoft\\Internet Explorer\\Low Rights\\ElevationPolicy\\"
+ L"{6C288DD7-76FB-4721-B628-56FAC252E199}";
} // namespace
-TEST_F(InstallWorkerTest, ElevationPolicyWorkItems) {
- const bool system_level = true;
- const HKEY root = HKEY_LOCAL_MACHINE;
- const bool multi_install = true;
- MockWorkItemList work_item_list;
-
- scoped_ptr<MockInstallationState> installation_state(
- BuildChromeInstallationState(system_level, multi_install));
-
- scoped_ptr<MockInstallerState> installer_state(
- BuildChromeInstallerState(system_level, multi_install,
- *installation_state,
- InstallerState::MULTI_INSTALL));
-
- EXPECT_CALL(work_item_list, AddCreateRegKeyWorkItem(root,
- StrEq(elevation_key))).Times(1);
-
- EXPECT_CALL(work_item_list, AddCreateRegKeyWorkItem(root,
- StrEq(dragdrop_key))).Times(1);
-
- EXPECT_CALL(work_item_list, AddSetRegDwordValueWorkItem(root,
- StrEq(elevation_key), StrEq(L"Policy"), 3, _)).Times(1);
-
- EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(root,
- StrEq(elevation_key), StrEq(L"AppName"),
- StrEq(installer::kChromeLauncherExe), _)).Times(1);
-
- EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(root,
- StrEq(elevation_key), StrEq(L"AppPath"), _, _)).Times(1);
-
- EXPECT_CALL(work_item_list, AddSetRegDwordValueWorkItem(root,
- StrEq(dragdrop_key), StrEq(L"Policy"), 3, _)).Times(1);
-
- EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(root,
- StrEq(dragdrop_key), StrEq(L"AppName"),
- StrEq(chrome::kBrowserProcessExecutableName), _)).Times(1);
-
- EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(root,
- StrEq(dragdrop_key), StrEq(L"AppPath"), _, _)).Times(1);
+// A test class for worker functions that manipulate the old IE low rights
+// policies.
+// Parameters:
+// bool : system_level_
+// bool : multi_install_
+class OldIELowRightsTests : public InstallWorkerTest,
+ public ::testing::WithParamInterface<std::tr1::tuple<bool, bool> > {
+ protected:
+ virtual void SetUp() OVERRIDE {
+ InstallWorkerTest::SetUp();
- AddElevationPolicyWorkItems(*installation_state.get(),
- *installer_state.get(),
- *new_version_.get(),
- &work_item_list);
-}
+ const ParamType& param = GetParam();
+ system_level_ = std::tr1::get<0>(param);
+ multi_install_ = std::tr1::get<1>(param);
+ root_key_ = system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
-TEST_F(InstallWorkerTest, ElevationPolicyUninstall) {
- const bool system_level = true;
- const HKEY root = HKEY_LOCAL_MACHINE;
- const bool multi_install = true;
- MockWorkItemList work_item_list;
+ installation_state_.reset(new MockInstallationState());
+ AddChromeFrameToInstallationState(system_level_, multi_install_, false,
+ installation_state_.get());
+ installer_state_.reset(BuildBasicInstallerState(
+ system_level_, multi_install_, *installation_state_,
+ multi_install_ ? InstallerState::MULTI_UPDATE :
+ InstallerState::SINGLE_INSTALL_OR_UPDATE));
+ AddChromeFrameToInstallerState(*installation_state_, false,
+ installer_state_.get());
+ }
- scoped_ptr<MockInstallationState> installation_state(
- BuildChromeInstallationState(system_level, multi_install));
+ scoped_ptr<MockInstallationState> installation_state_;
+ scoped_ptr<MockInstallerState> installer_state_;
+ bool system_level_;
+ bool multi_install_;
+ HKEY root_key_;
+};
- scoped_ptr<MockInstallerState> installer_state(
- BuildChromeInstallerState(system_level, multi_install,
- *installation_state,
- InstallerState::UNINSTALL));
+TEST_P(OldIELowRightsTests, AddDeleteOldIELowRightsPolicyWorkItems) {
+ StrictMock<MockWorkItemList> work_item_list;
- EXPECT_CALL(work_item_list, AddDeleteRegKeyWorkItem(root,
- StrEq(elevation_key))).Times(1);
- EXPECT_CALL(work_item_list, AddDeleteRegKeyWorkItem(root,
- StrEq(dragdrop_key))).Times(1);
+ EXPECT_CALL(work_item_list,
+ AddDeleteRegKeyWorkItem(root_key_, StrEq(old_elevation_key)))
+ .Times(1);
- AddElevationPolicyWorkItems(*installation_state.get(),
- *installer_state.get(),
- *new_version_.get(),
- &work_item_list);
+ AddDeleteOldIELowRightsPolicyWorkItems(*installer_state_.get(),
+ &work_item_list);
}
-TEST_F(InstallWorkerTest, ElevationPolicySingleNoop) {
- const bool system_level = true;
- const bool multi_install = false; // nothing should be done for single.
- MockWorkItemList work_item_list;
+TEST_P(OldIELowRightsTests, AddCopyIELowRightsPolicyWorkItems) {
+ StrictMock<MockWorkItemList> work_item_list;
- scoped_ptr<MockInstallationState> installation_state(
- BuildChromeInstallationState(system_level, multi_install));
+ // The old elevation policy key should only be copied when there's no old
+ // value.
+ EXPECT_CALL(work_item_list,
+ AddCopyRegKeyWorkItem(root_key_, StrEq(elevation_key),
+ StrEq(old_elevation_key),
+ Eq(WorkItem::IF_NOT_PRESENT))).Times(1);
- scoped_ptr<MockInstallerState> installer_state(
- BuildChromeInstallerState(system_level, multi_install,
- *installation_state,
- InstallerState::UNINSTALL));
-
- EXPECT_CALL(work_item_list, AddDeleteRegKeyWorkItem(_, _)).Times(0);
- EXPECT_CALL(work_item_list, AddCreateRegKeyWorkItem(_, _)).Times(0);
- EXPECT_CALL(work_item_list, AddSetRegDwordValueWorkItem(_, _, _, _, _))
- .Times(0);
- EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(_, _, _, _, _))
- .Times(0);
-
- AddElevationPolicyWorkItems(*installation_state.get(),
- *installer_state.get(),
- *new_version_.get(),
- &work_item_list);
+ AddCopyIELowRightsPolicyWorkItems(*installer_state_.get(), &work_item_list);
}
-TEST_F(InstallWorkerTest, ElevationPolicyExistingSingleCFNoop) {
- const bool system_level = true;
- const bool multi_install = true;
- MockWorkItemList work_item_list;
-
- scoped_ptr<MockInstallationState> installation_state(
- BuildChromeInstallationState(system_level, multi_install));
-
- MockProductState cf_state;
- cf_state.set_version(current_version_->Clone());
- cf_state.set_multi_install(false);
-
- installation_state->SetProductState(system_level,
- BrowserDistribution::CHROME_FRAME, cf_state);
-
- scoped_ptr<MockInstallerState> installer_state(
- BuildChromeInstallerState(system_level, multi_install,
- *installation_state,
- InstallerState::MULTI_INSTALL));
-
- EXPECT_CALL(work_item_list, AddDeleteRegKeyWorkItem(_, _)).Times(0);
- EXPECT_CALL(work_item_list, AddCreateRegKeyWorkItem(_, _)).Times(0);
- EXPECT_CALL(work_item_list, AddSetRegDwordValueWorkItem(_, _, _, _, _))
- .Times(0);
- EXPECT_CALL(work_item_list, AddSetRegStringValueWorkItem(_, _, _, _, _))
- .Times(0);
-
- AddElevationPolicyWorkItems(*installation_state.get(),
- *installer_state.get(),
- *new_version_.get(),
- &work_item_list);
-}
+INSTANTIATE_TEST_CASE_P(Variations, OldIELowRightsTests,
+ Combine(Bool(), Bool()));
TEST_F(InstallWorkerTest, GoogleUpdateWorkItemsTest) {
const bool system_level = true;
@@ -535,7 +495,7 @@ TEST_F(InstallWorkerTest, GoogleUpdateWorkItemsTest) {
MockWorkItemList work_item_list;
scoped_ptr<MockInstallationState> installation_state(
- BuildChromeInstallationState(system_level, multi_install));
+ BuildChromeInstallationState(system_level, false));
MockProductState cf_state;
cf_state.set_version(current_version_->Clone());
« no previous file with comments | « chrome/installer/setup/install_worker.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698