Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Unified Diff: components/policy/core/common/cloud/cloud_policy_refresh_scheduler_unittest.cc

Issue 2472593003: Fix behavior of cloud policy refreshes scheduled for soon (Closed)
Patch Set: Change comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/policy/core/common/cloud/cloud_policy_refresh_scheduler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/cloud/cloud_policy_refresh_scheduler_unittest.cc
diff --git a/components/policy/core/common/cloud/cloud_policy_refresh_scheduler_unittest.cc b/components/policy/core/common/cloud/cloud_policy_refresh_scheduler_unittest.cc
index 8df64b1bbd6d58f27415bec89f9bd9dad008a569..9b9fbe3378cd9ef1773ec62a044e7b822f6d7e31 100644
--- a/components/policy/core/common/cloud/cloud_policy_refresh_scheduler_unittest.cc
+++ b/components/policy/core/common/cloud/cloud_policy_refresh_scheduler_unittest.cc
@@ -211,6 +211,36 @@ TEST_F(CloudPolicyRefreshSchedulerTest, RefreshSoon) {
Mock::VerifyAndClearExpectations(&client_);
}
+TEST_F(CloudPolicyRefreshSchedulerTest, RefreshSoonOverriding) {
+ std::unique_ptr<CloudPolicyRefreshScheduler> scheduler(
+ CreateRefreshScheduler());
+
+ // The refresh scheduled for soon overrides the previously scheduled refresh.
+ scheduler->RefreshSoon();
+ CheckTiming(0);
+
+ // The refresh scheduled for soon is not overridden by the change of the
+ // desired refresh delay.
+ const int64_t kNewPolicyRefreshRate = 12 * 60 * 60 * 1000;
+ scheduler->SetDesiredRefreshDelay(kNewPolicyRefreshRate);
+ CheckTiming(0);
+
+ // The refresh scheduled for soon is not overridden by the notification on the
+ // already fetched policy.
+ client_.SetPolicy(dm_protocol::kChromeUserPolicyType, std::string(),
+ em::PolicyFetchResponse());
+ store_.NotifyStoreLoaded();
+ CheckTiming(0);
+
+ EXPECT_CALL(client_, FetchPolicy()).Times(1);
+ task_runner_->RunUntilIdle();
+ Mock::VerifyAndClearExpectations(&client_);
+
+ // The next refresh is scheduled according to the normal rate.
+ client_.NotifyPolicyFetched();
+ CheckTiming(kNewPolicyRefreshRate);
+}
+
TEST_F(CloudPolicyRefreshSchedulerTest, InvalidationsAvailable) {
std::unique_ptr<CloudPolicyRefreshScheduler> scheduler(
new CloudPolicyRefreshScheduler(&client_, &store_, task_runner_));
« no previous file with comments | « components/policy/core/common/cloud/cloud_policy_refresh_scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698