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

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

Issue 288313003: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: implemented rch's comments Created 6 years, 7 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
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_packet_generator.h" 5 #include "net/quic/quic_packet_generator.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "net/quic/crypto/crypto_protocol.h" 9 #include "net/quic/crypto/crypto_protocol.h"
10 #include "net/quic/crypto/null_encrypter.h" 10 #include "net/quic/crypto/null_encrypter.h"
11 #include "net/quic/crypto/quic_decrypter.h" 11 #include "net/quic/crypto/quic_decrypter.h"
12 #include "net/quic/crypto/quic_encrypter.h" 12 #include "net/quic/crypto/quic_encrypter.h"
13 #include "net/quic/quic_utils.h" 13 #include "net/quic/quic_utils.h"
14 #include "net/quic/test_tools/quic_packet_creator_peer.h"
14 #include "net/quic/test_tools/quic_test_utils.h" 15 #include "net/quic/test_tools/quic_test_utils.h"
15 #include "net/quic/test_tools/simple_quic_framer.h" 16 #include "net/quic/test_tools/simple_quic_framer.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 using base::StringPiece; 20 using base::StringPiece;
20 using std::string; 21 using std::string;
21 using testing::InSequence; 22 using testing::InSequence;
22 using testing::Return; 23 using testing::Return;
23 using testing::SaveArg; 24 using testing::SaveArg;
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 433
433 PacketContents contents; 434 PacketContents contents;
434 contents.num_stream_frames = 2; 435 contents.num_stream_frames = 2;
435 CheckPacketContains(contents, packet_); 436 CheckPacketContains(contents, packet_);
436 } 437 }
437 438
438 TEST_F(QuicPacketGeneratorTest, ConsumeDataFEC) { 439 TEST_F(QuicPacketGeneratorTest, ConsumeDataFEC) {
439 delegate_.SetCanWriteAnything(); 440 delegate_.SetCanWriteAnything();
440 441
441 // Send FEC every two packets. 442 // Send FEC every two packets.
442 creator_.options()->max_packets_per_fec_group = 2; 443 EXPECT_TRUE(QuicPacketCreatorPeer::SwitchFecProtectionOn(&creator_, 2));
443 444
444 { 445 {
445 InSequence dummy; 446 InSequence dummy;
446 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce( 447 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce(
447 DoAll(SaveArg<0>(&packet_), Return(true))); 448 DoAll(SaveArg<0>(&packet_), Return(true)));
448 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce( 449 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce(
449 DoAll(SaveArg<0>(&packet2_), Return(true))); 450 DoAll(SaveArg<0>(&packet2_), Return(true)));
450 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce( 451 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce(
451 DoAll(SaveArg<0>(&packet3_), Return(true))); 452 DoAll(SaveArg<0>(&packet3_), Return(true)));
452 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce( 453 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce(
(...skipping 15 matching lines...) Expand all
468 CheckPacketIsFec(packet3_, 1); 469 CheckPacketIsFec(packet3_, 1);
469 470
470 CheckPacketHasSingleStreamFrame(packet4_); 471 CheckPacketHasSingleStreamFrame(packet4_);
471 CheckPacketIsFec(packet5_, 4); 472 CheckPacketIsFec(packet5_, 4);
472 } 473 }
473 474
474 TEST_F(QuicPacketGeneratorTest, ConsumeDataSendsFecAtEnd) { 475 TEST_F(QuicPacketGeneratorTest, ConsumeDataSendsFecAtEnd) {
475 delegate_.SetCanWriteAnything(); 476 delegate_.SetCanWriteAnything();
476 477
477 // Send FEC every six packets. 478 // Send FEC every six packets.
478 creator_.options()->max_packets_per_fec_group = 6; 479 EXPECT_TRUE(QuicPacketCreatorPeer::SwitchFecProtectionOn(&creator_, 6));
479
480 { 480 {
481 InSequence dummy; 481 InSequence dummy;
482 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce( 482 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce(
483 DoAll(SaveArg<0>(&packet_), Return(true))); 483 DoAll(SaveArg<0>(&packet_), Return(true)));
484 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce( 484 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce(
485 DoAll(SaveArg<0>(&packet2_), Return(true))); 485 DoAll(SaveArg<0>(&packet2_), Return(true)));
486 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce( 486 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce(
487 DoAll(SaveArg<0>(&packet3_), Return(true))); 487 DoAll(SaveArg<0>(&packet3_), Return(true)));
488 } 488 }
489 489
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 629
630 // The second should have the remainder of the stream data. 630 // The second should have the remainder of the stream data.
631 PacketContents contents2; 631 PacketContents contents2;
632 contents2.num_goaway_frames = 1; 632 contents2.num_goaway_frames = 1;
633 contents2.num_stream_frames = 1; 633 contents2.num_stream_frames = 1;
634 CheckPacketContains(contents2, packet2_); 634 CheckPacketContains(contents2, packet2_);
635 } 635 }
636 636
637 } // namespace test 637 } // namespace test
638 } // namespace net 638 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698