| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 const char kServerHostname[] = "www.example.com"; | 36 const char kServerHostname[] = "www.example.com"; |
| 37 const uint16 kPort = 80; | 37 const uint16 kPort = 80; |
| 38 | 38 |
| 39 class ToolsQuicClientSessionTest | 39 class ToolsQuicClientSessionTest |
| 40 : public ::testing::TestWithParam<QuicVersion> { | 40 : public ::testing::TestWithParam<QuicVersion> { |
| 41 protected: | 41 protected: |
| 42 ToolsQuicClientSessionTest() | 42 ToolsQuicClientSessionTest() |
| 43 : connection_(new PacketSavingConnection(false, | 43 : connection_(new PacketSavingConnection(false, |
| 44 SupportedVersions(GetParam()))) { | 44 SupportedVersions(GetParam()))) { |
| 45 crypto_config_.SetDefaults(); | |
| 46 session_.reset(new QuicClientSession(DefaultQuicConfig(), connection_)); | 45 session_.reset(new QuicClientSession(DefaultQuicConfig(), connection_)); |
| 47 session_->InitializeSession( | 46 session_->InitializeSession( |
| 48 QuicServerId(kServerHostname, kPort, false, PRIVACY_MODE_DISABLED), | 47 QuicServerId(kServerHostname, kPort, false, PRIVACY_MODE_DISABLED), |
| 49 &crypto_config_); | 48 &crypto_config_); |
| 50 session_->config()->SetDefaults(); | |
| 51 } | 49 } |
| 52 | 50 |
| 53 void CompleteCryptoHandshake() { | 51 void CompleteCryptoHandshake() { |
| 54 ASSERT_TRUE(session_->CryptoConnect()); | 52 ASSERT_TRUE(session_->CryptoConnect()); |
| 55 CryptoTestUtils::HandshakeWithFakeServer( | 53 CryptoTestUtils::HandshakeWithFakeServer( |
| 56 connection_, session_->GetCryptoStream()); | 54 connection_, session_->GetCryptoStream()); |
| 57 } | 55 } |
| 58 | 56 |
| 59 PacketSavingConnection* connection_; | 57 PacketSavingConnection* connection_; |
| 60 scoped_ptr<QuicClientSession> session_; | 58 scoped_ptr<QuicClientSession> session_; |
| 61 QuicCryptoClientConfig crypto_config_; | 59 QuicCryptoClientConfig crypto_config_; |
| 62 }; | 60 }; |
| 63 | 61 |
| 64 INSTANTIATE_TEST_CASE_P(Tests, ToolsQuicClientSessionTest, | 62 INSTANTIATE_TEST_CASE_P(Tests, ToolsQuicClientSessionTest, |
| 65 ::testing::ValuesIn(QuicSupportedVersions())); | 63 ::testing::ValuesIn(QuicSupportedVersions())); |
| 66 | 64 |
| 67 TEST_P(ToolsQuicClientSessionTest, CryptoConnect) { | 65 TEST_P(ToolsQuicClientSessionTest, CryptoConnect) { |
| 68 CompleteCryptoHandshake(); | 66 CompleteCryptoHandshake(); |
| 69 } | 67 } |
| 70 | 68 |
| 71 TEST_P(ToolsQuicClientSessionTest, MaxNumStreams) { | 69 TEST_P(ToolsQuicClientSessionTest, MaxNumStreams) { |
| 72 session_->config()->SetMaxStreamsPerConnection(1, 1); | 70 session_->config()->SetMaxStreamsPerConnection(1, 1); |
| 73 // FLAGS_max_streams_per_connection = 1; | 71 // FLAGS_max_streams_per_connection = 1; |
| 74 // Initialize crypto before the client session will create a stream. | 72 // Initialize crypto before the client session will create a stream. |
| 75 CompleteCryptoHandshake(); | 73 CompleteCryptoHandshake(); |
| 76 | 74 |
| 77 QuicSpdyClientStream* stream = | 75 QuicSpdyClientStream* stream = session_->CreateOutgoingDataStream(); |
| 78 session_->CreateOutgoingDataStream(); | |
| 79 ASSERT_TRUE(stream); | 76 ASSERT_TRUE(stream); |
| 80 EXPECT_FALSE(session_->CreateOutgoingDataStream()); | 77 EXPECT_FALSE(session_->CreateOutgoingDataStream()); |
| 81 | 78 |
| 82 // Close a stream and ensure I can now open a new one. | 79 // Close a stream and ensure I can now open a new one. |
| 83 session_->CloseStream(stream->id()); | 80 session_->CloseStream(stream->id()); |
| 84 stream = session_->CreateOutgoingDataStream(); | 81 stream = session_->CreateOutgoingDataStream(); |
| 85 EXPECT_TRUE(stream); | 82 EXPECT_TRUE(stream); |
| 86 } | 83 } |
| 87 | 84 |
| 88 TEST_P(ToolsQuicClientSessionTest, GoAwayReceived) { | 85 TEST_P(ToolsQuicClientSessionTest, GoAwayReceived) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Close connection shouldn't be called. | 141 // Close connection shouldn't be called. |
| 145 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(0); | 142 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(0); |
| 146 session_->connection()->ProcessUdpPacket(client_address, server_address, | 143 session_->connection()->ProcessUdpPacket(client_address, server_address, |
| 147 valid_packet); | 144 valid_packet); |
| 148 } | 145 } |
| 149 | 146 |
| 150 } // namespace | 147 } // namespace |
| 151 } // namespace test | 148 } // namespace test |
| 152 } // namespace tools | 149 } // namespace tools |
| 153 } // namespace net | 150 } // namespace net |
| OLD | NEW |