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/util.h" | 5 #include "components/domain_reliability/util.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 DomainReliabilityMockTimeTest : public testing::Test { | 16 class DomainReliabilityMockTimeTest : public testing::Test { |
17 protected: | 17 protected: |
18 MockTime time_; | 18 MockTime time_; |
19 }; | 19 }; |
20 | 20 |
21 TEST_F(DomainReliabilityMockTimeTest, Null) { | 21 TEST_F(DomainReliabilityMockTimeTest, Create) { |
22 } | 22 } |
23 | 23 |
24 TEST_F(DomainReliabilityMockTimeTest, NowAndAdvance) { | 24 TEST_F(DomainReliabilityMockTimeTest, NowAndAdvance) { |
25 const TimeDelta delta = TimeDelta::FromSeconds(1); | 25 const TimeDelta delta = TimeDelta::FromSeconds(1); |
26 | 26 |
27 TimeTicks initial = time_.NowTicks(); | 27 TimeTicks initial = time_.NowTicks(); |
28 time_.Advance(delta); | 28 time_.Advance(delta); |
29 TimeTicks final = time_.NowTicks(); | 29 TimeTicks final = time_.NowTicks(); |
30 EXPECT_EQ(delta, final - initial); | 30 EXPECT_EQ(delta, final - initial); |
31 } | 31 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 callback.callback())); | 114 callback.callback())); |
115 time_.Advance(delta); | 115 time_.Advance(delta); |
116 EXPECT_FALSE(callback.called()); | 116 EXPECT_FALSE(callback.called()); |
117 EXPECT_TRUE(timer->IsRunning()); | 117 EXPECT_TRUE(timer->IsRunning()); |
118 time_.Advance(delta); | 118 time_.Advance(delta); |
119 EXPECT_TRUE(callback.called()); | 119 EXPECT_TRUE(callback.called()); |
120 EXPECT_FALSE(timer->IsRunning()); | 120 EXPECT_FALSE(timer->IsRunning()); |
121 } | 121 } |
122 | 122 |
123 } // namespace domain_reliability | 123 } // namespace domain_reliability |
OLD | NEW |