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 "base/callback.h" | 5 #include "base/callback.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/policy/cloud_policy_refresh_scheduler.h" | 10 #include "chrome/browser/policy/cloud_policy_refresh_scheduler.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 | 62 |
63 CloudPolicyRefreshScheduler* CreateRefreshScheduler() { | 63 CloudPolicyRefreshScheduler* CreateRefreshScheduler() { |
64 return new CloudPolicyRefreshScheduler(&client_, &store_, &prefs_, | 64 return new CloudPolicyRefreshScheduler(&client_, &store_, &prefs_, |
65 prefs::kUserPolicyRefreshRate, | 65 prefs::kUserPolicyRefreshRate, |
66 task_runner_); | 66 task_runner_); |
67 } | 67 } |
68 | 68 |
69 void NotifyIPAddressChanged() { | 69 void NotifyIPAddressChanged() { |
70 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 70 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
71 loop_.RunAllPending(); | 71 loop_.RunUntilIdle(); |
72 } | 72 } |
73 | 73 |
74 void CheckTiming(int64 expected_delay_ms) { | 74 void CheckTiming(int64 expected_delay_ms) { |
75 base::Time now(base::Time::NowFromSystemTime()); | 75 base::Time now(base::Time::NowFromSystemTime()); |
76 base::TimeDelta expected_delay( | 76 base::TimeDelta expected_delay( |
77 base::TimeDelta::FromMilliseconds(expected_delay_ms)); | 77 base::TimeDelta::FromMilliseconds(expected_delay_ms)); |
78 EXPECT_GE(last_delay_, expected_delay - (now - last_refresh_)); | 78 EXPECT_GE(last_delay_, expected_delay - (now - last_refresh_)); |
79 EXPECT_LE(last_delay_, expected_delay); | 79 EXPECT_LE(last_delay_, expected_delay); |
80 } | 80 } |
81 | 81 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 EXPECT_EQ(base::TimeDelta(), last_delay_); | 271 EXPECT_EQ(base::TimeDelta(), last_delay_); |
272 EXPECT_TRUE(last_callback_.is_null()); | 272 EXPECT_TRUE(last_callback_.is_null()); |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 INSTANTIATE_TEST_CASE_P(CloudPolicyRefreshSchedulerClientErrorTest, | 276 INSTANTIATE_TEST_CASE_P(CloudPolicyRefreshSchedulerClientErrorTest, |
277 CloudPolicyRefreshSchedulerClientErrorTest, | 277 CloudPolicyRefreshSchedulerClientErrorTest, |
278 testing::ValuesIn(kClientErrorTestCases)); | 278 testing::ValuesIn(kClientErrorTestCases)); |
279 | 279 |
280 } // namespace policy | 280 } // namespace policy |
OLD | NEW |