Make FakeHardware the default for all unit tests.
Previously, unit tests by default ran with a MockSystemState
that used the Hardware class instead of the FakeHardware mock.
This changes to make all tests use the FakeHardware mock
unconditionally.
BUG=None
TEST=unit tests
Change-Id: I9d70aec0d59c5913968e4d37f1d4a2a28e854920
Reviewed-on: https://chromium-review.googlesource.com/174915
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Richard Barnette <jrbarnette@chromium.org>
diff --git a/payload_state_unittest.cc b/payload_state_unittest.cc
index ec79950..4efce28 100644
--- a/payload_state_unittest.cc
+++ b/payload_state_unittest.cc
@@ -1353,7 +1353,6 @@
}
TEST(PayloadStateTest, RebootAfterUpdateFailedMetric) {
- FakeHardware fake_hardware;
MockSystemState mock_system_state;
OmahaResponse response;
PayloadState payload_state;
@@ -1366,8 +1365,8 @@
prefs.Init(FilePath(temp_dir));
mock_system_state.set_prefs(&prefs);
- fake_hardware.SetBootDevice("/dev/sda3");
- mock_system_state.set_hardware(&fake_hardware);
+ FakeHardware* fake_hardware = mock_system_state.get_fake_hardware();
+ fake_hardware->SetBootDevice("/dev/sda3");
EXPECT_TRUE(payload_state.Initialize(&mock_system_state));
SetupPayloadStateWith2Urls("Hash3141", true, &payload_state, &response);
@@ -1404,7 +1403,6 @@
}
TEST(PayloadStateTest, RebootAfterUpdateSucceed) {
- FakeHardware fake_hardware;
MockSystemState mock_system_state;
OmahaResponse response;
PayloadState payload_state;
@@ -1417,8 +1415,8 @@
prefs.Init(FilePath(temp_dir));
mock_system_state.set_prefs(&prefs);
- fake_hardware.SetBootDevice("/dev/sda3");
- mock_system_state.set_hardware(&fake_hardware);
+ FakeHardware* fake_hardware = mock_system_state.get_fake_hardware();
+ fake_hardware->SetBootDevice("/dev/sda3");
EXPECT_TRUE(payload_state.Initialize(&mock_system_state));
SetupPayloadStateWith2Urls("Hash3141", true, &payload_state, &response);
@@ -1429,7 +1427,7 @@
payload_state.ExpectRebootInNewVersion("Version:12345678");
// Change the BootDevice to a different one, no metric should be sent.
- fake_hardware.SetBootDevice("/dev/sda5");
+ fake_hardware->SetBootDevice("/dev/sda5");
EXPECT_CALL(*mock_system_state.mock_metrics_lib(), SendToUMA(
"Installer.RebootToNewPartitionAttempt", _, _, _, _))
@@ -1438,7 +1436,7 @@
// A second reboot in eiher partition should not send a metric.
payload_state.ReportFailedBootIfNeeded();
- fake_hardware.SetBootDevice("/dev/sda3");
+ fake_hardware->SetBootDevice("/dev/sda3");
payload_state.ReportFailedBootIfNeeded();
EXPECT_TRUE(utils::RecursiveUnlinkDir(temp_dir));