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

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

Issue 312553003: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_packet_generator.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 SerializedPacket packet_; 224 SerializedPacket packet_;
225 SerializedPacket packet2_; 225 SerializedPacket packet2_;
226 SerializedPacket packet3_; 226 SerializedPacket packet3_;
227 SerializedPacket packet4_; 227 SerializedPacket packet4_;
228 SerializedPacket packet5_; 228 SerializedPacket packet5_;
229 229
230 private: 230 private:
231 scoped_ptr<char[]> data_array_; 231 scoped_ptr<char[]> data_array_;
232 }; 232 };
233 233
234 class MockDebugDelegate : public QuicPacketGenerator::DebugDelegateInterface { 234 class MockDebugDelegate : public QuicPacketGenerator::DebugDelegate {
235 public: 235 public:
236 MOCK_METHOD1(OnFrameAddedToPacket, 236 MOCK_METHOD1(OnFrameAddedToPacket,
237 void(const QuicFrame&)); 237 void(const QuicFrame&));
238 }; 238 };
239 239
240 TEST_F(QuicPacketGeneratorTest, ShouldSendAck_NotWritable) { 240 TEST_F(QuicPacketGeneratorTest, ShouldSendAck_NotWritable) {
241 delegate_.SetCanNotWrite(); 241 delegate_.SetCanNotWrite();
242 242
243 generator_.SetShouldSendAck(false, false); 243 generator_.SetShouldSendAck(false, false);
244 EXPECT_TRUE(generator_.HasQueuedFrames()); 244 EXPECT_TRUE(generator_.HasQueuedFrames());
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 EXPECT_FALSE(generator_.HasQueuedFrames()); 496 EXPECT_FALSE(generator_.HasQueuedFrames());
497 497
498 CheckPacketHasSingleStreamFrame(packet_); 498 CheckPacketHasSingleStreamFrame(packet_);
499 CheckPacketHasSingleStreamFrame(packet2_); 499 CheckPacketHasSingleStreamFrame(packet2_);
500 CheckPacketIsFec(packet3_, 1); 500 CheckPacketIsFec(packet3_, 1);
501 } 501 }
502 502
503 TEST_F(QuicPacketGeneratorTest, ConsumeData_FramesPreviouslyQueued) { 503 TEST_F(QuicPacketGeneratorTest, ConsumeData_FramesPreviouslyQueued) {
504 // Set the packet size be enough for two stream frames with 0 stream offset, 504 // Set the packet size be enough for two stream frames with 0 stream offset,
505 // but not enough for a stream frame of 0 offset and one with non-zero offset. 505 // but not enough for a stream frame of 0 offset and one with non-zero offset.
506 creator_.options()->max_packet_length = 506 size_t length =
507 NullEncrypter().GetCiphertextSize(0) + 507 NullEncrypter().GetCiphertextSize(0) +
508 GetPacketHeaderSize(creator_.options()->send_connection_id_length, 508 GetPacketHeaderSize(creator_.connection_id_length(),
509 true, 509 true,
510 creator_.options()->send_sequence_number_length, 510 creator_.next_sequence_number_length(),
511 NOT_IN_FEC_GROUP) + 511 NOT_IN_FEC_GROUP) +
512 // Add an extra 3 bytes for the payload and 1 byte so BytesFree is larger 512 // Add an extra 3 bytes for the payload and 1 byte so BytesFree is larger
513 // than the GetMinStreamFrameSize. 513 // than the GetMinStreamFrameSize.
514 QuicFramer::GetMinStreamFrameSize(framer_.version(), 1, 0, false, 514 QuicFramer::GetMinStreamFrameSize(framer_.version(), 1, 0, false,
515 NOT_IN_FEC_GROUP) + 3 + 515 NOT_IN_FEC_GROUP) + 3 +
516 QuicFramer::GetMinStreamFrameSize(framer_.version(), 1, 0, true, 516 QuicFramer::GetMinStreamFrameSize(framer_.version(), 1, 0, true,
517 NOT_IN_FEC_GROUP) + 1; 517 NOT_IN_FEC_GROUP) + 1;
518 creator_.set_max_packet_length(length);
518 delegate_.SetCanWriteAnything(); 519 delegate_.SetCanWriteAnything();
519 { 520 {
520 InSequence dummy; 521 InSequence dummy;
521 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce( 522 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce(
522 DoAll(SaveArg<0>(&packet_), Return(true))); 523 DoAll(SaveArg<0>(&packet_), Return(true)));
523 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce( 524 EXPECT_CALL(delegate_, OnSerializedPacket(_)).WillOnce(
524 DoAll(SaveArg<0>(&packet2_), Return(true))); 525 DoAll(SaveArg<0>(&packet2_), Return(true)));
525 } 526 }
526 generator_.StartBatchOperations(); 527 generator_.StartBatchOperations();
527 // Queue enough data to prevent a stream frame with a non-zero offset from 528 // Queue enough data to prevent a stream frame with a non-zero offset from
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 630
630 // The second should have the remainder of the stream data. 631 // The second should have the remainder of the stream data.
631 PacketContents contents2; 632 PacketContents contents2;
632 contents2.num_goaway_frames = 1; 633 contents2.num_goaway_frames = 1;
633 contents2.num_stream_frames = 1; 634 contents2.num_stream_frames = 1;
634 CheckPacketContains(contents2, packet2_); 635 CheckPacketContains(contents2, packet2_);
635 } 636 }
636 637
637 } // namespace test 638 } // namespace test
638 } // namespace net 639 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_packet_generator.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698