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

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

Issue 413403008: Remove QUIC_VERSION_15 now that Chrome Stable supports QUIC_VERSION_16. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0723
Patch Set: Created 6 years, 4 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_test.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 "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "net/quic/crypto/null_encrypter.h" 8 #include "net/quic/crypto/null_encrypter.h"
9 #include "net/quic/crypto/quic_decrypter.h" 9 #include "net/quic/crypto/quic_decrypter.h"
10 #include "net/quic/crypto/quic_encrypter.h" 10 #include "net/quic/crypto/quic_encrypter.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 MockEntropyCalculator entropy_calculator_; 144 MockEntropyCalculator entropy_calculator_;
145 }; 145 };
146 146
147 // Run all packet creator tests with all supported versions of QUIC, and with 147 // Run all packet creator tests with all supported versions of QUIC, and with
148 // and without version in the packet header. 148 // and without version in the packet header.
149 INSTANTIATE_TEST_CASE_P(QuicPacketCreatorTests, 149 INSTANTIATE_TEST_CASE_P(QuicPacketCreatorTests,
150 QuicPacketCreatorTest, 150 QuicPacketCreatorTest,
151 ::testing::ValuesIn(GetTestParams())); 151 ::testing::ValuesIn(GetTestParams()));
152 152
153 TEST_P(QuicPacketCreatorTest, SerializeFrames) { 153 TEST_P(QuicPacketCreatorTest, SerializeFrames) {
154 frames_.push_back(QuicFrame(new QuicAckFrame(MakeAckFrame(0u, 0u)))); 154 frames_.push_back(QuicFrame(new QuicAckFrame(MakeAckFrame(0u))));
155 frames_.push_back(QuicFrame(new QuicStreamFrame(0u, false, 0u, IOVector()))); 155 frames_.push_back(QuicFrame(new QuicStreamFrame(0u, false, 0u, IOVector())));
156 frames_.push_back(QuicFrame(new QuicStreamFrame(0u, true, 0u, IOVector()))); 156 frames_.push_back(QuicFrame(new QuicStreamFrame(0u, true, 0u, IOVector())));
157 SerializedPacket serialized = creator_.SerializeAllFrames(frames_); 157 SerializedPacket serialized = creator_.SerializeAllFrames(frames_);
158 delete frames_[0].ack_frame; 158 delete frames_[0].ack_frame;
159 delete frames_[1].stream_frame; 159 delete frames_[1].stream_frame;
160 delete frames_[2].stream_frame; 160 delete frames_[2].stream_frame;
161 161
162 { 162 {
163 InSequence s; 163 InSequence s;
164 EXPECT_CALL(framer_visitor_, OnPacket()); 164 EXPECT_CALL(framer_visitor_, OnPacket());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); 216 EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_));
217 EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); 217 EXPECT_CALL(framer_visitor_, OnPacketHeader(_));
218 EXPECT_CALL(framer_visitor_, OnFecData(_)); 218 EXPECT_CALL(framer_visitor_, OnFecData(_));
219 EXPECT_CALL(framer_visitor_, OnPacketComplete()); 219 EXPECT_CALL(framer_visitor_, OnPacketComplete());
220 } 220 }
221 ProcessPacket(serialized.packet); 221 ProcessPacket(serialized.packet);
222 delete serialized.packet; 222 delete serialized.packet;
223 } 223 }
224 224
225 TEST_P(QuicPacketCreatorTest, SerializeChangingSequenceNumberLength) { 225 TEST_P(QuicPacketCreatorTest, SerializeChangingSequenceNumberLength) {
226 frames_.push_back(QuicFrame(new QuicAckFrame(MakeAckFrame(0u, 0u)))); 226 frames_.push_back(QuicFrame(new QuicAckFrame(MakeAckFrame(0u))));
227 creator_.AddSavedFrame(frames_[0]); 227 creator_.AddSavedFrame(frames_[0]);
228 creator_.set_next_sequence_number_length(PACKET_4BYTE_SEQUENCE_NUMBER); 228 creator_.set_next_sequence_number_length(PACKET_4BYTE_SEQUENCE_NUMBER);
229 SerializedPacket serialized = creator_.SerializePacket(); 229 SerializedPacket serialized = creator_.SerializePacket();
230 // The sequence number length will not change mid-packet. 230 // The sequence number length will not change mid-packet.
231 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, serialized.sequence_number_length); 231 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, serialized.sequence_number_length);
232 232
233 { 233 {
234 InSequence s; 234 InSequence s;
235 EXPECT_CALL(framer_visitor_, OnPacket()); 235 EXPECT_CALL(framer_visitor_, OnPacket());
236 EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_)); 236 EXPECT_CALL(framer_visitor_, OnUnauthenticatedPublicHeader(_));
(...skipping 20 matching lines...) Expand all
257 EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_)); 257 EXPECT_CALL(framer_visitor_, OnDecryptedPacket(_));
258 EXPECT_CALL(framer_visitor_, OnPacketHeader(_)); 258 EXPECT_CALL(framer_visitor_, OnPacketHeader(_));
259 EXPECT_CALL(framer_visitor_, OnAckFrame(_)); 259 EXPECT_CALL(framer_visitor_, OnAckFrame(_));
260 EXPECT_CALL(framer_visitor_, OnPacketComplete()); 260 EXPECT_CALL(framer_visitor_, OnPacketComplete());
261 } 261 }
262 ProcessPacket(serialized.packet); 262 ProcessPacket(serialized.packet);
263 delete serialized.packet; 263 delete serialized.packet;
264 } 264 }
265 265
266 TEST_P(QuicPacketCreatorTest, ChangeSequenceNumberLengthMidPacket) { 266 TEST_P(QuicPacketCreatorTest, ChangeSequenceNumberLengthMidPacket) {
267 if (GetParam().version <= QUIC_VERSION_15) {
268 return;
269 }
270 // Changing the sequence number length with queued frames in the creator 267 // Changing the sequence number length with queued frames in the creator
271 // should hold the change until after any currently queued frames are 268 // should hold the change until after any currently queued frames are
272 // serialized. 269 // serialized.
273 270
274 // Packet 1. 271 // Packet 1.
275 // Queue a frame in the creator. 272 // Queue a frame in the creator.
276 EXPECT_FALSE(creator_.HasPendingFrames()); 273 EXPECT_FALSE(creator_.HasPendingFrames());
277 QuicFrame ack_frame = QuicFrame(new QuicAckFrame(MakeAckFrame(0u, 0u))); 274 QuicFrame ack_frame = QuicFrame(new QuicAckFrame(MakeAckFrame(0u)));
278 creator_.AddSavedFrame(ack_frame); 275 creator_.AddSavedFrame(ack_frame);
279 276
280 // Now change sequence number length. 277 // Now change sequence number length.
281 creator_.set_next_sequence_number_length(PACKET_4BYTE_SEQUENCE_NUMBER); 278 creator_.set_next_sequence_number_length(PACKET_4BYTE_SEQUENCE_NUMBER);
282 279
283 // Add a STOP_WAITING frame since it contains a packet sequence number, 280 // Add a STOP_WAITING frame since it contains a packet sequence number,
284 // whose length should be 1. 281 // whose length should be 1.
285 QuicStopWaitingFrame stop_waiting_frame; 282 QuicStopWaitingFrame stop_waiting_frame;
286 EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(&stop_waiting_frame))); 283 EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(&stop_waiting_frame)));
287 EXPECT_TRUE(creator_.HasPendingFrames()); 284 EXPECT_TRUE(creator_.HasPendingFrames());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 // Test goal is to test the following sequence (P1 => generate Packet 1): 343 // Test goal is to test the following sequence (P1 => generate Packet 1):
347 // P1 <change seq num length> P2 FEC, 344 // P1 <change seq num length> P2 FEC,
348 // and we expect that sequence number length should not change until the end 345 // and we expect that sequence number length should not change until the end
349 // of the open FEC group. 346 // of the open FEC group.
350 347
351 // Enable FEC protection, and send FEC packet every 6 packets. 348 // Enable FEC protection, and send FEC packet every 6 packets.
352 EXPECT_TRUE(SwitchFecProtectionOn(6)); 349 EXPECT_TRUE(SwitchFecProtectionOn(6));
353 // Should return false since we do not have enough packets in the FEC group to 350 // Should return false since we do not have enough packets in the FEC group to
354 // trigger an FEC packet. 351 // trigger an FEC packet.
355 ASSERT_FALSE(creator_.ShouldSendFec(/*force_close=*/false)); 352 ASSERT_FALSE(creator_.ShouldSendFec(/*force_close=*/false));
356 frames_.push_back(QuicFrame(new QuicAckFrame(MakeAckFrame(0u, 0u)))); 353 frames_.push_back(QuicFrame(new QuicAckFrame(MakeAckFrame(0u))));
357 354
358 // Generate Packet 1. 355 // Generate Packet 1.
359 creator_.AddSavedFrame(frames_[0]); 356 creator_.AddSavedFrame(frames_[0]);
360 // Change the sequence number length mid-FEC group and it should not change. 357 // Change the sequence number length mid-FEC group and it should not change.
361 creator_.set_next_sequence_number_length(PACKET_4BYTE_SEQUENCE_NUMBER); 358 creator_.set_next_sequence_number_length(PACKET_4BYTE_SEQUENCE_NUMBER);
362 SerializedPacket serialized = creator_.SerializePacket(); 359 SerializedPacket serialized = creator_.SerializePacket();
363 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, serialized.sequence_number_length); 360 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, serialized.sequence_number_length);
364 361
365 { 362 {
366 InSequence s; 363 InSequence s;
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 client_framer_.GetMaxPlaintextSize(creator_.max_packet_length()); 861 client_framer_.GetMaxPlaintextSize(creator_.max_packet_length());
865 EXPECT_FALSE(creator_.HasPendingFrames()); 862 EXPECT_FALSE(creator_.HasPendingFrames());
866 EXPECT_EQ(max_plaintext_size - 863 EXPECT_EQ(max_plaintext_size -
867 GetPacketHeaderSize( 864 GetPacketHeaderSize(
868 creator_.connection_id_length(), 865 creator_.connection_id_length(),
869 QuicPacketCreatorPeer::SendVersionInPacket(&creator_), 866 QuicPacketCreatorPeer::SendVersionInPacket(&creator_),
870 PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP), 867 PACKET_1BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP),
871 creator_.BytesFree()); 868 creator_.BytesFree());
872 869
873 // Add a variety of frame types and then a padding frame. 870 // Add a variety of frame types and then a padding frame.
874 QuicAckFrame ack_frame(MakeAckFrame(0u, 0u)); 871 QuicAckFrame ack_frame(MakeAckFrame(0u));
875 EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(&ack_frame))); 872 EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(&ack_frame)));
876 EXPECT_TRUE(creator_.HasPendingFrames()); 873 EXPECT_TRUE(creator_.HasPendingFrames());
877 874
878 QuicCongestionFeedbackFrame congestion_feedback; 875 QuicCongestionFeedbackFrame congestion_feedback;
879 congestion_feedback.type = kFixRate; 876 congestion_feedback.type = kFixRate;
880 EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(&congestion_feedback))); 877 EXPECT_TRUE(creator_.AddSavedFrame(QuicFrame(&congestion_feedback)));
881 EXPECT_TRUE(creator_.HasPendingFrames()); 878 EXPECT_TRUE(creator_.HasPendingFrames());
882 879
883 QuicFrame frame; 880 QuicFrame frame;
884 size_t consumed = creator_.CreateStreamFrame( 881 size_t consumed = creator_.CreateStreamFrame(
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 // After 64 calls, BoolSource will refresh the bucket - make sure it does. 1012 // After 64 calls, BoolSource will refresh the bucket - make sure it does.
1016 mock_random_.ChangeValue(); 1013 mock_random_.ChangeValue();
1017 } 1014 }
1018 1015
1019 delete frames_[0].stream_frame; 1016 delete frames_[0].stream_frame;
1020 } 1017 }
1021 1018
1022 } // namespace 1019 } // namespace
1023 } // namespace test 1020 } // namespace test
1024 } // namespace net 1021 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_framer_test.cc ('k') | net/quic/quic_packet_generator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698