| 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 #include "net/quic/test_tools/quic_test_utils.h" | 5 #include "net/quic/test_tools/quic_test_utils.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/sha1.h" | 10 #include "base/sha1.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // Re-construct the data packet with data ownership. | 77 // Re-construct the data packet with data ownership. |
| 78 return new QuicPacket(buffer, length, /* owns_buffer */ true, | 78 return new QuicPacket(buffer, length, /* owns_buffer */ true, |
| 79 header.public_header.connection_id_length, | 79 header.public_header.connection_id_length, |
| 80 header.public_header.version_flag, | 80 header.public_header.version_flag, |
| 81 header.public_header.multipath_flag, | 81 header.public_header.multipath_flag, |
| 82 header.public_header.nonce != nullptr, | 82 header.public_header.nonce != nullptr, |
| 83 header.public_header.packet_number_length); | 83 header.public_header.packet_number_length); |
| 84 } | 84 } |
| 85 | 85 |
| 86 QuicFlagSaver::QuicFlagSaver() { | 86 QuicFlagSaver::QuicFlagSaver() { |
| 87 #define QUIC_FLAG(type, flag, value) \ | 87 // This checks that |flag| is set to an expected value. A prior test is |
| 88 CHECK_EQ(value, flag) << "Flag set to an expected value. A prior test is " \ | 88 // likely setting a flag without using a QuicFlagSaver if this fails. |
| 89 "likely setting a flag " \ | 89 #define QUIC_FLAG(type, flag, value) CHECK_EQ(value, flag); |
| 90 << "without using a QuicFlagSaver"; | |
| 91 #include "net/quic/core/quic_flags_list.h" | 90 #include "net/quic/core/quic_flags_list.h" |
| 92 #undef QUIC_FLAG | 91 #undef QUIC_FLAG |
| 93 } | 92 } |
| 94 | 93 |
| 95 QuicFlagSaver::~QuicFlagSaver() { | 94 QuicFlagSaver::~QuicFlagSaver() { |
| 96 #define QUIC_FLAG(type, flag, value) flag = value; | 95 #define QUIC_FLAG(type, flag, value) flag = value; |
| 97 #include "net/quic/core/quic_flags_list.h" | 96 #include "net/quic/core/quic_flags_list.h" |
| 98 #undef QUIC_FLAG | 97 #undef QUIC_FLAG |
| 99 } | 98 } |
| 100 | 99 |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 QuicTime::Delta connection_start_time, | 843 QuicTime::Delta connection_start_time, |
| 845 QuicVersionVector supported_versions, | 844 QuicVersionVector supported_versions, |
| 846 MockQuicConnectionHelper* helper, | 845 MockQuicConnectionHelper* helper, |
| 847 MockAlarmFactory* alarm_factory, | 846 MockAlarmFactory* alarm_factory, |
| 848 QuicCryptoClientConfig* crypto_client_config, | 847 QuicCryptoClientConfig* crypto_client_config, |
| 849 PacketSavingConnection** client_connection, | 848 PacketSavingConnection** client_connection, |
| 850 TestQuicSpdyClientSession** client_session) { | 849 TestQuicSpdyClientSession** client_session) { |
| 851 CHECK(crypto_client_config); | 850 CHECK(crypto_client_config); |
| 852 CHECK(client_connection); | 851 CHECK(client_connection); |
| 853 CHECK(client_session); | 852 CHECK(client_session); |
| 854 CHECK(!connection_start_time.IsZero()) | 853 // Connections must start at non-zero times, otherwise the strike-register |
| 855 << "Connections must start at non-zero times, otherwise the " | 854 // will be unhappy. |
| 856 << "strike-register will be unhappy."; | 855 CHECK(!connection_start_time.IsZero()); |
| 857 | 856 |
| 858 QuicConfig config = supports_stateless_rejects | 857 QuicConfig config = supports_stateless_rejects |
| 859 ? DefaultQuicConfigStatelessRejects() | 858 ? DefaultQuicConfigStatelessRejects() |
| 860 : DefaultQuicConfig(); | 859 : DefaultQuicConfig(); |
| 861 *client_connection = new PacketSavingConnection( | 860 *client_connection = new PacketSavingConnection( |
| 862 helper, alarm_factory, Perspective::IS_CLIENT, supported_versions); | 861 helper, alarm_factory, Perspective::IS_CLIENT, supported_versions); |
| 863 *client_session = new TestQuicSpdyClientSession( | 862 *client_session = new TestQuicSpdyClientSession( |
| 864 *client_connection, config, server_id, crypto_client_config); | 863 *client_connection, config, server_id, crypto_client_config); |
| 865 (*client_connection)->AdvanceTime(connection_start_time); | 864 (*client_connection)->AdvanceTime(connection_start_time); |
| 866 } | 865 } |
| 867 | 866 |
| 868 void CreateServerSessionForTest( | 867 void CreateServerSessionForTest( |
| 869 QuicServerId server_id, | 868 QuicServerId server_id, |
| 870 QuicTime::Delta connection_start_time, | 869 QuicTime::Delta connection_start_time, |
| 871 QuicVersionVector supported_versions, | 870 QuicVersionVector supported_versions, |
| 872 MockQuicConnectionHelper* helper, | 871 MockQuicConnectionHelper* helper, |
| 873 MockAlarmFactory* alarm_factory, | 872 MockAlarmFactory* alarm_factory, |
| 874 QuicCryptoServerConfig* server_crypto_config, | 873 QuicCryptoServerConfig* server_crypto_config, |
| 875 QuicCompressedCertsCache* compressed_certs_cache, | 874 QuicCompressedCertsCache* compressed_certs_cache, |
| 876 PacketSavingConnection** server_connection, | 875 PacketSavingConnection** server_connection, |
| 877 TestQuicSpdyServerSession** server_session) { | 876 TestQuicSpdyServerSession** server_session) { |
| 878 CHECK(server_crypto_config); | 877 CHECK(server_crypto_config); |
| 879 CHECK(server_connection); | 878 CHECK(server_connection); |
| 880 CHECK(server_session); | 879 CHECK(server_session); |
| 881 CHECK(!connection_start_time.IsZero()) | 880 // Connections must start at non-zero times, otherwise the strike-register |
| 882 << "Connections must start at non-zero times, otherwise the " | 881 // will be unhappy. |
| 883 << "strike-register will be unhappy."; | 882 CHECK(!connection_start_time.IsZero()); |
| 884 | 883 |
| 885 *server_connection = new PacketSavingConnection( | 884 *server_connection = new PacketSavingConnection( |
| 886 helper, alarm_factory, Perspective::IS_SERVER, supported_versions); | 885 helper, alarm_factory, Perspective::IS_SERVER, supported_versions); |
| 887 *server_session = new TestQuicSpdyServerSession( | 886 *server_session = new TestQuicSpdyServerSession( |
| 888 *server_connection, DefaultQuicConfig(), server_crypto_config, | 887 *server_connection, DefaultQuicConfig(), server_crypto_config, |
| 889 compressed_certs_cache); | 888 compressed_certs_cache); |
| 890 | 889 |
| 891 // We advance the clock initially because the default time is zero and the | 890 // We advance the clock initially because the default time is zero and the |
| 892 // strike register worries that we've just overflowed a uint32_t time. | 891 // strike register worries that we've just overflowed a uint32_t time. |
| 893 (*server_connection)->AdvanceTime(connection_start_time); | 892 (*server_connection)->AdvanceTime(connection_start_time); |
| 894 } | 893 } |
| 895 | 894 |
| 896 QuicStreamId QuicClientDataStreamId(int i) { | 895 QuicStreamId QuicClientDataStreamId(int i) { |
| 897 return kClientDataStreamId1 + 2 * i; | 896 return kClientDataStreamId1 + 2 * i; |
| 898 } | 897 } |
| 899 | 898 |
| 900 } // namespace test | 899 } // namespace test |
| 901 } // namespace net | 900 } // namespace net |
| OLD | NEW |