| 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 "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 client_.SetPolicy(PolicyNamespaceKey(dm_protocol::kChromeUserPolicyType, | 120 client_.SetPolicy(PolicyNamespaceKey(dm_protocol::kChromeUserPolicyType, |
| 121 std::string()), | 121 std::string()), |
| 122 em::PolicyFetchResponse()); | 122 em::PolicyFetchResponse()); |
| 123 scoped_ptr<CloudPolicyRefreshScheduler> scheduler(CreateRefreshScheduler()); | 123 scoped_ptr<CloudPolicyRefreshScheduler> scheduler(CreateRefreshScheduler()); |
| 124 CheckTiming(kPolicyRefreshRate); | 124 CheckTiming(kPolicyRefreshRate); |
| 125 EXPECT_CALL(client_, FetchPolicy()).Times(1); | 125 EXPECT_CALL(client_, FetchPolicy()).Times(1); |
| 126 task_runner_->RunUntilIdle(); | 126 task_runner_->RunUntilIdle(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 TEST_F(CloudPolicyRefreshSchedulerTest, Unregistered) { | 129 TEST_F(CloudPolicyRefreshSchedulerTest, Unregistered) { |
| 130 client_.SetDMToken(""); | 130 client_.SetDMToken(std::string()); |
| 131 scoped_ptr<CloudPolicyRefreshScheduler> scheduler(CreateRefreshScheduler()); | 131 scoped_ptr<CloudPolicyRefreshScheduler> scheduler(CreateRefreshScheduler()); |
| 132 client_.NotifyPolicyFetched(); | 132 client_.NotifyPolicyFetched(); |
| 133 client_.NotifyRegistrationStateChanged(); | 133 client_.NotifyRegistrationStateChanged(); |
| 134 client_.NotifyClientError(); | 134 client_.NotifyClientError(); |
| 135 scheduler->SetRefreshDelay(12 * 60 * 60 * 1000); | 135 scheduler->SetRefreshDelay(12 * 60 * 60 * 1000); |
| 136 store_.NotifyStoreLoaded(); | 136 store_.NotifyStoreLoaded(); |
| 137 store_.NotifyStoreError(); | 137 store_.NotifyStoreError(); |
| 138 EXPECT_TRUE(task_runner_->GetPendingTasks().empty()); | 138 EXPECT_TRUE(task_runner_->GetPendingTasks().empty()); |
| 139 } | 139 } |
| 140 | 140 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 client_.NotifyPolicyFetched(); | 175 client_.NotifyPolicyFetched(); |
| 176 CheckTiming(kPolicyRefreshRate); | 176 CheckTiming(kPolicyRefreshRate); |
| 177 } | 177 } |
| 178 | 178 |
| 179 TEST_F(CloudPolicyRefreshSchedulerSteadyStateTest, OnRegistrationStateChanged) { | 179 TEST_F(CloudPolicyRefreshSchedulerSteadyStateTest, OnRegistrationStateChanged) { |
| 180 client_.SetDMToken("new_token"); | 180 client_.SetDMToken("new_token"); |
| 181 client_.NotifyRegistrationStateChanged(); | 181 client_.NotifyRegistrationStateChanged(); |
| 182 EXPECT_EQ(GetLastDelay(), base::TimeDelta()); | 182 EXPECT_EQ(GetLastDelay(), base::TimeDelta()); |
| 183 | 183 |
| 184 task_runner_->ClearPendingTasks(); | 184 task_runner_->ClearPendingTasks(); |
| 185 client_.SetDMToken(""); | 185 client_.SetDMToken(std::string()); |
| 186 client_.NotifyRegistrationStateChanged(); | 186 client_.NotifyRegistrationStateChanged(); |
| 187 EXPECT_TRUE(task_runner_->GetPendingTasks().empty()); | 187 EXPECT_TRUE(task_runner_->GetPendingTasks().empty()); |
| 188 } | 188 } |
| 189 | 189 |
| 190 TEST_F(CloudPolicyRefreshSchedulerSteadyStateTest, OnStoreLoaded) { | 190 TEST_F(CloudPolicyRefreshSchedulerSteadyStateTest, OnStoreLoaded) { |
| 191 store_.NotifyStoreLoaded(); | 191 store_.NotifyStoreLoaded(); |
| 192 CheckTiming(kPolicyRefreshRate); | 192 CheckTiming(kPolicyRefreshRate); |
| 193 } | 193 } |
| 194 | 194 |
| 195 TEST_F(CloudPolicyRefreshSchedulerSteadyStateTest, OnStoreError) { | 195 TEST_F(CloudPolicyRefreshSchedulerSteadyStateTest, OnStoreError) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 EXPECT_EQ(base::TimeDelta(), GetLastDelay()); | 285 EXPECT_EQ(base::TimeDelta(), GetLastDelay()); |
| 286 EXPECT_TRUE(task_runner_->GetPendingTasks().empty()); | 286 EXPECT_TRUE(task_runner_->GetPendingTasks().empty()); |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 | 289 |
| 290 INSTANTIATE_TEST_CASE_P(CloudPolicyRefreshSchedulerClientErrorTest, | 290 INSTANTIATE_TEST_CASE_P(CloudPolicyRefreshSchedulerClientErrorTest, |
| 291 CloudPolicyRefreshSchedulerClientErrorTest, | 291 CloudPolicyRefreshSchedulerClientErrorTest, |
| 292 testing::ValuesIn(kClientErrorTestCases)); | 292 testing::ValuesIn(kClientErrorTestCases)); |
| 293 | 293 |
| 294 } // namespace policy | 294 } // namespace policy |
| OLD | NEW |