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

Side by Side Diff: net/quic/quic_framer_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_framer.cc ('k') | net/quic/quic_packet_creator.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_framer.h" 5 #include "net/quic/quic_framer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 QuicPacketSequenceNumber wire_sequence_number = 487 QuicPacketSequenceNumber wire_sequence_number =
488 expected_sequence_number & kMask; 488 expected_sequence_number & kMask;
489 QuicFramerPeer::SetLastSequenceNumber(&framer_, last_sequence_number); 489 QuicFramerPeer::SetLastSequenceNumber(&framer_, last_sequence_number);
490 EXPECT_EQ(expected_sequence_number, 490 EXPECT_EQ(expected_sequence_number,
491 QuicFramerPeer::CalculatePacketSequenceNumberFromWire( 491 QuicFramerPeer::CalculatePacketSequenceNumberFromWire(
492 &framer_, PACKET_6BYTE_SEQUENCE_NUMBER, wire_sequence_number)) 492 &framer_, PACKET_6BYTE_SEQUENCE_NUMBER, wire_sequence_number))
493 << "last_sequence_number: " << last_sequence_number 493 << "last_sequence_number: " << last_sequence_number
494 << " wire_sequence_number: " << wire_sequence_number; 494 << " wire_sequence_number: " << wire_sequence_number;
495 } 495 }
496 496
497 QuicPacket* BuildDataPacket(const QuicPacketHeader& header,
498 const QuicFrames& frames) {
499 return BuildUnsizedDataPacket(&framer_, header, frames).packet;
500 }
501
497 test::TestEncrypter* encrypter_; 502 test::TestEncrypter* encrypter_;
498 test::TestDecrypter* decrypter_; 503 test::TestDecrypter* decrypter_;
499 QuicVersion version_; 504 QuicVersion version_;
500 QuicTime start_; 505 QuicTime start_;
501 QuicFramer framer_; 506 QuicFramer framer_;
502 test::TestQuicVisitor visitor_; 507 test::TestQuicVisitor visitor_;
503 test::TestEntropyCalculator entropy_calculator_; 508 test::TestEntropyCalculator entropy_calculator_;
504 }; 509 };
505 510
506 // Run all framer tests with all supported versions of QUIC. 511 // Run all framer tests with all supported versions of QUIC.
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after
2141 ASSERT_EQ(1u, visitor_.ack_frames_.size()); 2146 ASSERT_EQ(1u, visitor_.ack_frames_.size());
2142 QuicAckFrame* frame = visitor_.ack_frames_[0]; 2147 QuicAckFrame* frame = visitor_.ack_frames_[0];
2143 EXPECT_EQ(0xBA, frame->received_info.entropy_hash); 2148 EXPECT_EQ(0xBA, frame->received_info.entropy_hash);
2144 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), 2149 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF),
2145 frame->received_info.largest_observed); 2150 frame->received_info.largest_observed);
2146 ASSERT_EQ(0u, frame->received_info.missing_packets.size()); 2151 ASSERT_EQ(0u, frame->received_info.missing_packets.size());
2147 2152
2148 // Verify that the packet re-serializes identically. 2153 // Verify that the packet re-serializes identically.
2149 QuicFrames frames; 2154 QuicFrames frames;
2150 frames.push_back(QuicFrame(frame)); 2155 frames.push_back(QuicFrame(frame));
2151 scoped_ptr<QuicPacket> data( 2156 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames));
2152 framer_.BuildUnsizedDataPacket(*visitor_.header_, frames).packet);
2153 ASSERT_TRUE(data != NULL); 2157 ASSERT_TRUE(data != NULL);
2154 2158
2155 test::CompareCharArraysWithHexError("constructed packet", 2159 test::CompareCharArraysWithHexError("constructed packet",
2156 data->data(), data->length(), 2160 data->data(), data->length(),
2157 AsChars(packet), arraysize(packet)); 2161 AsChars(packet), arraysize(packet));
2158 } 2162 }
2159 2163
2160 TEST_P(QuicFramerTest, AckFrameNoNacks15) { 2164 TEST_P(QuicFramerTest, AckFrameNoNacks15) {
2161 if (framer_.version() > QUIC_VERSION_15) { 2165 if (framer_.version() > QUIC_VERSION_15) {
2162 return; 2166 return;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2203 EXPECT_EQ(0xAB, frame->sent_info.entropy_hash); 2207 EXPECT_EQ(0xAB, frame->sent_info.entropy_hash);
2204 EXPECT_EQ(0xBA, frame->received_info.entropy_hash); 2208 EXPECT_EQ(0xBA, frame->received_info.entropy_hash);
2205 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), 2209 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF),
2206 frame->received_info.largest_observed); 2210 frame->received_info.largest_observed);
2207 ASSERT_EQ(0u, frame->received_info.missing_packets.size()); 2211 ASSERT_EQ(0u, frame->received_info.missing_packets.size());
2208 EXPECT_EQ(GG_UINT64_C(0x0123456789AA0), frame->sent_info.least_unacked); 2212 EXPECT_EQ(GG_UINT64_C(0x0123456789AA0), frame->sent_info.least_unacked);
2209 2213
2210 // Verify that the packet re-serializes identically. 2214 // Verify that the packet re-serializes identically.
2211 QuicFrames frames; 2215 QuicFrames frames;
2212 frames.push_back(QuicFrame(frame)); 2216 frames.push_back(QuicFrame(frame));
2213 scoped_ptr<QuicPacket> data( 2217 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames));
2214 framer_.BuildUnsizedDataPacket(*visitor_.header_, frames).packet);
2215 ASSERT_TRUE(data != NULL); 2218 ASSERT_TRUE(data != NULL);
2216 2219
2217 test::CompareCharArraysWithHexError("constructed packet", 2220 test::CompareCharArraysWithHexError("constructed packet",
2218 data->data(), data->length(), 2221 data->data(), data->length(),
2219 AsChars(packet), arraysize(packet)); 2222 AsChars(packet), arraysize(packet));
2220 } 2223 }
2221 2224
2222 TEST_P(QuicFramerTest, AckFrame500Nacks) { 2225 TEST_P(QuicFramerTest, AckFrame500Nacks) {
2223 if (framer_.version() <= QUIC_VERSION_15) { 2226 if (framer_.version() <= QUIC_VERSION_15) {
2224 return; 2227 return;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 SequenceNumberSet::const_iterator first_missing_iter = 2281 SequenceNumberSet::const_iterator first_missing_iter =
2279 frame->received_info.missing_packets.begin(); 2282 frame->received_info.missing_packets.begin();
2280 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE) - 499, *first_missing_iter); 2283 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE) - 499, *first_missing_iter);
2281 SequenceNumberSet::const_reverse_iterator last_missing_iter = 2284 SequenceNumberSet::const_reverse_iterator last_missing_iter =
2282 frame->received_info.missing_packets.rbegin(); 2285 frame->received_info.missing_packets.rbegin();
2283 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *last_missing_iter); 2286 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *last_missing_iter);
2284 2287
2285 // Verify that the packet re-serializes identically. 2288 // Verify that the packet re-serializes identically.
2286 QuicFrames frames; 2289 QuicFrames frames;
2287 frames.push_back(QuicFrame(frame)); 2290 frames.push_back(QuicFrame(frame));
2288 scoped_ptr<QuicPacket> data( 2291 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames));
2289 framer_.BuildUnsizedDataPacket(*visitor_.header_, frames).packet);
2290 ASSERT_TRUE(data != NULL); 2292 ASSERT_TRUE(data != NULL);
2291 2293
2292 test::CompareCharArraysWithHexError("constructed packet", 2294 test::CompareCharArraysWithHexError("constructed packet",
2293 data->data(), data->length(), 2295 data->data(), data->length(),
2294 AsChars(packet), arraysize(packet)); 2296 AsChars(packet), arraysize(packet));
2295 } 2297 }
2296 2298
2297 TEST_P(QuicFramerTest, AckFrame500Nacks15) { 2299 TEST_P(QuicFramerTest, AckFrame500Nacks15) {
2298 if (framer_.version() != QUIC_VERSION_15) { 2300 if (framer_.version() != QUIC_VERSION_15) {
2299 return; 2301 return;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 frame->received_info.missing_packets.begin(); 2362 frame->received_info.missing_packets.begin();
2361 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE) - 499, *first_missing_iter); 2363 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE) - 499, *first_missing_iter);
2362 SequenceNumberSet::const_reverse_iterator last_missing_iter = 2364 SequenceNumberSet::const_reverse_iterator last_missing_iter =
2363 frame->received_info.missing_packets.rbegin(); 2365 frame->received_info.missing_packets.rbegin();
2364 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *last_missing_iter); 2366 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *last_missing_iter);
2365 EXPECT_EQ(GG_UINT64_C(0x0123456789AA0), frame->sent_info.least_unacked); 2367 EXPECT_EQ(GG_UINT64_C(0x0123456789AA0), frame->sent_info.least_unacked);
2366 2368
2367 // Verify that the packet re-serializes identically. 2369 // Verify that the packet re-serializes identically.
2368 QuicFrames frames; 2370 QuicFrames frames;
2369 frames.push_back(QuicFrame(frame)); 2371 frames.push_back(QuicFrame(frame));
2370 scoped_ptr<QuicPacket> data( 2372 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames));
2371 framer_.BuildUnsizedDataPacket(*visitor_.header_, frames).packet);
2372 ASSERT_TRUE(data != NULL); 2373 ASSERT_TRUE(data != NULL);
2373 2374
2374 test::CompareCharArraysWithHexError("constructed packet", 2375 test::CompareCharArraysWithHexError("constructed packet",
2375 data->data(), data->length(), 2376 data->data(), data->length(),
2376 AsChars(packet), arraysize(packet)); 2377 AsChars(packet), arraysize(packet));
2377 } 2378 }
2378 2379
2379 TEST_P(QuicFramerTest, CongestionFeedbackFrameTCP) { 2380 TEST_P(QuicFramerTest, CongestionFeedbackFrameTCP) {
2380 unsigned char packet[] = { 2381 unsigned char packet[] = {
2381 // public flags (8 byte connection_id) 2382 // public flags (8 byte connection_id)
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
3238 // frame type (padding frame) 3239 // frame type (padding frame)
3239 0x00, 3240 0x00,
3240 0x00, 0x00, 0x00, 0x00 3241 0x00, 0x00, 0x00, 0x00
3241 }; 3242 };
3242 3243
3243 uint64 header_size = 3244 uint64 header_size =
3244 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 3245 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3245 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 3246 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
3246 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); 3247 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
3247 3248
3248 scoped_ptr<QuicPacket> data( 3249 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3249 framer_.BuildUnsizedDataPacket(header, frames).packet);
3250 ASSERT_TRUE(data != NULL); 3250 ASSERT_TRUE(data != NULL);
3251 3251
3252 test::CompareCharArraysWithHexError("constructed packet", 3252 test::CompareCharArraysWithHexError("constructed packet",
3253 data->data(), data->length(), 3253 data->data(), data->length(),
3254 AsChars(packet), 3254 AsChars(packet),
3255 arraysize(packet)); 3255 arraysize(packet));
3256 } 3256 }
3257 3257
3258 TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) { 3258 TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) {
3259 QuicPacketHeader header; 3259 QuicPacketHeader header;
(...skipping 25 matching lines...) Expand all
3285 // frame type (padding frame) 3285 // frame type (padding frame)
3286 0x00, 3286 0x00,
3287 0x00, 0x00, 0x00, 0x00 3287 0x00, 0x00, 0x00, 0x00
3288 }; 3288 };
3289 3289
3290 uint64 header_size = 3290 uint64 header_size =
3291 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 3291 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3292 PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 3292 PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
3293 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); 3293 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
3294 3294
3295 scoped_ptr<QuicPacket> data( 3295 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3296 framer_.BuildUnsizedDataPacket(header, frames).packet);
3297 ASSERT_TRUE(data != NULL); 3296 ASSERT_TRUE(data != NULL);
3298 3297
3299 test::CompareCharArraysWithHexError("constructed packet", 3298 test::CompareCharArraysWithHexError("constructed packet",
3300 data->data(), data->length(), 3299 data->data(), data->length(),
3301 AsChars(packet), 3300 AsChars(packet),
3302 arraysize(packet)); 3301 arraysize(packet));
3303 } 3302 }
3304 3303
3305 TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) { 3304 TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) {
3306 QuicPacketHeader header; 3305 QuicPacketHeader header;
(...skipping 25 matching lines...) Expand all
3332 // frame type (padding frame) 3331 // frame type (padding frame)
3333 0x00, 3332 0x00,
3334 0x00, 0x00, 0x00, 0x00 3333 0x00, 0x00, 0x00, 0x00
3335 }; 3334 };
3336 3335
3337 uint64 header_size = 3336 uint64 header_size =
3338 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 3337 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3339 PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 3338 PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
3340 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); 3339 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
3341 3340
3342 scoped_ptr<QuicPacket> data( 3341 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3343 framer_.BuildUnsizedDataPacket(header, frames).packet);
3344 ASSERT_TRUE(data != NULL); 3342 ASSERT_TRUE(data != NULL);
3345 3343
3346 test::CompareCharArraysWithHexError("constructed packet", 3344 test::CompareCharArraysWithHexError("constructed packet",
3347 data->data(), data->length(), 3345 data->data(), data->length(),
3348 AsChars(packet), 3346 AsChars(packet),
3349 arraysize(packet)); 3347 arraysize(packet));
3350 } 3348 }
3351 3349
3352 TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) { 3350 TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) {
3353 QuicPacketHeader header; 3351 QuicPacketHeader header;
(...skipping 25 matching lines...) Expand all
3379 // frame type (padding frame) 3377 // frame type (padding frame)
3380 0x00, 3378 0x00,
3381 0x00, 0x00, 0x00, 0x00 3379 0x00, 0x00, 0x00, 0x00
3382 }; 3380 };
3383 3381
3384 uint64 header_size = 3382 uint64 header_size =
3385 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 3383 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3386 PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 3384 PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
3387 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); 3385 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
3388 3386
3389 scoped_ptr<QuicPacket> data( 3387 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3390 framer_.BuildUnsizedDataPacket(header, frames).packet);
3391 ASSERT_TRUE(data != NULL); 3388 ASSERT_TRUE(data != NULL);
3392 3389
3393 test::CompareCharArraysWithHexError("constructed packet", 3390 test::CompareCharArraysWithHexError("constructed packet",
3394 data->data(), data->length(), 3391 data->data(), data->length(),
3395 AsChars(packet), 3392 AsChars(packet),
3396 arraysize(packet)); 3393 arraysize(packet));
3397 } 3394 }
3398 3395
3399 TEST_P(QuicFramerTest, BuildStreamFramePacket) { 3396 TEST_P(QuicFramerTest, BuildStreamFramePacket) {
3400 QuicPacketHeader header; 3397 QuicPacketHeader header;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3433 0x04, 0x03, 0x02, 0x01, 3430 0x04, 0x03, 0x02, 0x01,
3434 // offset 3431 // offset
3435 0x54, 0x76, 0x10, 0x32, 3432 0x54, 0x76, 0x10, 0x32,
3436 0xDC, 0xFE, 0x98, 0xBA, 3433 0xDC, 0xFE, 0x98, 0xBA,
3437 // data 3434 // data
3438 'h', 'e', 'l', 'l', 3435 'h', 'e', 'l', 'l',
3439 'o', ' ', 'w', 'o', 3436 'o', ' ', 'w', 'o',
3440 'r', 'l', 'd', '!', 3437 'r', 'l', 'd', '!',
3441 }; 3438 };
3442 3439
3443 scoped_ptr<QuicPacket> data( 3440 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3444 framer_.BuildUnsizedDataPacket(header, frames).packet);
3445 ASSERT_TRUE(data != NULL); 3441 ASSERT_TRUE(data != NULL);
3446 3442
3447 test::CompareCharArraysWithHexError("constructed packet", 3443 test::CompareCharArraysWithHexError("constructed packet",
3448 data->data(), data->length(), 3444 data->data(), data->length(),
3449 AsChars(packet), arraysize(packet)); 3445 AsChars(packet), arraysize(packet));
3450 } 3446 }
3451 3447
3452 TEST_P(QuicFramerTest, BuildStreamFramePacketInFecGroup) { 3448 TEST_P(QuicFramerTest, BuildStreamFramePacketInFecGroup) {
3453 QuicPacketHeader header; 3449 QuicPacketHeader header;
3454 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 3450 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3489 0x54, 0x76, 0x10, 0x32, 3485 0x54, 0x76, 0x10, 0x32,
3490 0xDC, 0xFE, 0x98, 0xBA, 3486 0xDC, 0xFE, 0x98, 0xBA,
3491 // data length (since packet is in an FEC group) 3487 // data length (since packet is in an FEC group)
3492 0x0C, 0x00, 3488 0x0C, 0x00,
3493 // data 3489 // data
3494 'h', 'e', 'l', 'l', 3490 'h', 'e', 'l', 'l',
3495 'o', ' ', 'w', 'o', 3491 'o', ' ', 'w', 'o',
3496 'r', 'l', 'd', '!', 3492 'r', 'l', 'd', '!',
3497 }; 3493 };
3498 3494
3499 scoped_ptr<QuicPacket> data( 3495 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3500 framer_.BuildUnsizedDataPacket(header, frames).packet);
3501 ASSERT_TRUE(data != NULL); 3496 ASSERT_TRUE(data != NULL);
3502 3497
3503 test::CompareCharArraysWithHexError("constructed packet", 3498 test::CompareCharArraysWithHexError("constructed packet",
3504 data->data(), data->length(), 3499 data->data(), data->length(),
3505 AsChars(packet), arraysize(packet)); 3500 AsChars(packet), arraysize(packet));
3506 } 3501 }
3507 3502
3508 TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) { 3503 TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) {
3509 QuicPacketHeader header; 3504 QuicPacketHeader header;
3510 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 3505 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3545 // offset 3540 // offset
3546 0x54, 0x76, 0x10, 0x32, 3541 0x54, 0x76, 0x10, 0x32,
3547 0xDC, 0xFE, 0x98, 0xBA, 3542 0xDC, 0xFE, 0x98, 0xBA,
3548 // data 3543 // data
3549 'h', 'e', 'l', 'l', 3544 'h', 'e', 'l', 'l',
3550 'o', ' ', 'w', 'o', 3545 'o', ' ', 'w', 'o',
3551 'r', 'l', 'd', '!', 3546 'r', 'l', 'd', '!',
3552 }; 3547 };
3553 3548
3554 QuicFramerPeer::SetIsServer(&framer_, false); 3549 QuicFramerPeer::SetIsServer(&framer_, false);
3555 scoped_ptr<QuicPacket> data( 3550 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3556 framer_.BuildUnsizedDataPacket(header, frames).packet);
3557 ASSERT_TRUE(data != NULL); 3551 ASSERT_TRUE(data != NULL);
3558 3552
3559 test::CompareCharArraysWithHexError("constructed packet", 3553 test::CompareCharArraysWithHexError("constructed packet",
3560 data->data(), data->length(), 3554 data->data(), data->length(),
3561 AsChars(packet), arraysize(packet)); 3555 AsChars(packet), arraysize(packet));
3562 } 3556 }
3563 3557
3564 TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) { 3558 TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) {
3565 QuicPacketPublicHeader header; 3559 QuicPacketPublicHeader header;
3566 header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 3560 header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3635 // num missing packet ranges 3629 // num missing packet ranges
3636 0x01, 3630 0x01,
3637 // missing packet delta 3631 // missing packet delta
3638 0x01, 3632 0x01,
3639 // 0 more missing packets in range. 3633 // 0 more missing packets in range.
3640 0x00, 3634 0x00,
3641 // 0 revived packets. 3635 // 0 revived packets.
3642 0x00, 3636 0x00,
3643 }; 3637 };
3644 3638
3645 scoped_ptr<QuicPacket> data( 3639 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3646 framer_.BuildUnsizedDataPacket(header, frames).packet);
3647 ASSERT_TRUE(data != NULL); 3640 ASSERT_TRUE(data != NULL);
3648 3641
3649 test::CompareCharArraysWithHexError("constructed packet", 3642 test::CompareCharArraysWithHexError("constructed packet",
3650 data->data(), data->length(), 3643 data->data(), data->length(),
3651 AsChars(packet), arraysize(packet)); 3644 AsChars(packet), arraysize(packet));
3652 } 3645 }
3653 3646
3654 TEST_P(QuicFramerTest, BuildAckFramePacket15) { 3647 TEST_P(QuicFramerTest, BuildAckFramePacket15) {
3655 if (version_ != QUIC_VERSION_15) { 3648 if (version_ != QUIC_VERSION_15) {
3656 return; 3649 return;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3706 // num missing packet ranges 3699 // num missing packet ranges
3707 0x01, 3700 0x01,
3708 // missing packet delta 3701 // missing packet delta
3709 0x01, 3702 0x01,
3710 // 0 more missing packets in range. 3703 // 0 more missing packets in range.
3711 0x00, 3704 0x00,
3712 // 0 revived packets. 3705 // 0 revived packets.
3713 0x00, 3706 0x00,
3714 }; 3707 };
3715 3708
3716 scoped_ptr<QuicPacket> data( 3709 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3717 framer_.BuildUnsizedDataPacket(header, frames).packet);
3718 ASSERT_TRUE(data != NULL); 3710 ASSERT_TRUE(data != NULL);
3719 3711
3720 test::CompareCharArraysWithHexError("constructed packet", 3712 test::CompareCharArraysWithHexError("constructed packet",
3721 data->data(), data->length(), 3713 data->data(), data->length(),
3722 AsChars(packet), arraysize(packet)); 3714 AsChars(packet), arraysize(packet));
3723 } 3715 }
3724 3716
3725 // TODO(jri): Add test for tuncated packets in which the original ack frame had 3717 // TODO(jri): Add test for tuncated packets in which the original ack frame had
3726 // revived packets. (In both the large and small packet cases below). 3718 // revived packets. (In both the large and small packet cases below).
3727 TEST_P(QuicFramerTest, BuildTruncatedAckFrameLargePacket) { 3719 TEST_P(QuicFramerTest, BuildTruncatedAckFrameLargePacket) {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
3939 0x00, 3931 0x00,
3940 3932
3941 // frame type (congestion feedback frame) 3933 // frame type (congestion feedback frame)
3942 0x20, 3934 0x20,
3943 // congestion feedback type (TCP) 3935 // congestion feedback type (TCP)
3944 0x00, 3936 0x00,
3945 // TCP receive window 3937 // TCP receive window
3946 0x03, 0x04, 3938 0x03, 0x04,
3947 }; 3939 };
3948 3940
3949 scoped_ptr<QuicPacket> data( 3941 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3950 framer_.BuildUnsizedDataPacket(header, frames).packet);
3951 ASSERT_TRUE(data != NULL); 3942 ASSERT_TRUE(data != NULL);
3952 3943
3953 test::CompareCharArraysWithHexError("constructed packet", 3944 test::CompareCharArraysWithHexError("constructed packet",
3954 data->data(), data->length(), 3945 data->data(), data->length(),
3955 AsChars(packet), arraysize(packet)); 3946 AsChars(packet), arraysize(packet));
3956 } 3947 }
3957 3948
3958 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInterArrival) { 3949 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInterArrival) {
3959 QuicPacketHeader header; 3950 QuicPacketHeader header;
3960 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 3951 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4009 // sequence delta 4000 // sequence delta
4010 0x01, 0x00, 4001 0x01, 0x00,
4011 // time delta 4002 // time delta
4012 0x01, 0x00, 0x00, 0x00, 4003 0x01, 0x00, 0x00, 0x00,
4013 // sequence delta (skip one packet) 4004 // sequence delta (skip one packet)
4014 0x03, 0x00, 4005 0x03, 0x00,
4015 // time delta 4006 // time delta
4016 0x02, 0x00, 0x00, 0x00, 4007 0x02, 0x00, 0x00, 0x00,
4017 }; 4008 };
4018 4009
4019 scoped_ptr<QuicPacket> data( 4010 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4020 framer_.BuildUnsizedDataPacket(header, frames).packet);
4021 ASSERT_TRUE(data != NULL); 4011 ASSERT_TRUE(data != NULL);
4022 4012
4023 test::CompareCharArraysWithHexError("constructed packet", 4013 test::CompareCharArraysWithHexError("constructed packet",
4024 data->data(), data->length(), 4014 data->data(), data->length(),
4025 AsChars(packet), arraysize(packet)); 4015 AsChars(packet), arraysize(packet));
4026 } 4016 }
4027 4017
4028 TEST_P(QuicFramerTest, BuildStopWaitingPacket) { 4018 TEST_P(QuicFramerTest, BuildStopWaitingPacket) {
4029 if (version_ <= QUIC_VERSION_15) { 4019 if (version_ <= QUIC_VERSION_15) {
4030 return; 4020 return;
(...skipping 28 matching lines...) Expand all
4059 4049
4060 // frame type (stop waiting frame) 4050 // frame type (stop waiting frame)
4061 0x06, 4051 0x06,
4062 // entropy hash of sent packets till least awaiting - 1. 4052 // entropy hash of sent packets till least awaiting - 1.
4063 0x14, 4053 0x14,
4064 // least packet sequence number awaiting an ack, delta from sequence number. 4054 // least packet sequence number awaiting an ack, delta from sequence number.
4065 0x08, 0x00, 0x00, 0x00, 4055 0x08, 0x00, 0x00, 0x00,
4066 0x00, 0x00, 4056 0x00, 0x00,
4067 }; 4057 };
4068 4058
4069 scoped_ptr<QuicPacket> data( 4059 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4070 framer_.BuildUnsizedDataPacket(header, frames).packet);
4071 ASSERT_TRUE(data != NULL); 4060 ASSERT_TRUE(data != NULL);
4072 4061
4073 test::CompareCharArraysWithHexError("constructed packet", 4062 test::CompareCharArraysWithHexError("constructed packet",
4074 data->data(), data->length(), 4063 data->data(), data->length(),
4075 AsChars(packet), arraysize(packet)); 4064 AsChars(packet), arraysize(packet));
4076 } 4065 }
4077 4066
4078 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketFixRate) { 4067 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketFixRate) {
4079 QuicPacketHeader header; 4068 QuicPacketHeader header;
4080 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4069 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 25 matching lines...) Expand all
4106 0x00, 4095 0x00,
4107 4096
4108 // frame type (congestion feedback frame) 4097 // frame type (congestion feedback frame)
4109 0x20, 4098 0x20,
4110 // congestion feedback type (fix rate) 4099 // congestion feedback type (fix rate)
4111 0x02, 4100 0x02,
4112 // bitrate_in_bytes_per_second; 4101 // bitrate_in_bytes_per_second;
4113 0x01, 0x02, 0x03, 0x04, 4102 0x01, 0x02, 0x03, 0x04,
4114 }; 4103 };
4115 4104
4116 scoped_ptr<QuicPacket> data( 4105 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4117 framer_.BuildUnsizedDataPacket(header, frames).packet);
4118 ASSERT_TRUE(data != NULL); 4106 ASSERT_TRUE(data != NULL);
4119 4107
4120 test::CompareCharArraysWithHexError("constructed packet", 4108 test::CompareCharArraysWithHexError("constructed packet",
4121 data->data(), data->length(), 4109 data->data(), data->length(),
4122 AsChars(packet), arraysize(packet)); 4110 AsChars(packet), arraysize(packet));
4123 } 4111 }
4124 4112
4125 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInvalidFeedback) { 4113 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInvalidFeedback) {
4126 QuicPacketHeader header; 4114 QuicPacketHeader header;
4127 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4115 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4128 header.public_header.reset_flag = false; 4116 header.public_header.reset_flag = false;
4129 header.public_header.version_flag = false; 4117 header.public_header.version_flag = false;
4130 header.fec_flag = false; 4118 header.fec_flag = false;
4131 header.entropy_flag = false; 4119 header.entropy_flag = false;
4132 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4120 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4133 header.fec_group = 0; 4121 header.fec_group = 0;
4134 4122
4135 QuicCongestionFeedbackFrame congestion_feedback_frame; 4123 QuicCongestionFeedbackFrame congestion_feedback_frame;
4136 congestion_feedback_frame.type = 4124 congestion_feedback_frame.type =
4137 static_cast<CongestionFeedbackType>(kFixRate + 1); 4125 static_cast<CongestionFeedbackType>(kFixRate + 1);
4138 4126
4139 QuicFrames frames; 4127 QuicFrames frames;
4140 frames.push_back(QuicFrame(&congestion_feedback_frame)); 4128 frames.push_back(QuicFrame(&congestion_feedback_frame));
4141 4129
4142 scoped_ptr<QuicPacket> data; 4130 scoped_ptr<QuicPacket> data;
4143 EXPECT_DFATAL( 4131 EXPECT_DFATAL(
4144 data.reset(framer_.BuildUnsizedDataPacket(header, frames).packet), 4132 data.reset(BuildDataPacket(header, frames)),
4145 "AppendCongestionFeedbackFrame failed"); 4133 "AppendCongestionFeedbackFrame failed");
4146 ASSERT_TRUE(data == NULL); 4134 ASSERT_TRUE(data == NULL);
4147 } 4135 }
4148 4136
4149 TEST_P(QuicFramerTest, BuildRstFramePacketQuic) { 4137 TEST_P(QuicFramerTest, BuildRstFramePacketQuic) {
4150 QuicPacketHeader header; 4138 QuicPacketHeader header;
4151 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4139 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4152 header.public_header.reset_flag = false; 4140 header.public_header.reset_flag = false;
4153 header.public_header.version_flag = false; 4141 header.public_header.version_flag = false;
4154 header.fec_flag = false; 4142 header.fec_flag = false;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4188 // error details 4176 // error details
4189 'b', 'e', 'c', 'a', 4177 'b', 'e', 'c', 'a',
4190 'u', 's', 'e', ' ', 4178 'u', 's', 'e', ' ',
4191 'I', ' ', 'c', 'a', 4179 'I', ' ', 'c', 'a',
4192 'n', 4180 'n',
4193 }; 4181 };
4194 4182
4195 QuicFrames frames; 4183 QuicFrames frames;
4196 frames.push_back(QuicFrame(&rst_frame)); 4184 frames.push_back(QuicFrame(&rst_frame));
4197 4185
4198 scoped_ptr<QuicPacket> data( 4186 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4199 framer_.BuildUnsizedDataPacket(header, frames).packet);
4200 ASSERT_TRUE(data != NULL); 4187 ASSERT_TRUE(data != NULL);
4201 4188
4202 test::CompareCharArraysWithHexError("constructed packet", 4189 test::CompareCharArraysWithHexError("constructed packet",
4203 data->data(), data->length(), 4190 data->data(), data->length(),
4204 AsChars(packet), arraysize(packet)); 4191 AsChars(packet), arraysize(packet));
4205 } 4192 }
4206 4193
4207 TEST_P(QuicFramerTest, BuildCloseFramePacket) { 4194 TEST_P(QuicFramerTest, BuildCloseFramePacket) {
4208 QuicPacketHeader header; 4195 QuicPacketHeader header;
4209 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4196 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 29 matching lines...) Expand all
4239 0x08, 0x07, 0x06, 0x05, 4226 0x08, 0x07, 0x06, 0x05,
4240 // error details length 4227 // error details length
4241 0x0d, 0x00, 4228 0x0d, 0x00,
4242 // error details 4229 // error details
4243 'b', 'e', 'c', 'a', 4230 'b', 'e', 'c', 'a',
4244 'u', 's', 'e', ' ', 4231 'u', 's', 'e', ' ',
4245 'I', ' ', 'c', 'a', 4232 'I', ' ', 'c', 'a',
4246 'n', 4233 'n',
4247 }; 4234 };
4248 4235
4249 scoped_ptr<QuicPacket> data( 4236 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4250 framer_.BuildUnsizedDataPacket(header, frames).packet);
4251 ASSERT_TRUE(data != NULL); 4237 ASSERT_TRUE(data != NULL);
4252 4238
4253 test::CompareCharArraysWithHexError("constructed packet", 4239 test::CompareCharArraysWithHexError("constructed packet",
4254 data->data(), data->length(), 4240 data->data(), data->length(),
4255 AsChars(packet), arraysize(packet)); 4241 AsChars(packet), arraysize(packet));
4256 } 4242 }
4257 4243
4258 TEST_P(QuicFramerTest, BuildGoAwayPacket) { 4244 TEST_P(QuicFramerTest, BuildGoAwayPacket) {
4259 QuicPacketHeader header; 4245 QuicPacketHeader header;
4260 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4246 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4293 0x04, 0x03, 0x02, 0x01, 4279 0x04, 0x03, 0x02, 0x01,
4294 // error details length 4280 // error details length
4295 0x0d, 0x00, 4281 0x0d, 0x00,
4296 // error details 4282 // error details
4297 'b', 'e', 'c', 'a', 4283 'b', 'e', 'c', 'a',
4298 'u', 's', 'e', ' ', 4284 'u', 's', 'e', ' ',
4299 'I', ' ', 'c', 'a', 4285 'I', ' ', 'c', 'a',
4300 'n', 4286 'n',
4301 }; 4287 };
4302 4288
4303 scoped_ptr<QuicPacket> data( 4289 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4304 framer_.BuildUnsizedDataPacket(header, frames).packet);
4305 ASSERT_TRUE(data != NULL); 4290 ASSERT_TRUE(data != NULL);
4306 4291
4307 test::CompareCharArraysWithHexError("constructed packet", 4292 test::CompareCharArraysWithHexError("constructed packet",
4308 data->data(), data->length(), 4293 data->data(), data->length(),
4309 AsChars(packet), arraysize(packet)); 4294 AsChars(packet), arraysize(packet));
4310 } 4295 }
4311 4296
4312 TEST_P(QuicFramerTest, BuildWindowUpdatePacket) { 4297 TEST_P(QuicFramerTest, BuildWindowUpdatePacket) {
4313 QuicPacketHeader header; 4298 QuicPacketHeader header;
4314 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4299 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 25 matching lines...) Expand all
4340 4325
4341 // frame type (window update frame) 4326 // frame type (window update frame)
4342 0x04, 4327 0x04,
4343 // stream id 4328 // stream id
4344 0x04, 0x03, 0x02, 0x01, 4329 0x04, 0x03, 0x02, 0x01,
4345 // byte offset 4330 // byte offset
4346 0x88, 0x77, 0x66, 0x55, 4331 0x88, 0x77, 0x66, 0x55,
4347 0x44, 0x33, 0x22, 0x11, 4332 0x44, 0x33, 0x22, 0x11,
4348 }; 4333 };
4349 4334
4350 scoped_ptr<QuicPacket> data( 4335 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4351 framer_.BuildUnsizedDataPacket(header, frames).packet);
4352 ASSERT_TRUE(data != NULL); 4336 ASSERT_TRUE(data != NULL);
4353 4337
4354 test::CompareCharArraysWithHexError("constructed packet", data->data(), 4338 test::CompareCharArraysWithHexError("constructed packet", data->data(),
4355 data->length(), AsChars(packet), 4339 data->length(), AsChars(packet),
4356 arraysize(packet)); 4340 arraysize(packet));
4357 } 4341 }
4358 4342
4359 TEST_P(QuicFramerTest, BuildBlockedPacket) { 4343 TEST_P(QuicFramerTest, BuildBlockedPacket) {
4360 QuicPacketHeader header; 4344 QuicPacketHeader header;
4361 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4345 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 21 matching lines...) Expand all
4383 0x34, 0x12, 4367 0x34, 0x12,
4384 // private flags(entropy) 4368 // private flags(entropy)
4385 0x01, 4369 0x01,
4386 4370
4387 // frame type (blocked frame) 4371 // frame type (blocked frame)
4388 0x05, 4372 0x05,
4389 // stream id 4373 // stream id
4390 0x04, 0x03, 0x02, 0x01, 4374 0x04, 0x03, 0x02, 0x01,
4391 }; 4375 };
4392 4376
4393 scoped_ptr<QuicPacket> data( 4377 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4394 framer_.BuildUnsizedDataPacket(header, frames).packet);
4395 ASSERT_TRUE(data != NULL); 4378 ASSERT_TRUE(data != NULL);
4396 4379
4397 test::CompareCharArraysWithHexError("constructed packet", data->data(), 4380 test::CompareCharArraysWithHexError("constructed packet", data->data(),
4398 data->length(), AsChars(packet), 4381 data->length(), AsChars(packet),
4399 arraysize(packet)); 4382 arraysize(packet));
4400 } 4383 }
4401 4384
4402 TEST_P(QuicFramerTest, BuildPingPacket) { 4385 TEST_P(QuicFramerTest, BuildPingPacket) {
4403 QuicPacketHeader header; 4386 QuicPacketHeader header;
4404 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4387 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 19 matching lines...) Expand all
4424 0xBC, 0x9A, 0x78, 0x56, 4407 0xBC, 0x9A, 0x78, 0x56,
4425 0x34, 0x12, 4408 0x34, 0x12,
4426 // private flags(entropy) 4409 // private flags(entropy)
4427 0x01, 4410 0x01,
4428 4411
4429 // frame type (ping frame) 4412 // frame type (ping frame)
4430 0x07, 4413 0x07,
4431 }; 4414 };
4432 4415
4433 if (version_ > QUIC_VERSION_17) { 4416 if (version_ > QUIC_VERSION_17) {
4434 scoped_ptr<QuicPacket> data( 4417 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4435 framer_.BuildUnsizedDataPacket(header, frames).packet);
4436 ASSERT_TRUE(data != NULL); 4418 ASSERT_TRUE(data != NULL);
4437 4419
4438 test::CompareCharArraysWithHexError("constructed packet", data->data(), 4420 test::CompareCharArraysWithHexError("constructed packet", data->data(),
4439 data->length(), AsChars(packet), 4421 data->length(), AsChars(packet),
4440 arraysize(packet)); 4422 arraysize(packet));
4441 } else { 4423 } else {
4442 string expected_error = 4424 string expected_error =
4443 "Attempt to add a PingFrame in " + QuicVersionToString(version_); 4425 "Attempt to add a PingFrame in " + QuicVersionToString(version_);
4444 EXPECT_DFATAL(framer_.BuildUnsizedDataPacket(header, frames), 4426 EXPECT_DFATAL(BuildDataPacket(header, frames),
4445 expected_error); 4427 expected_error);
4446 return; 4428 return;
4447 } 4429 }
4448 } 4430 }
4449 4431
4450 TEST_P(QuicFramerTest, BuildPublicResetPacket) { 4432 TEST_P(QuicFramerTest, BuildPublicResetPacket) {
4451 QuicPublicResetPacket reset_packet; 4433 QuicPublicResetPacket reset_packet;
4452 reset_packet.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4434 reset_packet.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4453 reset_packet.public_header.reset_flag = true; 4435 reset_packet.public_header.reset_flag = true;
4454 reset_packet.public_header.version_flag = false; 4436 reset_packet.public_header.version_flag = false;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
4763 ack_frame.received_info.missing_packets.insert(i); 4745 ack_frame.received_info.missing_packets.insert(i);
4764 } 4746 }
4765 4747
4766 // Create a packet with just the ack. 4748 // Create a packet with just the ack.
4767 QuicFrame frame; 4749 QuicFrame frame;
4768 frame.type = ACK_FRAME; 4750 frame.type = ACK_FRAME;
4769 frame.ack_frame = &ack_frame; 4751 frame.ack_frame = &ack_frame;
4770 QuicFrames frames; 4752 QuicFrames frames;
4771 frames.push_back(frame); 4753 frames.push_back(frame);
4772 4754
4773 scoped_ptr<QuicPacket> raw_ack_packet( 4755 scoped_ptr<QuicPacket> raw_ack_packet(BuildDataPacket(header, frames));
4774 framer_.BuildUnsizedDataPacket(header, frames).packet);
4775 ASSERT_TRUE(raw_ack_packet != NULL); 4756 ASSERT_TRUE(raw_ack_packet != NULL);
4776 4757
4777 scoped_ptr<QuicEncryptedPacket> ack_packet( 4758 scoped_ptr<QuicEncryptedPacket> ack_packet(
4778 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number, 4759 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number,
4779 *raw_ack_packet)); 4760 *raw_ack_packet));
4780 4761
4781 // Now make sure we can turn our ack packet back into an ack frame. 4762 // Now make sure we can turn our ack packet back into an ack frame.
4782 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet)); 4763 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet));
4783 ASSERT_EQ(1u, visitor_.ack_frames_.size()); 4764 ASSERT_EQ(1u, visitor_.ack_frames_.size());
4784 const QuicAckFrame& processed_ack_frame = *visitor_.ack_frames_[0]; 4765 const QuicAckFrame& processed_ack_frame = *visitor_.ack_frames_[0];
(...skipping 27 matching lines...) Expand all
4812 ack_frame.received_info.missing_packets.insert(i); 4793 ack_frame.received_info.missing_packets.insert(i);
4813 } 4794 }
4814 4795
4815 // Create a packet with just the ack. 4796 // Create a packet with just the ack.
4816 QuicFrame frame; 4797 QuicFrame frame;
4817 frame.type = ACK_FRAME; 4798 frame.type = ACK_FRAME;
4818 frame.ack_frame = &ack_frame; 4799 frame.ack_frame = &ack_frame;
4819 QuicFrames frames; 4800 QuicFrames frames;
4820 frames.push_back(frame); 4801 frames.push_back(frame);
4821 4802
4822 scoped_ptr<QuicPacket> raw_ack_packet( 4803 scoped_ptr<QuicPacket> raw_ack_packet(BuildDataPacket(header, frames));
4823 framer_.BuildUnsizedDataPacket(header, frames).packet);
4824 ASSERT_TRUE(raw_ack_packet != NULL); 4804 ASSERT_TRUE(raw_ack_packet != NULL);
4825 4805
4826 scoped_ptr<QuicEncryptedPacket> ack_packet( 4806 scoped_ptr<QuicEncryptedPacket> ack_packet(
4827 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number, 4807 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number,
4828 *raw_ack_packet)); 4808 *raw_ack_packet));
4829 4809
4830 // Now make sure we can turn our ack packet back into an ack frame. 4810 // Now make sure we can turn our ack packet back into an ack frame.
4831 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet)); 4811 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet));
4832 4812
4833 // Test for clean truncation of the ack by comparing the length of the 4813 // Test for clean truncation of the ack by comparing the length of the
4834 // original packets to the re-serialized packets. 4814 // original packets to the re-serialized packets.
4835 frames.clear(); 4815 frames.clear();
4836 frame.type = ACK_FRAME; 4816 frame.type = ACK_FRAME;
4837 frame.ack_frame = visitor_.ack_frames_[0]; 4817 frame.ack_frame = visitor_.ack_frames_[0];
4838 frames.push_back(frame); 4818 frames.push_back(frame);
4839 4819
4840 size_t original_raw_length = raw_ack_packet->length(); 4820 size_t original_raw_length = raw_ack_packet->length();
4841 raw_ack_packet.reset( 4821 raw_ack_packet.reset(BuildDataPacket(header, frames));
4842 framer_.BuildUnsizedDataPacket(header, frames).packet);
4843 ASSERT_TRUE(raw_ack_packet != NULL); 4822 ASSERT_TRUE(raw_ack_packet != NULL);
4844 EXPECT_EQ(original_raw_length, raw_ack_packet->length()); 4823 EXPECT_EQ(original_raw_length, raw_ack_packet->length());
4845 ASSERT_TRUE(raw_ack_packet != NULL); 4824 ASSERT_TRUE(raw_ack_packet != NULL);
4846 } 4825 }
4847 4826
4848 TEST_P(QuicFramerTest, EntropyFlagTest) { 4827 TEST_P(QuicFramerTest, EntropyFlagTest) {
4849 unsigned char packet[] = { 4828 unsigned char packet[] = {
4850 // public flags (8 byte connection_id) 4829 // public flags (8 byte connection_id)
4851 0x3C, 4830 0x3C,
4852 // connection_id 4831 // connection_id
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
4972 EXPECT_CALL(visitor, OnPacketComplete()); 4951 EXPECT_CALL(visitor, OnPacketComplete());
4973 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true)); 4952 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true));
4974 4953
4975 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 4954 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
4976 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 4955 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
4977 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 4956 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
4978 } 4957 }
4979 4958
4980 } // namespace test 4959 } // namespace test
4981 } // namespace net 4960 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_packet_creator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698