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 21 matching lines...) Expand all Loading... |
32 namespace test { | 32 namespace test { |
33 namespace { | 33 namespace { |
34 | 34 |
35 const char kServerHostname[] = "www.example.org"; | 35 const char kServerHostname[] = "www.example.org"; |
36 const uint16 kPort = 80; | 36 const uint16 kPort = 80; |
37 | 37 |
38 class ToolsQuicClientSessionTest | 38 class ToolsQuicClientSessionTest |
39 : public ::testing::TestWithParam<QuicVersion> { | 39 : public ::testing::TestWithParam<QuicVersion> { |
40 protected: | 40 protected: |
41 ToolsQuicClientSessionTest() | 41 ToolsQuicClientSessionTest() |
42 : connection_( | 42 : connection_(new PacketSavingConnection(Perspective::IS_CLIENT, |
43 new PacketSavingConnection(false, SupportedVersions(GetParam()))) { | 43 SupportedVersions(GetParam()))) { |
44 session_.reset(new QuicClientSession(DefaultQuicConfig(), connection_)); | 44 session_.reset(new QuicClientSession(DefaultQuicConfig(), connection_)); |
45 session_->InitializeSession( | 45 session_->InitializeSession( |
46 QuicServerId(kServerHostname, kPort, false, PRIVACY_MODE_DISABLED), | 46 QuicServerId(kServerHostname, kPort, false, PRIVACY_MODE_DISABLED), |
47 &crypto_config_); | 47 &crypto_config_); |
48 // Advance the time, because timers do not like uninitialized times. | 48 // Advance the time, because timers do not like uninitialized times. |
49 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 49 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
50 } | 50 } |
51 | 51 |
52 void CompleteCryptoHandshake() { | 52 void CompleteCryptoHandshake() { |
53 session_->CryptoConnect(); | 53 session_->CryptoConnect(); |
54 CryptoTestUtils::HandshakeWithFakeServer( | 54 CryptoTestUtils::HandshakeWithFakeServer( |
55 connection_, session_->GetCryptoStream()); | 55 connection_, session_->GetCryptoStream()); |
56 } | 56 } |
57 | 57 |
58 PacketSavingConnection* connection_; | 58 PacketSavingConnection* connection_; |
59 scoped_ptr<QuicClientSession> session_; | 59 scoped_ptr<QuicClientSession> session_; |
60 QuicCryptoClientConfig crypto_config_; | 60 QuicCryptoClientConfig crypto_config_; |
61 }; | 61 }; |
62 | 62 |
63 INSTANTIATE_TEST_CASE_P(Tests, ToolsQuicClientSessionTest, | 63 INSTANTIATE_TEST_CASE_P(Tests, ToolsQuicClientSessionTest, |
64 ::testing::ValuesIn(QuicSupportedVersions())); | 64 ::testing::ValuesIn(QuicSupportedVersions())); |
65 | 65 |
66 TEST_P(ToolsQuicClientSessionTest, CryptoConnect) { | 66 TEST_P(ToolsQuicClientSessionTest, CryptoConnect) { |
67 CompleteCryptoHandshake(); | 67 CompleteCryptoHandshake(); |
68 } | 68 } |
69 | 69 |
70 TEST_P(ToolsQuicClientSessionTest, MaxNumStreams) { | 70 TEST_P(ToolsQuicClientSessionTest, MaxNumStreams) { |
71 session_->config()->SetMaxStreamsPerConnection(1, 1); | 71 session_->config()->SetMaxStreamsPerConnection(1, 1); |
72 // FLAGS_max_streams_per_connection = 1; | 72 |
73 // Initialize crypto before the client session will create a stream. | 73 // Initialize crypto before the client session will create a stream. |
74 CompleteCryptoHandshake(); | 74 CompleteCryptoHandshake(); |
75 | 75 |
76 QuicSpdyClientStream* stream = session_->CreateOutgoingDataStream(); | 76 QuicSpdyClientStream* stream = session_->CreateOutgoingDataStream(); |
77 ASSERT_TRUE(stream); | 77 ASSERT_TRUE(stream); |
78 EXPECT_FALSE(session_->CreateOutgoingDataStream()); | 78 EXPECT_FALSE(session_->CreateOutgoingDataStream()); |
79 | 79 |
80 // Close a stream and ensure I can now open a new one. | 80 // Close a stream and ensure I can now open a new one. |
81 session_->CloseStream(stream->id()); | 81 session_->CloseStream(stream->id()); |
82 stream = session_->CreateOutgoingDataStream(); | 82 stream = session_->CreateOutgoingDataStream(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // Close connection shouldn't be called. | 136 // Close connection shouldn't be called. |
137 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(0); | 137 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(0); |
138 session_->connection()->ProcessUdpPacket(client_address, server_address, | 138 session_->connection()->ProcessUdpPacket(client_address, server_address, |
139 valid_packet); | 139 valid_packet); |
140 } | 140 } |
141 | 141 |
142 } // namespace | 142 } // namespace |
143 } // namespace test | 143 } // namespace test |
144 } // namespace tools | 144 } // namespace tools |
145 } // namespace net | 145 } // namespace net |
OLD | NEW |