Revise the SystemState hierarchy.
* Removed all #includes from SystemState; added includes in .cc files
that use the various objects (MetricsLibrary, DevicePolicy, etc).
* MockSystemState:
- Regulated the set of getters/setters: foo() returns the current Foo
object interface; this object can be overridden by set_foo();
mock_foo() or fake_foo() returns the default (internal) mock/fake
equivalent, and fails if it is different from foo() (safety).
- Make member declaration order consistent with that of API.
- Removed MOCK_METHOD declarations for two methods and replaced them
with fake getter/setter. This means that MockSystemState is now
reduced to a fake, and can be renamed (separate CL). This also means
that a few tests have a slightly different semantics now.
* All virtual overrides are qualified as such. However, removed the
'const' method qualified from all getters: it made little sense,
especially when considering that getters are handing addresses of
internal mock members.
* Made the UpdateAttempter a contained member of both
{Real,Mock}SystemState, resolving initialization dependencies. In
general, the invariant is that all members of the SystemState that
rely on it being fully populated by the time of their initialization,
need to export a separate Init() method, that will be called (by the
SystemState implementation constructor or Init() method) only after
all members are set.
* Made the mock GPIO handler and connection manager contained members of
MockSystemState; the destructor could safely be moved.
* Cleanup in UpdateAttempter (part of resolving dependencies):
- Ordinary member initialization done via default initializers
(constants) or initializer list in the constructor (parameters).
- Init() method only does work that cannot be done during
construction, with appropriate comment documenting the need for it.
- Better reuse via constructor delegation.
BUG=chromium:358278
TEST=Unit tests.
Change-Id: I96ff6fc7e7400b0a9feb6cc8d4ffe97a51000f91
Reviewed-on: https://chromium-review.googlesource.com/193587
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
diff --git a/update_check_scheduler_unittest.cc b/update_check_scheduler_unittest.cc
index 0eed080..d4a5a1e 100644
--- a/update_check_scheduler_unittest.cc
+++ b/update_check_scheduler_unittest.cc
@@ -171,7 +171,7 @@
TEST_F(UpdateCheckSchedulerTest, RunBootDeviceRemovableTest) {
scheduler_.enabled_ = true;
- mock_system_state_.get_fake_hardware()->SetIsOfficialBuild(true);
+ mock_system_state_.fake_hardware()->SetIsOfficialBuild(true);
EXPECT_CALL(scheduler_, IsBootDeviceRemovable())
.Times(1)
.WillOnce(Return(true));
@@ -182,7 +182,7 @@
TEST_F(UpdateCheckSchedulerTest, RunNonOfficialBuildTest) {
scheduler_.enabled_ = true;
- mock_system_state_.get_fake_hardware()->SetIsOfficialBuild(false);
+ mock_system_state_.fake_hardware()->SetIsOfficialBuild(false);
scheduler_.Run();
EXPECT_FALSE(scheduler_.enabled_);
EXPECT_EQ(NULL, attempter_.update_check_scheduler());
@@ -194,7 +194,7 @@
UpdateCheckScheduler::kTimeoutRegularFuzz,
&interval_min,
&interval_max);
- mock_system_state_.get_fake_hardware()->SetIsOfficialBuild(true);
+ mock_system_state_.fake_hardware()->SetIsOfficialBuild(true);
EXPECT_CALL(scheduler_, IsBootDeviceRemovable())
.Times(1)
.WillOnce(Return(false));
@@ -281,7 +281,7 @@
TEST_F(UpdateCheckSchedulerTest, StaticCheckOOBECompleteTest) {
scheduler_.scheduled_ = true;
EXPECT_TRUE(scheduler_.mock_system_state_ != NULL);
- scheduler_.mock_system_state_->get_fake_hardware()->SetIsOOBEComplete(
+ scheduler_.mock_system_state_->fake_hardware()->SetIsOOBEComplete(
Time::UnixEpoch());
EXPECT_CALL(attempter_, Update("", "", false, false, false))
.Times(1)
@@ -293,7 +293,7 @@
TEST_F(UpdateCheckSchedulerTest, StaticCheckOOBENotCompleteTest) {
scheduler_.scheduled_ = true;
- scheduler_.mock_system_state_->get_fake_hardware()->UnsetIsOOBEComplete();
+ scheduler_.mock_system_state_->fake_hardware()->UnsetIsOOBEComplete();
EXPECT_CALL(attempter_, Update("", "", _, _, _)).Times(0);
int interval_min, interval_max;
FuzzRange(UpdateCheckScheduler::kTimeoutInitialInterval,