update_engine: Mock out UpdateAttempter and OmahaRequestParams.
These classes are used by other classes so we need to have a way to
unit test those. This patch converts some public methods on these
classes to virtual methods so they can be mocked. It implements a
new MockOmahaRequestParams with all the public methods behaving like
the real object by default. This is now the default class used by the
FakeSystemState. Finally, the UpdateAttempterMock is renamed to
MockUpdateAttempter to be more consistent with other classes in
the project.
BUG=None
TEST=Unittest pass. Follow up CL using these classes also passes.
Change-Id: Iacb7e19d10c1526cea9659c27ab798cad126816f
Reviewed-on: https://chromium-review.googlesource.com/225855
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
diff --git a/omaha_request_params.h b/omaha_request_params.h
index 7e2486a..6290322 100644
--- a/omaha_request_params.h
+++ b/omaha_request_params.h
@@ -194,11 +194,11 @@
// True if we're trying to update to a more stable channel.
// i.e. index(target_channel) > index(current_channel).
- bool to_more_stable_channel() const;
+ virtual bool to_more_stable_channel() const;
// Returns the app id corresponding to the current value of the
// download channel.
- std::string GetAppId() const;
+ virtual std::string GetAppId() const;
// Suggested defaults
static const char* const kAppId;
@@ -224,7 +224,8 @@
// channel changes done by the user in order to avoid having to solve
// numerous edge cases around ensuring the powerwash happens as intended in
// all such cases.
- bool SetTargetChannel(const std::string& channel, bool is_powerwash_allowed);
+ virtual bool SetTargetChannel(const std::string& channel,
+ bool is_powerwash_allowed);
// Updates the download channel for this particular attempt from the current
// value of target channel. This method takes a "snapshot" of the current
@@ -232,9 +233,9 @@
// this attempt (i.e. initial request as well as download progress/error
// event requests). The snapshot will be updated only when either this method
// or Init is called again.
- void UpdateDownloadChannel();
+ virtual void UpdateDownloadChannel();
- bool is_powerwash_allowed() const { return is_powerwash_allowed_; }
+ virtual bool is_powerwash_allowed() const { return is_powerwash_allowed_; }
// For unit-tests.
void set_root(const std::string& root);