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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 // Queue enough data to prevent a stream frame with a non-zero offset from | 709 // Queue enough data to prevent a stream frame with a non-zero offset from |
710 // fitting. | 710 // fitting. |
711 QuicConsumedData consumed = | 711 QuicConsumedData consumed = |
712 generator_.ConsumeData(kHeadersStreamId, MakeIOVector("foo"), 0, false, | 712 generator_.ConsumeData(kHeadersStreamId, MakeIOVector("foo"), 0, false, |
713 MAY_FEC_PROTECT, nullptr); | 713 MAY_FEC_PROTECT, nullptr); |
714 EXPECT_EQ(3u, consumed.bytes_consumed); | 714 EXPECT_EQ(3u, consumed.bytes_consumed); |
715 EXPECT_FALSE(consumed.fin_consumed); | 715 EXPECT_FALSE(consumed.fin_consumed); |
716 EXPECT_TRUE(generator_.HasQueuedFrames()); | 716 EXPECT_TRUE(generator_.HasQueuedFrames()); |
717 | 717 |
718 // This frame will not fit with the existing frame, causing the queued frame | 718 // This frame will not fit with the existing frame, causing the queued frame |
719 // to be serialized, and it will not fit with another frame like it, so it is | 719 // to be serialized, and it will be added to a new open packet. |
720 // serialized by itself. | |
721 consumed = generator_.ConsumeData(kHeadersStreamId, MakeIOVector("bar"), 3, | 720 consumed = generator_.ConsumeData(kHeadersStreamId, MakeIOVector("bar"), 3, |
722 true, MAY_FEC_PROTECT, nullptr); | 721 true, MAY_FEC_PROTECT, nullptr); |
723 EXPECT_EQ(3u, consumed.bytes_consumed); | 722 EXPECT_EQ(3u, consumed.bytes_consumed); |
724 EXPECT_TRUE(consumed.fin_consumed); | 723 EXPECT_TRUE(consumed.fin_consumed); |
| 724 EXPECT_TRUE(generator_.HasQueuedFrames()); |
| 725 |
| 726 creator_->Flush(); |
725 EXPECT_FALSE(generator_.HasQueuedFrames()); | 727 EXPECT_FALSE(generator_.HasQueuedFrames()); |
726 | 728 |
727 PacketContents contents; | 729 PacketContents contents; |
728 contents.num_stream_frames = 1; | 730 contents.num_stream_frames = 1; |
729 CheckPacketContains(contents, 0); | 731 CheckPacketContains(contents, 0); |
730 CheckPacketContains(contents, 1); | 732 CheckPacketContains(contents, 1); |
731 } | 733 } |
732 | 734 |
733 TEST_P(QuicPacketGeneratorTest, NoFecPacketSentWhenBatchEnds) { | 735 TEST_P(QuicPacketGeneratorTest, NoFecPacketSentWhenBatchEnds) { |
734 delegate_.SetCanWriteAnything(); | 736 delegate_.SetCanWriteAnything(); |
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 // This will not serialize any packets, because of the invalid frame. | 1675 // This will not serialize any packets, because of the invalid frame. |
1674 EXPECT_CALL(delegate_, | 1676 EXPECT_CALL(delegate_, |
1675 CloseConnection(QUIC_FAILED_TO_SERIALIZE_PACKET, false)); | 1677 CloseConnection(QUIC_FAILED_TO_SERIALIZE_PACKET, false)); |
1676 EXPECT_DFATAL(generator_.FinishBatchOperations(), | 1678 EXPECT_DFATAL(generator_.FinishBatchOperations(), |
1677 "packet_number_length 1 is too small " | 1679 "packet_number_length 1 is too small " |
1678 "for least_unacked_delta: 1001"); | 1680 "for least_unacked_delta: 1001"); |
1679 } | 1681 } |
1680 | 1682 |
1681 } // namespace test | 1683 } // namespace test |
1682 } // namespace net | 1684 } // namespace net |
OLD | NEW |