| 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 30 matching lines...) Expand all  Loading... | 
| 41 namespace net { | 41 namespace net { | 
| 42 | 42 | 
| 43 namespace test { | 43 namespace test { | 
| 44 | 44 | 
| 45 static const QuicConnectionId kTestConnectionId = 42; | 45 static const QuicConnectionId kTestConnectionId = 42; | 
| 46 static const uint16_t kTestPort = 12345; | 46 static const uint16_t kTestPort = 12345; | 
| 47 static const uint32_t kInitialStreamFlowControlWindowForTest = | 47 static const uint32_t kInitialStreamFlowControlWindowForTest = | 
| 48     1024 * 1024;  // 1 MB | 48     1024 * 1024;  // 1 MB | 
| 49 static const uint32_t kInitialSessionFlowControlWindowForTest = | 49 static const uint32_t kInitialSessionFlowControlWindowForTest = | 
| 50     1536 * 1024;  // 1.5 MB | 50     1536 * 1024;  // 1.5 MB | 
| 51 // Data stream IDs start at 5: the crypto stream is 1, headers stream is 3. |  | 
| 52 static const QuicStreamId kClientDataStreamId1 = 5; |  | 
| 53 static const QuicStreamId kClientDataStreamId2 = 7; |  | 
| 54 static const QuicStreamId kClientDataStreamId3 = 9; |  | 
| 55 static const QuicStreamId kServerDataStreamId1 = 4; |  | 
| 56 | 51 | 
| 57 // Returns the test peer IP address. | 52 // Returns the test peer IP address. | 
| 58 QuicIpAddress TestPeerIPAddress(); | 53 QuicIpAddress TestPeerIPAddress(); | 
| 59 | 54 | 
| 60 // Upper limit on versions we support. | 55 // Upper limit on versions we support. | 
| 61 QuicVersion QuicVersionMax(); | 56 QuicVersion QuicVersionMax(); | 
| 62 | 57 | 
| 63 // Lower limit on versions we support. | 58 // Lower limit on versions we support. | 
| 64 QuicVersion QuicVersionMin(); | 59 QuicVersion QuicVersionMin(); | 
| 65 | 60 | 
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 941     QuicServerId server_id, | 936     QuicServerId server_id, | 
| 942     QuicTime::Delta connection_start_time, | 937     QuicTime::Delta connection_start_time, | 
| 943     QuicVersionVector supported_versions, | 938     QuicVersionVector supported_versions, | 
| 944     MockQuicConnectionHelper* helper, | 939     MockQuicConnectionHelper* helper, | 
| 945     MockAlarmFactory* alarm_factory, | 940     MockAlarmFactory* alarm_factory, | 
| 946     QuicCryptoServerConfig* crypto_server_config, | 941     QuicCryptoServerConfig* crypto_server_config, | 
| 947     QuicCompressedCertsCache* compressed_certs_cache, | 942     QuicCompressedCertsCache* compressed_certs_cache, | 
| 948     PacketSavingConnection** server_connection, | 943     PacketSavingConnection** server_connection, | 
| 949     TestQuicSpdyServerSession** server_session); | 944     TestQuicSpdyServerSession** server_session); | 
| 950 | 945 | 
| 951 // Helper to generate client side stream ids, generalizes |  | 
| 952 // kClientDataStreamId1 etc. above. |  | 
| 953 QuicStreamId QuicClientDataStreamId(int i); |  | 
| 954 |  | 
| 955 // Verifies that the relative error of |actual| with respect to |expected| is | 946 // Verifies that the relative error of |actual| with respect to |expected| is | 
| 956 // no more than |margin|. | 947 // no more than |margin|. | 
| 957 | 948 | 
| 958 template <typename T> | 949 template <typename T> | 
| 959 void ExpectApproxEq(T expected, T actual, float relative_margin) { | 950 void ExpectApproxEq(T expected, T actual, float relative_margin) { | 
| 960   // If |relative_margin| > 1 and T is an unsigned type, the comparison will | 951   // If |relative_margin| > 1 and T is an unsigned type, the comparison will | 
| 961   // underflow. | 952   // underflow. | 
| 962   ASSERT_LE(relative_margin, 1); | 953   ASSERT_LE(relative_margin, 1); | 
| 963   ASSERT_GE(relative_margin, 0); | 954   ASSERT_GE(relative_margin, 0); | 
| 964 | 955 | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 983 | 974 | 
| 984 // Utility function that returns an QuicIOVector object wrapped around |str|. | 975 // Utility function that returns an QuicIOVector object wrapped around |str|. | 
| 985 // // |str|'s data is stored in |iov|. | 976 // // |str|'s data is stored in |iov|. | 
| 986 inline QuicIOVector MakeIOVector(QuicStringPiece str, struct iovec* iov) { | 977 inline QuicIOVector MakeIOVector(QuicStringPiece str, struct iovec* iov) { | 
| 987   iov->iov_base = const_cast<char*>(str.data()); | 978   iov->iov_base = const_cast<char*>(str.data()); | 
| 988   iov->iov_len = static_cast<size_t>(str.size()); | 979   iov->iov_len = static_cast<size_t>(str.size()); | 
| 989   QuicIOVector quic_iov(iov, 1, str.size()); | 980   QuicIOVector quic_iov(iov, 1, str.size()); | 
| 990   return quic_iov; | 981   return quic_iov; | 
| 991 } | 982 } | 
| 992 | 983 | 
|  | 984 // Utilities that will adapt stream ids when http stream pairs are | 
|  | 985 // enabled. | 
|  | 986 QuicStreamId NextStreamId(QuicVersion version); | 
|  | 987 QuicStreamId GetNthClientInitiatedStreamId(QuicVersion version, int n); | 
|  | 988 QuicStreamId GetNthServerInitiatedStreamId(QuicVersion version, int n); | 
|  | 989 | 
| 993 }  // namespace test | 990 }  // namespace test | 
| 994 }  // namespace net | 991 }  // namespace net | 
| 995 | 992 | 
| 996 #endif  // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 993 #endif  // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 
| OLD | NEW | 
|---|