PolicyManager: Add a new State class grouping the state providers.
The policy implementations need access to the providers to discover
the variables exposed by them. Instead of having global variables to
access each providers, we add a new State interface that groups all
the providers in the same way a provider groups all the variables.
This interface class allows to create a mock/fake class for testing
the policies.
Other minor fixes to the fakes are included in this patch.
BUG=chromium:338591
TEST=Simple unit test passes.
Change-Id: I7fe46dfc8416ee39ace3290628b7bae440213b29
Reviewed-on: https://chromium-review.googlesource.com/187705
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/policy_manager/policy_manager_unittest.cc b/policy_manager/policy_manager_unittest.cc
index dc906f1..ba001c9 100644
--- a/policy_manager/policy_manager_unittest.cc
+++ b/policy_manager/policy_manager_unittest.cc
@@ -35,7 +35,7 @@
// class extends the DefaultPolicy class to allow extensions of the Policy
// class without extending nor changing this test.
class FailingPolicy : public DefaultPolicy {
- virtual EvalStatus UpdateCheckAllowed(EvaluationContext* ec,
+ virtual EvalStatus UpdateCheckAllowed(EvaluationContext* ec, State* state,
string* error,
bool* result) const {
*error = "FailingPolicy failed.";
@@ -45,7 +45,7 @@
// The LazyPolicy always returns
class LazyPolicy : public DefaultPolicy {
- virtual EvalStatus UpdateCheckAllowed(EvaluationContext* ec,
+ virtual EvalStatus UpdateCheckAllowed(EvaluationContext* ec, State* state,
string* error,
bool* result) const {
return EvalStatusAskMeAgainLater;
@@ -64,7 +64,7 @@
bool result;
// Tests that the method is called on the policy_ instance.
- EXPECT_CALL(*policy, UpdateCheckAllowed(_, _, _))
+ EXPECT_CALL(*policy, UpdateCheckAllowed(_, _, _, _))
.WillOnce(Return(EvalStatusSucceeded));
EvalStatus status = pmut_.PolicyRequest(&Policy::UpdateCheckAllowed, &result);
EXPECT_EQ(status, EvalStatusSucceeded);