| 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_chromium_client_session.h" | 5 #include "net/quic/quic_chromium_client_session.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 namespace test { | 39 namespace test { |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| 42 const char kServerHostname[] = "www.example.org"; | 42 const char kServerHostname[] = "www.example.org"; |
| 43 const uint16 kServerPort = 80; | 43 const uint16 kServerPort = 80; |
| 44 | 44 |
| 45 class QuicChromiumClientSessionTest | 45 class QuicChromiumClientSessionTest |
| 46 : public ::testing::TestWithParam<QuicVersion> { | 46 : public ::testing::TestWithParam<QuicVersion> { |
| 47 protected: | 47 protected: |
| 48 QuicChromiumClientSessionTest() | 48 QuicChromiumClientSessionTest() |
| 49 : connection_(new PacketSavingConnection(&helper_, | 49 : crypto_config_(CryptoTestUtils::ProofVerifierForTesting()), |
| 50 connection_(new PacketSavingConnection(&helper_, |
| 50 Perspective::IS_CLIENT, | 51 Perspective::IS_CLIENT, |
| 51 SupportedVersions(GetParam()))), | 52 SupportedVersions(GetParam()))), |
| 52 session_(connection_, | 53 session_(connection_, |
| 53 GetSocket().Pass(), | 54 GetSocket().Pass(), |
| 54 /*stream_factory=*/nullptr, | 55 /*stream_factory=*/nullptr, |
| 55 /*crypto_client_stream_factory=*/nullptr, | 56 /*crypto_client_stream_factory=*/nullptr, |
| 56 &clock_, | 57 &clock_, |
| 57 &transport_security_state_, | 58 &transport_security_state_, |
| 58 make_scoped_ptr((QuicServerInfo*)nullptr), | 59 make_scoped_ptr((QuicServerInfo*)nullptr), |
| 59 QuicServerId(kServerHostname, | 60 QuicServerId(kServerHostname, |
| 60 kServerPort, | 61 kServerPort, |
| 61 /*is_secure=*/false, | |
| 62 PRIVACY_MODE_DISABLED), | 62 PRIVACY_MODE_DISABLED), |
| 63 kQuicYieldAfterPacketsRead, | 63 kQuicYieldAfterPacketsRead, |
| 64 QuicTime::Delta::FromMilliseconds( | 64 QuicTime::Delta::FromMilliseconds( |
| 65 kQuicYieldAfterDurationMilliseconds), | 65 kQuicYieldAfterDurationMilliseconds), |
| 66 /*cert_verify_flags=*/0, | 66 /*cert_verify_flags=*/0, |
| 67 DefaultQuicConfig(), | 67 DefaultQuicConfig(), |
| 68 &crypto_config_, | 68 &crypto_config_, |
| 69 "CONNECTION_UNKNOWN", | 69 "CONNECTION_UNKNOWN", |
| 70 base::TimeTicks::Now(), | 70 base::TimeTicks::Now(), |
| 71 base::ThreadTaskRunnerHandle::Get().get(), | 71 base::ThreadTaskRunnerHandle::Get().get(), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 89 | 89 |
| 90 void CompleteCryptoHandshake() { | 90 void CompleteCryptoHandshake() { |
| 91 ASSERT_EQ(ERR_IO_PENDING, | 91 ASSERT_EQ(ERR_IO_PENDING, |
| 92 session_.CryptoConnect(false, callback_.callback())); | 92 session_.CryptoConnect(false, callback_.callback())); |
| 93 CryptoTestUtils::HandshakeWithFakeServer(&helper_, connection_, | 93 CryptoTestUtils::HandshakeWithFakeServer(&helper_, connection_, |
| 94 session_.GetCryptoStream()); | 94 session_.GetCryptoStream()); |
| 95 ASSERT_EQ(OK, callback_.WaitForResult()); | 95 ASSERT_EQ(OK, callback_.WaitForResult()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 MockHelper helper_; | 98 MockHelper helper_; |
| 99 QuicCryptoClientConfig crypto_config_; |
| 99 PacketSavingConnection* connection_; | 100 PacketSavingConnection* connection_; |
| 100 TestNetLog net_log_; | 101 TestNetLog net_log_; |
| 101 MockClientSocketFactory socket_factory_; | 102 MockClientSocketFactory socket_factory_; |
| 102 StaticSocketDataProvider socket_data_; | 103 StaticSocketDataProvider socket_data_; |
| 103 TransportSecurityState transport_security_state_; | 104 TransportSecurityState transport_security_state_; |
| 104 QuicChromiumClientSession session_; | 105 QuicChromiumClientSession session_; |
| 105 MockClock clock_; | 106 MockClock clock_; |
| 106 MockRandom random_; | 107 MockRandom random_; |
| 107 QuicConnectionVisitorInterface* visitor_; | 108 QuicConnectionVisitorInterface* visitor_; |
| 108 TestCompletionCallback callback_; | 109 TestCompletionCallback callback_; |
| 109 QuicCryptoClientConfig crypto_config_; | |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 INSTANTIATE_TEST_CASE_P(Tests, | 112 INSTANTIATE_TEST_CASE_P(Tests, |
| 113 QuicChromiumClientSessionTest, | 113 QuicChromiumClientSessionTest, |
| 114 ::testing::ValuesIn(QuicSupportedVersions())); | 114 ::testing::ValuesIn(QuicSupportedVersions())); |
| 115 | 115 |
| 116 TEST_P(QuicChromiumClientSessionTest, CryptoConnect) { | 116 TEST_P(QuicChromiumClientSessionTest, CryptoConnect) { |
| 117 CompleteCryptoHandshake(); | 117 CompleteCryptoHandshake(); |
| 118 } | 118 } |
| 119 | 119 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 session_.OnProofVerifyDetailsAvailable(details); | 250 session_.OnProofVerifyDetailsAvailable(details); |
| 251 CompleteCryptoHandshake(); | 251 CompleteCryptoHandshake(); |
| 252 QuicChromiumClientSessionPeer::SetChannelIDSent(&session_, true); | 252 QuicChromiumClientSessionPeer::SetChannelIDSent(&session_, true); |
| 253 | 253 |
| 254 EXPECT_TRUE(session_.CanPool("mail.example.org", PRIVACY_MODE_DISABLED)); | 254 EXPECT_TRUE(session_.CanPool("mail.example.org", PRIVACY_MODE_DISABLED)); |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace | 257 } // namespace |
| 258 } // namespace test | 258 } // namespace test |
| 259 } // namespace net | 259 } // namespace net |
| OLD | NEW |