OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/domain_reliability/scheduler.h" | 5 #include "components/domain_reliability/scheduler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "components/domain_reliability/test_util.h" | 9 #include "components/domain_reliability/test_util.h" |
10 #include "components/domain_reliability/util.h" | 10 #include "components/domain_reliability/util.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 using base::TimeDelta; | 13 using base::TimeDelta; |
14 using base::TimeTicks; | 14 using base::TimeTicks; |
15 | 15 |
16 namespace domain_reliability { | 16 namespace domain_reliability { |
17 | 17 |
18 class DomainReliabilitySchedulerTest : public testing::Test { | 18 class DomainReliabilitySchedulerTest : public testing::Test { |
19 public: | 19 public: |
20 DomainReliabilitySchedulerTest() : | 20 DomainReliabilitySchedulerTest() : num_collectors_(0), |
21 num_collectors_(0), | 21 params_(CreateDefaultParams()), |
22 params_(CreateDefaultParams()), | 22 callback_called_(false) { |
23 callback_called_(false) { | |
24 } | 23 } |
25 | 24 |
26 void CreateScheduler(int num_collectors) { | 25 void CreateScheduler(int num_collectors) { |
27 DCHECK_LT(0, num_collectors); | 26 DCHECK_LT(0, num_collectors); |
28 DCHECK(!scheduler_); | 27 DCHECK(!scheduler_); |
29 | 28 |
30 num_collectors_ = num_collectors; | 29 num_collectors_ = num_collectors; |
31 scheduler_.reset(new DomainReliabilityScheduler( | 30 scheduler_.reset(new DomainReliabilityScheduler( |
32 &time_, | 31 &time_, |
33 num_collectors_, | 32 num_collectors_, |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 205 |
207 ASSERT_TRUE(CheckPendingUpload(zero_delta(), max_delay() - min_delay())); | 206 ASSERT_TRUE(CheckPendingUpload(zero_delta(), max_delay() - min_delay())); |
208 time_.Advance(retry_interval()); | 207 time_.Advance(retry_interval()); |
209 | 208 |
210 // T = min_delay + retry_interval; collector 0 should be active again. | 209 // T = min_delay + retry_interval; collector 0 should be active again. |
211 ASSERT_TRUE(CheckStartingUpload(0)); | 210 ASSERT_TRUE(CheckStartingUpload(0)); |
212 scheduler_->OnUploadComplete(true); | 211 scheduler_->OnUploadComplete(true); |
213 } | 212 } |
214 | 213 |
215 } // namespace domain_reliability | 214 } // namespace domain_reliability |
OLD | NEW |