OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/proximity_auth/cryptauth/sync_scheduler_impl.h" | 5 #include "components/proximity_auth/cryptauth/sync_scheduler_impl.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "base/timer/mock_timer.h" | 10 #include "base/timer/mock_timer.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
10 | 12 |
11 namespace proximity_auth { | 13 namespace proximity_auth { |
12 | 14 |
13 using Strategy = SyncScheduler::Strategy; | 15 using Strategy = SyncScheduler::Strategy; |
14 using SyncState = SyncScheduler::SyncState; | 16 using SyncState = SyncScheduler::SyncState; |
15 | 17 |
16 namespace { | 18 namespace { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 zero_elapsed_time_(base::TimeDelta::FromSeconds(0)), | 82 zero_elapsed_time_(base::TimeDelta::FromSeconds(0)), |
81 scheduler_(new TestSyncSchedulerImpl(this, | 83 scheduler_(new TestSyncSchedulerImpl(this, |
82 refresh_period_, | 84 refresh_period_, |
83 base_recovery_period_, | 85 base_recovery_period_, |
84 0)) {} | 86 0)) {} |
85 | 87 |
86 ~ProximityAuthSyncSchedulerImplTest() override {} | 88 ~ProximityAuthSyncSchedulerImplTest() override {} |
87 | 89 |
88 void OnSyncRequested( | 90 void OnSyncRequested( |
89 scoped_ptr<SyncScheduler::SyncRequest> sync_request) override { | 91 scoped_ptr<SyncScheduler::SyncRequest> sync_request) override { |
90 sync_request_ = sync_request.Pass(); | 92 sync_request_ = std::move(sync_request); |
91 } | 93 } |
92 | 94 |
93 base::MockTimer* timer() { return scheduler_->timer(); } | 95 base::MockTimer* timer() { return scheduler_->timer(); } |
94 | 96 |
95 // The time deltas used to configure |scheduler_|. | 97 // The time deltas used to configure |scheduler_|. |
96 base::TimeDelta refresh_period_; | 98 base::TimeDelta refresh_period_; |
97 base::TimeDelta base_recovery_period_; | 99 base::TimeDelta base_recovery_period_; |
98 base::TimeDelta zero_elapsed_time_; | 100 base::TimeDelta zero_elapsed_time_; |
99 | 101 |
100 // The scheduler instance under test. | 102 // The scheduler instance under test. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 // This could happen in rare cases where the system clock changes. | 282 // This could happen in rare cases where the system clock changes. |
281 scheduler_->Start(base::TimeDelta::FromDays(-1000), | 283 scheduler_->Start(base::TimeDelta::FromDays(-1000), |
282 Strategy::PERIODIC_REFRESH); | 284 Strategy::PERIODIC_REFRESH); |
283 | 285 |
284 base::TimeDelta zero_delta = base::TimeDelta::FromSeconds(0); | 286 base::TimeDelta zero_delta = base::TimeDelta::FromSeconds(0); |
285 EXPECT_EQ(zero_delta, scheduler_->GetTimeToNextSync()); | 287 EXPECT_EQ(zero_delta, scheduler_->GetTimeToNextSync()); |
286 EXPECT_EQ(zero_delta, timer()->GetCurrentDelay()); | 288 EXPECT_EQ(zero_delta, timer()->GetCurrentDelay()); |
287 } | 289 } |
288 | 290 |
289 } // namespace proximity_auth | 291 } // namespace proximity_auth |
OLD | NEW |