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

Side by Side Diff: net/quic/test_tools/quic_test_utils.cc

Issue 2236463004: Rename QuicSupportedVersions to QuicAllSupportedVersions. Add QuicCurrentSupportedVersions which re… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@129437595
Patch Set: update more files outside net/ Created 4 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/test_tools/quic_test_utils.h ('k') | net/quic/test_tools/simple_quic_framer.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/test_tools/quic_test_utils.h" 5 #include "net/quic/test_tools/quic_test_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/sha1.h" 9 #include "base/sha1.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 244 }
245 245
246 MockQuicConnection::MockQuicConnection(MockQuicConnectionHelper* helper, 246 MockQuicConnection::MockQuicConnection(MockQuicConnectionHelper* helper,
247 MockAlarmFactory* alarm_factory, 247 MockAlarmFactory* alarm_factory,
248 Perspective perspective) 248 Perspective perspective)
249 : MockQuicConnection(kTestConnectionId, 249 : MockQuicConnection(kTestConnectionId,
250 IPEndPoint(TestPeerIPAddress(), kTestPort), 250 IPEndPoint(TestPeerIPAddress(), kTestPort),
251 helper, 251 helper,
252 alarm_factory, 252 alarm_factory,
253 perspective, 253 perspective,
254 QuicSupportedVersions()) {} 254 AllSupportedVersions()) {}
255 255
256 MockQuicConnection::MockQuicConnection(IPEndPoint address, 256 MockQuicConnection::MockQuicConnection(IPEndPoint address,
257 MockQuicConnectionHelper* helper, 257 MockQuicConnectionHelper* helper,
258 MockAlarmFactory* alarm_factory, 258 MockAlarmFactory* alarm_factory,
259 Perspective perspective) 259 Perspective perspective)
260 : MockQuicConnection(kTestConnectionId, 260 : MockQuicConnection(kTestConnectionId,
261 address, 261 address,
262 helper, 262 helper,
263 alarm_factory, 263 alarm_factory,
264 perspective, 264 perspective,
265 QuicSupportedVersions()) {} 265 AllSupportedVersions()) {}
266 266
267 MockQuicConnection::MockQuicConnection(QuicConnectionId connection_id, 267 MockQuicConnection::MockQuicConnection(QuicConnectionId connection_id,
268 MockQuicConnectionHelper* helper, 268 MockQuicConnectionHelper* helper,
269 MockAlarmFactory* alarm_factory, 269 MockAlarmFactory* alarm_factory,
270 Perspective perspective) 270 Perspective perspective)
271 : MockQuicConnection(connection_id, 271 : MockQuicConnection(connection_id,
272 IPEndPoint(TestPeerIPAddress(), kTestPort), 272 IPEndPoint(TestPeerIPAddress(), kTestPort),
273 helper, 273 helper,
274 alarm_factory, 274 alarm_factory,
275 perspective, 275 perspective,
276 QuicSupportedVersions()) {} 276 CurrentSupportedVersions()) {}
277 277
278 MockQuicConnection::MockQuicConnection( 278 MockQuicConnection::MockQuicConnection(
279 MockQuicConnectionHelper* helper, 279 MockQuicConnectionHelper* helper,
280 MockAlarmFactory* alarm_factory, 280 MockAlarmFactory* alarm_factory,
281 Perspective perspective, 281 Perspective perspective,
282 const QuicVersionVector& supported_versions) 282 const QuicVersionVector& supported_versions)
283 : MockQuicConnection(kTestConnectionId, 283 : MockQuicConnection(kTestConnectionId,
284 IPEndPoint(TestPeerIPAddress(), kTestPort), 284 IPEndPoint(TestPeerIPAddress(), kTestPort),
285 helper, 285 helper,
286 alarm_factory, 286 alarm_factory,
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 return hex; 501 return hex;
502 } 502 }
503 503
504 } // namespace 504 } // namespace
505 505
506 IPAddress TestPeerIPAddress() { 506 IPAddress TestPeerIPAddress() {
507 return Loopback4(); 507 return Loopback4();
508 } 508 }
509 509
510 QuicVersion QuicVersionMax() { 510 QuicVersion QuicVersionMax() {
511 return QuicSupportedVersions().front(); 511 return AllSupportedVersions().front();
512 } 512 }
513 513
514 QuicVersion QuicVersionMin() { 514 QuicVersion QuicVersionMin() {
515 return QuicSupportedVersions().back(); 515 return AllSupportedVersions().back();
516 } 516 }
517 517
518 IPAddress Loopback4() { 518 IPAddress Loopback4() {
519 return IPAddress::IPv4Localhost(); 519 return IPAddress::IPv4Localhost();
520 } 520 }
521 521
522 IPAddress Loopback6() { 522 IPAddress Loopback6() {
523 return IPAddress::IPv6Localhost(); 523 return IPAddress::IPv6Localhost();
524 } 524 }
525 525
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 header.public_header.packet_number_length = packet_number_length; 600 header.public_header.packet_number_length = packet_number_length;
601 header.path_id = path_id; 601 header.path_id = path_id;
602 header.packet_number = packet_number; 602 header.packet_number = packet_number;
603 header.entropy_flag = false; 603 header.entropy_flag = false;
604 header.entropy_hash = 0; 604 header.entropy_hash = 0;
605 header.fec_flag = false; 605 header.fec_flag = false;
606 QuicStreamFrame stream_frame(1, false, 0, StringPiece(data)); 606 QuicStreamFrame stream_frame(1, false, 0, StringPiece(data));
607 QuicFrame frame(&stream_frame); 607 QuicFrame frame(&stream_frame);
608 QuicFrames frames; 608 QuicFrames frames;
609 frames.push_back(frame); 609 frames.push_back(frame);
610 QuicFramer framer(versions != nullptr ? *versions : QuicSupportedVersions(), 610 QuicFramer framer(
611 QuicTime::Zero(), perspective); 611 versions != nullptr ? *versions : CurrentSupportedVersions(),
612 QuicTime::Zero(), perspective);
612 613
613 std::unique_ptr<QuicPacket> packet( 614 std::unique_ptr<QuicPacket> packet(
614 BuildUnsizedDataPacket(&framer, header, frames)); 615 BuildUnsizedDataPacket(&framer, header, frames));
615 EXPECT_TRUE(packet != nullptr); 616 EXPECT_TRUE(packet != nullptr);
616 char* buffer = new char[kMaxPacketSize]; 617 char* buffer = new char[kMaxPacketSize];
617 size_t encrypted_length = framer.EncryptPayload( 618 size_t encrypted_length = framer.EncryptPayload(
618 ENCRYPTION_NONE, path_id, packet_number, *packet, buffer, kMaxPacketSize); 619 ENCRYPTION_NONE, path_id, packet_number, *packet, buffer, kMaxPacketSize);
619 EXPECT_NE(0u, encrypted_length); 620 EXPECT_NE(0u, encrypted_length);
620 return new QuicEncryptedPacket(buffer, encrypted_length, true); 621 return new QuicEncryptedPacket(buffer, encrypted_length, true);
621 } 622 }
(...skipping 28 matching lines...) Expand all
650 header.public_header.packet_number_length = packet_number_length; 651 header.public_header.packet_number_length = packet_number_length;
651 header.path_id = path_id; 652 header.path_id = path_id;
652 header.packet_number = packet_number; 653 header.packet_number = packet_number;
653 header.entropy_flag = false; 654 header.entropy_flag = false;
654 header.entropy_hash = 0; 655 header.entropy_hash = 0;
655 header.fec_flag = false; 656 header.fec_flag = false;
656 QuicStreamFrame stream_frame(1, false, 0, StringPiece(data)); 657 QuicStreamFrame stream_frame(1, false, 0, StringPiece(data));
657 QuicFrame frame(&stream_frame); 658 QuicFrame frame(&stream_frame);
658 QuicFrames frames; 659 QuicFrames frames;
659 frames.push_back(frame); 660 frames.push_back(frame);
660 QuicFramer framer(versions != nullptr ? *versions : QuicSupportedVersions(), 661 QuicFramer framer(versions != nullptr ? *versions : AllSupportedVersions(),
661 QuicTime::Zero(), perspective); 662 QuicTime::Zero(), perspective);
662 663
663 std::unique_ptr<QuicPacket> packet( 664 std::unique_ptr<QuicPacket> packet(
664 BuildUnsizedDataPacket(&framer, header, frames)); 665 BuildUnsizedDataPacket(&framer, header, frames));
665 EXPECT_TRUE(packet != nullptr); 666 EXPECT_TRUE(packet != nullptr);
666 667
667 if (framer.version() <= QUIC_VERSION_33) { 668 if (framer.version() <= QUIC_VERSION_33) {
668 // Now set the packet's private flags byte to 0xFF, which is an invalid 669 // Now set the packet's private flags byte to 0xFF, which is an invalid
669 // value. 670 // value.
670 reinterpret_cast<unsigned char*>( 671 reinterpret_cast<unsigned char*>(
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 return true; 730 return true;
730 } 731 }
731 732
732 static QuicPacket* ConstructPacketFromHandshakeMessage( 733 static QuicPacket* ConstructPacketFromHandshakeMessage(
733 QuicConnectionId connection_id, 734 QuicConnectionId connection_id,
734 const CryptoHandshakeMessage& message, 735 const CryptoHandshakeMessage& message,
735 bool should_include_version) { 736 bool should_include_version) {
736 CryptoFramer crypto_framer; 737 CryptoFramer crypto_framer;
737 std::unique_ptr<QuicData> data( 738 std::unique_ptr<QuicData> data(
738 crypto_framer.ConstructHandshakeMessage(message)); 739 crypto_framer.ConstructHandshakeMessage(message));
739 QuicFramer quic_framer(QuicSupportedVersions(), QuicTime::Zero(), 740 QuicFramer quic_framer(AllSupportedVersions(), QuicTime::Zero(),
740 Perspective::IS_CLIENT); 741 Perspective::IS_CLIENT);
741 742
742 QuicPacketHeader header; 743 QuicPacketHeader header;
743 header.public_header.connection_id = connection_id; 744 header.public_header.connection_id = connection_id;
744 header.public_header.reset_flag = false; 745 header.public_header.reset_flag = false;
745 header.public_header.version_flag = should_include_version; 746 header.public_header.version_flag = should_include_version;
746 header.packet_number = 1; 747 header.packet_number = 1;
747 header.entropy_flag = false; 748 header.entropy_flag = false;
748 header.entropy_hash = 0; 749 header.entropy_hash = 0;
749 header.fec_flag = false; 750 header.fec_flag = false;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 // strike register worries that we've just overflowed a uint32_t time. 900 // strike register worries that we've just overflowed a uint32_t time.
900 (*server_connection)->AdvanceTime(connection_start_time); 901 (*server_connection)->AdvanceTime(connection_start_time);
901 } 902 }
902 903
903 QuicStreamId QuicClientDataStreamId(int i) { 904 QuicStreamId QuicClientDataStreamId(int i) {
904 return kClientDataStreamId1 + 2 * i; 905 return kClientDataStreamId1 + 2 * i;
905 } 906 }
906 907
907 } // namespace test 908 } // namespace test
908 } // namespace net 909 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | net/quic/test_tools/simple_quic_framer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698