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_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" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 size_t num_stream_frames; | 93 size_t num_stream_frames; |
94 | 94 |
95 QuicFecGroupNumber fec_group; | 95 QuicFecGroupNumber fec_group; |
96 }; | 96 }; |
97 | 97 |
98 } // namespace | 98 } // namespace |
99 | 99 |
100 class QuicPacketGeneratorTest : public ::testing::Test { | 100 class QuicPacketGeneratorTest : public ::testing::Test { |
101 protected: | 101 protected: |
102 QuicPacketGeneratorTest() | 102 QuicPacketGeneratorTest() |
103 : framer_(QuicVersionMax(), QuicTime::Zero(), false), | 103 : framer_(QuicSupportedVersions(), QuicTime::Zero(), false), |
104 creator_(42, &framer_, &random_, false), | 104 creator_(42, &framer_, &random_, false), |
105 generator_(&delegate_, NULL, &creator_), | 105 generator_(&delegate_, NULL, &creator_), |
106 packet_(0, PACKET_1BYTE_SEQUENCE_NUMBER, NULL, 0, NULL), | 106 packet_(0, PACKET_1BYTE_SEQUENCE_NUMBER, NULL, 0, NULL), |
107 packet2_(0, PACKET_1BYTE_SEQUENCE_NUMBER, NULL, 0, NULL), | 107 packet2_(0, PACKET_1BYTE_SEQUENCE_NUMBER, NULL, 0, NULL), |
108 packet3_(0, PACKET_1BYTE_SEQUENCE_NUMBER, NULL, 0, NULL), | 108 packet3_(0, PACKET_1BYTE_SEQUENCE_NUMBER, NULL, 0, NULL), |
109 packet4_(0, PACKET_1BYTE_SEQUENCE_NUMBER, NULL, 0, NULL), | 109 packet4_(0, PACKET_1BYTE_SEQUENCE_NUMBER, NULL, 0, NULL), |
110 packet5_(0, PACKET_1BYTE_SEQUENCE_NUMBER, NULL, 0, NULL) { | 110 packet5_(0, PACKET_1BYTE_SEQUENCE_NUMBER, NULL, 0, NULL) { |
111 } | 111 } |
112 | 112 |
113 ~QuicPacketGeneratorTest() { | 113 ~QuicPacketGeneratorTest() { |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 EXPECT_FALSE(generator_.HasQueuedFrames()); | 474 EXPECT_FALSE(generator_.HasQueuedFrames()); |
475 | 475 |
476 CheckPacketHasSingleStreamFrame(packet_); | 476 CheckPacketHasSingleStreamFrame(packet_); |
477 CheckPacketHasSingleStreamFrame(packet2_); | 477 CheckPacketHasSingleStreamFrame(packet2_); |
478 CheckPacketIsFec(packet3_, 1); | 478 CheckPacketIsFec(packet3_, 1); |
479 } | 479 } |
480 | 480 |
481 TEST_F(QuicPacketGeneratorTest, ConsumeData_FramesPreviouslyQueued) { | 481 TEST_F(QuicPacketGeneratorTest, ConsumeData_FramesPreviouslyQueued) { |
482 // Set the packet size be enough for two stream frames with 0 stream offset, | 482 // Set the packet size be enough for two stream frames with 0 stream offset, |
483 // but not enough for a stream frame of 0 offset and one with non-zero offset. | 483 // but not enough for a stream frame of 0 offset and one with non-zero offset. |
484 bool use_short_hash = framer_.version() >= QUIC_VERSION_11; | |
485 creator_.options()->max_packet_length = | 484 creator_.options()->max_packet_length = |
486 NullEncrypter(use_short_hash).GetCiphertextSize(0) + | 485 NullEncrypter(false).GetCiphertextSize(0) + |
487 GetPacketHeaderSize(creator_.options()->send_guid_length, | 486 GetPacketHeaderSize(creator_.options()->send_guid_length, |
488 true, | 487 true, |
489 creator_.options()->send_sequence_number_length, | 488 creator_.options()->send_sequence_number_length, |
490 NOT_IN_FEC_GROUP) + | 489 NOT_IN_FEC_GROUP) + |
491 // Add an extra 3 bytes for the payload and 1 byte so BytesFree is larger | 490 // Add an extra 3 bytes for the payload and 1 byte so BytesFree is larger |
492 // than the GetMinStreamFrameSize. | 491 // than the GetMinStreamFrameSize. |
493 QuicFramer::GetMinStreamFrameSize(framer_.version(), 1, 0, false) + 3 + | 492 QuicFramer::GetMinStreamFrameSize(framer_.version(), 1, 0, false) + 3 + |
494 QuicFramer::GetMinStreamFrameSize(framer_.version(), 1, 0, true) + 1; | 493 QuicFramer::GetMinStreamFrameSize(framer_.version(), 1, 0, true) + 1; |
495 delegate_.SetCanWriteAnything(); | 494 delegate_.SetCanWriteAnything(); |
496 { | 495 { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 | 604 |
606 // The second should have the remainder of the stream data. | 605 // The second should have the remainder of the stream data. |
607 PacketContents contents2; | 606 PacketContents contents2; |
608 contents2.num_goaway_frames = 1; | 607 contents2.num_goaway_frames = 1; |
609 contents2.num_stream_frames = 1; | 608 contents2.num_stream_frames = 1; |
610 CheckPacketContains(contents2, packet2_); | 609 CheckPacketContains(contents2, packet2_); |
611 } | 610 } |
612 | 611 |
613 } // namespace test | 612 } // namespace test |
614 } // namespace net | 613 } // namespace net |
OLD | NEW |