OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/quic_sent_packet_manager.h" | 5 #include "net/quic/quic_sent_packet_manager.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 8 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
9 #include "net/quic/test_tools/quic_test_utils.h" | 9 #include "net/quic/test_tools/quic_test_utils.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 for (int i = 0; i < 5; ++i) { | 1113 for (int i = 0; i < 5; ++i) { |
1114 EXPECT_EQ(delay, | 1114 EXPECT_EQ(delay, |
1115 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_)); | 1115 QuicSentPacketManagerPeer::GetRetransmissionDelay(&manager_)); |
1116 delay = delay.Add(delay); | 1116 delay = delay.Add(delay); |
1117 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 1117 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
1118 manager_.OnRetransmissionTimeout(); | 1118 manager_.OnRetransmissionTimeout(); |
1119 RetransmitNextPacket(i + 2); | 1119 RetransmitNextPacket(i + 2); |
1120 } | 1120 } |
1121 } | 1121 } |
1122 | 1122 |
| 1123 TEST_F(QuicSentPacketManagerTest, GetLossDelay) { |
| 1124 MockLossAlgorithm* loss_algorithm = new MockLossAlgorithm(); |
| 1125 QuicSentPacketManagerPeer::SetLossAlgorithm(&manager_, loss_algorithm); |
| 1126 |
| 1127 EXPECT_CALL(*loss_algorithm, GetLossTimeout()) |
| 1128 .WillRepeatedly(Return(QuicTime::Zero())); |
| 1129 SendDataPacket(1); |
| 1130 SendDataPacket(2); |
| 1131 |
| 1132 // Handle an ack which causes the loss algorithm to be evaluated and |
| 1133 // set the loss timeout. |
| 1134 EXPECT_CALL(*send_algorithm_, UpdateRtt(_)); |
| 1135 EXPECT_CALL(*send_algorithm_, OnPacketAcked(2, _)); |
| 1136 EXPECT_CALL(*loss_algorithm, DetectLostPackets(_, _, _, _)) |
| 1137 .WillOnce(Return(SequenceNumberSet())); |
| 1138 ReceivedPacketInfo received_info; |
| 1139 received_info.largest_observed = 2; |
| 1140 received_info.missing_packets.insert(1); |
| 1141 manager_.OnIncomingAck(received_info, clock_.Now()); |
| 1142 |
| 1143 QuicTime timeout(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(10))); |
| 1144 EXPECT_CALL(*loss_algorithm, GetLossTimeout()) |
| 1145 .WillRepeatedly(Return(timeout)); |
| 1146 EXPECT_EQ(timeout, manager_.GetRetransmissionTime()); |
| 1147 |
| 1148 // Fire the retransmission timeout and ensure the loss detection algorithm |
| 1149 // is invoked. |
| 1150 EXPECT_CALL(*loss_algorithm, DetectLostPackets(_, _, _, _)) |
| 1151 .WillOnce(Return(SequenceNumberSet())); |
| 1152 manager_.OnRetransmissionTimeout(); |
| 1153 } |
| 1154 |
1123 } // namespace | 1155 } // namespace |
1124 } // namespace test | 1156 } // namespace test |
1125 } // namespace net | 1157 } // namespace net |
OLD | NEW |