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 "net/quic/quic_unacked_packet_map.h" | 5 #include "net/quic/quic_unacked_packet_map.h" |
6 | 6 |
7 #include "net/quic/test_tools/quic_test_utils.h" | 7 #include "net/quic/test_tools/quic_test_utils.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 using std::min; | 10 using std::min; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 VerifyInFlightPackets(pending4, arraysize(pending4)); | 248 VerifyInFlightPackets(pending4, arraysize(pending4)); |
249 QuicPacketSequenceNumber retransmittable4[] = { 7 }; | 249 QuicPacketSequenceNumber retransmittable4[] = { 7 }; |
250 VerifyRetransmittablePackets(retransmittable4, arraysize(retransmittable4)); | 250 VerifyRetransmittablePackets(retransmittable4, arraysize(retransmittable4)); |
251 | 251 |
252 // Remove the older two transmissions from in flight. | 252 // Remove the older two transmissions from in flight. |
253 unacked_packets_.RemoveFromInFlight(3); | 253 unacked_packets_.RemoveFromInFlight(3); |
254 unacked_packets_.RemoveFromInFlight(5); | 254 unacked_packets_.RemoveFromInFlight(5); |
255 QuicPacketSequenceNumber pending5[] = { 7 }; | 255 QuicPacketSequenceNumber pending5[] = { 7 }; |
256 VerifyInFlightPackets(pending5, arraysize(pending5)); | 256 VerifyInFlightPackets(pending5, arraysize(pending5)); |
257 | 257 |
258 // Now test ClearPreviousTransmissions. | 258 // Now test ClearAllPreviousTransmissions, leaving one packet. |
259 unacked_packets_.ClearPreviousRetransmissions(5); | 259 unacked_packets_.ClearAllPreviousRetransmissions(); |
260 QuicPacketSequenceNumber unacked5[] = { 7 }; | 260 QuicPacketSequenceNumber unacked5[] = { 7 }; |
261 VerifyUnackedPackets(unacked5, arraysize(unacked5)); | 261 VerifyUnackedPackets(unacked5, arraysize(unacked5)); |
262 QuicPacketSequenceNumber retransmittable5[] = { 7 }; | 262 QuicPacketSequenceNumber retransmittable5[] = { 7 }; |
263 VerifyRetransmittablePackets(retransmittable5, arraysize(retransmittable5)); | 263 VerifyRetransmittablePackets(retransmittable5, arraysize(retransmittable5)); |
264 } | 264 } |
265 | 265 |
| 266 TEST_F(QuicUnackedPacketMapTest, RestoreInflight) { |
| 267 // Simulate a retransmittable packet being sent, retransmitted, and the first |
| 268 // transmission being acked. |
| 269 unacked_packets_.AddPacket(CreateRetransmittablePacket(1)); |
| 270 unacked_packets_.SetSent(1, now_, kDefaultLength, true); |
| 271 unacked_packets_.OnRetransmittedPacket(1, 2, RTO_RETRANSMISSION); |
| 272 unacked_packets_.RemoveFromInFlight(1); |
| 273 unacked_packets_.SetSent(2, now_, kDefaultLength, true); |
| 274 |
| 275 QuicPacketSequenceNumber unacked[] = { 1, 2 }; |
| 276 VerifyUnackedPackets(unacked, arraysize(unacked)); |
| 277 QuicPacketSequenceNumber retransmittable[] = { 2 }; |
| 278 VerifyInFlightPackets(retransmittable, arraysize(retransmittable)); |
| 279 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); |
| 280 EXPECT_EQ(kDefaultLength, unacked_packets_.bytes_in_flight()); |
| 281 |
| 282 // Simulate an F-RTO, and restore 1 to flight. |
| 283 unacked_packets_.RestoreInFlight(1); |
| 284 VerifyUnackedPackets(unacked, arraysize(unacked)); |
| 285 VerifyInFlightPackets(unacked, arraysize(unacked)); |
| 286 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); |
| 287 EXPECT_EQ(2 * kDefaultLength, unacked_packets_.bytes_in_flight()); |
| 288 } |
| 289 |
266 } // namespace | 290 } // namespace |
267 } // namespace test | 291 } // namespace test |
268 } // namespace net | 292 } // namespace net |
OLD | NEW |