OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" | 5 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 scheduler->SetDesiredRefreshDelay(kPolicyRefreshRate); | 65 scheduler->SetDesiredRefreshDelay(kPolicyRefreshRate); |
66 return scheduler; | 66 return scheduler; |
67 } | 67 } |
68 | 68 |
69 void NotifyIPAddressChanged() { | 69 void NotifyIPAddressChanged() { |
70 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 70 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
71 base::RunLoop().RunUntilIdle(); | 71 base::RunLoop().RunUntilIdle(); |
72 } | 72 } |
73 | 73 |
74 base::TimeDelta GetLastDelay() const { | 74 base::TimeDelta GetLastDelay() const { |
75 const std::deque<base::TestPendingTask>& pending_tasks = | 75 if (!task_runner_->HasPendingTask()) |
76 task_runner_->GetPendingTasks(); | 76 return base::TimeDelta(); |
77 return | 77 return task_runner_->FinalPendingTaskDelay(); |
78 pending_tasks.empty() ? base::TimeDelta() : pending_tasks.back().delay; | |
79 } | 78 } |
80 | 79 |
81 void CheckTiming(int64_t expected_delay_ms) const { | 80 void CheckTiming(int64_t expected_delay_ms) const { |
82 CheckTimingWithAge(base::TimeDelta::FromMilliseconds(expected_delay_ms), | 81 CheckTimingWithAge(base::TimeDelta::FromMilliseconds(expected_delay_ms), |
83 base::TimeDelta()); | 82 base::TimeDelta()); |
84 } | 83 } |
85 | 84 |
86 // Checks that the latest refresh scheduled used an offset of | 85 // Checks that the latest refresh scheduled used an offset of |
87 // |offset_from_last_refresh| from the time of the previous refresh. | 86 // |offset_from_last_refresh| from the time of the previous refresh. |
88 // |cache_age| is how old the cache was when the refresh was issued. | 87 // |cache_age| is how old the cache was when the refresh was issued. |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 EXPECT_EQ(base::TimeDelta(), GetLastDelay()); | 453 EXPECT_EQ(base::TimeDelta(), GetLastDelay()); |
455 EXPECT_FALSE(task_runner_->HasPendingTask()); | 454 EXPECT_FALSE(task_runner_->HasPendingTask()); |
456 } | 455 } |
457 } | 456 } |
458 | 457 |
459 INSTANTIATE_TEST_CASE_P(CloudPolicyRefreshSchedulerClientErrorTest, | 458 INSTANTIATE_TEST_CASE_P(CloudPolicyRefreshSchedulerClientErrorTest, |
460 CloudPolicyRefreshSchedulerClientErrorTest, | 459 CloudPolicyRefreshSchedulerClientErrorTest, |
461 testing::ValuesIn(kClientErrorTestCases)); | 460 testing::ValuesIn(kClientErrorTestCases)); |
462 | 461 |
463 } // namespace policy | 462 } // namespace policy |
OLD | NEW |