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/policy_manager.h b/policy_manager/policy_manager.h
index 51cc24a..33bb89c 100644
--- a/policy_manager/policy_manager.h
+++ b/policy_manager/policy_manager.h
@@ -11,8 +11,6 @@
#include <base/memory/ref_counted.h>
#include <base/memory/scoped_ptr.h>
-#include "update_engine/clock_interface.h"
-#include "update_engine/dbus_wrapper_interface.h"
#include "update_engine/policy_manager/default_policy.h"
#include "update_engine/policy_manager/policy.h"
#include "update_engine/policy_manager/state.h"
@@ -24,10 +22,10 @@
public:
PolicyManager() {}
- // Initializes the PolicyManager instance. Returns whether the initialization
- // succeeded.
- bool Init(chromeos_update_engine::DBusWrapperInterface* dbus,
- chromeos_update_engine::ClockInterface* clock);
+ // Initializes the PolicyManager instance, assuming ownership on the provided
+ // |state|, which is assumed to be pre-initialized. Returns whether the
+ // initialization succeeded.
+ bool Init(State* state);
// PolicyRequest() evaluates the given policy with the provided arguments and
// returns the result. The |policy_method| is the pointer-to-method of the