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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 unacked_packets_.IncreaseLargestObserved(1); | 112 unacked_packets_.IncreaseLargestObserved(1); |
113 VerifyUnackedPackets(NULL, 0); | 113 VerifyUnackedPackets(NULL, 0); |
114 VerifyInFlightPackets(NULL, 0); | 114 VerifyInFlightPackets(NULL, 0); |
115 VerifyRetransmittablePackets(NULL, 0); | 115 VerifyRetransmittablePackets(NULL, 0); |
116 } | 116 } |
117 | 117 |
118 TEST_F(QuicUnackedPacketMapTest, DiscardOldRttOnly) { | 118 TEST_F(QuicUnackedPacketMapTest, DiscardOldRttOnly) { |
119 // Acks are only tracked for RTT measurement purposes, and are discarded | 119 // Acks are only tracked for RTT measurement purposes, and are discarded |
120 // when more than 200 accumulate. | 120 // when more than 200 accumulate. |
121 for (int i = 1; i < 400; ++i) { | 121 for (size_t i = 1; i < 400; ++i) { |
122 unacked_packets_.AddPacket(CreateNonRetransmittablePacket(i)); | 122 unacked_packets_.AddPacket(CreateNonRetransmittablePacket(i)); |
123 unacked_packets_.SetSent(i, now_, kDefaultAckLength, false); | 123 unacked_packets_.SetSent(i, now_, kDefaultAckLength, false); |
124 unacked_packets_.RemoveObsoletePackets(); | 124 unacked_packets_.RemoveObsoletePackets(); |
125 EXPECT_EQ(static_cast<size_t>(min(i, 200)), | 125 EXPECT_EQ(min(i, 200lu), |
126 unacked_packets_.GetNumUnackedPacketsDebugOnly()); | 126 unacked_packets_.GetNumUnackedPacketsDebugOnly()); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 TEST_F(QuicUnackedPacketMapTest, RetransmittableInflightAndRtt) { | 130 TEST_F(QuicUnackedPacketMapTest, RetransmittableInflightAndRtt) { |
131 // Simulate a retransmittable packet being sent and acked. | 131 // Simulate a retransmittable packet being sent and acked. |
132 unacked_packets_.AddPacket(CreateRetransmittablePacket(1)); | 132 unacked_packets_.AddPacket(CreateRetransmittablePacket(1)); |
133 unacked_packets_.SetSent(1, now_, kDefaultLength, true); | 133 unacked_packets_.SetSent(1, now_, kDefaultLength, true); |
134 | 134 |
135 QuicPacketSequenceNumber unacked[] = { 1 }; | 135 QuicPacketSequenceNumber unacked[] = { 1 }; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 unacked_packets_.RestoreInFlight(1); | 283 unacked_packets_.RestoreInFlight(1); |
284 VerifyUnackedPackets(unacked, arraysize(unacked)); | 284 VerifyUnackedPackets(unacked, arraysize(unacked)); |
285 VerifyInFlightPackets(unacked, arraysize(unacked)); | 285 VerifyInFlightPackets(unacked, arraysize(unacked)); |
286 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); | 286 VerifyRetransmittablePackets(retransmittable, arraysize(retransmittable)); |
287 EXPECT_EQ(2 * kDefaultLength, unacked_packets_.bytes_in_flight()); | 287 EXPECT_EQ(2 * kDefaultLength, unacked_packets_.bytes_in_flight()); |
288 } | 288 } |
289 | 289 |
290 } // namespace | 290 } // namespace |
291 } // namespace test | 291 } // namespace test |
292 } // namespace net | 292 } // namespace net |
OLD | NEW |