| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/quic/quic_time.h" | 5 #include "net/quic/quic_time.h" |
| 6 #include "net/quic/test_tools/mock_clock.h" | 6 #include "net/quic/test_tools/mock_clock.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 namespace test { | 10 namespace test { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 TEST_F(QuicTimeTest, SubtractDelta) { | 92 TEST_F(QuicTimeTest, SubtractDelta) { |
| 93 QuicTime time = QuicTime::FromMilliseconds(2); | 93 QuicTime time = QuicTime::FromMilliseconds(2); |
| 94 EXPECT_EQ(QuicTime::FromMilliseconds(1), | 94 EXPECT_EQ(QuicTime::FromMilliseconds(1), |
| 95 time.Subtract(QuicTime::Delta::FromMilliseconds(1))); | 95 time.Subtract(QuicTime::Delta::FromMilliseconds(1))); |
| 96 } | 96 } |
| 97 | 97 |
| 98 TEST_F(QuicTimeTest, MockClock) { | 98 TEST_F(QuicTimeTest, MockClock) { |
| 99 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); | 99 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); |
| 100 | 100 |
| 101 QuicTime now = clock_.Now(); | 101 QuicTime now = clock_.ApproximateNow(); |
| 102 QuicTime time = QuicTime::FromMicroseconds(1000); | 102 QuicTime time = QuicTime::FromMicroseconds(1000); |
| 103 | 103 |
| 104 EXPECT_EQ(now, time); | 104 EXPECT_EQ(now, time); |
| 105 | 105 |
| 106 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); | 106 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); |
| 107 now = clock_.Now(); | 107 now = clock_.ApproximateNow(); |
| 108 | 108 |
| 109 EXPECT_NE(now, time); | 109 EXPECT_NE(now, time); |
| 110 | 110 |
| 111 time = time.Add(QuicTime::Delta::FromMilliseconds(1)); | 111 time = time.Add(QuicTime::Delta::FromMilliseconds(1)); |
| 112 EXPECT_EQ(now, time); | 112 EXPECT_EQ(now, time); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace test | 115 } // namespace test |
| 116 } // namespace net | 116 } // namespace net |
| OLD | NEW |