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

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

Issue 1459343009: Make QuicPacketCreator be able to serialize packet itself when it does not have room for next strea… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@107733506
Patch Set: Created 5 years, 1 month 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"
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698