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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 // Now claim it's one, but set the ordering so it was sent "after" the first | 1307 // Now claim it's one, but set the ordering so it was sent "after" the first |
1308 // one. This should cause a connection error. | 1308 // one. This should cause a connection error. |
1309 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 1309 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
1310 peer_creator_.set_sequence_number(7); | 1310 peer_creator_.set_sequence_number(7); |
1311 EXPECT_CALL(visitor_, | 1311 EXPECT_CALL(visitor_, |
1312 OnConnectionClosed(QUIC_INVALID_STOP_WAITING_DATA, false)); | 1312 OnConnectionClosed(QUIC_INVALID_STOP_WAITING_DATA, false)); |
1313 QuicStopWaitingFrame frame3 = InitStopWaitingFrame(1); | 1313 QuicStopWaitingFrame frame3 = InitStopWaitingFrame(1); |
1314 ProcessStopWaitingPacket(&frame3); | 1314 ProcessStopWaitingPacket(&frame3); |
1315 } | 1315 } |
1316 | 1316 |
| 1317 TEST_P(QuicConnectionTest, TooManySentPackets) { |
| 1318 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1319 |
| 1320 for (int i = 0; i < 1100; ++i) { |
| 1321 SendStreamDataToPeer(1, "foo", 3 * i, !kFin, nullptr); |
| 1322 } |
| 1323 |
| 1324 // Ack packet 1, which leaves more than the limit outstanding. |
| 1325 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1326 if (FLAGS_quic_too_many_outstanding_packets) { |
| 1327 EXPECT_CALL(visitor_, |
| 1328 OnConnectionClosed(QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS, |
| 1329 false)); |
| 1330 EXPECT_CALL(visitor_, OnCanWrite()).Times(0); |
| 1331 } else { |
| 1332 EXPECT_CALL(visitor_, OnCanWrite()).Times(1); |
| 1333 } |
| 1334 // Nack every packet except the last one, leaving a huge gap. |
| 1335 QuicAckFrame frame1 = InitAckFrame(1100); |
| 1336 for (QuicPacketSequenceNumber i = 1; i < 1100; ++i) { |
| 1337 NackPacket(i, &frame1); |
| 1338 } |
| 1339 ProcessAckPacket(&frame1); |
| 1340 } |
| 1341 |
| 1342 TEST_P(QuicConnectionTest, TooManyReceivedPackets) { |
| 1343 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1344 |
| 1345 if (FLAGS_quic_too_many_outstanding_packets) { |
| 1346 EXPECT_CALL(visitor_, |
| 1347 OnConnectionClosed(QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS, |
| 1348 false)); |
| 1349 } |
| 1350 |
| 1351 // Miss every other packet for 1000 packets. |
| 1352 for (QuicPacketSequenceNumber i = 1; i < 1000; ++i) { |
| 1353 ProcessPacket(i * 2); |
| 1354 if (!connection_.connected()) { |
| 1355 break; |
| 1356 } |
| 1357 } |
| 1358 } |
| 1359 |
1317 TEST_P(QuicConnectionTest, LargestObservedLower) { | 1360 TEST_P(QuicConnectionTest, LargestObservedLower) { |
1318 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1361 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1319 | 1362 |
1320 SendStreamDataToPeer(1, "foo", 0, !kFin, nullptr); | 1363 SendStreamDataToPeer(1, "foo", 0, !kFin, nullptr); |
1321 SendStreamDataToPeer(1, "bar", 3, !kFin, nullptr); | 1364 SendStreamDataToPeer(1, "bar", 3, !kFin, nullptr); |
1322 SendStreamDataToPeer(1, "eep", 6, !kFin, nullptr); | 1365 SendStreamDataToPeer(1, "eep", 6, !kFin, nullptr); |
1323 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1366 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
1324 | 1367 |
1325 // Start out saying the largest observed is 2. | 1368 // Start out saying the largest observed is 2. |
1326 QuicAckFrame frame1 = InitAckFrame(1); | 1369 QuicAckFrame frame1 = InitAckFrame(1); |
(...skipping 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4064 QuicBlockedFrame blocked; | 4107 QuicBlockedFrame blocked; |
4065 blocked.stream_id = 3; | 4108 blocked.stream_id = 3; |
4066 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 4109 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
4067 ProcessFramePacket(QuicFrame(&blocked)); | 4110 ProcessFramePacket(QuicFrame(&blocked)); |
4068 EXPECT_TRUE(ack_alarm->IsSet()); | 4111 EXPECT_TRUE(ack_alarm->IsSet()); |
4069 } | 4112 } |
4070 | 4113 |
4071 } // namespace | 4114 } // namespace |
4072 } // namespace test | 4115 } // namespace test |
4073 } // namespace net | 4116 } // namespace net |
OLD | NEW |