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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); | 1352 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); |
1353 QuicPacketCreatorPeer::SetSequenceNumber(&peer_creator_, 7); | 1353 QuicPacketCreatorPeer::SetSequenceNumber(&peer_creator_, 7); |
1354 EXPECT_CALL(visitor_, | 1354 EXPECT_CALL(visitor_, |
1355 OnConnectionClosed(QUIC_INVALID_STOP_WAITING_DATA, false)); | 1355 OnConnectionClosed(QUIC_INVALID_STOP_WAITING_DATA, false)); |
1356 QuicStopWaitingFrame frame3 = InitStopWaitingFrame(1); | 1356 QuicStopWaitingFrame frame3 = InitStopWaitingFrame(1); |
1357 ProcessStopWaitingPacket(&frame3); | 1357 ProcessStopWaitingPacket(&frame3); |
1358 } | 1358 } |
1359 | 1359 |
1360 TEST_P(QuicConnectionTest, TooManySentPackets) { | 1360 TEST_P(QuicConnectionTest, TooManySentPackets) { |
1361 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1361 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1362 | 1362 const QuicPacketCount num_sent_packets = kMaxTrackedPackets + 100; |
1363 for (int i = 0; i < 1100; ++i) { | 1363 for (QuicPacketCount i = 0; i < num_sent_packets; ++i) { |
1364 SendStreamDataToPeer(1, "foo", 3 * i, !kFin, nullptr); | 1364 SendStreamDataToPeer(1, "foo", 3 * i, !kFin, nullptr); |
1365 } | 1365 } |
1366 | 1366 |
1367 // Ack packet 1, which leaves more than the limit outstanding. | 1367 // Ack packet 1, which leaves more than the limit outstanding. |
1368 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1368 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
1369 EXPECT_CALL(visitor_, OnConnectionClosed( | 1369 EXPECT_CALL(visitor_, OnConnectionClosed( |
1370 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS, false)); | 1370 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS, false)); |
1371 // We're receive buffer limited, so the connection won't try to write more. | 1371 // We're receive buffer limited, so the connection won't try to write more. |
1372 EXPECT_CALL(visitor_, OnCanWrite()).Times(0); | 1372 EXPECT_CALL(visitor_, OnCanWrite()).Times(0); |
1373 | 1373 |
1374 // Nack every packet except the last one, leaving a huge gap. | 1374 // Nack every packet except the last one, leaving a huge gap. |
1375 QuicAckFrame frame1 = InitAckFrame(1100); | 1375 QuicAckFrame frame1 = InitAckFrame(num_sent_packets); |
1376 for (QuicPacketSequenceNumber i = 1; i < 1100; ++i) { | 1376 for (QuicPacketSequenceNumber i = 1; i < num_sent_packets; ++i) { |
1377 NackPacket(i, &frame1); | 1377 NackPacket(i, &frame1); |
1378 } | 1378 } |
1379 ProcessAckPacket(&frame1); | 1379 ProcessAckPacket(&frame1); |
1380 } | 1380 } |
1381 | 1381 |
1382 TEST_P(QuicConnectionTest, TooManyReceivedPackets) { | 1382 TEST_P(QuicConnectionTest, TooManyReceivedPackets) { |
1383 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1383 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1384 EXPECT_CALL(visitor_, OnConnectionClosed( | 1384 EXPECT_CALL(visitor_, OnConnectionClosed( |
1385 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS, false)); | 1385 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS, false)); |
1386 | 1386 |
1387 // Miss every other packet for 1000 packets. | 1387 // Miss every other packet for 5000 packets. |
1388 for (QuicPacketSequenceNumber i = 1; i < 1000; ++i) { | 1388 for (QuicPacketSequenceNumber i = 1; i < kMaxTrackedPackets; ++i) { |
1389 ProcessPacket(i * 2); | 1389 ProcessPacket(i * 2); |
1390 if (!connection_.connected()) { | 1390 if (!connection_.connected()) { |
1391 break; | 1391 break; |
1392 } | 1392 } |
1393 } | 1393 } |
1394 } | 1394 } |
1395 | 1395 |
1396 TEST_P(QuicConnectionTest, LargestObservedLower) { | 1396 TEST_P(QuicConnectionTest, LargestObservedLower) { |
1397 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1397 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1398 | 1398 |
(...skipping 2980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4379 // Regression test for b/18594622 | 4379 // Regression test for b/18594622 |
4380 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); | 4380 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); |
4381 EXPECT_DFATAL( | 4381 EXPECT_DFATAL( |
4382 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), | 4382 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), |
4383 "Attempt to send empty stream frame"); | 4383 "Attempt to send empty stream frame"); |
4384 } | 4384 } |
4385 | 4385 |
4386 } // namespace | 4386 } // namespace |
4387 } // namespace test | 4387 } // namespace test |
4388 } // namespace net | 4388 } // namespace net |
OLD | NEW |