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 "base/macros.h" | 9 #include "base/macros.h" |
10 #include "net/quic/crypto/crypto_protocol.h" | 10 #include "net/quic/crypto/crypto_protocol.h" |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 CheckPacketContains(contents, 0); | 438 CheckPacketContains(contents, 0); |
439 } | 439 } |
440 | 440 |
441 TEST_F(QuicPacketGeneratorTest, ConsumeData_FramesPreviouslyQueued) { | 441 TEST_F(QuicPacketGeneratorTest, ConsumeData_FramesPreviouslyQueued) { |
442 // Set the packet size be enough for two stream frames with 0 stream offset, | 442 // Set the packet size be enough for two stream frames with 0 stream offset, |
443 // but not enough for a stream frame of 0 offset and one with non-zero offset. | 443 // but not enough for a stream frame of 0 offset and one with non-zero offset. |
444 size_t length = | 444 size_t length = |
445 NullEncrypter().GetCiphertextSize(0) + | 445 NullEncrypter().GetCiphertextSize(0) + |
446 GetPacketHeaderSize( | 446 GetPacketHeaderSize( |
447 creator_->connection_id_length(), kIncludeVersion, !kIncludePathId, | 447 creator_->connection_id_length(), kIncludeVersion, !kIncludePathId, |
448 QuicPacketCreatorPeer::NextPacketNumberLength(creator_), | 448 QuicPacketCreatorPeer::NextPacketNumberLength(creator_)) + |
449 NOT_IN_FEC_GROUP) + | |
450 // Add an extra 3 bytes for the payload and 1 byte so BytesFree is larger | 449 // Add an extra 3 bytes for the payload and 1 byte so BytesFree is larger |
451 // than the GetMinStreamFrameSize. | 450 // than the GetMinStreamFrameSize. |
452 QuicFramer::GetMinStreamFrameSize(1, 0, false, NOT_IN_FEC_GROUP) + 3 + | 451 QuicFramer::GetMinStreamFrameSize(1, 0, false) + 3 + |
453 QuicFramer::GetMinStreamFrameSize(1, 0, true, NOT_IN_FEC_GROUP) + 1; | 452 QuicFramer::GetMinStreamFrameSize(1, 0, true) + 1; |
454 generator_.SetMaxPacketLength(length, /*force=*/false); | 453 generator_.SetMaxPacketLength(length, /*force=*/false); |
455 delegate_.SetCanWriteAnything(); | 454 delegate_.SetCanWriteAnything(); |
456 { | 455 { |
457 InSequence dummy; | 456 InSequence dummy; |
458 EXPECT_CALL(delegate_, OnSerializedPacket(_)) | 457 EXPECT_CALL(delegate_, OnSerializedPacket(_)) |
459 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket)); | 458 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket)); |
460 EXPECT_CALL(delegate_, OnSerializedPacket(_)) | 459 EXPECT_CALL(delegate_, OnSerializedPacket(_)) |
461 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket)); | 460 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket)); |
462 } | 461 } |
463 generator_.StartBatchOperations(); | 462 generator_.StartBatchOperations(); |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 EXPECT_CALL(delegate_, OnSerializedPacket(_)) | 910 EXPECT_CALL(delegate_, OnSerializedPacket(_)) |
912 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket)); | 911 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket)); |
913 generator_.FlushAllQueuedFrames(); | 912 generator_.FlushAllQueuedFrames(); |
914 EXPECT_FALSE(generator_.HasQueuedFrames()); | 913 EXPECT_FALSE(generator_.HasQueuedFrames()); |
915 generator_.SetCurrentPath(kTestPathId1, 1, 0); | 914 generator_.SetCurrentPath(kTestPathId1, 1, 0); |
916 EXPECT_EQ(kTestPathId1, QuicPacketCreatorPeer::GetCurrentPath(creator_)); | 915 EXPECT_EQ(kTestPathId1, QuicPacketCreatorPeer::GetCurrentPath(creator_)); |
917 } | 916 } |
918 | 917 |
919 } // namespace test | 918 } // namespace test |
920 } // namespace net | 919 } // namespace net |
OLD | NEW |