OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/core/quic_server_session_base.h" | 5 #include "net/quic/core/quic_server_session_base.h" |
6 | 6 |
7 #include <cstdint> | 7 #include <cstdint> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "net/quic/core/crypto/quic_crypto_server_config.h" | 11 #include "net/quic/core/crypto/quic_crypto_server_config.h" |
12 #include "net/quic/core/crypto/quic_random.h" | 12 #include "net/quic/core/crypto/quic_random.h" |
13 #include "net/quic/core/proto/cached_network_parameters.pb.h" | 13 #include "net/quic/core/proto/cached_network_parameters.pb.h" |
14 #include "net/quic/core/quic_connection.h" | 14 #include "net/quic/core/quic_connection.h" |
15 #include "net/quic/core/quic_crypto_server_stream.h" | 15 #include "net/quic/core/quic_crypto_server_stream.h" |
16 #include "net/quic/core/quic_utils.h" | 16 #include "net/quic/core/quic_utils.h" |
17 #include "net/quic/platform/api/quic_flags.h" | 17 #include "net/quic/platform/api/quic_flags.h" |
18 #include "net/quic/platform/api/quic_ptr_util.h" | 18 #include "net/quic/platform/api/quic_ptr_util.h" |
19 #include "net/quic/platform/api/quic_socket_address.h" | 19 #include "net/quic/platform/api/quic_socket_address.h" |
| 20 #include "net/quic/platform/api/quic_test.h" |
20 #include "net/quic/test_tools/crypto_test_utils.h" | 21 #include "net/quic/test_tools/crypto_test_utils.h" |
21 #include "net/quic/test_tools/fake_proof_source.h" | 22 #include "net/quic/test_tools/fake_proof_source.h" |
22 #include "net/quic/test_tools/quic_config_peer.h" | 23 #include "net/quic/test_tools/quic_config_peer.h" |
23 #include "net/quic/test_tools/quic_connection_peer.h" | 24 #include "net/quic/test_tools/quic_connection_peer.h" |
24 #include "net/quic/test_tools/quic_crypto_server_config_peer.h" | 25 #include "net/quic/test_tools/quic_crypto_server_config_peer.h" |
25 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 26 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
26 #include "net/quic/test_tools/quic_session_peer.h" | 27 #include "net/quic/test_tools/quic_session_peer.h" |
27 #include "net/quic/test_tools/quic_spdy_session_peer.h" | 28 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
28 #include "net/quic/test_tools/quic_spdy_stream_peer.h" | 29 #include "net/quic/test_tools/quic_spdy_stream_peer.h" |
29 #include "net/quic/test_tools/quic_stream_peer.h" | 30 #include "net/quic/test_tools/quic_stream_peer.h" |
30 #include "net/quic/test_tools/quic_sustained_bandwidth_recorder_peer.h" | 31 #include "net/quic/test_tools/quic_sustained_bandwidth_recorder_peer.h" |
31 #include "net/quic/test_tools/quic_test_utils.h" | 32 #include "net/quic/test_tools/quic_test_utils.h" |
32 #include "net/test/gtest_util.h" | 33 #include "net/test/gtest_util.h" |
33 #include "net/tools/quic/quic_epoll_connection_helper.h" | 34 #include "net/tools/quic/quic_epoll_connection_helper.h" |
34 #include "net/tools/quic/quic_simple_server_stream.h" | 35 #include "net/tools/quic/quic_simple_server_stream.h" |
35 #include "net/tools/quic/test_tools/mock_quic_session_visitor.h" | 36 #include "net/tools/quic/test_tools/mock_quic_session_visitor.h" |
36 #include "testing/gmock/include/gmock/gmock.h" | |
37 #include "testing/gtest/include/gtest/gtest.h" | |
38 | 37 |
39 using std::string; | 38 using std::string; |
40 using testing::StrictMock; | 39 using testing::StrictMock; |
41 using testing::_; | 40 using testing::_; |
42 | 41 |
43 namespace net { | 42 namespace net { |
44 namespace test { | 43 namespace test { |
45 | 44 |
46 class QuicServerSessionBasePeer { | 45 class QuicServerSessionBasePeer { |
47 public: | 46 public: |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support, this, | 110 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support, this, |
112 stream_helper()); | 111 stream_helper()); |
113 } | 112 } |
114 | 113 |
115 private: | 114 private: |
116 QuicHttpResponseCache* response_cache_; // Owned by QuicServerSessionBaseTest | 115 QuicHttpResponseCache* response_cache_; // Owned by QuicServerSessionBaseTest |
117 }; | 116 }; |
118 | 117 |
119 const size_t kMaxStreamsForTest = 10; | 118 const size_t kMaxStreamsForTest = 10; |
120 | 119 |
121 class QuicServerSessionBaseTest : public ::testing::TestWithParam<QuicVersion> { | 120 class QuicServerSessionBaseTest : public QuicTestWithParam<QuicVersion> { |
122 protected: | 121 protected: |
123 QuicServerSessionBaseTest() | 122 QuicServerSessionBaseTest() |
124 : QuicServerSessionBaseTest(crypto_test_utils::ProofSourceForTesting()) {} | 123 : QuicServerSessionBaseTest(crypto_test_utils::ProofSourceForTesting()) {} |
125 | 124 |
126 explicit QuicServerSessionBaseTest(std::unique_ptr<ProofSource> proof_source) | 125 explicit QuicServerSessionBaseTest(std::unique_ptr<ProofSource> proof_source) |
127 : crypto_config_(QuicCryptoServerConfig::TESTING, | 126 : crypto_config_(QuicCryptoServerConfig::TESTING, |
128 QuicRandom::GetInstance(), | 127 QuicRandom::GetInstance(), |
129 std::move(proof_source)), | 128 std::move(proof_source)), |
130 compressed_certs_cache_( | 129 compressed_certs_cache_( |
131 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) { | 130 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) { |
(...skipping 25 matching lines...) Expand all Loading... |
157 MockQuicConnectionHelper helper_; | 156 MockQuicConnectionHelper helper_; |
158 MockAlarmFactory alarm_factory_; | 157 MockAlarmFactory alarm_factory_; |
159 StrictMock<MockQuicConnection>* connection_; | 158 StrictMock<MockQuicConnection>* connection_; |
160 QuicConfig config_; | 159 QuicConfig config_; |
161 QuicCryptoServerConfig crypto_config_; | 160 QuicCryptoServerConfig crypto_config_; |
162 QuicCompressedCertsCache compressed_certs_cache_; | 161 QuicCompressedCertsCache compressed_certs_cache_; |
163 QuicHttpResponseCache response_cache_; | 162 QuicHttpResponseCache response_cache_; |
164 std::unique_ptr<TestServerSession> session_; | 163 std::unique_ptr<TestServerSession> session_; |
165 std::unique_ptr<CryptoHandshakeMessage> handshake_message_; | 164 std::unique_ptr<CryptoHandshakeMessage> handshake_message_; |
166 QuicConnectionVisitorInterface* visitor_; | 165 QuicConnectionVisitorInterface* visitor_; |
167 QuicFlagSaver flags_; // Save/restore all QUIC flag values. | |
168 }; | 166 }; |
169 | 167 |
170 // Compares CachedNetworkParameters. | 168 // Compares CachedNetworkParameters. |
171 MATCHER_P(EqualsProto, network_params, "") { | 169 MATCHER_P(EqualsProto, network_params, "") { |
172 CachedNetworkParameters reference(network_params); | 170 CachedNetworkParameters reference(network_params); |
173 return (arg->bandwidth_estimate_bytes_per_second() == | 171 return (arg->bandwidth_estimate_bytes_per_second() == |
174 reference.bandwidth_estimate_bytes_per_second() && | 172 reference.bandwidth_estimate_bytes_per_second() && |
175 arg->bandwidth_estimate_bytes_per_second() == | 173 arg->bandwidth_estimate_bytes_per_second() == |
176 reference.bandwidth_estimate_bytes_per_second() && | 174 reference.bandwidth_estimate_bytes_per_second() && |
177 arg->max_bandwidth_estimate_bytes_per_second() == | 175 arg->max_bandwidth_estimate_bytes_per_second() == |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 | 632 |
635 // Allow the async ProofSource::GetProof call to complete. Verify (under | 633 // Allow the async ProofSource::GetProof call to complete. Verify (under |
636 // asan) that this does not result in accesses to any freed memory from the | 634 // asan) that this does not result in accesses to any freed memory from the |
637 // session or its subobjects. | 635 // session or its subobjects. |
638 GetFakeProofSource()->InvokePendingCallback(0); | 636 GetFakeProofSource()->InvokePendingCallback(0); |
639 } | 637 } |
640 | 638 |
641 } // namespace | 639 } // namespace |
642 } // namespace test | 640 } // namespace test |
643 } // namespace net | 641 } // namespace net |
OLD | NEW |