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

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

Issue 1660593004: Landing Recent QUIC changes until 01/28/2016 18:41 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0202
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 unified diff | 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 »
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_creator.h" 5 #include "net/quic/quic_packet_creator.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 99 }
100 100
101 void SaveSerializedPacket(SerializedPacket* serialized_packet) { 101 void SaveSerializedPacket(SerializedPacket* serialized_packet) {
102 if (serialized_packet == nullptr) { 102 if (serialized_packet == nullptr) {
103 return; 103 return;
104 } 104 }
105 105
106 serialized_packet_ = *serialized_packet; 106 serialized_packet_ = *serialized_packet;
107 serialized_packet_.packet = serialized_packet->packet->Clone(); 107 serialized_packet_.packet = serialized_packet->packet->Clone();
108 delete serialized_packet->packet; 108 delete serialized_packet->packet;
109 serialized_packet->retransmittable_frames.clear();
109 } 110 }
110 111
111 protected: 112 protected:
112 QuicPacketCreatorTest() 113 QuicPacketCreatorTest()
113 : server_framer_(SupportedVersions(GetParam().version), 114 : server_framer_(SupportedVersions(GetParam().version),
114 QuicTime::Zero(), 115 QuicTime::Zero(),
115 Perspective::IS_SERVER), 116 Perspective::IS_SERVER),
116 client_framer_(SupportedVersions(GetParam().version), 117 client_framer_(SupportedVersions(GetParam().version),
117 QuicTime::Zero(), 118 QuicTime::Zero(),
118 Perspective::IS_CLIENT), 119 Perspective::IS_CLIENT),
(...skipping 14 matching lines...) Expand all
133 client_framer_.set_received_entropy_calculator(&entropy_calculator_); 134 client_framer_.set_received_entropy_calculator(&entropy_calculator_);
134 server_framer_.set_visitor(&framer_visitor_); 135 server_framer_.set_visitor(&framer_visitor_);
135 // TODO(ianswett): Fix this test so it uses a non-null encrypter. 136 // TODO(ianswett): Fix this test so it uses a non-null encrypter.
136 FLAGS_quic_never_write_unencrypted_data = false; 137 FLAGS_quic_never_write_unencrypted_data = false;
137 FLAGS_quic_no_unencrypted_fec = false; 138 FLAGS_quic_no_unencrypted_fec = false;
138 } 139 }
139 140
140 ~QuicPacketCreatorTest() override {} 141 ~QuicPacketCreatorTest() override {}
141 142
142 SerializedPacket SerializeAllFrames(const QuicFrames& frames) { 143 SerializedPacket SerializeAllFrames(const QuicFrames& frames) {
143 SerializedPacket packet = 144 SerializedPacket packet = QuicPacketCreatorPeer::SerializeAllFrames(
144 creator_.SerializeAllFrames(frames, buffer_, kMaxPacketSize); 145 &creator_, frames, buffer_, kMaxPacketSize);
145 EXPECT_EQ(QuicPacketCreatorPeer::GetEncryptionLevel(&creator_), 146 EXPECT_EQ(QuicPacketCreatorPeer::GetEncryptionLevel(&creator_),
146 packet.encryption_level); 147 packet.encryption_level);
147 return packet; 148 return packet;
148 } 149 }
149 150
150 void ProcessPacket(QuicEncryptedPacket* encrypted) { 151 void ProcessPacket(QuicEncryptedPacket* encrypted) {
151 server_framer_.ProcessPacket(*encrypted); 152 server_framer_.ProcessPacket(*encrypted);
152 } 153 }
153 154
154 void CheckStreamFrame(const QuicFrame& frame, 155 void CheckStreamFrame(const QuicFrame& frame,
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 EXPECT_TRUE(creator_.HasPendingFrames()); 1201 EXPECT_TRUE(creator_.HasPendingFrames());
1201 EXPECT_EQ(0u, creator_.BytesFree()); 1202 EXPECT_EQ(0u, creator_.BytesFree());
1202 1203
1203 // Packet is full. Creator will flush. 1204 // Packet is full. Creator will flush.
1204 EXPECT_CALL(delegate_, OnSerializedPacket(_)) 1205 EXPECT_CALL(delegate_, OnSerializedPacket(_))
1205 .WillOnce(Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket)); 1206 .WillOnce(Invoke(this, &QuicPacketCreatorTest::SaveSerializedPacket));
1206 EXPECT_FALSE(creator_.AddSavedFrame(QuicFrame(&ack_frame))); 1207 EXPECT_FALSE(creator_.AddSavedFrame(QuicFrame(&ack_frame)));
1207 1208
1208 // Ensure the packet is successfully created. 1209 // Ensure the packet is successfully created.
1209 ASSERT_TRUE(serialized_packet_.packet); 1210 ASSERT_TRUE(serialized_packet_.packet);
1210 ASSERT_TRUE(serialized_packet_.retransmittable_frames); 1211 ASSERT_FALSE(serialized_packet_.retransmittable_frames.empty());
1211 QuicFrames* retransmittable = serialized_packet_.retransmittable_frames; 1212 const QuicFrames& retransmittable = serialized_packet_.retransmittable_frames;
1212 ASSERT_EQ(1u, retransmittable->size()); 1213 ASSERT_EQ(1u, retransmittable.size());
1213 EXPECT_EQ(STREAM_FRAME, (*retransmittable)[0].type); 1214 EXPECT_EQ(STREAM_FRAME, retransmittable[0].type);
1214 ASSERT_TRUE((*retransmittable)[0].stream_frame); 1215 ASSERT_TRUE(retransmittable[0].stream_frame);
1215 ClearSerializedPacket(&serialized_packet_); 1216 ClearSerializedPacket(&serialized_packet_);
1216 1217
1217 EXPECT_FALSE(creator_.HasPendingFrames()); 1218 EXPECT_FALSE(creator_.HasPendingFrames());
1218 EXPECT_EQ(max_plaintext_size - 1219 EXPECT_EQ(max_plaintext_size -
1219 GetPacketHeaderSize( 1220 GetPacketHeaderSize(
1220 creator_.connection_id_length(), 1221 creator_.connection_id_length(),
1221 QuicPacketCreatorPeer::SendVersionInPacket(&creator_), 1222 QuicPacketCreatorPeer::SendVersionInPacket(&creator_),
1222 /*include_path_id=*/false, PACKET_1BYTE_PACKET_NUMBER, 1223 /*include_path_id=*/false, PACKET_1BYTE_PACKET_NUMBER,
1223 NOT_IN_FEC_GROUP), 1224 NOT_IN_FEC_GROUP),
1224 creator_.BytesFree()); 1225 creator_.BytesFree());
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 EXPECT_CALL(delegate_, CloseConnection(QUIC_UNENCRYPTED_FEC_DATA, _)); 1694 EXPECT_CALL(delegate_, CloseConnection(QUIC_UNENCRYPTED_FEC_DATA, _));
1694 char seralized_fec_buffer[kMaxPacketSize]; 1695 char seralized_fec_buffer[kMaxPacketSize];
1695 EXPECT_DFATAL(QuicPacketCreatorPeer::SerializeFec( 1696 EXPECT_DFATAL(QuicPacketCreatorPeer::SerializeFec(
1696 &creator_, seralized_fec_buffer, kMaxPacketSize), 1697 &creator_, seralized_fec_buffer, kMaxPacketSize),
1697 "SerializeFEC must be called with encryption."); 1698 "SerializeFEC must be called with encryption.");
1698 } 1699 }
1699 1700
1700 } // namespace 1701 } // namespace
1701 } // namespace test 1702 } // namespace test
1702 } // namespace net 1703 } // namespace net
OLDNEW
« 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