PolicyManager: Include the Polling interval for kVariableModePoll variables.
A kVariableModePoll variable requires to be polled to know the if the
value changed. This patch adds a new GetPollInterval method that
tells how often a kVariableModePoll variable should be polled. This
value will be used by the policy manager to trigger re-evaluations
of the same policy request.
BUG=chromium:341209
TEST=unit tests added and passes.
Change-Id: I9c982ec8106ce39a0bc0889df7686add131b3bea
Reviewed-on: https://chromium-review.googlesource.com/187703
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/policy_manager/variable_unittest.cc b/policy_manager/variable_unittest.cc
index e346c0d..5d3b8d9 100644
--- a/policy_manager/variable_unittest.cc
+++ b/policy_manager/variable_unittest.cc
@@ -6,6 +6,7 @@
#include "update_engine/policy_manager/variable.h"
+using base::TimeDelta;
using std::string;
namespace chromeos_policy_manager {
@@ -16,6 +17,8 @@
public:
DefaultVariable(const string& name, VariableMode mode)
: Variable<T>(name, mode) {}
+ DefaultVariable(const string& name, const TimeDelta& poll_interval)
+ : Variable<T>(name, poll_interval) {}
virtual ~DefaultVariable() {}
protected:
@@ -40,4 +43,17 @@
EXPECT_EQ(other_var.GetMode(), kVariableModePoll);
}
+TEST(PmBaseVariableTest, DefaultPollIntervalTest) {
+ DefaultVariable<int> const_var("const_var", kVariableModeConst);
+ EXPECT_EQ(const_var.GetPollInterval(), TimeDelta());
+ DefaultVariable<int> poll_var("poll_var", kVariableModePoll);
+ EXPECT_EQ(poll_var.GetPollInterval(), TimeDelta::FromMinutes(5));
+}
+
+TEST(PmBaseVariableTest, GetPollIntervalTest) {
+ DefaultVariable<int> var("var", TimeDelta::FromMinutes(3));
+ EXPECT_EQ(var.GetMode(), kVariableModePoll);
+ EXPECT_EQ(var.GetPollInterval(), TimeDelta::FromMinutes(3));
+}
+
} // namespace chromeos_policy_manager