update_engine: Use PrefsInterface from SystemState
There is no need to pass the Pref class around (at least not in cros)
since we have the SystemState as the global context and we can get the
pref from there.
BUG=b:171829801
TEST=cros_workon_make --board reef --test update_engine
Change-Id: I9f5fb8a118fab2ef0e188c42f746dafb1094972c
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2548740
Tested-by: Amin Hassani <ahassani@chromium.org>
Commit-Queue: Jae Hoon Kim <kimjae@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
diff --git a/cros/fake_system_state.h b/cros/fake_system_state.h
index b1d5952..7eb830c 100644
--- a/cros/fake_system_state.h
+++ b/cros/fake_system_state.h
@@ -25,6 +25,7 @@
#include "update_engine/common/fake_boot_control.h"
#include "update_engine/common/fake_clock.h"
#include "update_engine/common/fake_hardware.h"
+#include "update_engine/common/fake_prefs.h"
#include "update_engine/common/mock_metrics_reporter.h"
#include "update_engine/common/mock_prefs.h"
#include "update_engine/common/system_state.h"
@@ -200,6 +201,16 @@
return &fake_hardware_;
}
+ inline FakePrefs* fake_prefs() {
+ CHECK(prefs_ == &fake_prefs_);
+ return &fake_prefs_;
+ }
+
+ inline FakePrefs* fake_powerwash_safe_prefs() {
+ CHECK(powerwash_safe_prefs_ == &fake_powerwash_safe_prefs_);
+ return &fake_powerwash_safe_prefs_;
+ }
+
inline testing::NiceMock<MockMetricsReporter>* mock_metrics_reporter() {
CHECK(metrics_reporter_ == &mock_metrics_reporter_);
return &mock_metrics_reporter_;
@@ -245,10 +256,14 @@
FakeSystemState();
// Default mock/fake implementations (owned).
+ chromeos_update_manager::FakeUpdateManager fake_update_manager_;
FakeBootControl fake_boot_control_;
FakeClock fake_clock_;
- testing::NiceMock<MockConnectionManager> mock_connection_manager_;
FakeHardware fake_hardware_;
+ FakePrefs fake_prefs_;
+ FakePrefs fake_powerwash_safe_prefs_;
+
+ testing::NiceMock<MockConnectionManager> mock_connection_manager_;
testing::NiceMock<MockMetricsReporter> mock_metrics_reporter_;
testing::NiceMock<MockPrefs> mock_prefs_;
testing::NiceMock<MockPrefs> mock_powerwash_safe_prefs_;
@@ -256,7 +271,6 @@
testing::NiceMock<MockUpdateAttempter> mock_update_attempter_;
testing::NiceMock<MockOmahaRequestParams> mock_request_params_;
testing::NiceMock<MockP2PManager> mock_p2p_manager_;
- chromeos_update_manager::FakeUpdateManager fake_update_manager_;
testing::NiceMock<MockPowerManager> mock_power_manager_;
// Pointers to objects that client code can override. They are initialized to