PM: Inject providers to RealState and PolicyManager.
Since RealState allocated a set of hard-coded real providers, it was
necessary for us to pass in underlying interfaces in order to be able to
mock dependencies like DBus or a system clock. This worked but scaled
poorly as we needed to test higher level classes like PolicyManager.
Instead, we now allow to inject the provider objects themselves into
RealState, and a State object into PolicyManager, which allows us to
easily fake them at each level for testing purposes.
BUG=None
TEST=Unit tests.
Change-Id: I85b38990e42039cb6cf37e97234fd18e2c3fea2e
Reviewed-on: https://chromium-review.googlesource.com/189776
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/policy_manager/real_state.h b/policy_manager/real_state.h
index 48ab56c..e2eddd7 100644
--- a/policy_manager/real_state.h
+++ b/policy_manager/real_state.h
@@ -5,17 +5,18 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_STATE_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_STATE_H_
-#include "update_engine/clock_interface.h"
-#include "update_engine/dbus_wrapper_interface.h"
+#include "update_engine/clock.h"
#include "update_engine/policy_manager/state.h"
+#include "update_engine/real_dbus_wrapper.h"
namespace chromeos_policy_manager {
// State implementation class.
class RealState : public State {
public:
- RealState(chromeos_update_engine::DBusWrapperInterface* dbus,
- chromeos_update_engine::ClockInterface* clock);
+ // Instantiate with given providers, assuming ownership of them.
+ RealState(RandomProvider* random_provider, ShillProvider* shill_provider);
+
~RealState() {}
private: