| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/congestion_control/pacing_sender.h" | 5 #include "net/quic/congestion_control/pacing_sender.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "net/quic/quic_protocol.h" | 9 #include "net/quic/quic_protocol.h" |
| 10 #include "net/quic/test_tools/mock_clock.h" | 10 #include "net/quic/test_tools/mock_clock.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 : zero_time_(QuicTime::Delta::Zero()), | 23 : zero_time_(QuicTime::Delta::Zero()), |
| 24 infinite_time_(QuicTime::Delta::Infinite()), | 24 infinite_time_(QuicTime::Delta::Infinite()), |
| 25 sequence_number_(1), | 25 sequence_number_(1), |
| 26 mock_sender_(new StrictMock<MockSendAlgorithm>()), | 26 mock_sender_(new StrictMock<MockSendAlgorithm>()), |
| 27 pacing_sender_(new PacingSender(mock_sender_, | 27 pacing_sender_(new PacingSender(mock_sender_, |
| 28 QuicTime::Delta::FromMilliseconds(1))) { | 28 QuicTime::Delta::FromMilliseconds(1))) { |
| 29 // Pick arbitrary time. | 29 // Pick arbitrary time. |
| 30 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(9)); | 30 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(9)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 virtual ~PacingSenderTest() {} | 33 virtual ~PacingSenderTest() OVERRIDE {} |
| 34 | 34 |
| 35 void CheckPacketIsSentImmediately() { | 35 void CheckPacketIsSentImmediately() { |
| 36 // In order for the packet to be sendable, the underlying sender must | 36 // In order for the packet to be sendable, the underlying sender must |
| 37 // permit it to be sent immediately. | 37 // permit it to be sent immediately. |
| 38 EXPECT_CALL(*mock_sender_, TimeUntilSend(clock_.Now(), | 38 EXPECT_CALL(*mock_sender_, TimeUntilSend(clock_.Now(), |
| 39 NOT_RETRANSMISSION, | 39 NOT_RETRANSMISSION, |
| 40 HAS_RETRANSMITTABLE_DATA, | 40 HAS_RETRANSMITTABLE_DATA, |
| 41 NOT_HANDSHAKE)) | 41 NOT_HANDSHAKE)) |
| 42 .WillOnce(Return(zero_time_)); | 42 .WillOnce(Return(zero_time_)); |
| 43 // Verify that the packet can be sent immediately. | 43 // Verify that the packet can be sent immediately. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); | 159 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); |
| 160 | 160 |
| 161 // Wake up early, but after enough time has passed to permit a send. | 161 // Wake up early, but after enough time has passed to permit a send. |
| 162 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); | 162 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); |
| 163 CheckPacketIsSentImmediately(); | 163 CheckPacketIsSentImmediately(); |
| 164 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); | 164 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); |
| 165 } | 165 } |
| 166 | 166 |
| 167 } // namespace test | 167 } // namespace test |
| 168 } // namespace net | 168 } // namespace net |
| OLD | NEW |