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

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

Issue 6288009: More installer refactoring in the interest of fixing some bugs and cleaning t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
===================================================================
--- chrome/installer/setup/install_worker_unittest.cc (revision 72487)
+++ chrome/installer/setup/install_worker_unittest.cc (working copy)
@@ -8,19 +8,13 @@
#include "base/version.h"
#include "chrome/installer/util/installation_state.h"
#include "chrome/installer/util/installer_state.h"
-#include "chrome/installer/util/package.h"
-#include "chrome/installer/util/package_properties.h"
#include "chrome/installer/util/work_item_list.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gmock/include/gmock/gmock.h"
-using installer::ChromiumPackageProperties;
using installer::InstallationState;
using installer::InstallerState;
-using installer::Package;
-using installer::PackageProperties;
-using installer::PackagePropertiesImpl;
using installer::ProductState;
using ::testing::_;
@@ -66,20 +60,17 @@
bool));
};
+class MockProductState : public ProductState {
+ public:
+ // Takes ownership of |version|.
+ void set_version(Version* version) { version_.reset(version); }
+};
+
// Okay, so this isn't really a mock as such, but it does add setter methods
// to make it easier to build custom InstallationStates.
class MockInstallationState : public InstallationState {
public:
// Included for testing.
- void SetMultiPackageState(bool system_install,
- const ProductState& package_state) {
- ProductState& target =
- (system_install ? system_products_ : user_products_)
- [MULTI_PACKAGE_INDEX];
- target.CopyFrom(package_state);
- }
-
- // Included for testing.
void SetProductState(bool system_install,
BrowserDistribution::Type type,
const ProductState& product_state) {
@@ -91,8 +82,8 @@
class MockInstallerState : public InstallerState {
public:
- void set_system_install(bool system_install) {
- system_install_ = system_install;
+ void set_level(Level level) {
+ level_ = level;
}
void set_operation(Operation operation) { operation_ = operation; }
@@ -125,14 +116,13 @@
}
virtual void TearDown() {
-
}
MockInstallationState* BuildChromeSingleSystemInstallationState() {
scoped_ptr<MockInstallationState> installation_state(
new MockInstallationState());
- ProductState product_state;
+ MockProductState product_state;
product_state.set_version(current_version_->Clone());
// Do not call SetMultiPackageState since this is a single install.
installation_state->SetProductState(true,
@@ -142,14 +132,19 @@
return installation_state.release();
}
- MockInstallerState* BuildChromeSingleSystemInstallerState() {
+ MockInstallerState* BuildChromeSingleSystemInstallerState(
+ const InstallationState& machine_state) {
scoped_ptr<MockInstallerState> installer_state(new MockInstallerState());
- installer_state->set_system_install(true);
+ installer_state->set_level(InstallerState::SYSTEM_LEVEL);
installer_state->set_operation(InstallerState::SINGLE_INSTALL_OR_UPDATE);
// Hope this next one isn't checked for now.
installer_state->set_state_key(L"PROBABLY_INVALID_REG_PATH");
-
+ const ProductState* chrome =
+ machine_state.GetProductState(true,
+ BrowserDistribution::CHROME_BROWSER);
+ installer_state->AddProductFromState(BrowserDistribution::CHROME_BROWSER,
+ *chrome);
return installer_state.release();
}
@@ -173,19 +168,8 @@
BuildChromeSingleSystemInstallationState());
scoped_ptr<InstallerState> installer_state(
- BuildChromeSingleSystemInstallerState());
+ BuildChromeSingleSystemInstallerState(*installation_state));
- // This MUST outlive the package, since the package doesn't assume ownership
- // of it. Note: This feels like an implementation bug:
- // The PackageProperties <-> Package relationship is 1:1 and nothing else
- // uses the PackageProperties. I have the feeling that PackageProperties, and
- // perhaps Package itself should not exist at all.
- scoped_ptr<PackageProperties> package_properties(
- new ChromiumPackageProperties());
-
- scoped_refptr<Package> package(
- new Package(false, true, installation_path_, package_properties.get()));
-
// Set up some expectations.
// TODO(robertshield): Set up some real expectations.
EXPECT_CALL(work_item_list, AddCopyTreeWorkItem(_,_,_,_,_))
@@ -193,13 +177,11 @@
AddInstallWorkItems(*installation_state.get(),
*installer_state.get(),
- false,
setup_path_,
archive_path_,
src_path_,
temp_dir_,
*new_version_.get(),
&current_version_,
- *package.get(),
&work_item_list);
}
« 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