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(); | |
39 } | 38 } |
40 | 39 |
41 ::testing::AssertionResult CheckNoPendingUpload() { | 40 ::testing::AssertionResult CheckNoPendingUpload() { |
42 DCHECK(scheduler_); | 41 DCHECK(scheduler_); |
43 | 42 |
44 if (!callback_called_) | 43 if (!callback_called_) |
45 return ::testing::AssertionSuccess(); | 44 return ::testing::AssertionSuccess(); |
46 | 45 |
47 return ::testing::AssertionFailure() | 46 return ::testing::AssertionFailure() |
48 << "expected no upload, got upload between " | 47 << "expected no upload, got upload between " |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 ASSERT_TRUE(CheckPendingUpload(min_delay(), max_delay())); | 235 ASSERT_TRUE(CheckPendingUpload(min_delay(), max_delay())); |
237 | 236 |
238 time_.Advance(min_delay()); | 237 time_.Advance(min_delay()); |
239 ASSERT_TRUE(CheckStartingUpload(0)); | 238 ASSERT_TRUE(CheckStartingUpload(0)); |
240 scheduler_->OnUploadComplete(true); | 239 scheduler_->OnUploadComplete(true); |
241 ASSERT_TRUE(CheckNoPendingUpload()); | 240 ASSERT_TRUE(CheckNoPendingUpload()); |
242 } | 241 } |
243 | 242 |
244 } // namespace | 243 } // namespace |
245 } // namespace domain_reliability | 244 } // namespace domain_reliability |
OLD | NEW |