| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // packet could not be created. | 172 // packet could not be created. |
| 173 QuicPacket* BuildUnsizedDataPacket(QuicFramer* framer, | 173 QuicPacket* BuildUnsizedDataPacket(QuicFramer* framer, |
| 174 const QuicPacketHeader& header, | 174 const QuicPacketHeader& header, |
| 175 const QuicFrames& frames); | 175 const QuicFrames& frames); |
| 176 // Returns a QuicPacket that is owned by the caller, and of size |packet_size|. | 176 // Returns a QuicPacket that is owned by the caller, and of size |packet_size|. |
| 177 QuicPacket* BuildUnsizedDataPacket(QuicFramer* framer, | 177 QuicPacket* BuildUnsizedDataPacket(QuicFramer* framer, |
| 178 const QuicPacketHeader& header, | 178 const QuicPacketHeader& header, |
| 179 const QuicFrames& frames, | 179 const QuicFrames& frames, |
| 180 size_t packet_size); | 180 size_t packet_size); |
| 181 | 181 |
| 182 // When constructed, checks that all QUIC flags have their correct default | |
| 183 // values and when destructed, restores those values. | |
| 184 class QuicFlagSaver { | |
| 185 public: | |
| 186 QuicFlagSaver(); | |
| 187 ~QuicFlagSaver(); | |
| 188 }; | |
| 189 | |
| 190 // Compute SHA-1 hash of the supplied std::string. | 182 // Compute SHA-1 hash of the supplied std::string. |
| 191 std::string Sha1Hash(QuicStringPiece data); | 183 std::string Sha1Hash(QuicStringPiece data); |
| 192 | 184 |
| 193 // Given endpoint in memory |connection_id|, returns peer's in memory connection | 185 // Given endpoint in memory |connection_id|, returns peer's in memory connection |
| 194 // id. | 186 // id. |
| 195 QuicConnectionId GetPeerInMemoryConnectionId(QuicConnectionId connection_id); | 187 QuicConnectionId GetPeerInMemoryConnectionId(QuicConnectionId connection_id); |
| 196 | 188 |
| 197 // Simple random number generator used to compute random numbers suitable | 189 // Simple random number generator used to compute random numbers suitable |
| 198 // for pseudo-randomly dropping packets in tests. It works by computing | 190 // for pseudo-randomly dropping packets in tests. It works by computing |
| 199 // the sha1 hash of the current seed, and using the first 64 bits as | 191 // the sha1 hash of the current seed, and using the first 64 bits as |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 iov->iov_base = const_cast<char*>(str.data()); | 987 iov->iov_base = const_cast<char*>(str.data()); |
| 996 iov->iov_len = static_cast<size_t>(str.size()); | 988 iov->iov_len = static_cast<size_t>(str.size()); |
| 997 QuicIOVector quic_iov(iov, 1, str.size()); | 989 QuicIOVector quic_iov(iov, 1, str.size()); |
| 998 return quic_iov; | 990 return quic_iov; |
| 999 } | 991 } |
| 1000 | 992 |
| 1001 } // namespace test | 993 } // namespace test |
| 1002 } // namespace net | 994 } // namespace net |
| 1003 | 995 |
| 1004 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 996 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| OLD | NEW |