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

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

Issue 11820005: Largest received -> largest observed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_framer.h » ('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 "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
8 #include "net/quic/congestion_control/quic_receipt_metrics_collector.h" 8 #include "net/quic/congestion_control/quic_receipt_metrics_collector.h"
9 #include "net/quic/congestion_control/quic_send_scheduler.h" 9 #include "net/quic/congestion_control/quic_send_scheduler.h"
10 #include "net/quic/crypto/null_encrypter.h" 10 #include "net/quic/crypto/null_encrypter.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 QuicStreamFrame frame1_; 345 QuicStreamFrame frame1_;
346 QuicStreamFrame frame2_; 346 QuicStreamFrame frame2_;
347 bool accept_packet_; 347 bool accept_packet_;
348 348
349 private: 349 private:
350 DISALLOW_COPY_AND_ASSIGN(QuicConnectionTest); 350 DISALLOW_COPY_AND_ASSIGN(QuicConnectionTest);
351 }; 351 };
352 352
353 TEST_F(QuicConnectionTest, PacketsInOrder) { 353 TEST_F(QuicConnectionTest, PacketsInOrder) {
354 ProcessPacket(1); 354 ProcessPacket(1);
355 EXPECT_EQ(1u, last_ack()->received_info.largest_received); 355 EXPECT_EQ(1u, last_ack()->received_info.largest_observed);
356 EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size()); 356 EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size());
357 357
358 ProcessPacket(2); 358 ProcessPacket(2);
359 EXPECT_EQ(2u, last_ack()->received_info.largest_received); 359 EXPECT_EQ(2u, last_ack()->received_info.largest_observed);
360 EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size()); 360 EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size());
361 361
362 ProcessPacket(3); 362 ProcessPacket(3);
363 EXPECT_EQ(3u, last_ack()->received_info.largest_received); 363 EXPECT_EQ(3u, last_ack()->received_info.largest_observed);
364 EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size()); 364 EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size());
365 } 365 }
366 366
367 TEST_F(QuicConnectionTest, PacketsRejected) { 367 TEST_F(QuicConnectionTest, PacketsRejected) {
368 ProcessPacket(1); 368 ProcessPacket(1);
369 EXPECT_EQ(1u, last_ack()->received_info.largest_received); 369 EXPECT_EQ(1u, last_ack()->received_info.largest_observed);
370 EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size()); 370 EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size());
371 371
372 accept_packet_ = false; 372 accept_packet_ = false;
373 ProcessPacket(2); 373 ProcessPacket(2);
374 // We should not have an ack for two. 374 // We should not have an ack for two.
375 EXPECT_EQ(1u, last_ack()->received_info.largest_received); 375 EXPECT_EQ(1u, last_ack()->received_info.largest_observed);
376 EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size()); 376 EXPECT_EQ(0u, last_ack()->received_info.missing_packets.size());
377 } 377 }
378 378
379 TEST_F(QuicConnectionTest, PacketsOutOfOrder) { 379 TEST_F(QuicConnectionTest, PacketsOutOfOrder) {
380 ProcessPacket(3); 380 ProcessPacket(3);
381 EXPECT_EQ(3u, last_ack()->received_info.largest_received); 381 EXPECT_EQ(3u, last_ack()->received_info.largest_observed);
382 EXPECT_TRUE(IsMissing(2)); 382 EXPECT_TRUE(IsMissing(2));
383 EXPECT_TRUE(IsMissing(1)); 383 EXPECT_TRUE(IsMissing(1));
384 384
385 ProcessPacket(2); 385 ProcessPacket(2);
386 EXPECT_EQ(3u, last_ack()->received_info.largest_received); 386 EXPECT_EQ(3u, last_ack()->received_info.largest_observed);
387 EXPECT_FALSE(IsMissing(2)); 387 EXPECT_FALSE(IsMissing(2));
388 EXPECT_TRUE(IsMissing(1)); 388 EXPECT_TRUE(IsMissing(1));
389 389
390 ProcessPacket(1); 390 ProcessPacket(1);
391 EXPECT_EQ(3u, last_ack()->received_info.largest_received); 391 EXPECT_EQ(3u, last_ack()->received_info.largest_observed);
392 EXPECT_FALSE(IsMissing(2)); 392 EXPECT_FALSE(IsMissing(2));
393 EXPECT_FALSE(IsMissing(1)); 393 EXPECT_FALSE(IsMissing(1));
394 } 394 }
395 395
396 TEST_F(QuicConnectionTest, DuplicatePacket) { 396 TEST_F(QuicConnectionTest, DuplicatePacket) {
397 ProcessPacket(3); 397 ProcessPacket(3);
398 EXPECT_EQ(3u, last_ack()->received_info.largest_received); 398 EXPECT_EQ(3u, last_ack()->received_info.largest_observed);
399 EXPECT_TRUE(IsMissing(2)); 399 EXPECT_TRUE(IsMissing(2));
400 EXPECT_TRUE(IsMissing(1)); 400 EXPECT_TRUE(IsMissing(1));
401 401
402 // Send packet 3 again, but do not set the expectation that 402 // Send packet 3 again, but do not set the expectation that
403 // the visitor OnPacket() will be called. 403 // the visitor OnPacket() will be called.
404 ProcessDataPacket(3, 0); 404 ProcessDataPacket(3, 0);
405 EXPECT_EQ(3u, last_ack()->received_info.largest_received); 405 EXPECT_EQ(3u, last_ack()->received_info.largest_observed);
406 EXPECT_TRUE(IsMissing(2)); 406 EXPECT_TRUE(IsMissing(2));
407 EXPECT_TRUE(IsMissing(1)); 407 EXPECT_TRUE(IsMissing(1));
408 } 408 }
409 409
410 TEST_F(QuicConnectionTest, PacketsOutOfOrderWithAdditionsAndLeastAwaiting) { 410 TEST_F(QuicConnectionTest, PacketsOutOfOrderWithAdditionsAndLeastAwaiting) {
411 ProcessPacket(3); 411 ProcessPacket(3);
412 EXPECT_EQ(3u, last_ack()->received_info.largest_received); 412 EXPECT_EQ(3u, last_ack()->received_info.largest_observed);
413 EXPECT_TRUE(IsMissing(2)); 413 EXPECT_TRUE(IsMissing(2));
414 EXPECT_TRUE(IsMissing(1)); 414 EXPECT_TRUE(IsMissing(1));
415 415
416 ProcessPacket(2); 416 ProcessPacket(2);
417 EXPECT_EQ(3u, last_ack()->received_info.largest_received); 417 EXPECT_EQ(3u, last_ack()->received_info.largest_observed);
418 EXPECT_TRUE(IsMissing(1)); 418 EXPECT_TRUE(IsMissing(1));
419 419
420 ProcessPacket(5); 420 ProcessPacket(5);
421 EXPECT_EQ(5u, last_ack()->received_info.largest_received); 421 EXPECT_EQ(5u, last_ack()->received_info.largest_observed);
422 EXPECT_TRUE(IsMissing(1)); 422 EXPECT_TRUE(IsMissing(1));
423 EXPECT_TRUE(IsMissing(4)); 423 EXPECT_TRUE(IsMissing(4));
424 424
425 // Pretend at this point the client has gotten acks for 2 and 3 and 1 is a 425 // Pretend at this point the client has gotten acks for 2 and 3 and 1 is a
426 // packet the peer will not retransmit. It indicates this by sending 'least 426 // packet the peer will not retransmit. It indicates this by sending 'least
427 // awaiting' is 4. The connection should then realize 1 will not be 427 // awaiting' is 4. The connection should then realize 1 will not be
428 // retransmitted, and will remove it from the missing list. 428 // retransmitted, and will remove it from the missing list.
429 creator_.set_sequence_number(5); 429 creator_.set_sequence_number(5);
430 QuicAckFrame frame(0, 4); 430 QuicAckFrame frame(0, 4);
431 ProcessAckPacket(&frame); 431 ProcessAckPacket(&frame);
432 432
433 // Force an ack to be sent. 433 // Force an ack to be sent.
434 SendAckPacketToPeer(); 434 SendAckPacketToPeer();
435 EXPECT_TRUE(IsMissing(4)); 435 EXPECT_TRUE(IsMissing(4));
436 } 436 }
437 437
438 TEST_F(QuicConnectionTest, RejectPacketTooFarOut) { 438 TEST_F(QuicConnectionTest, RejectPacketTooFarOut) {
439 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a 439 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a
440 // packet call to the visitor. 440 // packet call to the visitor.
441 ProcessDataPacket(6000, 0); 441 ProcessDataPacket(6000, 0);
442 442
443 SendAckPacketToPeer(); // Packet 2 443 SendAckPacketToPeer(); // Packet 2
444 EXPECT_EQ(0u, last_ack()->received_info.largest_received); 444 EXPECT_EQ(0u, last_ack()->received_info.largest_observed);
445 } 445 }
446 446
447 TEST_F(QuicConnectionTest, TruncatedAck) { 447 TEST_F(QuicConnectionTest, TruncatedAck) {
448 EXPECT_CALL(visitor_, OnAck(_)).Times(testing::AnyNumber()); 448 EXPECT_CALL(visitor_, OnAck(_)).Times(testing::AnyNumber());
449 for (int i = 0; i < 200; ++i) { 449 for (int i = 0; i < 200; ++i) {
450 SendStreamDataToPeer(1, "foo", i * 3, false, NULL); 450 SendStreamDataToPeer(1, "foo", i * 3, false, NULL);
451 } 451 }
452 452
453 QuicAckFrame frame(0, 1); 453 QuicAckFrame frame(0, 1);
454 frame.received_info.RecordReceived(193); 454 frame.received_info.RecordReceived(193);
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 1040
1041 // Queue the first packet. 1041 // Queue the first packet.
1042 EXPECT_CALL(*scheduler_, SentPacket(_, _, _)).Times(17); 1042 EXPECT_CALL(*scheduler_, SentPacket(_, _, _)).Times(17);
1043 EXPECT_EQ(17u, connection_.SendStreamData( 1043 EXPECT_EQ(17u, connection_.SendStreamData(
1044 1, "EnoughDataToQueue", 0, false, NULL).bytes_consumed); 1044 1, "EnoughDataToQueue", 0, false, NULL).bytes_consumed);
1045 } 1045 }
1046 1046
1047 } // namespace 1047 } // namespace
1048 } // namespace test 1048 } // namespace test
1049 } // namespace net 1049 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_framer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698