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

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

Issue 1904213002: QUIC: support diversified keys with version 33. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hkdf
Patch Set: Rebase Created 4 years, 7 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_packet_generator.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_packet_generator.h" 5 #include "net/quic/quic_packet_generator.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 CheckPacketContains(contents, 0); 443 CheckPacketContains(contents, 0);
444 } 444 }
445 445
446 TEST_F(QuicPacketGeneratorTest, ConsumeData_FramesPreviouslyQueued) { 446 TEST_F(QuicPacketGeneratorTest, ConsumeData_FramesPreviouslyQueued) {
447 // Set the packet size be enough for two stream frames with 0 stream offset, 447 // Set the packet size be enough for two stream frames with 0 stream offset,
448 // but not enough for a stream frame of 0 offset and one with non-zero offset. 448 // but not enough for a stream frame of 0 offset and one with non-zero offset.
449 size_t length = 449 size_t length =
450 NullEncrypter().GetCiphertextSize(0) + 450 NullEncrypter().GetCiphertextSize(0) +
451 GetPacketHeaderSize( 451 GetPacketHeaderSize(
452 creator_->connection_id_length(), kIncludeVersion, !kIncludePathId, 452 creator_->connection_id_length(), kIncludeVersion, !kIncludePathId,
453 !kIncludeDiversificationNonce,
453 QuicPacketCreatorPeer::NextPacketNumberLength(creator_)) + 454 QuicPacketCreatorPeer::NextPacketNumberLength(creator_)) +
454 // Add an extra 3 bytes for the payload and 1 byte so BytesFree is larger 455 // Add an extra 3 bytes for the payload and 1 byte so BytesFree is larger
455 // than the GetMinStreamFrameSize. 456 // than the GetMinStreamFrameSize.
456 QuicFramer::GetMinStreamFrameSize(1, 0, false) + 3 + 457 QuicFramer::GetMinStreamFrameSize(1, 0, false) + 3 +
457 QuicFramer::GetMinStreamFrameSize(1, 0, true) + 1; 458 QuicFramer::GetMinStreamFrameSize(1, 0, true) + 1;
458 generator_.SetMaxPacketLength(length); 459 generator_.SetMaxPacketLength(length);
459 delegate_.SetCanWriteAnything(); 460 delegate_.SetCanWriteAnything();
460 { 461 {
461 InSequence dummy; 462 InSequence dummy;
462 EXPECT_CALL(delegate_, OnSerializedPacket(_)) 463 EXPECT_CALL(delegate_, OnSerializedPacket(_))
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 // The second should have the remainder of the stream data. 569 // The second should have the remainder of the stream data.
569 PacketContents contents2; 570 PacketContents contents2;
570 contents2.num_goaway_frames = 1; 571 contents2.num_goaway_frames = 1;
571 contents2.num_stream_frames = 1; 572 contents2.num_stream_frames = 1;
572 CheckPacketContains(contents2, 1); 573 CheckPacketContains(contents2, 1);
573 } 574 }
574 575
575 TEST_F(QuicPacketGeneratorTest, TestConnectionIdLength) { 576 TEST_F(QuicPacketGeneratorTest, TestConnectionIdLength) {
576 generator_.SetConnectionIdLength(0); 577 generator_.SetConnectionIdLength(0);
577 EXPECT_EQ(PACKET_0BYTE_CONNECTION_ID, creator_->connection_id_length()); 578 EXPECT_EQ(PACKET_0BYTE_CONNECTION_ID, creator_->connection_id_length());
578 generator_.SetConnectionIdLength(1); 579
579 EXPECT_EQ(PACKET_1BYTE_CONNECTION_ID, creator_->connection_id_length()); 580 for (size_t i = 1; i < 10; i++) {
580 generator_.SetConnectionIdLength(2); 581 generator_.SetConnectionIdLength(i);
581 EXPECT_EQ(PACKET_4BYTE_CONNECTION_ID, creator_->connection_id_length()); 582 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, creator_->connection_id_length());
582 generator_.SetConnectionIdLength(3); 583 }
583 EXPECT_EQ(PACKET_4BYTE_CONNECTION_ID, creator_->connection_id_length());
584 generator_.SetConnectionIdLength(4);
585 EXPECT_EQ(PACKET_4BYTE_CONNECTION_ID, creator_->connection_id_length());
586 generator_.SetConnectionIdLength(5);
587 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, creator_->connection_id_length());
588 generator_.SetConnectionIdLength(6);
589 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, creator_->connection_id_length());
590 generator_.SetConnectionIdLength(7);
591 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, creator_->connection_id_length());
592 generator_.SetConnectionIdLength(8);
593 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, creator_->connection_id_length());
594 generator_.SetConnectionIdLength(9);
595 EXPECT_EQ(PACKET_8BYTE_CONNECTION_ID, creator_->connection_id_length());
596 } 584 }
597 585
598 // Test whether SetMaxPacketLength() works in the situation when the queue is 586 // Test whether SetMaxPacketLength() works in the situation when the queue is
599 // empty, and we send three packets worth of data. 587 // empty, and we send three packets worth of data.
600 TEST_F(QuicPacketGeneratorTest, SetMaxPacketLength_Initial) { 588 TEST_F(QuicPacketGeneratorTest, SetMaxPacketLength_Initial) {
601 delegate_.SetCanWriteAnything(); 589 delegate_.SetCanWriteAnything();
602 590
603 // Send enough data for three packets. 591 // Send enough data for three packets.
604 size_t data_len = 3 * kDefaultMaxPacketSize + 1; 592 size_t data_len = 3 * kDefaultMaxPacketSize + 1;
605 size_t packet_len = kDefaultMaxPacketSize + 100; 593 size_t packet_len = kDefaultMaxPacketSize + 100;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 EXPECT_CALL(delegate_, OnSerializedPacket(_)) 853 EXPECT_CALL(delegate_, OnSerializedPacket(_))
866 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket)); 854 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket));
867 generator_.FlushAllQueuedFrames(); 855 generator_.FlushAllQueuedFrames();
868 EXPECT_FALSE(generator_.HasQueuedFrames()); 856 EXPECT_FALSE(generator_.HasQueuedFrames());
869 generator_.SetCurrentPath(kTestPathId1, 1, 0); 857 generator_.SetCurrentPath(kTestPathId1, 1, 0);
870 EXPECT_EQ(kTestPathId1, QuicPacketCreatorPeer::GetCurrentPath(creator_)); 858 EXPECT_EQ(kTestPathId1, QuicPacketCreatorPeer::GetCurrentPath(creator_));
871 } 859 }
872 860
873 } // namespace test 861 } // namespace test
874 } // namespace net 862 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_packet_generator.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698