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/config.h" | 9 #include "components/domain_reliability/config.h" |
10 #include "components/domain_reliability/test_util.h" | 10 #include "components/domain_reliability/test_util.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 DCHECK_LT(0, num_collectors); | 28 DCHECK_LT(0, num_collectors); |
29 DCHECK(!scheduler_); | 29 DCHECK(!scheduler_); |
30 | 30 |
31 num_collectors_ = num_collectors; | 31 num_collectors_ = num_collectors; |
32 scheduler_.reset(new DomainReliabilityScheduler( | 32 scheduler_.reset(new DomainReliabilityScheduler( |
33 &time_, | 33 &time_, |
34 num_collectors_, | 34 num_collectors_, |
35 params_, | 35 params_, |
36 base::Bind(&DomainReliabilitySchedulerTest::ScheduleUploadCallback, | 36 base::Bind(&DomainReliabilitySchedulerTest::ScheduleUploadCallback, |
37 base::Unretained(this)))); | 37 base::Unretained(this)))); |
| 38 scheduler_->MakeDeterministicForTesting(); |
38 } | 39 } |
39 | 40 |
40 ::testing::AssertionResult CheckNoPendingUpload() { | 41 ::testing::AssertionResult CheckNoPendingUpload() { |
41 DCHECK(scheduler_); | 42 DCHECK(scheduler_); |
42 | 43 |
43 if (!callback_called_) | 44 if (!callback_called_) |
44 return ::testing::AssertionSuccess(); | 45 return ::testing::AssertionSuccess(); |
45 | 46 |
46 return ::testing::AssertionFailure() | 47 return ::testing::AssertionFailure() |
47 << "expected no upload, got upload between " | 48 << "expected no upload, got upload between " |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 ASSERT_TRUE(CheckPendingUpload(min_delay(), max_delay())); | 236 ASSERT_TRUE(CheckPendingUpload(min_delay(), max_delay())); |
236 | 237 |
237 time_.Advance(min_delay()); | 238 time_.Advance(min_delay()); |
238 ASSERT_TRUE(CheckStartingUpload(0)); | 239 ASSERT_TRUE(CheckStartingUpload(0)); |
239 scheduler_->OnUploadComplete(true); | 240 scheduler_->OnUploadComplete(true); |
240 ASSERT_TRUE(CheckNoPendingUpload()); | 241 ASSERT_TRUE(CheckNoPendingUpload()); |
241 } | 242 } |
242 | 243 |
243 } // namespace | 244 } // namespace |
244 } // namespace domain_reliability | 245 } // namespace domain_reliability |
OLD | NEW |