| 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 } | |
| 23 | 22 |
| 24 TEST_F(DomainReliabilityMockTimeTest, NowAndAdvance) { | 23 TEST_F(DomainReliabilityMockTimeTest, NowAndAdvance) { |
| 25 const TimeDelta delta = TimeDelta::FromSeconds(1); | 24 const TimeDelta delta = TimeDelta::FromSeconds(1); |
| 26 | 25 |
| 27 TimeTicks initial = time_.NowTicks(); | 26 TimeTicks initial = time_.NowTicks(); |
| 28 time_.Advance(delta); | 27 time_.Advance(delta); |
| 29 TimeTicks final = time_.NowTicks(); | 28 TimeTicks final = time_.NowTicks(); |
| 30 EXPECT_EQ(delta, final - initial); | 29 EXPECT_EQ(delta, final - initial); |
| 31 } | 30 } |
| 32 | 31 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 callback.callback())); | 113 callback.callback())); |
| 115 time_.Advance(delta); | 114 time_.Advance(delta); |
| 116 EXPECT_FALSE(callback.called()); | 115 EXPECT_FALSE(callback.called()); |
| 117 EXPECT_TRUE(timer->IsRunning()); | 116 EXPECT_TRUE(timer->IsRunning()); |
| 118 time_.Advance(delta); | 117 time_.Advance(delta); |
| 119 EXPECT_TRUE(callback.called()); | 118 EXPECT_TRUE(callback.called()); |
| 120 EXPECT_FALSE(timer->IsRunning()); | 119 EXPECT_FALSE(timer->IsRunning()); |
| 121 } | 120 } |
| 122 | 121 |
| 123 } // namespace domain_reliability | 122 } // namespace domain_reliability |
| OLD | NEW |