OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 ProcessPacket(1); | 1257 ProcessPacket(1); |
1258 // Should ack immediately, since this fills the last hole. | 1258 // Should ack immediately, since this fills the last hole. |
1259 EXPECT_EQ(3u, writer_->packets_write_attempts()); | 1259 EXPECT_EQ(3u, writer_->packets_write_attempts()); |
1260 | 1260 |
1261 ProcessPacket(4); | 1261 ProcessPacket(4); |
1262 // Should not cause an ack. | 1262 // Should not cause an ack. |
1263 EXPECT_EQ(3u, writer_->packets_write_attempts()); | 1263 EXPECT_EQ(3u, writer_->packets_write_attempts()); |
1264 } | 1264 } |
1265 | 1265 |
1266 TEST_P(QuicConnectionTest, OutOfOrderAckReceiptCausesNoAck) { | 1266 TEST_P(QuicConnectionTest, OutOfOrderAckReceiptCausesNoAck) { |
1267 ValueRestore<bool> old_flag(&FLAGS_quic_dont_ack_acks, true); | |
1268 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1267 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1269 | 1268 |
1270 SendStreamDataToPeer(1, "foo", 0, !kFin, nullptr); | 1269 SendStreamDataToPeer(1, "foo", 0, !kFin, nullptr); |
1271 SendStreamDataToPeer(1, "bar", 3, !kFin, nullptr); | 1270 SendStreamDataToPeer(1, "bar", 3, !kFin, nullptr); |
1272 EXPECT_EQ(2u, writer_->packets_write_attempts()); | 1271 EXPECT_EQ(2u, writer_->packets_write_attempts()); |
1273 | 1272 |
1274 QuicAckFrame ack1 = InitAckFrame(1); | 1273 QuicAckFrame ack1 = InitAckFrame(1); |
1275 QuicAckFrame ack2 = InitAckFrame(2); | 1274 QuicAckFrame ack2 = InitAckFrame(2); |
1276 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1275 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
1277 ProcessAckPacket(2, &ack2); | 1276 ProcessAckPacket(2, &ack2); |
1278 // Should ack immediately since we have missing packets. | 1277 // Should ack immediately since we have missing packets. |
1279 EXPECT_EQ(2u, writer_->packets_write_attempts()); | 1278 EXPECT_EQ(2u, writer_->packets_write_attempts()); |
1280 | 1279 |
1281 ProcessAckPacket(1, &ack1); | 1280 ProcessAckPacket(1, &ack1); |
1282 // Should not ack an ack filling a missing packet. | 1281 // Should not ack an ack filling a missing packet. |
1283 EXPECT_EQ(2u, writer_->packets_write_attempts()); | 1282 EXPECT_EQ(2u, writer_->packets_write_attempts()); |
1284 } | 1283 } |
1285 | 1284 |
1286 TEST_P(QuicConnectionTest, OutOfOrderAckReceiptCausesOneAck) { | |
1287 ValueRestore<bool> old_flag(&FLAGS_quic_dont_ack_acks, false); | |
1288 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | |
1289 | |
1290 SendStreamDataToPeer(1, "foo", 0, !kFin, nullptr); | |
1291 SendStreamDataToPeer(1, "bar", 3, !kFin, nullptr); | |
1292 EXPECT_EQ(2u, writer_->packets_write_attempts()); | |
1293 | |
1294 QuicAckFrame ack1 = InitAckFrame(1); | |
1295 QuicAckFrame ack2 = InitAckFrame(2); | |
1296 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | |
1297 ProcessAckPacket(2, &ack2); | |
1298 // Should ack immediately since we have missing packets. | |
1299 EXPECT_EQ(3u, writer_->packets_write_attempts()); | |
1300 | |
1301 ProcessAckPacket(1, &ack1); | |
1302 // Should not ack an ack filling a missing packet. | |
1303 EXPECT_EQ(3u, writer_->packets_write_attempts()); | |
1304 } | |
1305 | |
1306 TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) { | 1285 TEST_P(QuicConnectionTest, AckReceiptCausesAckSend) { |
1307 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1286 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1308 | 1287 |
1309 QuicPacketSequenceNumber original; | 1288 QuicPacketSequenceNumber original; |
1310 QuicByteCount packet_size; | 1289 QuicByteCount packet_size; |
1311 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 1290 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
1312 .WillOnce(DoAll(SaveArg<2>(&original), SaveArg<3>(&packet_size), | 1291 .WillOnce(DoAll(SaveArg<2>(&original), SaveArg<3>(&packet_size), |
1313 Return(true))); | 1292 Return(true))); |
1314 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 1293 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
1315 QuicAckFrame frame = InitAckFrame(original); | 1294 QuicAckFrame frame = InitAckFrame(original); |
(...skipping 3350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4666 copt.push_back(kFSPA); | 4645 copt.push_back(kFSPA); |
4667 QuicConfigPeer::SetReceivedConnectionOptions(&config, copt); | 4646 QuicConfigPeer::SetReceivedConnectionOptions(&config, copt); |
4668 EXPECT_EQ(FEC_ANY_TRIGGER, generator_->fec_send_policy()); | 4647 EXPECT_EQ(FEC_ANY_TRIGGER, generator_->fec_send_policy()); |
4669 connection_.SetFromConfig(config); | 4648 connection_.SetFromConfig(config); |
4670 EXPECT_EQ(FEC_ALARM_TRIGGER, generator_->fec_send_policy()); | 4649 EXPECT_EQ(FEC_ALARM_TRIGGER, generator_->fec_send_policy()); |
4671 } | 4650 } |
4672 | 4651 |
4673 } // namespace | 4652 } // namespace |
4674 } // namespace test | 4653 } // namespace test |
4675 } // namespace net | 4654 } // namespace net |
OLD | NEW |