OLD | NEW |
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 <cstdint> | 10 #include <cstdint> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // Lower limit on versions we support. | 63 // Lower limit on versions we support. |
64 QuicVersion QuicVersionMin(); | 64 QuicVersion QuicVersionMin(); |
65 | 65 |
66 // Create an encrypted packet for testing. | 66 // Create an encrypted packet for testing. |
67 // If versions == nullptr, uses &AllSupportedVersions(). | 67 // If versions == nullptr, uses &AllSupportedVersions(). |
68 // Note that the packet is encrypted with NullEncrypter, so to decrypt the | 68 // Note that the packet is encrypted with NullEncrypter, so to decrypt the |
69 // constructed packet, the framer must be set to use NullDecrypter. | 69 // constructed packet, the framer must be set to use NullDecrypter. |
70 QuicEncryptedPacket* ConstructEncryptedPacket( | 70 QuicEncryptedPacket* ConstructEncryptedPacket( |
71 QuicConnectionId connection_id, | 71 QuicConnectionId connection_id, |
72 bool version_flag, | 72 bool version_flag, |
73 bool multipath_flag, | |
74 bool reset_flag, | 73 bool reset_flag, |
75 QuicPacketNumber packet_number, | 74 QuicPacketNumber packet_number, |
76 const std::string& data, | 75 const std::string& data, |
77 QuicConnectionIdLength connection_id_length, | 76 QuicConnectionIdLength connection_id_length, |
78 QuicPacketNumberLength packet_number_length, | 77 QuicPacketNumberLength packet_number_length, |
79 QuicVersionVector* versions, | 78 QuicVersionVector* versions, |
80 Perspective perspective); | 79 Perspective perspective); |
81 | 80 |
82 // Create an encrypted packet for testing. | 81 // Create an encrypted packet for testing. |
83 // If versions == nullptr, uses &AllSupportedVersions(). | 82 // If versions == nullptr, uses &AllSupportedVersions(). |
84 // Note that the packet is encrypted with NullEncrypter, so to decrypt the | 83 // Note that the packet is encrypted with NullEncrypter, so to decrypt the |
85 // constructed packet, the framer must be set to use NullDecrypter. | 84 // constructed packet, the framer must be set to use NullDecrypter. |
86 QuicEncryptedPacket* ConstructEncryptedPacket( | 85 QuicEncryptedPacket* ConstructEncryptedPacket( |
87 QuicConnectionId connection_id, | 86 QuicConnectionId connection_id, |
88 bool version_flag, | 87 bool version_flag, |
89 bool multipath_flag, | |
90 bool reset_flag, | 88 bool reset_flag, |
91 QuicPacketNumber packet_number, | 89 QuicPacketNumber packet_number, |
92 const std::string& data, | 90 const std::string& data, |
93 QuicConnectionIdLength connection_id_length, | 91 QuicConnectionIdLength connection_id_length, |
94 QuicPacketNumberLength packet_number_length, | 92 QuicPacketNumberLength packet_number_length, |
95 QuicVersionVector* versions); | 93 QuicVersionVector* versions); |
96 | 94 |
97 // This form assumes |versions| == nullptr. | 95 // This form assumes |versions| == nullptr. |
98 QuicEncryptedPacket* ConstructEncryptedPacket( | 96 QuicEncryptedPacket* ConstructEncryptedPacket( |
99 QuicConnectionId connection_id, | 97 QuicConnectionId connection_id, |
100 bool version_flag, | 98 bool version_flag, |
101 bool multipath_flag, | |
102 bool reset_flag, | 99 bool reset_flag, |
103 QuicPacketNumber packet_number, | 100 QuicPacketNumber packet_number, |
104 const std::string& data, | 101 const std::string& data, |
105 QuicConnectionIdLength connection_id_length, | 102 QuicConnectionIdLength connection_id_length, |
106 QuicPacketNumberLength packet_number_length); | 103 QuicPacketNumberLength packet_number_length); |
107 | 104 |
108 // This form assumes |connection_id_length| == PACKET_8BYTE_CONNECTION_ID, | 105 // This form assumes |connection_id_length| == PACKET_8BYTE_CONNECTION_ID, |
109 // |packet_number_length| == PACKET_6BYTE_PACKET_NUMBER and | 106 // |packet_number_length| == PACKET_6BYTE_PACKET_NUMBER and |
110 // |versions| == nullptr. | 107 // |versions| == nullptr. |
111 QuicEncryptedPacket* ConstructEncryptedPacket(QuicConnectionId connection_id, | 108 QuicEncryptedPacket* ConstructEncryptedPacket(QuicConnectionId connection_id, |
112 bool version_flag, | 109 bool version_flag, |
113 bool multipath_flag, | |
114 bool reset_flag, | 110 bool reset_flag, |
115 QuicPacketNumber packet_number, | 111 QuicPacketNumber packet_number, |
116 const std::string& data); | 112 const std::string& data); |
117 | 113 |
118 // Constructs a received packet for testing. The caller must take ownership of | 114 // Constructs a received packet for testing. The caller must take ownership of |
119 // the returned pointer. | 115 // the returned pointer. |
120 QuicReceivedPacket* ConstructReceivedPacket( | 116 QuicReceivedPacket* ConstructReceivedPacket( |
121 const QuicEncryptedPacket& encrypted_packet, | 117 const QuicEncryptedPacket& encrypted_packet, |
122 QuicTime receipt_time); | 118 QuicTime receipt_time); |
123 | 119 |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 iov->iov_base = const_cast<char*>(str.data()); | 979 iov->iov_base = const_cast<char*>(str.data()); |
984 iov->iov_len = static_cast<size_t>(str.size()); | 980 iov->iov_len = static_cast<size_t>(str.size()); |
985 QuicIOVector quic_iov(iov, 1, str.size()); | 981 QuicIOVector quic_iov(iov, 1, str.size()); |
986 return quic_iov; | 982 return quic_iov; |
987 } | 983 } |
988 | 984 |
989 } // namespace test | 985 } // namespace test |
990 } // namespace net | 986 } // namespace net |
991 | 987 |
992 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 988 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
OLD | NEW |