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

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

Issue 1138443003: Land Recent QUIC Changes until 05/13/2015 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile error fixes Created 5 years, 7 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_utils_test.cc ('k') | net/quic/test_tools/quic_test_utils.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 // 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 <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "net/quic/congestion_control/loss_detection_interface.h" 15 #include "net/quic/congestion_control/loss_detection_interface.h"
16 #include "net/quic/congestion_control/send_algorithm_interface.h" 16 #include "net/quic/congestion_control/send_algorithm_interface.h"
17 #include "net/quic/quic_ack_notifier.h" 17 #include "net/quic/quic_ack_notifier.h"
18 #include "net/quic/quic_client_session_base.h" 18 #include "net/quic/quic_client_session_base.h"
19 #include "net/quic/quic_connection.h" 19 #include "net/quic/quic_connection.h"
20 #include "net/quic/quic_framer.h" 20 #include "net/quic/quic_framer.h"
21 #include "net/quic/quic_protocol.h" 21 #include "net/quic/quic_protocol.h"
22 #include "net/quic/quic_sent_packet_manager.h" 22 #include "net/quic/quic_sent_packet_manager.h"
23 #include "net/quic/quic_session.h" 23 #include "net/quic/quic_session.h"
24 #include "net/quic/test_tools/mock_clock.h" 24 #include "net/quic/test_tools/mock_clock.h"
25 #include "net/quic/test_tools/mock_random.h" 25 #include "net/quic/test_tools/mock_random.h"
26 #include "net/spdy/spdy_framer.h" 26 #include "net/spdy/spdy_framer.h"
27 #include "net/tools/quic/quic_dispatcher.h" 27 #include "net/tools/quic/quic_dispatcher.h"
28 #include "net/tools/quic/quic_per_connection_packet_writer.h" 28 #include "net/tools/quic/quic_per_connection_packet_writer.h"
29 #include "net/tools/quic/quic_server_session.h"
29 #include "testing/gmock/include/gmock/gmock.h" 30 #include "testing/gmock/include/gmock/gmock.h"
30 31
31 namespace net { 32 namespace net {
32 33
33 namespace test { 34 namespace test {
34 35
35 static const QuicConnectionId kTestConnectionId = 42; 36 static const QuicConnectionId kTestConnectionId = 42;
36 static const uint16 kTestPort = 123; 37 static const uint16 kTestPort = 123;
37 static const uint32 kInitialStreamFlowControlWindowForTest = 38 static const uint32 kInitialStreamFlowControlWindowForTest =
38 1024 * 1024; // 1 MB 39 1024 * 1024; // 1 MB
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 QuicVersion version, 123 QuicVersion version,
123 bool include_version, 124 bool include_version,
124 QuicConnectionIdLength connection_id_length, 125 QuicConnectionIdLength connection_id_length,
125 QuicSequenceNumberLength sequence_number_length, 126 QuicSequenceNumberLength sequence_number_length,
126 InFecGroup is_in_fec_group, 127 InFecGroup is_in_fec_group,
127 size_t* payload_length); 128 size_t* payload_length);
128 129
129 // Returns QuicConfig set to default values. 130 // Returns QuicConfig set to default values.
130 QuicConfig DefaultQuicConfig(); 131 QuicConfig DefaultQuicConfig();
131 132
133 // Returns a QuicConfig set to default values that supports stateless rejects.
134 QuicConfig DefaultQuicConfigStatelessRejects();
135
132 // Returns a version vector consisting of |version|. 136 // Returns a version vector consisting of |version|.
133 QuicVersionVector SupportedVersions(QuicVersion version); 137 QuicVersionVector SupportedVersions(QuicVersion version);
134 138
135 // Testing convenience method to construct a QuicAckFrame with entropy_hash set 139 // Testing convenience method to construct a QuicAckFrame with entropy_hash set
136 // to 0 and largest_observed from peer set to |largest_observed|. 140 // to 0 and largest_observed from peer set to |largest_observed|.
137 QuicAckFrame MakeAckFrame(QuicPacketSequenceNumber largest_observed); 141 QuicAckFrame MakeAckFrame(QuicPacketSequenceNumber largest_observed);
138 142
139 // Testing convenience method to construct a QuicAckFrame with |num_nack_ranges| 143 // Testing convenience method to construct a QuicAckFrame with |num_nack_ranges|
140 // nack ranges of width 1 packet, starting from |least_unacked|. 144 // nack ranges of width 1 packet, starting from |least_unacked|.
141 QuicAckFrame MakeAckFrameWithNackRanges(size_t num_nack_ranges, 145 QuicAckFrame MakeAckFrameWithNackRanges(size_t num_nack_ranges,
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 703
700 MOCK_METHOD1(OnPublicResetPacket, void(const QuicPublicResetPacket&)); 704 MOCK_METHOD1(OnPublicResetPacket, void(const QuicPublicResetPacket&));
701 705
702 MOCK_METHOD1(OnVersionNegotiationPacket, 706 MOCK_METHOD1(OnVersionNegotiationPacket,
703 void(const QuicVersionNegotiationPacket&)); 707 void(const QuicVersionNegotiationPacket&));
704 708
705 MOCK_METHOD2(OnRevivedPacket, 709 MOCK_METHOD2(OnRevivedPacket,
706 void(const QuicPacketHeader&, StringPiece payload)); 710 void(const QuicPacketHeader&, StringPiece payload));
707 }; 711 };
708 712
713 class TestServerSession : public tools::QuicServerSession {
714 public:
715 TestServerSession(const QuicConfig& config, QuicConnection* connection);
716 ~TestServerSession() override;
717
718 private:
719 DISALLOW_COPY_AND_ASSIGN(TestServerSession);
720 };
721
722 // Creates and sets up a QuicCryptoClientStream for testing, and all
723 // its associated state.
724 //
725 // server_id: The server id associated with this stream.
726 // supports_stateless_rejects: Does this client support stateless rejects.
727 // connection_start_time: The time to set for the connection clock.
728 // Needed for strike-register nonce verification. The client
729 // connection_start_time should be synchronized witht the server
730 // start time, otherwise nonce verification will fail.
731 // crypto_client_config: Pointer to the crypto client config.
732 // client_connection: Pointer reference for newly created
733 // connection. This object will be owned by the
734 // client_session.
735 // client_session: Pointer reference for the newly created client
736 // session. The new object will be owned by the caller.
737 // client_stream: Pointer reference for the newly created crypto
738 // client stream. The new object will be owned by the caller.
739 void SetupCryptoClientStreamForTest(
740 QuicServerId server_id,
741 bool supports_stateless_rejects,
742 QuicTime::Delta connection_start_time,
743 QuicCryptoClientConfig* crypto_client_config,
744 PacketSavingConnection** client_connection,
745 TestClientSession** client_session,
746 QuicCryptoClientStream** client_stream);
747
748 // Creates and sets up a QuicCryptoServerStream for testing, and all
749 // its associated state.
750 //
751 // server_id: The server id associated with this stream.
752 // connection_start_time: The time to set for the connection clock.
753 // Needed for strike-register nonce verification. The server
754 // connection_start_time should be synchronized witht the client
755 // start time, otherwise nonce verification will fail.
756 // crypto_server_config: Pointer to the crypto server config.
757 // server_connection: Pointer reference for newly created
758 // connection. This object will be owned by the
759 // server_session.
760 // server_session: Pointer reference for the newly created server
761 // session. The new object will be owned by the caller.
762 // server_stream: Pointer reference for the newly created crypto
763 // server stream. The new object will be owned by the caller.
764 void SetupCryptoServerStreamForTest(
765 QuicServerId server_id,
766 QuicTime::Delta connection_start_time,
767 QuicCryptoServerConfig* crypto_server_config,
768 PacketSavingConnection** server_connection,
769 TestServerSession** server_session,
770 QuicCryptoServerStream** server_stream);
771
709 } // namespace test 772 } // namespace test
710 } // namespace net 773 } // namespace net
711 774
712 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ 775 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « net/quic/quic_utils_test.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