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

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

Issue 15937012: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small bug fixes Created 7 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
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_creator.h" 5 #include "net/quic/quic_packet_creator.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "net/quic/crypto/null_encrypter.h" 8 #include "net/quic/crypto/null_encrypter.h"
9 #include "net/quic/crypto/quic_decrypter.h" 9 #include "net/quic/crypto/quic_decrypter.h"
10 #include "net/quic/crypto/quic_encrypter.h" 10 #include "net/quic/crypto/quic_encrypter.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 EXPECT_EQ(GetParam(), header.public_header.version_flag); 218 EXPECT_EQ(GetParam(), header.public_header.version_flag);
219 delete serialized.packet; 219 delete serialized.packet;
220 } 220 }
221 221
222 TEST_P(QuicPacketCreatorTest, CreateStreamFrameTooLarge) { 222 TEST_P(QuicPacketCreatorTest, CreateStreamFrameTooLarge) {
223 if (!GetParam()) { 223 if (!GetParam()) {
224 creator_.StopSendingVersion(); 224 creator_.StopSendingVersion();
225 } 225 }
226 // A string larger than fits into a frame. 226 // A string larger than fits into a frame.
227 creator_.options()->max_packet_length = GetPacketLengthForOneStream( 227 creator_.options()->max_packet_length = GetPacketLengthForOneStream(
228 QuicPacketCreatorPeer::SendVersionInPacket(&creator_), 4); 228 QuicPacketCreatorPeer::SendVersionInPacket(&creator_),
229 NOT_IN_FEC_GROUP, 4);
229 QuicFrame frame; 230 QuicFrame frame;
230 size_t consumed = creator_.CreateStreamFrame(1u, "testTooLong", 0u, true, 231 size_t consumed = creator_.CreateStreamFrame(1u, "testTooLong", 0u, true,
231 &frame); 232 &frame);
232 EXPECT_EQ(4u, consumed); 233 EXPECT_EQ(4u, consumed);
233 CheckStreamFrame(frame, 1u, "test", 0u, false); 234 CheckStreamFrame(frame, 1u, "test", 0u, false);
234 delete frame.stream_frame; 235 delete frame.stream_frame;
235 } 236 }
236 237
237 TEST_P(QuicPacketCreatorTest, AddFrameAndSerialize) { 238 TEST_P(QuicPacketCreatorTest, AddFrameAndSerialize) {
238 if (!GetParam()) { 239 if (!GetParam()) {
239 creator_.StopSendingVersion(); 240 creator_.StopSendingVersion();
240 } 241 }
241 const size_t max_plaintext_size = 242 const size_t max_plaintext_size =
242 client_framer_.GetMaxPlaintextSize(creator_.options()->max_packet_length); 243 client_framer_.GetMaxPlaintextSize(creator_.options()->max_packet_length);
243 EXPECT_FALSE(creator_.HasPendingFrames()); 244 EXPECT_FALSE(creator_.HasPendingFrames());
244 EXPECT_EQ(max_plaintext_size - 245 EXPECT_EQ(max_plaintext_size -
245 GetPacketHeaderSize( 246 GetPacketHeaderSize(
246 QuicPacketCreatorPeer::SendVersionInPacket(&creator_)), 247 creator_.options()->send_guid_length,
248 QuicPacketCreatorPeer::SendVersionInPacket(&creator_),
249 NOT_IN_FEC_GROUP),
247 creator_.BytesFree()); 250 creator_.BytesFree());
248 251
249 // Add a variety of frame types and then a padding frame. 252 // Add a variety of frame types and then a padding frame.
250 QuicAckFrame ack_frame; 253 QuicAckFrame ack_frame;
251 EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(&ack_frame))); 254 EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(&ack_frame)));
252 EXPECT_TRUE(creator_.HasPendingFrames()); 255 EXPECT_TRUE(creator_.HasPendingFrames());
253 256
254 QuicCongestionFeedbackFrame congestion_feedback; 257 QuicCongestionFeedbackFrame congestion_feedback;
255 congestion_feedback.type = kFixRate; 258 congestion_feedback.type = kFixRate;
256 EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(&congestion_feedback))); 259 EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(&congestion_feedback)));
(...skipping 20 matching lines...) Expand all
277 ASSERT_TRUE(serialized.retransmittable_frames); 280 ASSERT_TRUE(serialized.retransmittable_frames);
278 RetransmittableFrames* retransmittable = serialized.retransmittable_frames; 281 RetransmittableFrames* retransmittable = serialized.retransmittable_frames;
279 ASSERT_EQ(1u, retransmittable->frames().size()); 282 ASSERT_EQ(1u, retransmittable->frames().size());
280 EXPECT_EQ(STREAM_FRAME, retransmittable->frames()[0].type); 283 EXPECT_EQ(STREAM_FRAME, retransmittable->frames()[0].type);
281 ASSERT_TRUE(retransmittable->frames()[0].stream_frame); 284 ASSERT_TRUE(retransmittable->frames()[0].stream_frame);
282 delete serialized.retransmittable_frames; 285 delete serialized.retransmittable_frames;
283 286
284 EXPECT_FALSE(creator_.HasPendingFrames()); 287 EXPECT_FALSE(creator_.HasPendingFrames());
285 EXPECT_EQ(max_plaintext_size - 288 EXPECT_EQ(max_plaintext_size -
286 GetPacketHeaderSize( 289 GetPacketHeaderSize(
287 QuicPacketCreatorPeer::SendVersionInPacket(&creator_)), 290 creator_.options()->send_guid_length,
291 QuicPacketCreatorPeer::SendVersionInPacket(&creator_),
292 NOT_IN_FEC_GROUP),
288 creator_.BytesFree()); 293 creator_.BytesFree());
289 } 294 }
290 295
291 } // namespace 296 } // namespace
292 } // namespace test 297 } // namespace test
293 } // namespace net 298 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698