| 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 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 QuicPacketCreatorPeer::SetSequenceNumber(&peer_creator_, 7); | 1374 QuicPacketCreatorPeer::SetSequenceNumber(&peer_creator_, 7); |
| 1375 EXPECT_CALL(visitor_, | 1375 EXPECT_CALL(visitor_, |
| 1376 OnConnectionClosed(QUIC_INVALID_STOP_WAITING_DATA, false)); | 1376 OnConnectionClosed(QUIC_INVALID_STOP_WAITING_DATA, false)); |
| 1377 QuicStopWaitingFrame frame3 = InitStopWaitingFrame(1); | 1377 QuicStopWaitingFrame frame3 = InitStopWaitingFrame(1); |
| 1378 ProcessStopWaitingPacket(&frame3); | 1378 ProcessStopWaitingPacket(&frame3); |
| 1379 } | 1379 } |
| 1380 | 1380 |
| 1381 TEST_P(QuicConnectionTest, TooManySentPackets) { | 1381 TEST_P(QuicConnectionTest, TooManySentPackets) { |
| 1382 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1382 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1383 | 1383 |
| 1384 for (int i = 0; i < 3100; ++i) { | 1384 const int num_packets = 5100; |
| 1385 for (int i = 0; i < num_packets; ++i) { |
| 1385 SendStreamDataToPeer(1, "foo", 3 * i, !kFin, nullptr); | 1386 SendStreamDataToPeer(1, "foo", 3 * i, !kFin, nullptr); |
| 1386 } | 1387 } |
| 1387 | 1388 |
| 1388 // Ack packet 1, which leaves more than the limit outstanding. | 1389 // Ack packet 1, which leaves more than the limit outstanding. |
| 1389 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); | 1390 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1390 EXPECT_CALL(visitor_, OnConnectionClosed( | 1391 EXPECT_CALL(visitor_, OnConnectionClosed( |
| 1391 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS, false)); | 1392 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS, false)); |
| 1392 // We're receive buffer limited, so the connection won't try to write more. | 1393 // We're receive buffer limited, so the connection won't try to write more. |
| 1393 EXPECT_CALL(visitor_, OnCanWrite()).Times(0); | 1394 EXPECT_CALL(visitor_, OnCanWrite()).Times(0); |
| 1394 | 1395 |
| 1395 // Nack every packet except the last one, leaving a huge gap. | 1396 // Nack every packet except the last one, leaving a huge gap. |
| 1396 QuicAckFrame frame1 = InitAckFrame(3100); | 1397 QuicAckFrame frame1 = InitAckFrame(num_packets); |
| 1397 for (QuicPacketSequenceNumber i = 1; i < 3100; ++i) { | 1398 for (QuicPacketSequenceNumber i = 1; i < num_packets; ++i) { |
| 1398 NackPacket(i, &frame1); | 1399 NackPacket(i, &frame1); |
| 1399 } | 1400 } |
| 1400 ProcessAckPacket(&frame1); | 1401 ProcessAckPacket(&frame1); |
| 1401 } | 1402 } |
| 1402 | 1403 |
| 1403 TEST_P(QuicConnectionTest, TooManyReceivedPackets) { | 1404 TEST_P(QuicConnectionTest, TooManyReceivedPackets) { |
| 1404 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1405 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1405 EXPECT_CALL(visitor_, OnConnectionClosed( | 1406 EXPECT_CALL(visitor_, OnConnectionClosed( |
| 1406 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS, false)); | 1407 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS, false)); |
| 1407 | 1408 |
| 1408 // Miss every other packet for 3000 packets. | 1409 // Miss every other packet for 5000 packets. |
| 1409 for (QuicPacketSequenceNumber i = 1; i < 3000; ++i) { | 1410 for (QuicPacketSequenceNumber i = 1; i < 5000; ++i) { |
| 1410 ProcessPacket(i * 2); | 1411 ProcessPacket(i * 2); |
| 1411 if (!connection_.connected()) { | 1412 if (!connection_.connected()) { |
| 1412 break; | 1413 break; |
| 1413 } | 1414 } |
| 1414 } | 1415 } |
| 1415 } | 1416 } |
| 1416 | 1417 |
| 1417 TEST_P(QuicConnectionTest, LargestObservedLower) { | 1418 TEST_P(QuicConnectionTest, LargestObservedLower) { |
| 1418 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1419 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1419 | 1420 |
| (...skipping 3034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4454 copt.push_back(kFSPA); | 4455 copt.push_back(kFSPA); |
| 4455 QuicConfigPeer::SetReceivedConnectionOptions(&config, copt); | 4456 QuicConfigPeer::SetReceivedConnectionOptions(&config, copt); |
| 4456 EXPECT_EQ(FEC_ANY_TRIGGER, generator_->fec_send_policy()); | 4457 EXPECT_EQ(FEC_ANY_TRIGGER, generator_->fec_send_policy()); |
| 4457 connection_.SetFromConfig(config); | 4458 connection_.SetFromConfig(config); |
| 4458 EXPECT_EQ(FEC_ALARM_TRIGGER, generator_->fec_send_policy()); | 4459 EXPECT_EQ(FEC_ALARM_TRIGGER, generator_->fec_send_policy()); |
| 4459 } | 4460 } |
| 4460 | 4461 |
| 4461 } // namespace | 4462 } // namespace |
| 4462 } // namespace test | 4463 } // namespace test |
| 4463 } // namespace net | 4464 } // namespace net |
| OLD | NEW |