| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 QuicTime::Delta rtt = QuicTime::Delta::FromMilliseconds(15); | 243 QuicTime::Delta rtt = QuicTime::Delta::FromMilliseconds(15); |
| 244 clock_.AdvanceTime(rtt); | 244 clock_.AdvanceTime(rtt); |
| 245 | 245 |
| 246 // Ack 1 but not 2. | 246 // Ack 1 but not 2. |
| 247 EXPECT_CALL(*send_algorithm_, UpdateRtt(rtt)); | 247 EXPECT_CALL(*send_algorithm_, UpdateRtt(rtt)); |
| 248 EXPECT_CALL(*send_algorithm_, OnPacketAcked(1, _)); | 248 EXPECT_CALL(*send_algorithm_, OnPacketAcked(1, _)); |
| 249 ReceivedPacketInfo received_info; | 249 ReceivedPacketInfo received_info; |
| 250 received_info.largest_observed = 1; | 250 received_info.largest_observed = 1; |
| 251 EXPECT_TRUE(manager_.OnIncomingAck(received_info, clock_.ApproximateNow())); | 251 EXPECT_TRUE(manager_.OnIncomingAck(received_info, clock_.ApproximateNow())); |
| 252 | 252 |
| 253 // 2 remains unacked, but no packets have retransmittable data. | 253 // No packets should be unacked. |
| 254 QuicPacketSequenceNumber unacked[] = { 2 }; | 254 VerifyUnackedPackets(NULL, 0); |
| 255 VerifyUnackedPackets(unacked, arraysize(unacked)); | |
| 256 EXPECT_FALSE(QuicSentPacketManagerPeer::HasPendingPackets(&manager_)); | 255 EXPECT_FALSE(QuicSentPacketManagerPeer::HasPendingPackets(&manager_)); |
| 257 VerifyRetransmittablePackets(NULL, 0); | 256 VerifyRetransmittablePackets(NULL, 0); |
| 258 | 257 |
| 259 // Verify that the retransmission alarm would not fire, | 258 // Verify that the retransmission alarm would not fire, |
| 260 // since there is no retransmittable data outstanding. | 259 // since there is no retransmittable data outstanding. |
| 261 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); | 260 EXPECT_EQ(QuicTime::Zero(), manager_.GetRetransmissionTime()); |
| 262 EXPECT_EQ(1u, stats_.packets_spuriously_retransmitted); | 261 EXPECT_EQ(1u, stats_.packets_spuriously_retransmitted); |
| 263 } | 262 } |
| 264 | 263 |
| 264 TEST_F(QuicSentPacketManagerTest, RetransmitAndSendThenAckPrevious) { |
| 265 SendDataPacket(1); |
| 266 RetransmitAndSendPacket(1, 2); |
| 267 QuicTime::Delta rtt = QuicTime::Delta::FromMilliseconds(15); |
| 268 clock_.AdvanceTime(rtt); |
| 269 |
| 270 // Ack 1 but not 2. |
| 271 EXPECT_CALL(*send_algorithm_, UpdateRtt(rtt)); |
| 272 EXPECT_CALL(*send_algorithm_, OnPacketAcked(1, _)); |
| 273 ReceivedPacketInfo received_info; |
| 274 received_info.largest_observed = 1; |
| 275 EXPECT_TRUE(manager_.OnIncomingAck(received_info, clock_.ApproximateNow())); |
| 276 |
| 277 // 2 remains unacked, but no packets have retransmittable data. |
| 278 QuicPacketSequenceNumber unacked[] = { 2 }; |
| 279 VerifyUnackedPackets(unacked, arraysize(unacked)); |
| 280 EXPECT_TRUE(QuicSentPacketManagerPeer::HasPendingPackets(&manager_)); |
| 281 VerifyRetransmittablePackets(NULL, 0); |
| 282 |
| 283 EXPECT_EQ(1u, stats_.packets_spuriously_retransmitted); |
| 284 } |
| 285 |
| 265 TEST_F(QuicSentPacketManagerTest, RetransmitThenAckPreviousThenNackRetransmit) { | 286 TEST_F(QuicSentPacketManagerTest, RetransmitThenAckPreviousThenNackRetransmit) { |
| 266 SendDataPacket(1); | 287 SendDataPacket(1); |
| 267 RetransmitPacket(1, 2); | 288 RetransmitPacket(1, 2); |
| 268 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 2, _, _, _)) | 289 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, 2, _, _, _)) |
| 269 .WillOnce(Return(true)); | 290 .WillOnce(Return(true)); |
| 270 manager_.OnPacketSent(2, clock_.ApproximateNow(), 1000, | 291 manager_.OnPacketSent(2, clock_.ApproximateNow(), 1000, |
| 271 NACK_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA); | 292 NACK_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA); |
| 272 QuicTime::Delta rtt = QuicTime::Delta::FromMilliseconds(15); | 293 QuicTime::Delta rtt = QuicTime::Delta::FromMilliseconds(15); |
| 273 clock_.AdvanceTime(rtt); | 294 clock_.AdvanceTime(rtt); |
| 274 | 295 |
| (...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 delay = delay.Add(delay); | 1223 delay = delay.Add(delay); |
| 1203 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 1224 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 1204 manager_.OnRetransmissionTimeout(); | 1225 manager_.OnRetransmissionTimeout(); |
| 1205 RetransmitNextPacket(i + 2); | 1226 RetransmitNextPacket(i + 2); |
| 1206 } | 1227 } |
| 1207 } | 1228 } |
| 1208 | 1229 |
| 1209 } // namespace | 1230 } // namespace |
| 1210 } // namespace test | 1231 } // namespace test |
| 1211 } // namespace net | 1232 } // namespace net |
| OLD | NEW |