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

Unified Diff: net/quic/quic_packet_creator_test.cc

Issue 1667003002: Replace QuicEncryptedPacket's fields with equivalents in SerializedPacket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@113395732
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_packet_creator.cc ('k') | net/quic/quic_packet_generator_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_packet_creator_test.cc
diff --git a/net/quic/quic_packet_creator_test.cc b/net/quic/quic_packet_creator_test.cc
index aba6f2e4e76bd4d7568e9fddc98ea500126220d0..2324516e019606a07854dc9101bd9c69023fa60d 100644
--- a/net/quic/quic_packet_creator_test.cc
+++ b/net/quic/quic_packet_creator_test.cc
@@ -102,14 +102,18 @@ class QuicPacketCreatorTest : public ::testing::TestWithParam<TestParams> {
if (serialized_packet == nullptr) {
return;
}
-
+ delete[] serialized_packet_.encrypted_buffer;
serialized_packet_ = *serialized_packet;
- serialized_packet_.packet = serialized_packet->packet->Clone();
- delete serialized_packet->packet;
+ serialized_packet_.encrypted_buffer =
+ QuicUtils::CopyBuffer(*serialized_packet);
serialized_packet->retransmittable_frames.clear();
}
- void DeleteSerializedPacket() { ClearSerializedPacket(&serialized_packet_); }
+ void DeleteSerializedPacket() {
+ delete[] serialized_packet_.encrypted_buffer;
+ serialized_packet_.encrypted_buffer = nullptr;
+ ClearSerializedPacket(&serialized_packet_);
+ }
protected:
QuicPacketCreatorTest()
@@ -140,7 +144,10 @@ class QuicPacketCreatorTest : public ::testing::TestWithParam<TestParams> {
FLAGS_quic_no_unencrypted_fec = false;
}
- ~QuicPacketCreatorTest() override {}
+ ~QuicPacketCreatorTest() override {
+ delete[] serialized_packet_.encrypted_buffer;
+ ClearSerializedPacket(&serialized_packet_);
+ }
SerializedPacket SerializeAllFrames(const QuicFrames& frames) {
SerializedPacket packet = QuicPacketCreatorPeer::SerializeAllFrames(
@@ -151,7 +158,9 @@ class QuicPacketCreatorTest : public ::testing::TestWithParam<TestParams> {
}
void ProcessPacket(const SerializedPacket& packet) {
- server_framer_.ProcessPacket(*packet.packet);
+ QuicEncryptedPacket encrypted_packet(packet.encrypted_buffer,
+ packet.encrypted_length);
+ server_framer_.ProcessPacket(encrypted_packet);
}
void CheckStreamFrame(const QuicFrame& frame,
@@ -261,7 +270,6 @@ TEST_P(QuicPacketCreatorTest, SerializeFrames) {
EXPECT_CALL(framer_visitor_, OnPacketComplete());
}
ProcessPacket(serialized);
- delete serialized.packet;
}
}
@@ -395,7 +403,7 @@ TEST_P(QuicPacketCreatorTest, ChangeSequenceNumberLengthMidPacket) {
.WillRepeatedly(
Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket));
creator_.Flush();
- ASSERT_TRUE(serialized_packet_.packet);
+ ASSERT_TRUE(serialized_packet_.encrypted_buffer);
EXPECT_EQ(PACKET_1BYTE_PACKET_NUMBER,
serialized_packet_.packet_number_length);
@@ -427,7 +435,7 @@ TEST_P(QuicPacketCreatorTest, ChangeSequenceNumberLengthMidPacket) {
// Ensure the packet is successfully created.
creator_.Flush();
- ASSERT_TRUE(serialized_packet_.packet);
+ ASSERT_TRUE(serialized_packet_.encrypted_buffer);
EXPECT_EQ(PACKET_4BYTE_PACKET_NUMBER,
serialized_packet_.packet_number_length);
@@ -596,7 +604,6 @@ TEST_P(QuicPacketCreatorTest, ReserializeFramesWithSequenceNumberLength) {
EXPECT_CALL(framer_visitor_, OnPacketComplete());
}
ProcessPacket(serialized);
- delete serialized.packet;
delete stream_frame;
}
@@ -621,7 +628,6 @@ TEST_P(QuicPacketCreatorTest, ReserializeCryptoFrameWithForwardSecurity) {
serialized = serialized_packet_;
}
EXPECT_EQ(ENCRYPTION_NONE, serialized.encryption_level);
- delete serialized.packet;
delete stream_frame;
}
@@ -646,7 +652,6 @@ TEST_P(QuicPacketCreatorTest, ReserializeFrameWithForwardSecurity) {
serialized = serialized_packet_;
}
EXPECT_EQ(ENCRYPTION_FORWARD_SECURE, serialized.encryption_level);
- delete serialized.packet;
delete stream_frame;
}
@@ -671,8 +676,7 @@ TEST_P(QuicPacketCreatorTest, ReserializeFramesWithPadding) {
if (FLAGS_quic_retransmit_via_onserializedpacket) {
serialized = serialized_packet_;
}
- EXPECT_EQ(kDefaultMaxPacketSize, serialized.packet->length());
- delete serialized.packet;
+ EXPECT_EQ(kDefaultMaxPacketSize, serialized.encrypted_length);
delete frame.stream_frame;
}
@@ -712,12 +716,11 @@ TEST_P(QuicPacketCreatorTest, ReserializeFramesWithFullPacketAndPadding) {
// will not be padded.
if (bytes_free < 3) {
EXPECT_EQ(kDefaultMaxPacketSize - bytes_free,
- serialized.packet->length());
+ serialized.encrypted_length);
} else {
- EXPECT_EQ(kDefaultMaxPacketSize, serialized.packet->length());
+ EXPECT_EQ(kDefaultMaxPacketSize, serialized.encrypted_length);
}
- delete serialized.packet;
delete frame.stream_frame;
frames_.clear();
}
@@ -745,7 +748,6 @@ TEST_P(QuicPacketCreatorTest, SerializeConnectionClose) {
EXPECT_CALL(framer_visitor_, OnPacketComplete());
ProcessPacket(serialized);
- delete serialized.packet;
}
TEST_P(QuicPacketCreatorTest, SwitchFecOnOffWithGroupInProgress) {
@@ -914,7 +916,7 @@ TEST_P(QuicPacketCreatorTest, StreamFrameConsumption) {
EXPECT_CALL(delegate_, OnSerializedPacket(_))
.WillOnce(Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket));
creator_.Flush();
- ASSERT_TRUE(serialized_packet_.packet);
+ ASSERT_TRUE(serialized_packet_.encrypted_buffer);
DeleteSerializedPacket();
}
}
@@ -966,7 +968,7 @@ TEST_P(QuicPacketCreatorTest, StreamFrameConsumptionWithFec) {
}
}
creator_.Flush();
- ASSERT_TRUE(serialized_packet_.packet);
+ ASSERT_TRUE(serialized_packet_.encrypted_buffer);
DeleteSerializedPacket();
}
}
@@ -994,15 +996,15 @@ TEST_P(QuicPacketCreatorTest, CryptoStreamFramePacketPadding) {
size_t bytes_consumed = frame.stream_frame->frame_length;
EXPECT_LT(0u, bytes_consumed);
creator_.Flush();
- ASSERT_TRUE(serialized_packet_.packet);
+ ASSERT_TRUE(serialized_packet_.encrypted_buffer);
// If there is not enough space in the packet to fit a padding frame
// (1 byte) and to expand the stream frame (another 2 bytes) the packet
// will not be padded.
if (bytes_free < 3) {
EXPECT_EQ(kDefaultMaxPacketSize - bytes_free,
- serialized_packet_.packet->length());
+ serialized_packet_.encrypted_length);
} else {
- EXPECT_EQ(kDefaultMaxPacketSize, serialized_packet_.packet->length());
+ EXPECT_EQ(kDefaultMaxPacketSize, serialized_packet_.encrypted_length);
}
DeleteSerializedPacket();
}
@@ -1031,12 +1033,12 @@ TEST_P(QuicPacketCreatorTest, NonCryptoStreamFramePacketNonPadding) {
size_t bytes_consumed = frame.stream_frame->frame_length;
EXPECT_LT(0u, bytes_consumed);
creator_.Flush();
- ASSERT_TRUE(serialized_packet_.packet);
+ ASSERT_TRUE(serialized_packet_.encrypted_buffer);
if (bytes_free > 0) {
EXPECT_EQ(kDefaultMaxPacketSize - bytes_free,
- serialized_packet_.packet->length());
+ serialized_packet_.encrypted_length);
} else {
- EXPECT_EQ(kDefaultMaxPacketSize, serialized_packet_.packet->length());
+ EXPECT_EQ(kDefaultMaxPacketSize, serialized_packet_.encrypted_length);
}
DeleteSerializedPacket();
}
@@ -1138,7 +1140,6 @@ TEST_P(QuicPacketCreatorTest, SerializeFrame) {
ProcessPacket(serialized);
EXPECT_EQ(GetParam().version_serialization,
header.public_header.version_flag);
- delete serialized.packet;
}
TEST_P(QuicPacketCreatorTest, ConsumeDataLargerThanOneStreamFrame) {
@@ -1209,7 +1210,7 @@ TEST_P(QuicPacketCreatorTest, AddFrameAndFlush) {
EXPECT_FALSE(creator_.AddSavedFrame(QuicFrame(&ack_frame)));
// Ensure the packet is successfully created.
- ASSERT_TRUE(serialized_packet_.packet);
+ ASSERT_TRUE(serialized_packet_.encrypted_buffer);
ASSERT_FALSE(serialized_packet_.retransmittable_frames.empty());
const QuicFrames& retransmittable = serialized_packet_.retransmittable_frames;
ASSERT_EQ(1u, retransmittable.size());
@@ -1265,9 +1266,9 @@ TEST_P(QuicPacketCreatorTest, SerializeTruncatedAckFrameWithLargePacketSize) {
.WillOnce(Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket));
size_t est_packet_size = creator_.PacketSize();
creator_.Flush();
- ASSERT_TRUE(serialized_packet_.packet);
+ ASSERT_TRUE(serialized_packet_.encrypted_buffer);
EXPECT_EQ(est_packet_size, client_framer_.GetMaxPlaintextSize(
- serialized_packet_.packet->length()));
+ serialized_packet_.encrypted_length));
DeleteSerializedPacket();
}
@@ -1303,9 +1304,9 @@ TEST_P(QuicPacketCreatorTest, SerializeTruncatedAckFrameWithSmallPacketSize) {
EXPECT_CALL(delegate_, OnSerializedPacket(_))
.WillOnce(Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket));
creator_.Flush();
- ASSERT_TRUE(serialized_packet_.packet);
+ ASSERT_TRUE(serialized_packet_.encrypted_buffer);
EXPECT_GE(est_packet_size, client_framer_.GetMaxPlaintextSize(
- serialized_packet_.packet->length()));
+ serialized_packet_.encrypted_length));
DeleteSerializedPacket();
}
@@ -1324,7 +1325,6 @@ TEST_P(QuicPacketCreatorTest, EntropyFlag) {
uint8_t rest_of_hash = serialized.entropy_hash & ~(1 << ((j + 1) % 8));
EXPECT_EQ(expected_rand_bool, observed_rand_bool);
EXPECT_EQ(0, rest_of_hash);
- delete serialized.packet;
}
// After 64 calls, BoolSource will refresh the bucket - make sure it does.
mock_random_.ChangeValue();
« no previous file with comments | « net/quic/quic_packet_creator.cc ('k') | net/quic/quic_packet_generator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698