| 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/tools/quic/quic_client_session.h" | 5 #include "net/tools/quic/quic_client_session.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "net/base/ip_endpoint.h" | 9 #include "net/base/ip_endpoint.h" |
| 10 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" | 10 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 using testing::AnyNumber; | 29 using testing::AnyNumber; |
| 30 using testing::Invoke; | 30 using testing::Invoke; |
| 31 using testing::Truly; | 31 using testing::Truly; |
| 32 using testing::_; | 32 using testing::_; |
| 33 | 33 |
| 34 namespace net { | 34 namespace net { |
| 35 namespace tools { | 35 namespace tools { |
| 36 namespace test { | 36 namespace test { |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 const char kServerHostname[] = "www.example.org"; | 39 const char kServerHostname[] = "test.example.com"; |
| 40 const uint16 kPort = 80; | 40 const uint16 kPort = 80; |
| 41 | 41 |
| 42 class ToolsQuicClientSessionTest | 42 class ToolsQuicClientSessionTest |
| 43 : public ::testing::TestWithParam<QuicVersion> { | 43 : public ::testing::TestWithParam<QuicVersion> { |
| 44 protected: | 44 protected: |
| 45 ToolsQuicClientSessionTest() | 45 ToolsQuicClientSessionTest() |
| 46 : connection_(new PacketSavingConnection(Perspective::IS_CLIENT, | 46 : crypto_config_(CryptoTestUtils::ProofVerifierForTesting()), |
| 47 SupportedVersions(GetParam()))) { | 47 connection_(new PacketSavingConnection(Perspective::IS_CLIENT, |
| 48 session_.reset(new QuicClientSession( | 48 SupportedVersions(GetParam()))), |
| 49 DefaultQuicConfig(), connection_, | 49 session_(new QuicClientSession( |
| 50 QuicServerId(kServerHostname, kPort, false, PRIVACY_MODE_DISABLED), | 50 DefaultQuicConfig(), |
| 51 &crypto_config_)); | 51 connection_, |
| 52 QuicServerId(kServerHostname, kPort, PRIVACY_MODE_DISABLED), |
| 53 &crypto_config_)) { |
| 52 session_->Initialize(); | 54 session_->Initialize(); |
| 53 // Advance the time, because timers do not like uninitialized times. | 55 // Advance the time, because timers do not like uninitialized times. |
| 54 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 56 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
| 55 } | 57 } |
| 56 | 58 |
| 57 void CompleteCryptoHandshake() { | 59 void CompleteCryptoHandshake() { |
| 58 session_->CryptoConnect(); | 60 session_->CryptoConnect(); |
| 59 CryptoTestUtils::HandshakeWithFakeServer( | 61 CryptoTestUtils::HandshakeWithFakeServer( |
| 60 connection_, session_->GetCryptoStream()); | 62 connection_, session_->GetCryptoStream()); |
| 61 } | 63 } |
| 62 | 64 |
| 65 QuicCryptoClientConfig crypto_config_; |
| 63 PacketSavingConnection* connection_; | 66 PacketSavingConnection* connection_; |
| 64 scoped_ptr<QuicClientSession> session_; | 67 scoped_ptr<QuicClientSession> session_; |
| 65 QuicCryptoClientConfig crypto_config_; | |
| 66 }; | 68 }; |
| 67 | 69 |
| 68 INSTANTIATE_TEST_CASE_P(Tests, ToolsQuicClientSessionTest, | 70 INSTANTIATE_TEST_CASE_P(Tests, ToolsQuicClientSessionTest, |
| 69 ::testing::ValuesIn(QuicSupportedVersions())); | 71 ::testing::ValuesIn(QuicSupportedVersions())); |
| 70 | 72 |
| 71 TEST_P(ToolsQuicClientSessionTest, CryptoConnect) { | 73 TEST_P(ToolsQuicClientSessionTest, CryptoConnect) { |
| 72 CompleteCryptoHandshake(); | 74 CompleteCryptoHandshake(); |
| 73 } | 75 } |
| 74 | 76 |
| 75 TEST_P(ToolsQuicClientSessionTest, MaxNumStreams) { | 77 TEST_P(ToolsQuicClientSessionTest, MaxNumStreams) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 PACKET_6BYTE_PACKET_NUMBER, nullptr)); | 180 PACKET_6BYTE_PACKET_NUMBER, nullptr)); |
| 179 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(1); | 181 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(1); |
| 180 session_->connection()->ProcessUdpPacket(client_address, server_address, | 182 session_->connection()->ProcessUdpPacket(client_address, server_address, |
| 181 *packet); | 183 *packet); |
| 182 } | 184 } |
| 183 | 185 |
| 184 } // namespace | 186 } // namespace |
| 185 } // namespace test | 187 } // namespace test |
| 186 } // namespace tools | 188 } // namespace tools |
| 187 } // namespace net | 189 } // namespace net |
| OLD | NEW |