Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: net/quic/quic_connection_test.cc

Issue 968233004: Land Recent QUIC Changes until 03/02/2015. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_client_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 bool entropy_flag, 704 bool entropy_flag,
705 EncryptionLevel level) { 705 EncryptionLevel level) {
706 scoped_ptr<QuicPacket> packet(ConstructDataPacket(number, fec_group, 706 scoped_ptr<QuicPacket> packet(ConstructDataPacket(number, fec_group,
707 entropy_flag)); 707 entropy_flag));
708 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( 708 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(
709 level, number, *packet)); 709 level, number, *packet));
710 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); 710 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
711 return encrypted->length(); 711 return encrypted->length();
712 } 712 }
713 713
714 void ProcessPingPacket(QuicPacketSequenceNumber number) {
715 scoped_ptr<QuicPacket> packet(ConstructPingPacket(number));
716 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(
717 ENCRYPTION_NONE, number, *packet));
718 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
719 }
720
721 void ProcessClosePacket(QuicPacketSequenceNumber number, 714 void ProcessClosePacket(QuicPacketSequenceNumber number,
722 QuicFecGroupNumber fec_group) { 715 QuicFecGroupNumber fec_group) {
723 scoped_ptr<QuicPacket> packet(ConstructClosePacket(number, fec_group)); 716 scoped_ptr<QuicPacket> packet(ConstructClosePacket(number, fec_group));
724 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( 717 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(
725 ENCRYPTION_NONE, number, *packet)); 718 ENCRYPTION_NONE, number, *packet));
726 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); 719 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
727 } 720 }
728 721
729 size_t ProcessFecProtectedPacket(QuicPacketSequenceNumber number, 722 size_t ProcessFecProtectedPacket(QuicPacketSequenceNumber number,
730 bool expect_revival, bool entropy_flag) { 723 bool expect_revival, bool entropy_flag) {
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 1345 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
1353 QuicPacketCreatorPeer::SetSequenceNumber(&peer_creator_, 7); 1346 QuicPacketCreatorPeer::SetSequenceNumber(&peer_creator_, 7);
1354 EXPECT_CALL(visitor_, 1347 EXPECT_CALL(visitor_,
1355 OnConnectionClosed(QUIC_INVALID_STOP_WAITING_DATA, false)); 1348 OnConnectionClosed(QUIC_INVALID_STOP_WAITING_DATA, false));
1356 QuicStopWaitingFrame frame3 = InitStopWaitingFrame(1); 1349 QuicStopWaitingFrame frame3 = InitStopWaitingFrame(1);
1357 ProcessStopWaitingPacket(&frame3); 1350 ProcessStopWaitingPacket(&frame3);
1358 } 1351 }
1359 1352
1360 TEST_P(QuicConnectionTest, TooManySentPackets) { 1353 TEST_P(QuicConnectionTest, TooManySentPackets) {
1361 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1354 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1362 1355 const QuicPacketCount num_sent_packets = kMaxTrackedPackets + 100;
1363 for (int i = 0; i < 1100; ++i) { 1356 for (QuicPacketCount i = 0; i < num_sent_packets; ++i) {
1364 SendStreamDataToPeer(1, "foo", 3 * i, !kFin, nullptr); 1357 SendStreamDataToPeer(1, "foo", 3 * i, !kFin, nullptr);
1365 } 1358 }
1366 1359
1367 // Ack packet 1, which leaves more than the limit outstanding. 1360 // Ack packet 1, which leaves more than the limit outstanding.
1368 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 1361 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
1369 EXPECT_CALL(visitor_, OnConnectionClosed( 1362 EXPECT_CALL(visitor_, OnConnectionClosed(
1370 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS, false)); 1363 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS, false));
1371 // We're receive buffer limited, so the connection won't try to write more. 1364 // We're receive buffer limited, so the connection won't try to write more.
1372 EXPECT_CALL(visitor_, OnCanWrite()).Times(0); 1365 EXPECT_CALL(visitor_, OnCanWrite()).Times(0);
1373 1366
1374 // Nack every packet except the last one, leaving a huge gap. 1367 // Nack every packet except the last one, leaving a huge gap.
1375 QuicAckFrame frame1 = InitAckFrame(1100); 1368 QuicAckFrame frame1 = InitAckFrame(num_sent_packets);
1376 for (QuicPacketSequenceNumber i = 1; i < 1100; ++i) { 1369 for (QuicPacketSequenceNumber i = 1; i < num_sent_packets; ++i) {
1377 NackPacket(i, &frame1); 1370 NackPacket(i, &frame1);
1378 } 1371 }
1379 ProcessAckPacket(&frame1); 1372 ProcessAckPacket(&frame1);
1380 } 1373 }
1381 1374
1382 TEST_P(QuicConnectionTest, TooManyReceivedPackets) { 1375 TEST_P(QuicConnectionTest, TooManyReceivedPackets) {
1383 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1376 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1384 EXPECT_CALL(visitor_, OnConnectionClosed( 1377 EXPECT_CALL(visitor_, OnConnectionClosed(
1385 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS, false)); 1378 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS, false));
1386 1379
1387 // Miss every other packet for 1000 packets. 1380 // Miss every other packet for 5000 packets.
1388 for (QuicPacketSequenceNumber i = 1; i < 1000; ++i) { 1381 for (QuicPacketSequenceNumber i = 1; i < kMaxTrackedPackets; ++i) {
1389 ProcessPacket(i * 2); 1382 ProcessPacket(i * 2);
1390 if (!connection_.connected()) { 1383 if (!connection_.connected()) {
1391 break; 1384 break;
1392 } 1385 }
1393 } 1386 }
1394 } 1387 }
1395 1388
1396 TEST_P(QuicConnectionTest, LargestObservedLower) { 1389 TEST_P(QuicConnectionTest, LargestObservedLower) {
1397 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1390 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1398 1391
(...skipping 2980 matching lines...) Expand 10 before | Expand all | Expand 10 after
4379 // Regression test for b/18594622 4372 // Regression test for b/18594622
4380 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 4373 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
4381 EXPECT_DFATAL( 4374 EXPECT_DFATAL(
4382 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), 4375 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()),
4383 "Attempt to send empty stream frame"); 4376 "Attempt to send empty stream frame");
4384 } 4377 }
4385 4378
4386 } // namespace 4379 } // namespace
4387 } // namespace test 4380 } // namespace test
4388 } // namespace net 4381 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_client_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698