| 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 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 received_info.largest_observed = 9; | 1012 received_info.largest_observed = 9; |
| 1013 received_info.missing_packets.insert(1); | 1013 received_info.missing_packets.insert(1); |
| 1014 received_info.missing_packets.insert(2); | 1014 received_info.missing_packets.insert(2); |
| 1015 received_info.missing_packets.insert(6); | 1015 received_info.missing_packets.insert(6); |
| 1016 received_info.missing_packets.insert(7); | 1016 received_info.missing_packets.insert(7); |
| 1017 manager_.OnIncomingAck(received_info, clock_.ApproximateNow()); | 1017 manager_.OnIncomingAck(received_info, clock_.ApproximateNow()); |
| 1018 | 1018 |
| 1019 EXPECT_FALSE(QuicSentPacketManagerPeer::HasUnackedCryptoPackets(&manager_)); | 1019 EXPECT_FALSE(QuicSentPacketManagerPeer::HasUnackedCryptoPackets(&manager_)); |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 TEST_F(QuicSentPacketManagerTest, CryptoHandshakeTimeoutUnsentDataPacket) { |
| 1023 // Send 2 crypto packets and serialize 1 data packet. |
| 1024 const size_t kNumSentCryptoPackets = 2; |
| 1025 for (size_t i = 1; i <= kNumSentCryptoPackets; ++i) { |
| 1026 SendCryptoPacket(i); |
| 1027 } |
| 1028 SerializedPacket packet(CreateDataPacket(3)); |
| 1029 manager_.OnSerializedPacket(packet); |
| 1030 EXPECT_TRUE(QuicSentPacketManagerPeer::HasUnackedCryptoPackets(&manager_)); |
| 1031 |
| 1032 // Retransmit 2 crypto packets, but not the serialized packet. |
| 1033 EXPECT_CALL(*send_algorithm_, OnPacketAbandoned(_, _)).Times(2); |
| 1034 manager_.OnRetransmissionTimeout(); |
| 1035 RetransmitNextPacket(6); |
| 1036 RetransmitNextPacket(7); |
| 1037 EXPECT_FALSE(manager_.HasPendingRetransmissions()); |
| 1038 EXPECT_TRUE(QuicSentPacketManagerPeer::HasUnackedCryptoPackets(&manager_)); |
| 1039 } |
| 1040 |
| 1022 TEST_F(QuicSentPacketManagerTest, RetransmissionTimeout) { | 1041 TEST_F(QuicSentPacketManagerTest, RetransmissionTimeout) { |
| 1023 // Send 100 packets and then ensure all are abandoned when the RTO fires. | 1042 // Send 100 packets and then ensure all are abandoned when the RTO fires. |
| 1024 const size_t kNumSentPackets = 100; | 1043 const size_t kNumSentPackets = 100; |
| 1025 for (size_t i = 1; i <= kNumSentPackets; ++i) { | 1044 for (size_t i = 1; i <= kNumSentPackets; ++i) { |
| 1026 SendDataPacket(i); | 1045 SendDataPacket(i); |
| 1027 } | 1046 } |
| 1028 | 1047 |
| 1029 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 1048 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 1030 manager_.OnRetransmissionTimeout(); | 1049 manager_.OnRetransmissionTimeout(); |
| 1031 } | 1050 } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 delay = delay.Add(delay); | 1169 delay = delay.Add(delay); |
| 1151 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); | 1170 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); |
| 1152 manager_.OnRetransmissionTimeout(); | 1171 manager_.OnRetransmissionTimeout(); |
| 1153 RetransmitNextPacket(i + 2); | 1172 RetransmitNextPacket(i + 2); |
| 1154 } | 1173 } |
| 1155 } | 1174 } |
| 1156 | 1175 |
| 1157 } // namespace | 1176 } // namespace |
| 1158 } // namespace test | 1177 } // namespace test |
| 1159 } // namespace net | 1178 } // namespace net |
| OLD | NEW |