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

Unified Diff: net/quic/quic_packet_generator_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_test.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_packet_generator_test.cc
diff --git a/net/quic/quic_packet_generator_test.cc b/net/quic/quic_packet_generator_test.cc
index b0986ec295af1816fd6baf60c620558cc4cc03a9..e25b649a4f0cd82fe859da200649ec8184b8383e 100644
--- a/net/quic/quic_packet_generator_test.cc
+++ b/net/quic/quic_packet_generator_test.cc
@@ -124,15 +124,15 @@ class QuicPacketGeneratorTest : public ::testing::TestWithParam<FecSendPolicy> {
~QuicPacketGeneratorTest() override {
for (SerializedPacket& packet : packets_) {
+ delete[] packet.encrypted_buffer;
QuicUtils::ClearSerializedPacket(&packet);
}
}
void SavePacket(SerializedPacket* packet) {
+ packet->encrypted_buffer = QuicUtils::CopyBuffer(*packet);
packets_.push_back(*packet);
- ASSERT_FALSE(packet->packet->owns_buffer());
- scoped_ptr<QuicEncryptedPacket> encrypted_deleter(packets_.back().packet);
- packets_.back().packet = packets_.back().packet->Clone();
+ packet->encrypted_buffer = nullptr;
packet->retransmittable_frames.clear();
}
@@ -165,8 +165,9 @@ class QuicPacketGeneratorTest : public ::testing::TestWithParam<FecSendPolicy> {
packet.retransmittable_frames.size());
}
- ASSERT_TRUE(packet.packet != nullptr);
- ASSERT_TRUE(simple_framer_.ProcessPacket(*packet.packet));
+ ASSERT_TRUE(packet.encrypted_buffer != nullptr);
+ ASSERT_TRUE(simple_framer_.ProcessPacket(
+ QuicEncryptedPacket(packet.encrypted_buffer, packet.encrypted_length)));
EXPECT_EQ(num_frames, simple_framer_.num_frames());
EXPECT_EQ(contents.num_ack_frames, simple_framer_.ack_frames().size());
EXPECT_EQ(contents.num_connection_close_frames,
@@ -191,8 +192,9 @@ class QuicPacketGeneratorTest : public ::testing::TestWithParam<FecSendPolicy> {
const SerializedPacket& packet = packets_[packet_index];
ASSERT_FALSE(packet.retransmittable_frames.empty());
EXPECT_EQ(1u, packet.retransmittable_frames.size());
- ASSERT_TRUE(packet.packet != nullptr);
- ASSERT_TRUE(simple_framer_.ProcessPacket(*packet.packet));
+ ASSERT_TRUE(packet.encrypted_buffer != nullptr);
+ ASSERT_TRUE(simple_framer_.ProcessPacket(
+ QuicEncryptedPacket(packet.encrypted_buffer, packet.encrypted_length)));
EXPECT_EQ(1u, simple_framer_.num_frames());
EXPECT_EQ(1u, simple_framer_.stream_frames().size());
}
@@ -207,8 +209,9 @@ class QuicPacketGeneratorTest : public ::testing::TestWithParam<FecSendPolicy> {
ASSERT_GT(packets_.size(), packet_index);
const SerializedPacket& packet = packets_[packet_index];
ASSERT_TRUE(packet.retransmittable_frames.empty());
- ASSERT_TRUE(packet.packet != nullptr);
- ASSERT_TRUE(simple_framer_.ProcessPacket(*packet.packet));
+ ASSERT_TRUE(packet.encrypted_buffer != nullptr);
+ ASSERT_TRUE(simple_framer_.ProcessPacket(
+ QuicEncryptedPacket(packet.encrypted_buffer, packet.encrypted_length)));
EXPECT_TRUE(simple_framer_.header().fec_flag);
}
@@ -415,7 +418,7 @@ TEST_P(QuicPacketGeneratorTest, ConsumeData_Handshake) {
ASSERT_EQ(1u, packets_.size());
ASSERT_EQ(kDefaultMaxPacketSize, generator_.GetMaxPacketLength());
- EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].packet->length());
+ EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].encrypted_length);
}
TEST_P(QuicPacketGeneratorTest, ConsumeData_EmptyData) {
@@ -1415,8 +1418,8 @@ TEST_P(QuicPacketGeneratorTest, SetMaxPacketLength_Initial) {
// ensure that |max_packet_length_| does not get changed incorrectly by the
// generator after first packet is serialized.
ASSERT_EQ(3u, packets_.size());
- EXPECT_EQ(packet_len, packets_[0].packet->length());
- EXPECT_EQ(packet_len, packets_[1].packet->length());
+ EXPECT_EQ(packet_len, packets_[0].encrypted_length);
+ EXPECT_EQ(packet_len, packets_[1].encrypted_length);
CheckAllPacketsHaveSingleStreamFrame();
}
@@ -1463,8 +1466,8 @@ TEST_P(QuicPacketGeneratorTest, SetMaxPacketLength_Middle) {
// We expect first data chunk to get fragmented, but the second one to fit
// into a single packet.
ASSERT_EQ(3u, packets_.size());
- EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].packet->length());
- EXPECT_LE(kDefaultMaxPacketSize, packets_[2].packet->length());
+ EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].encrypted_length);
+ EXPECT_LE(kDefaultMaxPacketSize, packets_[2].encrypted_length);
CheckAllPacketsHaveSingleStreamFrame();
}
@@ -1515,7 +1518,7 @@ TEST_P(QuicPacketGeneratorTest, SetMaxPacketLength_Midpacket) {
// We expect the first packet to contain two frames, and to not reflect the
// packet size change.
ASSERT_EQ(1u, packets_.size());
- EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].packet->length());
+ EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].encrypted_length);
PacketContents contents;
contents.num_stream_frames = 2;
@@ -1575,8 +1578,8 @@ TEST_P(QuicPacketGeneratorTest, SetMaxPacketLength_MidpacketFlush) {
// We expect the first packet to be underfilled, and the second packet be up
// to the new max packet size.
ASSERT_EQ(2u, packets_.size());
- EXPECT_GT(kDefaultMaxPacketSize, packets_[0].packet->length());
- EXPECT_EQ(packet_len, packets_[1].packet->length());
+ EXPECT_GT(kDefaultMaxPacketSize, packets_[0].encrypted_length);
+ EXPECT_EQ(packet_len, packets_[1].encrypted_length);
CheckAllPacketsHaveSingleStreamFrame();
}
@@ -1596,7 +1599,7 @@ TEST_P(QuicPacketGeneratorTest, GenerateMtuDiscoveryPacket_Simple) {
EXPECT_FALSE(generator_.HasQueuedFrames());
ASSERT_EQ(1u, packets_.size());
- EXPECT_EQ(target_mtu, packets_[0].packet->length());
+ EXPECT_EQ(target_mtu, packets_[0].encrypted_length);
PacketContents contents;
contents.num_mtu_discovery_frames = 1;
@@ -1643,9 +1646,9 @@ TEST_P(QuicPacketGeneratorTest, GenerateMtuDiscoveryPacket_SurroundedByData) {
EXPECT_FALSE(generator_.HasQueuedFrames());
ASSERT_EQ(5u, packets_.size());
- EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].packet->length());
- EXPECT_EQ(target_mtu, packets_[2].packet->length());
- EXPECT_EQ(kDefaultMaxPacketSize, packets_[3].packet->length());
+ EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].encrypted_length);
+ EXPECT_EQ(target_mtu, packets_[2].encrypted_length);
+ EXPECT_EQ(kDefaultMaxPacketSize, packets_[3].encrypted_length);
PacketContents probe_contents;
probe_contents.num_mtu_discovery_frames = 1;
« no previous file with comments | « net/quic/quic_packet_creator_test.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698