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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 unacked_packets_.AddSentPacket( | 182 unacked_packets_.AddSentPacket( |
183 CreateRetransmittablePacketForStream(1, stream_id), 0, NOT_RETRANSMISSION, | 183 CreateRetransmittablePacketForStream(1, stream_id), 0, NOT_RETRANSMISSION, |
184 now_, kDefaultLength, true); | 184 now_, kDefaultLength, true); |
185 | 185 |
186 QuicPacketSequenceNumber unacked[] = {1}; | 186 QuicPacketSequenceNumber unacked[] = {1}; |
187 VerifyUnackedPackets(unacked, arraysize(unacked)); | 187 VerifyUnackedPackets(unacked, arraysize(unacked)); |
188 VerifyInFlightPackets(unacked, arraysize(unacked)); | 188 VerifyInFlightPackets(unacked, arraysize(unacked)); |
189 QuicPacketSequenceNumber retransmittable[] = {1}; | 189 QuicPacketSequenceNumber retransmittable[] = {1}; |
190 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); | 190 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); |
191 | 191 |
192 unacked_packets_.StopRetransmissionForStream(stream_id); | 192 unacked_packets_.CancelRetransmissionsForStream(stream_id); |
193 VerifyUnackedPackets(unacked, arraysize(unacked)); | 193 VerifyUnackedPackets(unacked, arraysize(unacked)); |
194 VerifyInFlightPackets(unacked, arraysize(unacked)); | 194 VerifyInFlightPackets(unacked, arraysize(unacked)); |
195 VerifyRetransmittablePackets(nullptr, 0); | 195 VerifyRetransmittablePackets(nullptr, 0); |
196 } | 196 } |
197 | 197 |
198 TEST_F(QuicUnackedPacketMapTest, StopRetransmissionOnOtherStream) { | 198 TEST_F(QuicUnackedPacketMapTest, StopRetransmissionOnOtherStream) { |
199 const QuicStreamId stream_id = 2; | 199 const QuicStreamId stream_id = 2; |
200 unacked_packets_.AddSentPacket( | 200 unacked_packets_.AddSentPacket( |
201 CreateRetransmittablePacketForStream(1, stream_id), 0, NOT_RETRANSMISSION, | 201 CreateRetransmittablePacketForStream(1, stream_id), 0, NOT_RETRANSMISSION, |
202 now_, kDefaultLength, true); | 202 now_, kDefaultLength, true); |
203 | 203 |
204 QuicPacketSequenceNumber unacked[] = {1}; | 204 QuicPacketSequenceNumber unacked[] = {1}; |
205 VerifyUnackedPackets(unacked, arraysize(unacked)); | 205 VerifyUnackedPackets(unacked, arraysize(unacked)); |
206 VerifyInFlightPackets(unacked, arraysize(unacked)); | 206 VerifyInFlightPackets(unacked, arraysize(unacked)); |
207 QuicPacketSequenceNumber retransmittable[] = {1}; | 207 QuicPacketSequenceNumber retransmittable[] = {1}; |
208 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); | 208 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); |
209 | 209 |
210 // Stop retransmissions on another stream and verify the packet is unchanged. | 210 // Stop retransmissions on another stream and verify the packet is unchanged. |
211 unacked_packets_.StopRetransmissionForStream(stream_id + 2); | 211 unacked_packets_.CancelRetransmissionsForStream(stream_id + 2); |
212 VerifyUnackedPackets(unacked, arraysize(unacked)); | 212 VerifyUnackedPackets(unacked, arraysize(unacked)); |
213 VerifyInFlightPackets(unacked, arraysize(unacked)); | 213 VerifyInFlightPackets(unacked, arraysize(unacked)); |
214 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); | 214 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); |
215 } | 215 } |
216 | 216 |
217 TEST_F(QuicUnackedPacketMapTest, StopRetransmissionAfterRetransmission) { | 217 TEST_F(QuicUnackedPacketMapTest, StopRetransmissionAfterRetransmission) { |
218 const QuicStreamId stream_id = 2; | 218 const QuicStreamId stream_id = 2; |
219 unacked_packets_.AddSentPacket( | 219 unacked_packets_.AddSentPacket( |
220 CreateRetransmittablePacketForStream(1, stream_id), 0, NOT_RETRANSMISSION, | 220 CreateRetransmittablePacketForStream(1, stream_id), 0, NOT_RETRANSMISSION, |
221 now_, kDefaultLength, true); | 221 now_, kDefaultLength, true); |
222 unacked_packets_.AddSentPacket(CreateNonRetransmittablePacket(2), 1, | 222 unacked_packets_.AddSentPacket(CreateNonRetransmittablePacket(2), 1, |
223 LOSS_RETRANSMISSION, now_, kDefaultLength, | 223 LOSS_RETRANSMISSION, now_, kDefaultLength, |
224 true); | 224 true); |
225 | 225 |
226 QuicPacketSequenceNumber unacked[] = {1, 2}; | 226 QuicPacketSequenceNumber unacked[] = {1, 2}; |
227 VerifyUnackedPackets(unacked, arraysize(unacked)); | 227 VerifyUnackedPackets(unacked, arraysize(unacked)); |
228 VerifyInFlightPackets(unacked, arraysize(unacked)); | 228 VerifyInFlightPackets(unacked, arraysize(unacked)); |
229 QuicPacketSequenceNumber retransmittable[] = {2}; | 229 QuicPacketSequenceNumber retransmittable[] = {2}; |
230 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); | 230 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); |
231 | 231 |
232 unacked_packets_.StopRetransmissionForStream(stream_id); | 232 unacked_packets_.CancelRetransmissionsForStream(stream_id); |
233 VerifyUnackedPackets(unacked, arraysize(unacked)); | 233 VerifyUnackedPackets(unacked, arraysize(unacked)); |
234 VerifyInFlightPackets(unacked, arraysize(unacked)); | 234 VerifyInFlightPackets(unacked, arraysize(unacked)); |
235 VerifyRetransmittablePackets(nullptr, 0); | 235 VerifyRetransmittablePackets(nullptr, 0); |
236 } | 236 } |
237 | 237 |
238 TEST_F(QuicUnackedPacketMapTest, RetransmittedPacket) { | 238 TEST_F(QuicUnackedPacketMapTest, RetransmittedPacket) { |
239 // Simulate a retransmittable packet being sent, retransmitted, and the first | 239 // Simulate a retransmittable packet being sent, retransmitted, and the first |
240 // transmission being acked. | 240 // transmission being acked. |
241 unacked_packets_.AddSentPacket(CreateRetransmittablePacket(1), 0, | 241 unacked_packets_.AddSentPacket(CreateRetransmittablePacket(1), 0, |
242 NOT_RETRANSMISSION, now_, kDefaultLength, | 242 NOT_RETRANSMISSION, now_, kDefaultLength, |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 EXPECT_TRUE(unacked_packets_.IsUnacked(3)); | 437 EXPECT_TRUE(unacked_packets_.IsUnacked(3)); |
438 EXPECT_FALSE(unacked_packets_.IsUnacked(4)); | 438 EXPECT_FALSE(unacked_packets_.IsUnacked(4)); |
439 EXPECT_TRUE(unacked_packets_.IsUnacked(5)); | 439 EXPECT_TRUE(unacked_packets_.IsUnacked(5)); |
440 EXPECT_EQ(5u, unacked_packets_.largest_sent_packet()); | 440 EXPECT_EQ(5u, unacked_packets_.largest_sent_packet()); |
441 } | 441 } |
442 | 442 |
443 | 443 |
444 } // namespace | 444 } // namespace |
445 } // namespace test | 445 } // namespace test |
446 } // namespace net | 446 } // namespace net |
OLD | NEW |