| 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/quic_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "net/base/test_data_directory.h" | 9 #include "net/base/test_data_directory.h" |
| 10 #include "net/cert/cert_verifier.h" | 10 #include "net/cert/cert_verifier.h" |
| 11 #include "net/dns/mock_host_resolver.h" | 11 #include "net/dns/mock_host_resolver.h" |
| 12 #include "net/http/http_response_headers.h" | 12 #include "net/http/http_response_headers.h" |
| 13 #include "net/http/http_response_info.h" | 13 #include "net/http/http_response_info.h" |
| 14 #include "net/http/http_util.h" | 14 #include "net/http/http_util.h" |
| 15 #include "net/quic/crypto/crypto_handshake.h" | 15 #include "net/quic/crypto/crypto_handshake.h" |
| 16 #include "net/quic/crypto/proof_verifier_chromium.h" | 16 #include "net/quic/crypto/proof_verifier_chromium.h" |
| 17 #include "net/quic/crypto/quic_decrypter.h" | 17 #include "net/quic/crypto/quic_decrypter.h" |
| 18 #include "net/quic/crypto/quic_encrypter.h" | 18 #include "net/quic/crypto/quic_encrypter.h" |
| 19 #include "net/quic/quic_http_stream.h" | 19 #include "net/quic/quic_http_stream.h" |
| 20 #include "net/quic/quic_server_id.h" | 20 #include "net/quic/quic_server_id.h" |
| 21 #include "net/quic/test_tools/mock_clock.h" | 21 #include "net/quic/test_tools/mock_clock.h" |
| 22 #include "net/quic/test_tools/mock_crypto_client_stream_factory.h" | 22 #include "net/quic/test_tools/mock_crypto_client_stream_factory.h" |
| 23 #include "net/quic/test_tools/mock_random.h" | 23 #include "net/quic/test_tools/mock_random.h" |
| 24 #include "net/quic/test_tools/quic_test_packet_maker.h" | 24 #include "net/quic/test_tools/quic_test_packet_maker.h" |
| 25 #include "net/quic/test_tools/quic_test_utils.h" | 25 #include "net/quic/test_tools/quic_test_utils.h" |
| 26 #include "net/socket/socket_test_util.h" | 26 #include "net/socket/socket_test_util.h" |
| 27 #include "net/ssl/default_server_bound_cert_store.h" | 27 #include "net/ssl/channel_id_service.h" |
| 28 #include "net/ssl/default_channel_id_store.h" |
| 28 #include "net/test/cert_test_util.h" | 29 #include "net/test/cert_test_util.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 31 |
| 31 using base::StringPiece; | 32 using base::StringPiece; |
| 32 using std::string; | 33 using std::string; |
| 33 using std::vector; | 34 using std::vector; |
| 34 | 35 |
| 35 namespace net { | 36 namespace net { |
| 36 namespace test { | 37 namespace test { |
| 37 | 38 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 84 } |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 class QuicStreamFactoryTest : public ::testing::TestWithParam<QuicVersion> { | 87 class QuicStreamFactoryTest : public ::testing::TestWithParam<QuicVersion> { |
| 87 protected: | 88 protected: |
| 88 QuicStreamFactoryTest() | 89 QuicStreamFactoryTest() |
| 89 : random_generator_(0), | 90 : random_generator_(0), |
| 90 maker_(GetParam(), 0), | 91 maker_(GetParam(), 0), |
| 91 clock_(new MockClock()), | 92 clock_(new MockClock()), |
| 92 cert_verifier_(CertVerifier::CreateDefault()), | 93 cert_verifier_(CertVerifier::CreateDefault()), |
| 93 server_bound_cert_service_(new ServerBoundCertService( | 94 channel_id_service_(new ChannelIDService( |
| 94 new DefaultServerBoundCertStore(NULL), | 95 new DefaultChannelIDStore(NULL), |
| 95 base::MessageLoopProxy::current())), | 96 base::MessageLoopProxy::current())), |
| 96 factory_(&host_resolver_, &socket_factory_, | 97 factory_(&host_resolver_, &socket_factory_, |
| 97 base::WeakPtr<HttpServerProperties>(), cert_verifier_.get(), | 98 base::WeakPtr<HttpServerProperties>(), cert_verifier_.get(), |
| 98 server_bound_cert_service_.get(), | 99 channel_id_service_.get(), |
| 99 &crypto_client_stream_factory_, &random_generator_, clock_, | 100 &crypto_client_stream_factory_, &random_generator_, clock_, |
| 100 kDefaultMaxPacketSize, std::string(), | 101 kDefaultMaxPacketSize, std::string(), |
| 101 SupportedVersions(GetParam()), true, true, true, | 102 SupportedVersions(GetParam()), true, true, true, |
| 102 QuicTagVector()), | 103 QuicTagVector()), |
| 103 host_port_pair_(kDefaultServerHostName, kDefaultServerPort), | 104 host_port_pair_(kDefaultServerHostName, kDefaultServerPort), |
| 104 is_https_(false), | 105 is_https_(false), |
| 105 privacy_mode_(PRIVACY_MODE_DISABLED) { | 106 privacy_mode_(PRIVACY_MODE_DISABLED) { |
| 106 factory_.set_require_confirmation(false); | 107 factory_.set_require_confirmation(false); |
| 107 } | 108 } |
| 108 | 109 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 AdjustErrorForVersion(QUIC_RST_FLOW_CONTROL_ACCOUNTING, GetParam())); | 181 AdjustErrorForVersion(QUIC_RST_FLOW_CONTROL_ACCOUNTING, GetParam())); |
| 181 } | 182 } |
| 182 | 183 |
| 183 MockHostResolver host_resolver_; | 184 MockHostResolver host_resolver_; |
| 184 DeterministicMockClientSocketFactory socket_factory_; | 185 DeterministicMockClientSocketFactory socket_factory_; |
| 185 MockCryptoClientStreamFactory crypto_client_stream_factory_; | 186 MockCryptoClientStreamFactory crypto_client_stream_factory_; |
| 186 MockRandom random_generator_; | 187 MockRandom random_generator_; |
| 187 QuicTestPacketMaker maker_; | 188 QuicTestPacketMaker maker_; |
| 188 MockClock* clock_; // Owned by factory_. | 189 MockClock* clock_; // Owned by factory_. |
| 189 scoped_ptr<CertVerifier> cert_verifier_; | 190 scoped_ptr<CertVerifier> cert_verifier_; |
| 190 scoped_ptr<ServerBoundCertService> server_bound_cert_service_; | 191 scoped_ptr<ChannelIDService> channel_id_service_; |
| 191 QuicStreamFactory factory_; | 192 QuicStreamFactory factory_; |
| 192 HostPortPair host_port_pair_; | 193 HostPortPair host_port_pair_; |
| 193 bool is_https_; | 194 bool is_https_; |
| 194 PrivacyMode privacy_mode_; | 195 PrivacyMode privacy_mode_; |
| 195 BoundNetLog net_log_; | 196 BoundNetLog net_log_; |
| 196 TestCompletionCallback callback_; | 197 TestCompletionCallback callback_; |
| 197 }; | 198 }; |
| 198 | 199 |
| 199 INSTANTIATE_TEST_CASE_P(Version, QuicStreamFactoryTest, | 200 INSTANTIATE_TEST_CASE_P(Version, QuicStreamFactoryTest, |
| 200 ::testing::ValuesIn(QuicSupportedVersions())); | 201 ::testing::ValuesIn(QuicSupportedVersions())); |
| (...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 QuicCryptoClientConfig::CachedState* cached2 = | 1147 QuicCryptoClientConfig::CachedState* cached2 = |
| 1147 crypto_config->LookupOrCreate(server_id2); | 1148 crypto_config->LookupOrCreate(server_id2); |
| 1148 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); | 1149 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); |
| 1149 EXPECT_TRUE(cached2->source_address_token().empty()); | 1150 EXPECT_TRUE(cached2->source_address_token().empty()); |
| 1150 EXPECT_FALSE(cached2->proof_valid()); | 1151 EXPECT_FALSE(cached2->proof_valid()); |
| 1151 } | 1152 } |
| 1152 } | 1153 } |
| 1153 | 1154 |
| 1154 } // namespace test | 1155 } // namespace test |
| 1155 } // namespace net | 1156 } // namespace net |
| OLD | NEW |