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/dispatcher.h" | 5 #include "components/domain_reliability/dispatcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "components/domain_reliability/test_util.h" | 8 #include "components/domain_reliability/test_util.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 using base::TimeDelta; | 11 using base::TimeDelta; |
12 using base::TimeTicks; | 12 using base::TimeTicks; |
13 | 13 |
14 namespace domain_reliability { | 14 namespace domain_reliability { |
15 | 15 |
16 class DomainReliabilityDispatcherTest : public testing::Test { | 16 class DomainReliabilityDispatcherTest : public testing::Test { |
17 public: | 17 public: |
18 DomainReliabilityDispatcherTest() : dispatcher_(&time_) {} | 18 DomainReliabilityDispatcherTest() : dispatcher_(&time_) {} |
19 | 19 |
20 protected: | 20 protected: |
21 MockTime time_; | 21 MockTime time_; |
22 DomainReliabilityDispatcher dispatcher_; | 22 DomainReliabilityDispatcher dispatcher_; |
23 }; | 23 }; |
24 | 24 |
25 TEST_F(DomainReliabilityDispatcherTest, Create) { | 25 TEST_F(DomainReliabilityDispatcherTest, Create) {} |
26 } | |
27 | 26 |
28 TEST_F(DomainReliabilityDispatcherTest, TaskDoesntRunEarly) { | 27 TEST_F(DomainReliabilityDispatcherTest, TaskDoesntRunEarly) { |
29 TimeDelta delay = TimeDelta::FromSeconds(1); | 28 TimeDelta delay = TimeDelta::FromSeconds(1); |
30 TestCallback callback; | 29 TestCallback callback; |
31 | 30 |
32 dispatcher_.ScheduleTask(callback.callback(), 2 * delay, 3 * delay); | 31 dispatcher_.ScheduleTask(callback.callback(), 2 * delay, 3 * delay); |
33 time_.Advance(delay); | 32 time_.Advance(delay); |
34 dispatcher_.RunEligibleTasks(); | 33 dispatcher_.RunEligibleTasks(); |
35 EXPECT_FALSE(callback.called()); | 34 EXPECT_FALSE(callback.called()); |
36 } | 35 } |
(...skipping 15 matching lines...) Expand all Loading... |
52 TestCallback callback; | 51 TestCallback callback; |
53 | 52 |
54 dispatcher_.ScheduleTask(callback.callback(), 2 * delay, 3 * delay); | 53 dispatcher_.ScheduleTask(callback.callback(), 2 * delay, 3 * delay); |
55 time_.Advance(2 * delay); | 54 time_.Advance(2 * delay); |
56 EXPECT_FALSE(callback.called()); | 55 EXPECT_FALSE(callback.called()); |
57 time_.Advance(delay); | 56 time_.Advance(delay); |
58 EXPECT_TRUE(callback.called()); | 57 EXPECT_TRUE(callback.called()); |
59 } | 58 } |
60 | 59 |
61 } // namespace domain_reliability | 60 } // namespace domain_reliability |
OLD | NEW |