Rename MockSystemState into FakeSystemState.
This class is no longer a mock. The change also includes renaming the
appropriate files and the instances of this class.
BUG=chromium:358278
TEST=Unit tests.
Change-Id: Ifc20ead0d624eddf8827a6e6f39cd9b9207dcabf
Reviewed-on: https://chromium-review.googlesource.com/194088
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
diff --git a/utils_unittest.cc b/utils_unittest.cc
index 84c20cc..77a7d9b 100644
--- a/utils_unittest.cc
+++ b/utils_unittest.cc
@@ -17,7 +17,7 @@
#include <gtest/gtest.h>
#include "update_engine/fake_clock.h"
-#include "update_engine/mock_system_state.h"
+#include "update_engine/fake_system_state.h"
#include "update_engine/prefs.h"
#include "update_engine/test_utils.h"
#include "update_engine/utils.h"
@@ -548,7 +548,7 @@
}
TEST(UtilsTest, WallclockDurationHelper) {
- MockSystemState mock_system_state;
+ FakeSystemState fake_system_state;
FakeClock fake_clock;
base::TimeDelta duration;
string state_variable_key = "test-prefs";
@@ -558,30 +558,30 @@
EXPECT_TRUE(utils::MakeTempDirectory("DurationPrefs.XXXXXX", &temp_dir));
fake_prefs.Init(base::FilePath(temp_dir));
- mock_system_state.set_clock(&fake_clock);
- mock_system_state.set_prefs(&fake_prefs);
+ fake_system_state.set_clock(&fake_clock);
+ fake_system_state.set_prefs(&fake_prefs);
// Initialize wallclock to 1 sec.
fake_clock.SetWallclockTime(base::Time::FromInternalValue(1000000));
// First time called so no previous measurement available.
- EXPECT_FALSE(utils::WallclockDurationHelper(&mock_system_state,
+ EXPECT_FALSE(utils::WallclockDurationHelper(&fake_system_state,
state_variable_key,
&duration));
// Next time, we should get zero since the clock didn't advance.
- EXPECT_TRUE(utils::WallclockDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::WallclockDurationHelper(&fake_system_state,
state_variable_key,
&duration));
EXPECT_EQ(duration.InSeconds(), 0);
// We can also call it as many times as we want with it being
// considered a failure.
- EXPECT_TRUE(utils::WallclockDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::WallclockDurationHelper(&fake_system_state,
state_variable_key,
&duration));
EXPECT_EQ(duration.InSeconds(), 0);
- EXPECT_TRUE(utils::WallclockDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::WallclockDurationHelper(&fake_system_state,
state_variable_key,
&duration));
EXPECT_EQ(duration.InSeconds(), 0);
@@ -589,22 +589,22 @@
// Advance the clock one second, then we should get 1 sec on the
// next call and 0 sec on the subsequent call.
fake_clock.SetWallclockTime(base::Time::FromInternalValue(2000000));
- EXPECT_TRUE(utils::WallclockDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::WallclockDurationHelper(&fake_system_state,
state_variable_key,
&duration));
EXPECT_EQ(duration.InSeconds(), 1);
- EXPECT_TRUE(utils::WallclockDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::WallclockDurationHelper(&fake_system_state,
state_variable_key,
&duration));
EXPECT_EQ(duration.InSeconds(), 0);
// Advance clock two seconds and we should get 2 sec and then 0 sec.
fake_clock.SetWallclockTime(base::Time::FromInternalValue(4000000));
- EXPECT_TRUE(utils::WallclockDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::WallclockDurationHelper(&fake_system_state,
state_variable_key,
&duration));
EXPECT_EQ(duration.InSeconds(), 2);
- EXPECT_TRUE(utils::WallclockDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::WallclockDurationHelper(&fake_system_state,
state_variable_key,
&duration));
EXPECT_EQ(duration.InSeconds(), 0);
@@ -613,11 +613,11 @@
// adjustments, for example) so check that we properly handle this
// case.
fake_clock.SetWallclockTime(base::Time::FromInternalValue(3000000));
- EXPECT_FALSE(utils::WallclockDurationHelper(&mock_system_state,
+ EXPECT_FALSE(utils::WallclockDurationHelper(&fake_system_state,
state_variable_key,
&duration));
fake_clock.SetWallclockTime(base::Time::FromInternalValue(4000000));
- EXPECT_TRUE(utils::WallclockDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::WallclockDurationHelper(&fake_system_state,
state_variable_key,
&duration));
EXPECT_EQ(duration.InSeconds(), 1);
@@ -627,33 +627,33 @@
TEST(UtilsTest, MonotonicDurationHelper) {
int64_t storage = 0;
- MockSystemState mock_system_state;
+ FakeSystemState fake_system_state;
FakeClock fake_clock;
base::TimeDelta duration;
- mock_system_state.set_clock(&fake_clock);
+ fake_system_state.set_clock(&fake_clock);
// Initialize monotonic clock to 1 sec.
fake_clock.SetMonotonicTime(base::Time::FromInternalValue(1000000));
// First time called so no previous measurement available.
- EXPECT_FALSE(utils::MonotonicDurationHelper(&mock_system_state,
+ EXPECT_FALSE(utils::MonotonicDurationHelper(&fake_system_state,
&storage,
&duration));
// Next time, we should get zero since the clock didn't advance.
- EXPECT_TRUE(utils::MonotonicDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::MonotonicDurationHelper(&fake_system_state,
&storage,
&duration));
EXPECT_EQ(duration.InSeconds(), 0);
// We can also call it as many times as we want with it being
// considered a failure.
- EXPECT_TRUE(utils::MonotonicDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::MonotonicDurationHelper(&fake_system_state,
&storage,
&duration));
EXPECT_EQ(duration.InSeconds(), 0);
- EXPECT_TRUE(utils::MonotonicDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::MonotonicDurationHelper(&fake_system_state,
&storage,
&duration));
EXPECT_EQ(duration.InSeconds(), 0);
@@ -661,22 +661,22 @@
// Advance the clock one second, then we should get 1 sec on the
// next call and 0 sec on the subsequent call.
fake_clock.SetMonotonicTime(base::Time::FromInternalValue(2000000));
- EXPECT_TRUE(utils::MonotonicDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::MonotonicDurationHelper(&fake_system_state,
&storage,
&duration));
EXPECT_EQ(duration.InSeconds(), 1);
- EXPECT_TRUE(utils::MonotonicDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::MonotonicDurationHelper(&fake_system_state,
&storage,
&duration));
EXPECT_EQ(duration.InSeconds(), 0);
// Advance clock two seconds and we should get 2 sec and then 0 sec.
fake_clock.SetMonotonicTime(base::Time::FromInternalValue(4000000));
- EXPECT_TRUE(utils::MonotonicDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::MonotonicDurationHelper(&fake_system_state,
&storage,
&duration));
EXPECT_EQ(duration.InSeconds(), 2);
- EXPECT_TRUE(utils::MonotonicDurationHelper(&mock_system_state,
+ EXPECT_TRUE(utils::MonotonicDurationHelper(&fake_system_state,
&storage,
&duration));
EXPECT_EQ(duration.InSeconds(), 0);