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

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

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_headers_stream_test.cc » ('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 2361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 ASSERT_EQ(1u, visitor_.ack_frames_.size()); 2372 ASSERT_EQ(1u, visitor_.ack_frames_.size());
2373 QuicAckFrame* frame = visitor_.ack_frames_[0]; 2373 QuicAckFrame* frame = visitor_.ack_frames_[0];
2374 EXPECT_EQ(0xBA, frame->entropy_hash); 2374 EXPECT_EQ(0xBA, frame->entropy_hash);
2375 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame->largest_observed); 2375 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame->largest_observed);
2376 ASSERT_EQ(0u, frame->missing_packets.size()); 2376 ASSERT_EQ(0u, frame->missing_packets.size());
2377 2377
2378 // Verify that the packet re-serializes identically. 2378 // Verify that the packet re-serializes identically.
2379 QuicFrames frames; 2379 QuicFrames frames;
2380 frames.push_back(QuicFrame(frame)); 2380 frames.push_back(QuicFrame(frame));
2381 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames)); 2381 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames));
2382 ASSERT_TRUE(data != NULL); 2382 ASSERT_TRUE(data != nullptr);
2383 2383
2384 test::CompareCharArraysWithHexError("constructed packet", 2384 test::CompareCharArraysWithHexError("constructed packet",
2385 data->data(), data->length(), 2385 data->data(), data->length(),
2386 AsChars(packet), arraysize(packet)); 2386 AsChars(packet), arraysize(packet));
2387 } 2387 }
2388 2388
2389 TEST_P(QuicFramerTest, AckFrameNoNacks) { 2389 TEST_P(QuicFramerTest, AckFrameNoNacks) {
2390 if (version_ <= QUIC_VERSION_22) { 2390 if (version_ <= QUIC_VERSION_22) {
2391 return; 2391 return;
2392 } 2392 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 ASSERT_EQ(1u, visitor_.ack_frames_.size()); 2427 ASSERT_EQ(1u, visitor_.ack_frames_.size());
2428 QuicAckFrame* frame = visitor_.ack_frames_[0]; 2428 QuicAckFrame* frame = visitor_.ack_frames_[0];
2429 EXPECT_EQ(0xBA, frame->entropy_hash); 2429 EXPECT_EQ(0xBA, frame->entropy_hash);
2430 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame->largest_observed); 2430 EXPECT_EQ(GG_UINT64_C(0x0123456789ABF), frame->largest_observed);
2431 ASSERT_EQ(0u, frame->missing_packets.size()); 2431 ASSERT_EQ(0u, frame->missing_packets.size());
2432 2432
2433 // Verify that the packet re-serializes identically. 2433 // Verify that the packet re-serializes identically.
2434 QuicFrames frames; 2434 QuicFrames frames;
2435 frames.push_back(QuicFrame(frame)); 2435 frames.push_back(QuicFrame(frame));
2436 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames)); 2436 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames));
2437 ASSERT_TRUE(data != NULL); 2437 ASSERT_TRUE(data != nullptr);
2438 2438
2439 test::CompareCharArraysWithHexError("constructed packet", 2439 test::CompareCharArraysWithHexError("constructed packet",
2440 data->data(), data->length(), 2440 data->data(), data->length(),
2441 AsChars(packet), arraysize(packet)); 2441 AsChars(packet), arraysize(packet));
2442 } 2442 }
2443 2443
2444 TEST_P(QuicFramerTest, AckFrame500Nacksv22) { 2444 TEST_P(QuicFramerTest, AckFrame500Nacksv22) {
2445 if (version_ > QUIC_VERSION_22) { 2445 if (version_ > QUIC_VERSION_22) {
2446 return; 2446 return;
2447 } 2447 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 frame->missing_packets.begin(); 2500 frame->missing_packets.begin();
2501 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE) - 499, *first_missing_iter); 2501 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE) - 499, *first_missing_iter);
2502 SequenceNumberSet::const_reverse_iterator last_missing_iter = 2502 SequenceNumberSet::const_reverse_iterator last_missing_iter =
2503 frame->missing_packets.rbegin(); 2503 frame->missing_packets.rbegin();
2504 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *last_missing_iter); 2504 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *last_missing_iter);
2505 2505
2506 // Verify that the packet re-serializes identically. 2506 // Verify that the packet re-serializes identically.
2507 QuicFrames frames; 2507 QuicFrames frames;
2508 frames.push_back(QuicFrame(frame)); 2508 frames.push_back(QuicFrame(frame));
2509 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames)); 2509 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames));
2510 ASSERT_TRUE(data != NULL); 2510 ASSERT_TRUE(data != nullptr);
2511 2511
2512 test::CompareCharArraysWithHexError("constructed packet", 2512 test::CompareCharArraysWithHexError("constructed packet",
2513 data->data(), data->length(), 2513 data->data(), data->length(),
2514 AsChars(packet), arraysize(packet)); 2514 AsChars(packet), arraysize(packet));
2515 } 2515 }
2516 2516
2517 TEST_P(QuicFramerTest, AckFrame500Nacks) { 2517 TEST_P(QuicFramerTest, AckFrame500Nacks) {
2518 if (version_ <= QUIC_VERSION_22) { 2518 if (version_ <= QUIC_VERSION_22) {
2519 return; 2519 return;
2520 } 2520 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2575 frame->missing_packets.begin(); 2575 frame->missing_packets.begin();
2576 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE) - 499, *first_missing_iter); 2576 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE) - 499, *first_missing_iter);
2577 SequenceNumberSet::const_reverse_iterator last_missing_iter = 2577 SequenceNumberSet::const_reverse_iterator last_missing_iter =
2578 frame->missing_packets.rbegin(); 2578 frame->missing_packets.rbegin();
2579 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *last_missing_iter); 2579 EXPECT_EQ(GG_UINT64_C(0x0123456789ABE), *last_missing_iter);
2580 2580
2581 // Verify that the packet re-serializes identically. 2581 // Verify that the packet re-serializes identically.
2582 QuicFrames frames; 2582 QuicFrames frames;
2583 frames.push_back(QuicFrame(frame)); 2583 frames.push_back(QuicFrame(frame));
2584 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames)); 2584 scoped_ptr<QuicPacket> data(BuildDataPacket(*visitor_.header_, frames));
2585 ASSERT_TRUE(data != NULL); 2585 ASSERT_TRUE(data != nullptr);
2586 2586
2587 test::CompareCharArraysWithHexError("constructed packet", 2587 test::CompareCharArraysWithHexError("constructed packet",
2588 data->data(), data->length(), 2588 data->data(), data->length(),
2589 AsChars(packet), arraysize(packet)); 2589 AsChars(packet), arraysize(packet));
2590 } 2590 }
2591 2591
2592 TEST_P(QuicFramerTest, CongestionFeedbackFrameTCP) { 2592 TEST_P(QuicFramerTest, CongestionFeedbackFrameTCP) {
2593 unsigned char packet[] = { 2593 unsigned char packet[] = {
2594 // public flags (8 byte connection_id) 2594 // public flags (8 byte connection_id)
2595 0x3C, 2595 0x3C,
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
3303 0x00, 3303 0x00,
3304 0x00, 0x00, 0x00, 0x00 3304 0x00, 0x00, 0x00, 0x00
3305 }; 3305 };
3306 3306
3307 uint64 header_size = 3307 uint64 header_size =
3308 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 3308 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3309 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 3309 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
3310 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); 3310 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
3311 3311
3312 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 3312 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3313 ASSERT_TRUE(data != NULL); 3313 ASSERT_TRUE(data != nullptr);
3314 3314
3315 test::CompareCharArraysWithHexError("constructed packet", 3315 test::CompareCharArraysWithHexError("constructed packet",
3316 data->data(), data->length(), 3316 data->data(), data->length(),
3317 AsChars(packet), 3317 AsChars(packet),
3318 arraysize(packet)); 3318 arraysize(packet));
3319 } 3319 }
3320 3320
3321 TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) { 3321 TEST_P(QuicFramerTest, Build4ByteSequenceNumberPaddingFramePacket) {
3322 QuicPacketHeader header; 3322 QuicPacketHeader header;
3323 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 3323 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 25 matching lines...) Expand all
3349 0x00, 3349 0x00,
3350 0x00, 0x00, 0x00, 0x00 3350 0x00, 0x00, 0x00, 0x00
3351 }; 3351 };
3352 3352
3353 uint64 header_size = 3353 uint64 header_size =
3354 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 3354 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3355 PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 3355 PACKET_4BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
3356 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); 3356 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
3357 3357
3358 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 3358 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3359 ASSERT_TRUE(data != NULL); 3359 ASSERT_TRUE(data != nullptr);
3360 3360
3361 test::CompareCharArraysWithHexError("constructed packet", 3361 test::CompareCharArraysWithHexError("constructed packet",
3362 data->data(), data->length(), 3362 data->data(), data->length(),
3363 AsChars(packet), 3363 AsChars(packet),
3364 arraysize(packet)); 3364 arraysize(packet));
3365 } 3365 }
3366 3366
3367 TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) { 3367 TEST_P(QuicFramerTest, Build2ByteSequenceNumberPaddingFramePacket) {
3368 QuicPacketHeader header; 3368 QuicPacketHeader header;
3369 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 3369 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 25 matching lines...) Expand all
3395 0x00, 3395 0x00,
3396 0x00, 0x00, 0x00, 0x00 3396 0x00, 0x00, 0x00, 0x00
3397 }; 3397 };
3398 3398
3399 uint64 header_size = 3399 uint64 header_size =
3400 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 3400 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3401 PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 3401 PACKET_2BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
3402 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); 3402 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
3403 3403
3404 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 3404 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3405 ASSERT_TRUE(data != NULL); 3405 ASSERT_TRUE(data != nullptr);
3406 3406
3407 test::CompareCharArraysWithHexError("constructed packet", 3407 test::CompareCharArraysWithHexError("constructed packet",
3408 data->data(), data->length(), 3408 data->data(), data->length(),
3409 AsChars(packet), 3409 AsChars(packet),
3410 arraysize(packet)); 3410 arraysize(packet));
3411 } 3411 }
3412 3412
3413 TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) { 3413 TEST_P(QuicFramerTest, Build1ByteSequenceNumberPaddingFramePacket) {
3414 QuicPacketHeader header; 3414 QuicPacketHeader header;
3415 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 3415 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 25 matching lines...) Expand all
3441 0x00, 3441 0x00,
3442 0x00, 0x00, 0x00, 0x00 3442 0x00, 0x00, 0x00, 0x00
3443 }; 3443 };
3444 3444
3445 uint64 header_size = 3445 uint64 header_size =
3446 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 3446 GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
3447 PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP); 3447 PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP);
3448 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1); 3448 memset(packet + header_size + 1, 0x00, kMaxPacketSize - header_size - 1);
3449 3449
3450 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 3450 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3451 ASSERT_TRUE(data != NULL); 3451 ASSERT_TRUE(data != nullptr);
3452 3452
3453 test::CompareCharArraysWithHexError("constructed packet", 3453 test::CompareCharArraysWithHexError("constructed packet",
3454 data->data(), data->length(), 3454 data->data(), data->length(),
3455 AsChars(packet), 3455 AsChars(packet),
3456 arraysize(packet)); 3456 arraysize(packet));
3457 } 3457 }
3458 3458
3459 TEST_P(QuicFramerTest, BuildStreamFramePacket) { 3459 TEST_P(QuicFramerTest, BuildStreamFramePacket) {
3460 QuicPacketHeader header; 3460 QuicPacketHeader header;
3461 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 3461 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3494 // offset 3494 // offset
3495 0x54, 0x76, 0x10, 0x32, 3495 0x54, 0x76, 0x10, 0x32,
3496 0xDC, 0xFE, 0x98, 0xBA, 3496 0xDC, 0xFE, 0x98, 0xBA,
3497 // data 3497 // data
3498 'h', 'e', 'l', 'l', 3498 'h', 'e', 'l', 'l',
3499 'o', ' ', 'w', 'o', 3499 'o', ' ', 'w', 'o',
3500 'r', 'l', 'd', '!', 3500 'r', 'l', 'd', '!',
3501 }; 3501 };
3502 3502
3503 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 3503 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3504 ASSERT_TRUE(data != NULL); 3504 ASSERT_TRUE(data != nullptr);
3505 3505
3506 test::CompareCharArraysWithHexError("constructed packet", 3506 test::CompareCharArraysWithHexError("constructed packet",
3507 data->data(), data->length(), 3507 data->data(), data->length(),
3508 AsChars(packet), arraysize(packet)); 3508 AsChars(packet), arraysize(packet));
3509 } 3509 }
3510 3510
3511 TEST_P(QuicFramerTest, BuildStreamFramePacketInFecGroup) { 3511 TEST_P(QuicFramerTest, BuildStreamFramePacketInFecGroup) {
3512 QuicPacketHeader header; 3512 QuicPacketHeader header;
3513 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 3513 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
3514 header.public_header.reset_flag = false; 3514 header.public_header.reset_flag = false;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3549 0xDC, 0xFE, 0x98, 0xBA, 3549 0xDC, 0xFE, 0x98, 0xBA,
3550 // data length (since packet is in an FEC group) 3550 // data length (since packet is in an FEC group)
3551 0x0C, 0x00, 3551 0x0C, 0x00,
3552 // data 3552 // data
3553 'h', 'e', 'l', 'l', 3553 'h', 'e', 'l', 'l',
3554 'o', ' ', 'w', 'o', 3554 'o', ' ', 'w', 'o',
3555 'r', 'l', 'd', '!', 3555 'r', 'l', 'd', '!',
3556 }; 3556 };
3557 3557
3558 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 3558 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3559 ASSERT_TRUE(data != NULL); 3559 ASSERT_TRUE(data != nullptr);
3560 3560
3561 test::CompareCharArraysWithHexError("constructed packet", 3561 test::CompareCharArraysWithHexError("constructed packet",
3562 data->data(), data->length(), 3562 data->data(), data->length(),
3563 AsChars(packet), arraysize(packet)); 3563 AsChars(packet), arraysize(packet));
3564 } 3564 }
3565 3565
3566 TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) { 3566 TEST_P(QuicFramerTest, BuildStreamFramePacketWithVersionFlag) {
3567 QuicPacketHeader header; 3567 QuicPacketHeader header;
3568 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 3568 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
3569 header.public_header.reset_flag = false; 3569 header.public_header.reset_flag = false;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3604 0x54, 0x76, 0x10, 0x32, 3604 0x54, 0x76, 0x10, 0x32,
3605 0xDC, 0xFE, 0x98, 0xBA, 3605 0xDC, 0xFE, 0x98, 0xBA,
3606 // data 3606 // data
3607 'h', 'e', 'l', 'l', 3607 'h', 'e', 'l', 'l',
3608 'o', ' ', 'w', 'o', 3608 'o', ' ', 'w', 'o',
3609 'r', 'l', 'd', '!', 3609 'r', 'l', 'd', '!',
3610 }; 3610 };
3611 3611
3612 QuicFramerPeer::SetIsServer(&framer_, false); 3612 QuicFramerPeer::SetIsServer(&framer_, false);
3613 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 3613 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3614 ASSERT_TRUE(data != NULL); 3614 ASSERT_TRUE(data != nullptr);
3615 3615
3616 test::CompareCharArraysWithHexError("constructed packet", 3616 test::CompareCharArraysWithHexError("constructed packet",
3617 data->data(), data->length(), 3617 data->data(), data->length(),
3618 AsChars(packet), arraysize(packet)); 3618 AsChars(packet), arraysize(packet));
3619 } 3619 }
3620 3620
3621 TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) { 3621 TEST_P(QuicFramerTest, BuildVersionNegotiationPacket) {
3622 QuicPacketPublicHeader header; 3622 QuicPacketPublicHeader header;
3623 header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 3623 header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
3624 header.reset_flag = false; 3624 header.reset_flag = false;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3693 0x01, 3693 0x01,
3694 // missing packet delta 3694 // missing packet delta
3695 0x01, 3695 0x01,
3696 // 0 more missing packets in range. 3696 // 0 more missing packets in range.
3697 0x00, 3697 0x00,
3698 // 0 revived packets. 3698 // 0 revived packets.
3699 0x00, 3699 0x00,
3700 }; 3700 };
3701 3701
3702 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 3702 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3703 ASSERT_TRUE(data != NULL); 3703 ASSERT_TRUE(data != nullptr);
3704 3704
3705 test::CompareCharArraysWithHexError("constructed packet", 3705 test::CompareCharArraysWithHexError("constructed packet",
3706 data->data(), data->length(), 3706 data->data(), data->length(),
3707 AsChars(packet), arraysize(packet)); 3707 AsChars(packet), arraysize(packet));
3708 } 3708 }
3709 3709
3710 TEST_P(QuicFramerTest, BuildAckFramePacket) { 3710 TEST_P(QuicFramerTest, BuildAckFramePacket) {
3711 if (version_ <= QUIC_VERSION_22) { 3711 if (version_ <= QUIC_VERSION_22) {
3712 return; 3712 return;
3713 } 3713 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3758 0x01, 3758 0x01,
3759 // missing packet delta 3759 // missing packet delta
3760 0x01, 3760 0x01,
3761 // 0 more missing packets in range. 3761 // 0 more missing packets in range.
3762 0x00, 3762 0x00,
3763 // 0 revived packets. 3763 // 0 revived packets.
3764 0x00, 3764 0x00,
3765 }; 3765 };
3766 3766
3767 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 3767 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
3768 ASSERT_TRUE(data != NULL); 3768 ASSERT_TRUE(data != nullptr);
3769 3769
3770 test::CompareCharArraysWithHexError("constructed packet", 3770 test::CompareCharArraysWithHexError("constructed packet",
3771 data->data(), data->length(), 3771 data->data(), data->length(),
3772 AsChars(packet), arraysize(packet)); 3772 AsChars(packet), arraysize(packet));
3773 } 3773 }
3774 3774
3775 // TODO(jri): Add test for tuncated packets in which the original ack frame had 3775 // TODO(jri): Add test for tuncated packets in which the original ack frame had
3776 // revived packets. (In both the large and small packet cases below). 3776 // revived packets. (In both the large and small packet cases below).
3777 3777
3778 TEST_P(QuicFramerTest, BuildTruncatedAckFrameLargePacketv22) { 3778 TEST_P(QuicFramerTest, BuildTruncatedAckFrameLargePacketv22) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
3876 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 3876 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
3877 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 3877 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
3878 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 3878 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
3879 3879
3880 // 0 revived packets. 3880 // 0 revived packets.
3881 0x00, 3881 0x00,
3882 }; 3882 };
3883 3883
3884 scoped_ptr<QuicPacket> data( 3884 scoped_ptr<QuicPacket> data(
3885 framer_.BuildDataPacket(header, frames, kMaxPacketSize).packet); 3885 framer_.BuildDataPacket(header, frames, kMaxPacketSize).packet);
3886 ASSERT_TRUE(data != NULL); 3886 ASSERT_TRUE(data != nullptr);
3887 3887
3888 test::CompareCharArraysWithHexError("constructed packet", 3888 test::CompareCharArraysWithHexError("constructed packet",
3889 data->data(), data->length(), 3889 data->data(), data->length(),
3890 AsChars(packet), arraysize(packet)); 3890 AsChars(packet), arraysize(packet));
3891 } 3891 }
3892 3892
3893 TEST_P(QuicFramerTest, BuildTruncatedAckFrameLargePacket) { 3893 TEST_P(QuicFramerTest, BuildTruncatedAckFrameLargePacket) {
3894 if (version_ <= QUIC_VERSION_22) { 3894 if (version_ <= QUIC_VERSION_22) {
3895 return; 3895 return;
3896 } 3896 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
3991 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 3991 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
3992 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 3992 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
3993 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 3993 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
3994 3994
3995 // 0 revived packets. 3995 // 0 revived packets.
3996 0x00, 3996 0x00,
3997 }; 3997 };
3998 3998
3999 scoped_ptr<QuicPacket> data( 3999 scoped_ptr<QuicPacket> data(
4000 framer_.BuildDataPacket(header, frames, kMaxPacketSize).packet); 4000 framer_.BuildDataPacket(header, frames, kMaxPacketSize).packet);
4001 ASSERT_TRUE(data != NULL); 4001 ASSERT_TRUE(data != nullptr);
4002 4002
4003 test::CompareCharArraysWithHexError("constructed packet", 4003 test::CompareCharArraysWithHexError("constructed packet",
4004 data->data(), data->length(), 4004 data->data(), data->length(),
4005 AsChars(packet), arraysize(packet)); 4005 AsChars(packet), arraysize(packet));
4006 } 4006 }
4007 4007
4008 4008
4009 TEST_P(QuicFramerTest, BuildTruncatedAckFrameSmallPacketv22) { 4009 TEST_P(QuicFramerTest, BuildTruncatedAckFrameSmallPacketv22) {
4010 if (version_ > QUIC_VERSION_22) { 4010 if (version_ > QUIC_VERSION_22) {
4011 return; 4011 return;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4060 0x06, 4060 0x06,
4061 // {missing packet delta, further missing packets in range} 4061 // {missing packet delta, further missing packets in range}
4062 // 6 nack ranges 4062 // 6 nack ranges
4063 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 4063 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
4064 // 0 revived packets. 4064 // 0 revived packets.
4065 0x00, 4065 0x00,
4066 }; 4066 };
4067 4067
4068 scoped_ptr<QuicPacket> data( 4068 scoped_ptr<QuicPacket> data(
4069 framer_.BuildDataPacket(header, frames, 37u).packet); 4069 framer_.BuildDataPacket(header, frames, 37u).packet);
4070 ASSERT_TRUE(data != NULL); 4070 ASSERT_TRUE(data != nullptr);
4071 // Expect 1 byte unused since at least 2 bytes are needed to fit more nacks. 4071 // Expect 1 byte unused since at least 2 bytes are needed to fit more nacks.
4072 EXPECT_EQ(36u, data->length()); 4072 EXPECT_EQ(36u, data->length());
4073 test::CompareCharArraysWithHexError("constructed packet", 4073 test::CompareCharArraysWithHexError("constructed packet",
4074 data->data(), data->length(), 4074 data->data(), data->length(),
4075 AsChars(packet), arraysize(packet)); 4075 AsChars(packet), arraysize(packet));
4076 } 4076 }
4077 4077
4078 TEST_P(QuicFramerTest, BuildTruncatedAckFrameSmallPacket) { 4078 TEST_P(QuicFramerTest, BuildTruncatedAckFrameSmallPacket) {
4079 if (version_ <= QUIC_VERSION_22) { 4079 if (version_ <= QUIC_VERSION_22) {
4080 return; 4080 return;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4129 0x06, 4129 0x06,
4130 // {missing packet delta, further missing packets in range} 4130 // {missing packet delta, further missing packets in range}
4131 // 6 nack ranges 4131 // 6 nack ranges
4132 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 4132 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
4133 // 0 revived packets. 4133 // 0 revived packets.
4134 0x00, 4134 0x00,
4135 }; 4135 };
4136 4136
4137 scoped_ptr<QuicPacket> data( 4137 scoped_ptr<QuicPacket> data(
4138 framer_.BuildDataPacket(header, frames, 37u).packet); 4138 framer_.BuildDataPacket(header, frames, 37u).packet);
4139 ASSERT_TRUE(data != NULL); 4139 ASSERT_TRUE(data != nullptr);
4140 // Expect 1 byte unused since at least 2 bytes are needed to fit more nacks. 4140 // Expect 1 byte unused since at least 2 bytes are needed to fit more nacks.
4141 EXPECT_EQ(36u, data->length()); 4141 EXPECT_EQ(36u, data->length());
4142 test::CompareCharArraysWithHexError("constructed packet", 4142 test::CompareCharArraysWithHexError("constructed packet",
4143 data->data(), data->length(), 4143 data->data(), data->length(),
4144 AsChars(packet), arraysize(packet)); 4144 AsChars(packet), arraysize(packet));
4145 } 4145 }
4146 4146
4147 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketTCP) { 4147 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketTCP) {
4148 QuicPacketHeader header; 4148 QuicPacketHeader header;
4149 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4149 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
(...skipping 25 matching lines...) Expand all
4175 4175
4176 // frame type (congestion feedback frame) 4176 // frame type (congestion feedback frame)
4177 0x20, 4177 0x20,
4178 // congestion feedback type (TCP) 4178 // congestion feedback type (TCP)
4179 0x00, 4179 0x00,
4180 // TCP receive window 4180 // TCP receive window
4181 0x03, 0x04, 4181 0x03, 0x04,
4182 }; 4182 };
4183 4183
4184 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 4184 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4185 ASSERT_TRUE(data != NULL); 4185 ASSERT_TRUE(data != nullptr);
4186 4186
4187 test::CompareCharArraysWithHexError("constructed packet", 4187 test::CompareCharArraysWithHexError("constructed packet",
4188 data->data(), data->length(), 4188 data->data(), data->length(),
4189 AsChars(packet), arraysize(packet)); 4189 AsChars(packet), arraysize(packet));
4190 } 4190 }
4191 4191
4192 TEST_P(QuicFramerTest, BuildStopWaitingPacket) { 4192 TEST_P(QuicFramerTest, BuildStopWaitingPacket) {
4193 QuicPacketHeader header; 4193 QuicPacketHeader header;
4194 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4194 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4195 header.public_header.reset_flag = false; 4195 header.public_header.reset_flag = false;
(...skipping 25 matching lines...) Expand all
4221 // frame type (stop waiting frame) 4221 // frame type (stop waiting frame)
4222 0x06, 4222 0x06,
4223 // entropy hash of sent packets till least awaiting - 1. 4223 // entropy hash of sent packets till least awaiting - 1.
4224 0x14, 4224 0x14,
4225 // least packet sequence number awaiting an ack, delta from sequence number. 4225 // least packet sequence number awaiting an ack, delta from sequence number.
4226 0x08, 0x00, 0x00, 0x00, 4226 0x08, 0x00, 0x00, 0x00,
4227 0x00, 0x00, 4227 0x00, 0x00,
4228 }; 4228 };
4229 4229
4230 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 4230 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4231 ASSERT_TRUE(data != NULL); 4231 ASSERT_TRUE(data != nullptr);
4232 4232
4233 test::CompareCharArraysWithHexError("constructed packet", 4233 test::CompareCharArraysWithHexError("constructed packet",
4234 data->data(), data->length(), 4234 data->data(), data->length(),
4235 AsChars(packet), arraysize(packet)); 4235 AsChars(packet), arraysize(packet));
4236 } 4236 }
4237 4237
4238 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInvalidFeedback) { 4238 TEST_P(QuicFramerTest, BuildCongestionFeedbackFramePacketInvalidFeedback) {
4239 QuicPacketHeader header; 4239 QuicPacketHeader header;
4240 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4240 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4241 header.public_header.reset_flag = false; 4241 header.public_header.reset_flag = false;
4242 header.public_header.version_flag = false; 4242 header.public_header.version_flag = false;
4243 header.fec_flag = false; 4243 header.fec_flag = false;
4244 header.entropy_flag = false; 4244 header.entropy_flag = false;
4245 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4245 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4246 header.fec_group = 0; 4246 header.fec_group = 0;
4247 4247
4248 QuicCongestionFeedbackFrame congestion_feedback_frame; 4248 QuicCongestionFeedbackFrame congestion_feedback_frame;
4249 congestion_feedback_frame.type = 4249 congestion_feedback_frame.type =
4250 static_cast<CongestionFeedbackType>(kTCP + 1); 4250 static_cast<CongestionFeedbackType>(kTCP + 1);
4251 4251
4252 QuicFrames frames; 4252 QuicFrames frames;
4253 frames.push_back(QuicFrame(&congestion_feedback_frame)); 4253 frames.push_back(QuicFrame(&congestion_feedback_frame));
4254 4254
4255 scoped_ptr<QuicPacket> data; 4255 scoped_ptr<QuicPacket> data;
4256 EXPECT_DFATAL( 4256 EXPECT_DFATAL(
4257 data.reset(BuildDataPacket(header, frames)), 4257 data.reset(BuildDataPacket(header, frames)),
4258 "AppendCongestionFeedbackFrame failed"); 4258 "AppendCongestionFeedbackFrame failed");
4259 ASSERT_TRUE(data == NULL); 4259 ASSERT_TRUE(data == nullptr);
4260 } 4260 }
4261 4261
4262 TEST_P(QuicFramerTest, BuildRstFramePacketQuic) { 4262 TEST_P(QuicFramerTest, BuildRstFramePacketQuic) {
4263 QuicPacketHeader header; 4263 QuicPacketHeader header;
4264 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4264 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4265 header.public_header.reset_flag = false; 4265 header.public_header.reset_flag = false;
4266 header.public_header.version_flag = false; 4266 header.public_header.version_flag = false;
4267 header.fec_flag = false; 4267 header.fec_flag = false;
4268 header.entropy_flag = false; 4268 header.entropy_flag = false;
4269 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4269 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4302 'b', 'e', 'c', 'a', 4302 'b', 'e', 'c', 'a',
4303 'u', 's', 'e', ' ', 4303 'u', 's', 'e', ' ',
4304 'I', ' ', 'c', 'a', 4304 'I', ' ', 'c', 'a',
4305 'n', 4305 'n',
4306 }; 4306 };
4307 4307
4308 QuicFrames frames; 4308 QuicFrames frames;
4309 frames.push_back(QuicFrame(&rst_frame)); 4309 frames.push_back(QuicFrame(&rst_frame));
4310 4310
4311 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 4311 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4312 ASSERT_TRUE(data != NULL); 4312 ASSERT_TRUE(data != nullptr);
4313 4313
4314 test::CompareCharArraysWithHexError("constructed packet", 4314 test::CompareCharArraysWithHexError("constructed packet",
4315 data->data(), data->length(), 4315 data->data(), data->length(),
4316 AsChars(packet), arraysize(packet)); 4316 AsChars(packet), arraysize(packet));
4317 } 4317 }
4318 4318
4319 TEST_P(QuicFramerTest, BuildCloseFramePacket) { 4319 TEST_P(QuicFramerTest, BuildCloseFramePacket) {
4320 QuicPacketHeader header; 4320 QuicPacketHeader header;
4321 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4321 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4322 header.public_header.reset_flag = false; 4322 header.public_header.reset_flag = false;
(...skipping 29 matching lines...) Expand all
4352 // error details length 4352 // error details length
4353 0x0d, 0x00, 4353 0x0d, 0x00,
4354 // error details 4354 // error details
4355 'b', 'e', 'c', 'a', 4355 'b', 'e', 'c', 'a',
4356 'u', 's', 'e', ' ', 4356 'u', 's', 'e', ' ',
4357 'I', ' ', 'c', 'a', 4357 'I', ' ', 'c', 'a',
4358 'n', 4358 'n',
4359 }; 4359 };
4360 4360
4361 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 4361 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4362 ASSERT_TRUE(data != NULL); 4362 ASSERT_TRUE(data != nullptr);
4363 4363
4364 test::CompareCharArraysWithHexError("constructed packet", 4364 test::CompareCharArraysWithHexError("constructed packet",
4365 data->data(), data->length(), 4365 data->data(), data->length(),
4366 AsChars(packet), arraysize(packet)); 4366 AsChars(packet), arraysize(packet));
4367 } 4367 }
4368 4368
4369 TEST_P(QuicFramerTest, BuildGoAwayPacket) { 4369 TEST_P(QuicFramerTest, BuildGoAwayPacket) {
4370 QuicPacketHeader header; 4370 QuicPacketHeader header;
4371 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4371 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4372 header.public_header.reset_flag = false; 4372 header.public_header.reset_flag = false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4405 // error details length 4405 // error details length
4406 0x0d, 0x00, 4406 0x0d, 0x00,
4407 // error details 4407 // error details
4408 'b', 'e', 'c', 'a', 4408 'b', 'e', 'c', 'a',
4409 'u', 's', 'e', ' ', 4409 'u', 's', 'e', ' ',
4410 'I', ' ', 'c', 'a', 4410 'I', ' ', 'c', 'a',
4411 'n', 4411 'n',
4412 }; 4412 };
4413 4413
4414 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 4414 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4415 ASSERT_TRUE(data != NULL); 4415 ASSERT_TRUE(data != nullptr);
4416 4416
4417 test::CompareCharArraysWithHexError("constructed packet", 4417 test::CompareCharArraysWithHexError("constructed packet",
4418 data->data(), data->length(), 4418 data->data(), data->length(),
4419 AsChars(packet), arraysize(packet)); 4419 AsChars(packet), arraysize(packet));
4420 } 4420 }
4421 4421
4422 TEST_P(QuicFramerTest, BuildWindowUpdatePacket) { 4422 TEST_P(QuicFramerTest, BuildWindowUpdatePacket) {
4423 QuicPacketHeader header; 4423 QuicPacketHeader header;
4424 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4424 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4425 header.public_header.reset_flag = false; 4425 header.public_header.reset_flag = false;
(...skipping 25 matching lines...) Expand all
4451 // frame type (window update frame) 4451 // frame type (window update frame)
4452 0x04, 4452 0x04,
4453 // stream id 4453 // stream id
4454 0x04, 0x03, 0x02, 0x01, 4454 0x04, 0x03, 0x02, 0x01,
4455 // byte offset 4455 // byte offset
4456 0x88, 0x77, 0x66, 0x55, 4456 0x88, 0x77, 0x66, 0x55,
4457 0x44, 0x33, 0x22, 0x11, 4457 0x44, 0x33, 0x22, 0x11,
4458 }; 4458 };
4459 4459
4460 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 4460 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4461 ASSERT_TRUE(data != NULL); 4461 ASSERT_TRUE(data != nullptr);
4462 4462
4463 test::CompareCharArraysWithHexError("constructed packet", data->data(), 4463 test::CompareCharArraysWithHexError("constructed packet", data->data(),
4464 data->length(), AsChars(packet), 4464 data->length(), AsChars(packet),
4465 arraysize(packet)); 4465 arraysize(packet));
4466 } 4466 }
4467 4467
4468 TEST_P(QuicFramerTest, BuildBlockedPacket) { 4468 TEST_P(QuicFramerTest, BuildBlockedPacket) {
4469 QuicPacketHeader header; 4469 QuicPacketHeader header;
4470 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4470 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4471 header.public_header.reset_flag = false; 4471 header.public_header.reset_flag = false;
(...skipping 21 matching lines...) Expand all
4493 // private flags(entropy) 4493 // private flags(entropy)
4494 0x01, 4494 0x01,
4495 4495
4496 // frame type (blocked frame) 4496 // frame type (blocked frame)
4497 0x05, 4497 0x05,
4498 // stream id 4498 // stream id
4499 0x04, 0x03, 0x02, 0x01, 4499 0x04, 0x03, 0x02, 0x01,
4500 }; 4500 };
4501 4501
4502 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 4502 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4503 ASSERT_TRUE(data != NULL); 4503 ASSERT_TRUE(data != nullptr);
4504 4504
4505 test::CompareCharArraysWithHexError("constructed packet", data->data(), 4505 test::CompareCharArraysWithHexError("constructed packet", data->data(),
4506 data->length(), AsChars(packet), 4506 data->length(), AsChars(packet),
4507 arraysize(packet)); 4507 arraysize(packet));
4508 } 4508 }
4509 4509
4510 TEST_P(QuicFramerTest, BuildPingPacket) { 4510 TEST_P(QuicFramerTest, BuildPingPacket) {
4511 QuicPacketHeader header; 4511 QuicPacketHeader header;
4512 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4512 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4513 header.public_header.reset_flag = false; 4513 header.public_header.reset_flag = false;
(...skipping 19 matching lines...) Expand all
4533 0x34, 0x12, 4533 0x34, 0x12,
4534 // private flags(entropy) 4534 // private flags(entropy)
4535 0x01, 4535 0x01,
4536 4536
4537 // frame type (ping frame) 4537 // frame type (ping frame)
4538 0x07, 4538 0x07,
4539 }; 4539 };
4540 4540
4541 if (version_ >= QUIC_VERSION_18) { 4541 if (version_ >= QUIC_VERSION_18) {
4542 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames)); 4542 scoped_ptr<QuicPacket> data(BuildDataPacket(header, frames));
4543 ASSERT_TRUE(data != NULL); 4543 ASSERT_TRUE(data != nullptr);
4544 4544
4545 test::CompareCharArraysWithHexError("constructed packet", data->data(), 4545 test::CompareCharArraysWithHexError("constructed packet", data->data(),
4546 data->length(), AsChars(packet), 4546 data->length(), AsChars(packet),
4547 arraysize(packet)); 4547 arraysize(packet));
4548 } else { 4548 } else {
4549 string expected_error = 4549 string expected_error =
4550 "Attempt to add a PingFrame in " + QuicVersionToString(version_); 4550 "Attempt to add a PingFrame in " + QuicVersionToString(version_);
4551 EXPECT_DFATAL(BuildDataPacket(header, frames), 4551 EXPECT_DFATAL(BuildDataPacket(header, frames),
4552 expected_error); 4552 expected_error);
4553 return; 4553 return;
(...skipping 29 matching lines...) Expand all
4583 // nonce proof 4583 // nonce proof
4584 0x89, 0x67, 0x45, 0x23, 4584 0x89, 0x67, 0x45, 0x23,
4585 0x01, 0xEF, 0xCD, 0xAB, 4585 0x01, 0xEF, 0xCD, 0xAB,
4586 // rejected sequence number 4586 // rejected sequence number
4587 0xBC, 0x9A, 0x78, 0x56, 4587 0xBC, 0x9A, 0x78, 0x56,
4588 0x34, 0x12, 0x00, 0x00, 4588 0x34, 0x12, 0x00, 0x00,
4589 }; 4589 };
4590 4590
4591 scoped_ptr<QuicEncryptedPacket> data( 4591 scoped_ptr<QuicEncryptedPacket> data(
4592 framer_.BuildPublicResetPacket(reset_packet)); 4592 framer_.BuildPublicResetPacket(reset_packet));
4593 ASSERT_TRUE(data != NULL); 4593 ASSERT_TRUE(data != nullptr);
4594 4594
4595 test::CompareCharArraysWithHexError("constructed packet", 4595 test::CompareCharArraysWithHexError("constructed packet",
4596 data->data(), data->length(), 4596 data->data(), data->length(),
4597 AsChars(packet), arraysize(packet)); 4597 AsChars(packet), arraysize(packet));
4598 } 4598 }
4599 4599
4600 TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) { 4600 TEST_P(QuicFramerTest, BuildPublicResetPacketWithClientAddress) {
4601 QuicPublicResetPacket reset_packet; 4601 QuicPublicResetPacket reset_packet;
4602 reset_packet.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4602 reset_packet.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4603 reset_packet.public_header.reset_flag = true; 4603 reset_packet.public_header.reset_flag = true;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4635 0xBC, 0x9A, 0x78, 0x56, 4635 0xBC, 0x9A, 0x78, 0x56,
4636 0x34, 0x12, 0x00, 0x00, 4636 0x34, 0x12, 0x00, 0x00,
4637 // client address 4637 // client address
4638 0x02, 0x00, 4638 0x02, 0x00,
4639 0x7F, 0x00, 0x00, 0x01, 4639 0x7F, 0x00, 0x00, 0x01,
4640 0x34, 0x12, 4640 0x34, 0x12,
4641 }; 4641 };
4642 4642
4643 scoped_ptr<QuicEncryptedPacket> data( 4643 scoped_ptr<QuicEncryptedPacket> data(
4644 framer_.BuildPublicResetPacket(reset_packet)); 4644 framer_.BuildPublicResetPacket(reset_packet));
4645 ASSERT_TRUE(data != NULL); 4645 ASSERT_TRUE(data != nullptr);
4646 4646
4647 test::CompareCharArraysWithHexError("constructed packet", 4647 test::CompareCharArraysWithHexError("constructed packet",
4648 data->data(), data->length(), 4648 data->data(), data->length(),
4649 AsChars(packet), arraysize(packet)); 4649 AsChars(packet), arraysize(packet));
4650 } 4650 }
4651 4651
4652 TEST_P(QuicFramerTest, BuildFecPacket) { 4652 TEST_P(QuicFramerTest, BuildFecPacket) {
4653 QuicPacketHeader header; 4653 QuicPacketHeader header;
4654 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4654 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4655 header.public_header.reset_flag = false; 4655 header.public_header.reset_flag = false;
(...skipping 24 matching lines...) Expand all
4680 4680
4681 // redundancy 4681 // redundancy
4682 'a', 'b', 'c', 'd', 4682 'a', 'b', 'c', 'd',
4683 'e', 'f', 'g', 'h', 4683 'e', 'f', 'g', 'h',
4684 'i', 'j', 'k', 'l', 4684 'i', 'j', 'k', 'l',
4685 'm', 'n', 'o', 'p', 4685 'm', 'n', 'o', 'p',
4686 }; 4686 };
4687 4687
4688 scoped_ptr<QuicPacket> data( 4688 scoped_ptr<QuicPacket> data(
4689 framer_.BuildFecPacket(header, fec_data).packet); 4689 framer_.BuildFecPacket(header, fec_data).packet);
4690 ASSERT_TRUE(data != NULL); 4690 ASSERT_TRUE(data != nullptr);
4691 4691
4692 test::CompareCharArraysWithHexError("constructed packet", 4692 test::CompareCharArraysWithHexError("constructed packet",
4693 data->data(), data->length(), 4693 data->data(), data->length(),
4694 AsChars(packet), arraysize(packet)); 4694 AsChars(packet), arraysize(packet));
4695 } 4695 }
4696 4696
4697 TEST_P(QuicFramerTest, EncryptPacket) { 4697 TEST_P(QuicFramerTest, EncryptPacket) {
4698 QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC); 4698 QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC);
4699 unsigned char packet[] = { 4699 unsigned char packet[] = {
4700 // public flags (8 byte connection_id) 4700 // public flags (8 byte connection_id)
(...skipping 16 matching lines...) Expand all
4717 'm', 'n', 'o', 'p', 4717 'm', 'n', 'o', 'p',
4718 }; 4718 };
4719 4719
4720 scoped_ptr<QuicPacket> raw( 4720 scoped_ptr<QuicPacket> raw(
4721 QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false, 4721 QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false,
4722 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, 4722 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion,
4723 PACKET_6BYTE_SEQUENCE_NUMBER)); 4723 PACKET_6BYTE_SEQUENCE_NUMBER));
4724 scoped_ptr<QuicEncryptedPacket> encrypted( 4724 scoped_ptr<QuicEncryptedPacket> encrypted(
4725 framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw)); 4725 framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw));
4726 4726
4727 ASSERT_TRUE(encrypted.get() != NULL); 4727 ASSERT_TRUE(encrypted.get() != nullptr);
4728 EXPECT_TRUE(CheckEncryption(sequence_number, raw.get())); 4728 EXPECT_TRUE(CheckEncryption(sequence_number, raw.get()));
4729 } 4729 }
4730 4730
4731 TEST_P(QuicFramerTest, EncryptPacketWithVersionFlag) { 4731 TEST_P(QuicFramerTest, EncryptPacketWithVersionFlag) {
4732 QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC); 4732 QuicPacketSequenceNumber sequence_number = GG_UINT64_C(0x123456789ABC);
4733 unsigned char packet[] = { 4733 unsigned char packet[] = {
4734 // public flags (version, 8 byte connection_id) 4734 // public flags (version, 8 byte connection_id)
4735 0x3D, 4735 0x3D,
4736 // connection_id 4736 // connection_id
4737 0x10, 0x32, 0x54, 0x76, 4737 0x10, 0x32, 0x54, 0x76,
(...skipping 15 matching lines...) Expand all
4753 'm', 'n', 'o', 'p', 4753 'm', 'n', 'o', 'p',
4754 }; 4754 };
4755 4755
4756 scoped_ptr<QuicPacket> raw( 4756 scoped_ptr<QuicPacket> raw(
4757 QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false, 4757 QuicPacket::NewDataPacket(AsChars(packet), arraysize(packet), false,
4758 PACKET_8BYTE_CONNECTION_ID, kIncludeVersion, 4758 PACKET_8BYTE_CONNECTION_ID, kIncludeVersion,
4759 PACKET_6BYTE_SEQUENCE_NUMBER)); 4759 PACKET_6BYTE_SEQUENCE_NUMBER));
4760 scoped_ptr<QuicEncryptedPacket> encrypted( 4760 scoped_ptr<QuicEncryptedPacket> encrypted(
4761 framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw)); 4761 framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number, *raw));
4762 4762
4763 ASSERT_TRUE(encrypted.get() != NULL); 4763 ASSERT_TRUE(encrypted.get() != nullptr);
4764 EXPECT_TRUE(CheckEncryption(sequence_number, raw.get())); 4764 EXPECT_TRUE(CheckEncryption(sequence_number, raw.get()));
4765 } 4765 }
4766 4766
4767 TEST_P(QuicFramerTest, AckTruncationLargePacket) { 4767 TEST_P(QuicFramerTest, AckTruncationLargePacket) {
4768 QuicPacketHeader header; 4768 QuicPacketHeader header;
4769 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210); 4769 header.public_header.connection_id = GG_UINT64_C(0xFEDCBA9876543210);
4770 header.public_header.reset_flag = false; 4770 header.public_header.reset_flag = false;
4771 header.public_header.version_flag = false; 4771 header.public_header.version_flag = false;
4772 header.fec_flag = false; 4772 header.fec_flag = false;
4773 header.entropy_flag = false; 4773 header.entropy_flag = false;
4774 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC); 4774 header.packet_sequence_number = GG_UINT64_C(0x123456789ABC);
4775 header.fec_group = 0; 4775 header.fec_group = 0;
4776 4776
4777 // Create a packet with just the ack. 4777 // Create a packet with just the ack.
4778 QuicAckFrame ack_frame = MakeAckFrameWithNackRanges(300, 0u); 4778 QuicAckFrame ack_frame = MakeAckFrameWithNackRanges(300, 0u);
4779 QuicFrame frame; 4779 QuicFrame frame;
4780 frame.type = ACK_FRAME; 4780 frame.type = ACK_FRAME;
4781 frame.ack_frame = &ack_frame; 4781 frame.ack_frame = &ack_frame;
4782 QuicFrames frames; 4782 QuicFrames frames;
4783 frames.push_back(frame); 4783 frames.push_back(frame);
4784 4784
4785 // Build an ack packet with truncation due to limit in number of nack ranges. 4785 // Build an ack packet with truncation due to limit in number of nack ranges.
4786 scoped_ptr<QuicPacket> raw_ack_packet( 4786 scoped_ptr<QuicPacket> raw_ack_packet(
4787 framer_.BuildDataPacket(header, frames, kMaxPacketSize).packet); 4787 framer_.BuildDataPacket(header, frames, kMaxPacketSize).packet);
4788 ASSERT_TRUE(raw_ack_packet != NULL); 4788 ASSERT_TRUE(raw_ack_packet != nullptr);
4789 scoped_ptr<QuicEncryptedPacket> ack_packet( 4789 scoped_ptr<QuicEncryptedPacket> ack_packet(
4790 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number, 4790 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number,
4791 *raw_ack_packet)); 4791 *raw_ack_packet));
4792 // Now make sure we can turn our ack packet back into an ack frame. 4792 // Now make sure we can turn our ack packet back into an ack frame.
4793 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet)); 4793 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet));
4794 ASSERT_EQ(1u, visitor_.ack_frames_.size()); 4794 ASSERT_EQ(1u, visitor_.ack_frames_.size());
4795 QuicAckFrame& processed_ack_frame = *visitor_.ack_frames_[0]; 4795 QuicAckFrame& processed_ack_frame = *visitor_.ack_frames_[0];
4796 EXPECT_TRUE(processed_ack_frame.is_truncated); 4796 EXPECT_TRUE(processed_ack_frame.is_truncated);
4797 EXPECT_EQ(510u, processed_ack_frame.largest_observed); 4797 EXPECT_EQ(510u, processed_ack_frame.largest_observed);
4798 ASSERT_EQ(255u, processed_ack_frame.missing_packets.size()); 4798 ASSERT_EQ(255u, processed_ack_frame.missing_packets.size());
(...skipping 22 matching lines...) Expand all
4821 QuicAckFrame ack_frame = MakeAckFrameWithNackRanges(300, 0u); 4821 QuicAckFrame ack_frame = MakeAckFrameWithNackRanges(300, 0u);
4822 QuicFrame frame; 4822 QuicFrame frame;
4823 frame.type = ACK_FRAME; 4823 frame.type = ACK_FRAME;
4824 frame.ack_frame = &ack_frame; 4824 frame.ack_frame = &ack_frame;
4825 QuicFrames frames; 4825 QuicFrames frames;
4826 frames.push_back(frame); 4826 frames.push_back(frame);
4827 4827
4828 // Build an ack packet with truncation due to limit in number of nack ranges. 4828 // Build an ack packet with truncation due to limit in number of nack ranges.
4829 scoped_ptr<QuicPacket> raw_ack_packet( 4829 scoped_ptr<QuicPacket> raw_ack_packet(
4830 framer_.BuildDataPacket(header, frames, 500).packet); 4830 framer_.BuildDataPacket(header, frames, 500).packet);
4831 ASSERT_TRUE(raw_ack_packet != NULL); 4831 ASSERT_TRUE(raw_ack_packet != nullptr);
4832 scoped_ptr<QuicEncryptedPacket> ack_packet( 4832 scoped_ptr<QuicEncryptedPacket> ack_packet(
4833 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number, 4833 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number,
4834 *raw_ack_packet)); 4834 *raw_ack_packet));
4835 // Now make sure we can turn our ack packet back into an ack frame. 4835 // Now make sure we can turn our ack packet back into an ack frame.
4836 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet)); 4836 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet));
4837 ASSERT_EQ(1u, visitor_.ack_frames_.size()); 4837 ASSERT_EQ(1u, visitor_.ack_frames_.size());
4838 QuicAckFrame& processed_ack_frame = *visitor_.ack_frames_[0]; 4838 QuicAckFrame& processed_ack_frame = *visitor_.ack_frames_[0];
4839 EXPECT_TRUE(processed_ack_frame.is_truncated); 4839 EXPECT_TRUE(processed_ack_frame.is_truncated);
4840 EXPECT_EQ(476u, processed_ack_frame.largest_observed); 4840 EXPECT_EQ(476u, processed_ack_frame.largest_observed);
4841 ASSERT_EQ(238u, processed_ack_frame.missing_packets.size()); 4841 ASSERT_EQ(238u, processed_ack_frame.missing_packets.size());
(...skipping 23 matching lines...) Expand all
4865 QuicAckFrame ack_frame = MakeAckFrameWithNackRanges(300, 0u); 4865 QuicAckFrame ack_frame = MakeAckFrameWithNackRanges(300, 0u);
4866 QuicFrame frame; 4866 QuicFrame frame;
4867 frame.type = ACK_FRAME; 4867 frame.type = ACK_FRAME;
4868 frame.ack_frame = &ack_frame; 4868 frame.ack_frame = &ack_frame;
4869 QuicFrames frames; 4869 QuicFrames frames;
4870 frames.push_back(frame); 4870 frames.push_back(frame);
4871 4871
4872 // Build an ack packet with truncation due to limit in number of nack ranges. 4872 // Build an ack packet with truncation due to limit in number of nack ranges.
4873 scoped_ptr<QuicPacket> raw_ack_packet( 4873 scoped_ptr<QuicPacket> raw_ack_packet(
4874 framer_.BuildDataPacket(header, frames, 500).packet); 4874 framer_.BuildDataPacket(header, frames, 500).packet);
4875 ASSERT_TRUE(raw_ack_packet != NULL); 4875 ASSERT_TRUE(raw_ack_packet != nullptr);
4876 scoped_ptr<QuicEncryptedPacket> ack_packet( 4876 scoped_ptr<QuicEncryptedPacket> ack_packet(
4877 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number, 4877 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number,
4878 *raw_ack_packet)); 4878 *raw_ack_packet));
4879 // Now make sure we can turn our ack packet back into an ack frame. 4879 // Now make sure we can turn our ack packet back into an ack frame.
4880 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet)); 4880 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet));
4881 ASSERT_EQ(1u, visitor_.ack_frames_.size()); 4881 ASSERT_EQ(1u, visitor_.ack_frames_.size());
4882 QuicAckFrame& processed_ack_frame = *visitor_.ack_frames_[0]; 4882 QuicAckFrame& processed_ack_frame = *visitor_.ack_frames_[0];
4883 EXPECT_TRUE(processed_ack_frame.is_truncated); 4883 EXPECT_TRUE(processed_ack_frame.is_truncated);
4884 EXPECT_EQ(476u, processed_ack_frame.largest_observed); 4884 EXPECT_EQ(476u, processed_ack_frame.largest_observed);
4885 ASSERT_EQ(238u, processed_ack_frame.missing_packets.size()); 4885 ASSERT_EQ(238u, processed_ack_frame.missing_packets.size());
(...skipping 22 matching lines...) Expand all
4908 } 4908 }
4909 4909
4910 // Create a packet with just the ack. 4910 // Create a packet with just the ack.
4911 QuicFrame frame; 4911 QuicFrame frame;
4912 frame.type = ACK_FRAME; 4912 frame.type = ACK_FRAME;
4913 frame.ack_frame = &ack_frame; 4913 frame.ack_frame = &ack_frame;
4914 QuicFrames frames; 4914 QuicFrames frames;
4915 frames.push_back(frame); 4915 frames.push_back(frame);
4916 4916
4917 scoped_ptr<QuicPacket> raw_ack_packet(BuildDataPacket(header, frames)); 4917 scoped_ptr<QuicPacket> raw_ack_packet(BuildDataPacket(header, frames));
4918 ASSERT_TRUE(raw_ack_packet != NULL); 4918 ASSERT_TRUE(raw_ack_packet != nullptr);
4919 4919
4920 scoped_ptr<QuicEncryptedPacket> ack_packet( 4920 scoped_ptr<QuicEncryptedPacket> ack_packet(
4921 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number, 4921 framer_.EncryptPacket(ENCRYPTION_NONE, header.packet_sequence_number,
4922 *raw_ack_packet)); 4922 *raw_ack_packet));
4923 4923
4924 // Now make sure we can turn our ack packet back into an ack frame. 4924 // Now make sure we can turn our ack packet back into an ack frame.
4925 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet)); 4925 ASSERT_TRUE(framer_.ProcessPacket(*ack_packet));
4926 4926
4927 // Test for clean truncation of the ack by comparing the length of the 4927 // Test for clean truncation of the ack by comparing the length of the
4928 // original packets to the re-serialized packets. 4928 // original packets to the re-serialized packets.
4929 frames.clear(); 4929 frames.clear();
4930 frame.type = ACK_FRAME; 4930 frame.type = ACK_FRAME;
4931 frame.ack_frame = visitor_.ack_frames_[0]; 4931 frame.ack_frame = visitor_.ack_frames_[0];
4932 frames.push_back(frame); 4932 frames.push_back(frame);
4933 4933
4934 size_t original_raw_length = raw_ack_packet->length(); 4934 size_t original_raw_length = raw_ack_packet->length();
4935 raw_ack_packet.reset(BuildDataPacket(header, frames)); 4935 raw_ack_packet.reset(BuildDataPacket(header, frames));
4936 ASSERT_TRUE(raw_ack_packet != NULL); 4936 ASSERT_TRUE(raw_ack_packet != nullptr);
4937 EXPECT_EQ(original_raw_length, raw_ack_packet->length()); 4937 EXPECT_EQ(original_raw_length, raw_ack_packet->length());
4938 ASSERT_TRUE(raw_ack_packet != NULL); 4938 ASSERT_TRUE(raw_ack_packet != nullptr);
4939 } 4939 }
4940 4940
4941 TEST_P(QuicFramerTest, EntropyFlagTest) { 4941 TEST_P(QuicFramerTest, EntropyFlagTest) {
4942 unsigned char packet[] = { 4942 unsigned char packet[] = {
4943 // public flags (8 byte connection_id) 4943 // public flags (8 byte connection_id)
4944 0x3C, 4944 0x3C,
4945 // connection_id 4945 // connection_id
4946 0x10, 0x32, 0x54, 0x76, 4946 0x10, 0x32, 0x54, 0x76,
4947 0x98, 0xBA, 0xDC, 0xFE, 4947 0x98, 0xBA, 0xDC, 0xFE,
4948 // packet sequence number 4948 // packet sequence number
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
5065 EXPECT_CALL(visitor, OnPacketComplete()); 5065 EXPECT_CALL(visitor, OnPacketComplete());
5066 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true)); 5066 EXPECT_CALL(visitor, OnUnauthenticatedPublicHeader(_)).WillOnce(Return(true));
5067 5067
5068 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false); 5068 QuicEncryptedPacket encrypted(AsChars(packet), arraysize(packet), false);
5069 EXPECT_TRUE(framer_.ProcessPacket(encrypted)); 5069 EXPECT_TRUE(framer_.ProcessPacket(encrypted));
5070 EXPECT_EQ(QUIC_NO_ERROR, framer_.error()); 5070 EXPECT_EQ(QUIC_NO_ERROR, framer_.error());
5071 } 5071 }
5072 5072
5073 } // namespace test 5073 } // namespace test
5074 } // namespace net 5074 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer.cc ('k') | net/quic/quic_headers_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698