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

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

Issue 2236973002: Landing Recent QUIC changes until 4AM, Aug 7, 2016 UTC-4 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: flip quic_sequencer_buffer_retire_block_in_time to true 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
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 // Common utilities for Quic tests 5 // Common utilities for Quic tests
6 6
7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ 7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ 8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
9 9
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 // Returns an address for ::1. 70 // Returns an address for ::1.
71 IPAddress Loopback6(); 71 IPAddress Loopback6();
72 72
73 // Returns an address for 0.0.0.0. 73 // Returns an address for 0.0.0.0.
74 IPAddress Any4(); 74 IPAddress Any4();
75 75
76 void GenerateBody(std::string* body, int length); 76 void GenerateBody(std::string* body, int length);
77 77
78 // Create an encrypted packet for testing. 78 // Create an encrypted packet for testing.
79 // If versions == nullptr, uses &QuicSupportedVersions(). 79 // If versions == nullptr, uses &AllSupportedVersions().
80 // Note that the packet is encrypted with NullEncrypter, so to decrypt the 80 // Note that the packet is encrypted with NullEncrypter, so to decrypt the
81 // constructed packet, the framer must be set to use NullDecrypter. 81 // constructed packet, the framer must be set to use NullDecrypter.
82 QuicEncryptedPacket* ConstructEncryptedPacket( 82 QuicEncryptedPacket* ConstructEncryptedPacket(
83 QuicConnectionId connection_id, 83 QuicConnectionId connection_id,
84 bool version_flag, 84 bool version_flag,
85 bool multipath_flag, 85 bool multipath_flag,
86 bool reset_flag, 86 bool reset_flag,
87 QuicPathId path_id, 87 QuicPathId path_id,
88 QuicPacketNumber packet_number, 88 QuicPacketNumber packet_number,
89 const std::string& data, 89 const std::string& data,
90 QuicConnectionIdLength connection_id_length, 90 QuicConnectionIdLength connection_id_length,
91 QuicPacketNumberLength packet_number_length, 91 QuicPacketNumberLength packet_number_length,
92 QuicVersionVector* versions, 92 QuicVersionVector* versions,
93 Perspective perspective); 93 Perspective perspective);
94 94
95 // Create an encrypted packet for testing. 95 // Create an encrypted packet for testing.
96 // If versions == nullptr, uses &QuicSupportedVersions(). 96 // If versions == nullptr, uses &AllSupportedVersions().
97 // Note that the packet is encrypted with NullEncrypter, so to decrypt the 97 // Note that the packet is encrypted with NullEncrypter, so to decrypt the
98 // constructed packet, the framer must be set to use NullDecrypter. 98 // constructed packet, the framer must be set to use NullDecrypter.
99 QuicEncryptedPacket* ConstructEncryptedPacket( 99 QuicEncryptedPacket* ConstructEncryptedPacket(
100 QuicConnectionId connection_id, 100 QuicConnectionId connection_id,
101 bool version_flag, 101 bool version_flag,
102 bool multipath_flag, 102 bool multipath_flag,
103 bool reset_flag, 103 bool reset_flag,
104 QuicPathId path_id, 104 QuicPathId path_id,
105 QuicPacketNumber packet_number, 105 QuicPacketNumber packet_number,
106 const std::string& data, 106 const std::string& data,
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 void SendOrQueuePacket(SerializedPacket* packet) override; 491 void SendOrQueuePacket(SerializedPacket* packet) override;
492 492
493 std::vector<QuicEncryptedPacket*> encrypted_packets_; 493 std::vector<QuicEncryptedPacket*> encrypted_packets_;
494 494
495 private: 495 private:
496 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection); 496 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection);
497 }; 497 };
498 498
499 class MockQuicSession : public QuicSession { 499 class MockQuicSession : public QuicSession {
500 public: 500 public:
501 // Takes ownership of |connection|.
501 explicit MockQuicSession(QuicConnection* connection); 502 explicit MockQuicSession(QuicConnection* connection);
502 ~MockQuicSession() override; 503 ~MockQuicSession() override;
503 504
504 QuicCryptoStream* GetCryptoStream() override { return crypto_stream_.get(); } 505 QuicCryptoStream* GetCryptoStream() override { return crypto_stream_.get(); }
505 506
506 MOCK_METHOD3(OnConnectionClosed, 507 MOCK_METHOD3(OnConnectionClosed,
507 void(QuicErrorCode error, 508 void(QuicErrorCode error,
508 const std::string& error_details, 509 const std::string& error_details,
509 ConnectionCloseSource source)); 510 ConnectionCloseSource source));
510 MOCK_METHOD1(CreateIncomingDynamicStream, 511 MOCK_METHOD1(CreateIncomingDynamicStream,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 QuicAckListenerInterface* ack_notifier_delegate); 548 QuicAckListenerInterface* ack_notifier_delegate);
548 549
549 private: 550 private:
550 std::unique_ptr<QuicCryptoStream> crypto_stream_; 551 std::unique_ptr<QuicCryptoStream> crypto_stream_;
551 552
552 DISALLOW_COPY_AND_ASSIGN(MockQuicSession); 553 DISALLOW_COPY_AND_ASSIGN(MockQuicSession);
553 }; 554 };
554 555
555 class MockQuicSpdySession : public QuicSpdySession { 556 class MockQuicSpdySession : public QuicSpdySession {
556 public: 557 public:
558 // Takes ownership of |connection|.
557 explicit MockQuicSpdySession(QuicConnection* connection); 559 explicit MockQuicSpdySession(QuicConnection* connection);
558 ~MockQuicSpdySession() override; 560 ~MockQuicSpdySession() override;
559 561
560 QuicCryptoStream* GetCryptoStream() override { return crypto_stream_.get(); } 562 QuicCryptoStream* GetCryptoStream() override { return crypto_stream_.get(); }
561 const SpdyHeaderBlock& GetWriteHeaders() { return write_headers_; } 563 const SpdyHeaderBlock& GetWriteHeaders() { return write_headers_; }
562 564
563 // From QuicSession. 565 // From QuicSession.
564 MOCK_METHOD3(OnConnectionClosed, 566 MOCK_METHOD3(OnConnectionClosed,
565 void(QuicErrorCode error, 567 void(QuicErrorCode error,
566 const std::string& error_details, 568 const std::string& error_details,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 635
634 private: 636 private:
635 std::unique_ptr<QuicCryptoStream> crypto_stream_; 637 std::unique_ptr<QuicCryptoStream> crypto_stream_;
636 SpdyHeaderBlock write_headers_; 638 SpdyHeaderBlock write_headers_;
637 639
638 DISALLOW_COPY_AND_ASSIGN(MockQuicSpdySession); 640 DISALLOW_COPY_AND_ASSIGN(MockQuicSpdySession);
639 }; 641 };
640 642
641 class TestQuicSpdyServerSession : public QuicServerSessionBase { 643 class TestQuicSpdyServerSession : public QuicServerSessionBase {
642 public: 644 public:
645 // Takes ownership of |connection|.
643 TestQuicSpdyServerSession(QuicConnection* connection, 646 TestQuicSpdyServerSession(QuicConnection* connection,
644 const QuicConfig& config, 647 const QuicConfig& config,
645 const QuicCryptoServerConfig* crypto_config, 648 const QuicCryptoServerConfig* crypto_config,
646 QuicCompressedCertsCache* compressed_certs_cache); 649 QuicCompressedCertsCache* compressed_certs_cache);
647 ~TestQuicSpdyServerSession() override; 650 ~TestQuicSpdyServerSession() override;
648 651
649 MOCK_METHOD1(CreateIncomingDynamicStream, QuicSpdyStream*(QuicStreamId id)); 652 MOCK_METHOD1(CreateIncomingDynamicStream, QuicSpdyStream*(QuicStreamId id));
650 MOCK_METHOD1(CreateOutgoingDynamicStream, 653 MOCK_METHOD1(CreateOutgoingDynamicStream,
651 QuicSpdyStream*(SpdyPriority priority)); 654 QuicSpdyStream*(SpdyPriority priority));
652 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( 655 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 MOCK_METHOD0(RevertRetransmissionTimeout, void()); 746 MOCK_METHOD0(RevertRetransmissionTimeout, void());
744 MOCK_CONST_METHOD2(TimeUntilSend, 747 MOCK_CONST_METHOD2(TimeUntilSend,
745 QuicTime::Delta(QuicTime now, 748 QuicTime::Delta(QuicTime now,
746 QuicByteCount bytes_in_flight)); 749 QuicByteCount bytes_in_flight));
747 MOCK_CONST_METHOD1(PacingRate, QuicBandwidth(QuicByteCount)); 750 MOCK_CONST_METHOD1(PacingRate, QuicBandwidth(QuicByteCount));
748 MOCK_CONST_METHOD0(BandwidthEstimate, QuicBandwidth(void)); 751 MOCK_CONST_METHOD0(BandwidthEstimate, QuicBandwidth(void));
749 MOCK_CONST_METHOD0(HasReliableBandwidthEstimate, bool()); 752 MOCK_CONST_METHOD0(HasReliableBandwidthEstimate, bool());
750 MOCK_METHOD1(OnRttUpdated, void(QuicPacketNumber)); 753 MOCK_METHOD1(OnRttUpdated, void(QuicPacketNumber));
751 MOCK_CONST_METHOD0(RetransmissionDelay, QuicTime::Delta(void)); 754 MOCK_CONST_METHOD0(RetransmissionDelay, QuicTime::Delta(void));
752 MOCK_CONST_METHOD0(GetCongestionWindow, QuicByteCount()); 755 MOCK_CONST_METHOD0(GetCongestionWindow, QuicByteCount());
756 MOCK_CONST_METHOD0(GetDebugState, std::string());
753 MOCK_CONST_METHOD0(InSlowStart, bool()); 757 MOCK_CONST_METHOD0(InSlowStart, bool());
754 MOCK_CONST_METHOD0(InRecovery, bool()); 758 MOCK_CONST_METHOD0(InRecovery, bool());
755 MOCK_CONST_METHOD0(GetSlowStartThreshold, QuicByteCount()); 759 MOCK_CONST_METHOD0(GetSlowStartThreshold, QuicByteCount());
756 MOCK_CONST_METHOD0(GetCongestionControlType, CongestionControlType()); 760 MOCK_CONST_METHOD0(GetCongestionControlType, CongestionControlType());
757 MOCK_METHOD2(ResumeConnectionState, 761 MOCK_METHOD2(ResumeConnectionState,
758 void(const CachedNetworkParameters&, bool)); 762 void(const CachedNetworkParameters&, bool));
763 MOCK_METHOD1(OnApplicationLimited, void(QuicByteCount));
759 764
760 private: 765 private:
761 DISALLOW_COPY_AND_ASSIGN(MockSendAlgorithm); 766 DISALLOW_COPY_AND_ASSIGN(MockSendAlgorithm);
762 }; 767 };
763 768
764 class MockLossAlgorithm : public LossDetectionInterface { 769 class MockLossAlgorithm : public LossDetectionInterface {
765 public: 770 public:
766 MockLossAlgorithm(); 771 MockLossAlgorithm();
767 ~MockLossAlgorithm() override; 772 ~MockLossAlgorithm() override;
768 773
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 MOCK_CONST_METHOD0(GetRetransmissionTime, const QuicTime(void)); 936 MOCK_CONST_METHOD0(GetRetransmissionTime, const QuicTime(void));
932 MOCK_CONST_METHOD0(GetRttStats, const RttStats*(void)); 937 MOCK_CONST_METHOD0(GetRttStats, const RttStats*(void));
933 MOCK_CONST_METHOD0(BandwidthEstimate, QuicBandwidth(void)); 938 MOCK_CONST_METHOD0(BandwidthEstimate, QuicBandwidth(void));
934 MOCK_CONST_METHOD0(SustainedBandwidthRecorder, 939 MOCK_CONST_METHOD0(SustainedBandwidthRecorder,
935 const QuicSustainedBandwidthRecorder*(void)); 940 const QuicSustainedBandwidthRecorder*(void));
936 MOCK_CONST_METHOD0(GetCongestionWindowInTcpMss, QuicPacketCount(void)); 941 MOCK_CONST_METHOD0(GetCongestionWindowInTcpMss, QuicPacketCount(void));
937 MOCK_CONST_METHOD1(EstimateMaxPacketsInFlight, 942 MOCK_CONST_METHOD1(EstimateMaxPacketsInFlight,
938 QuicPacketCount(QuicByteCount)); 943 QuicPacketCount(QuicByteCount));
939 MOCK_CONST_METHOD0(GetCongestionWindowInBytes, QuicByteCount(void)); 944 MOCK_CONST_METHOD0(GetCongestionWindowInBytes, QuicByteCount(void));
940 MOCK_CONST_METHOD0(GetSlowStartThresholdInTcpMss, QuicPacketCount(void)); 945 MOCK_CONST_METHOD0(GetSlowStartThresholdInTcpMss, QuicPacketCount(void));
946 MOCK_CONST_METHOD0(GetDebugState, std::string());
941 MOCK_METHOD1(CancelRetransmissionsForStream, void(QuicStreamId)); 947 MOCK_METHOD1(CancelRetransmissionsForStream, void(QuicStreamId));
942 MOCK_METHOD2(OnConnectionMigration, void(QuicPathId, PeerAddressChangeType)); 948 MOCK_METHOD2(OnConnectionMigration, void(QuicPathId, PeerAddressChangeType));
943 MOCK_CONST_METHOD0(IsHandshakeConfirmed, bool(void)); 949 MOCK_CONST_METHOD0(IsHandshakeConfirmed, bool(void));
944 MOCK_METHOD1(SetDebugDelegate, void(DebugDelegate*)); 950 MOCK_METHOD1(SetDebugDelegate, void(DebugDelegate*));
945 MOCK_CONST_METHOD1(GetLargestObserved, QuicPacketNumber(QuicPathId)); 951 MOCK_CONST_METHOD1(GetLargestObserved, QuicPacketNumber(QuicPathId));
946 MOCK_CONST_METHOD1(GetLargestSentPacket, QuicPacketNumber(QuicPathId)); 952 MOCK_CONST_METHOD1(GetLargestSentPacket, QuicPacketNumber(QuicPathId));
947 MOCK_CONST_METHOD1(GetLeastPacketAwaitedByPeer, QuicPacketNumber(QuicPathId)); 953 MOCK_CONST_METHOD1(GetLeastPacketAwaitedByPeer, QuicPacketNumber(QuicPathId));
948 MOCK_METHOD1(SetNetworkChangeVisitor, void(NetworkChangeVisitor*)); 954 MOCK_METHOD1(SetNetworkChangeVisitor, void(NetworkChangeVisitor*));
949 MOCK_CONST_METHOD0(InSlowStart, bool(void)); 955 MOCK_CONST_METHOD0(InSlowStart, bool(void));
950 MOCK_CONST_METHOD0(GetConsecutiveRtoCount, size_t(void)); 956 MOCK_CONST_METHOD0(GetConsecutiveRtoCount, size_t(void));
951 MOCK_CONST_METHOD0(GetConsecutiveTlpCount, size_t(void)); 957 MOCK_CONST_METHOD0(GetConsecutiveTlpCount, size_t(void));
958 MOCK_METHOD0(OnApplicationLimited, void(void));
952 }; 959 };
953 960
954 class MockConnectionCloseDelegate 961 class MockConnectionCloseDelegate
955 : public QuicConnectionCloseDelegateInterface { 962 : public QuicConnectionCloseDelegateInterface {
956 public: 963 public:
957 MockConnectionCloseDelegate(); 964 MockConnectionCloseDelegate();
958 ~MockConnectionCloseDelegate() override; 965 ~MockConnectionCloseDelegate() override;
959 966
960 MOCK_METHOD3(OnUnrecoverableError, 967 MOCK_METHOD3(OnUnrecoverableError,
961 void(QuicErrorCode, 968 void(QuicErrorCode,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 TestQuicSpdyServerSession** server_session); 1023 TestQuicSpdyServerSession** server_session);
1017 1024
1018 // Helper to generate client side stream ids, generalizes 1025 // Helper to generate client side stream ids, generalizes
1019 // kClientDataStreamId1 etc. above. 1026 // kClientDataStreamId1 etc. above.
1020 QuicStreamId QuicClientDataStreamId(int i); 1027 QuicStreamId QuicClientDataStreamId(int i);
1021 1028
1022 } // namespace test 1029 } // namespace test
1023 } // namespace net 1030 } // namespace net
1024 1031
1025 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ 1032 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_sent_packet_manager_peer.cc ('k') | net/quic/test_tools/quic_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698