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_client_session.h" | 5 #include "net/quic/quic_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 25 matching lines...) Expand all Loading... |
36 namespace { | 36 namespace { |
37 | 37 |
38 const char kServerHostname[] = "www.example.org"; | 38 const char kServerHostname[] = "www.example.org"; |
39 const uint16 kServerPort = 80; | 39 const uint16 kServerPort = 80; |
40 | 40 |
41 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { | 41 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { |
42 protected: | 42 protected: |
43 QuicClientSessionTest() | 43 QuicClientSessionTest() |
44 : connection_( | 44 : connection_( |
45 new PacketSavingConnection(false, SupportedVersions(GetParam()))), | 45 new PacketSavingConnection(false, SupportedVersions(GetParam()))), |
46 session_(connection_, GetSocket().Pass(), NULL, | 46 session_(connection_, GetSocket().Pass(), nullptr, |
47 &transport_security_state_, | 47 &transport_security_state_, |
48 make_scoped_ptr((QuicServerInfo*)NULL), DefaultQuicConfig(), | 48 make_scoped_ptr((QuicServerInfo*)nullptr), DefaultQuicConfig(), |
49 base::MessageLoop::current()->message_loop_proxy().get(), | 49 base::MessageLoop::current()->message_loop_proxy().get(), |
50 &net_log_) { | 50 &net_log_) { |
51 session_.InitializeSession(QuicServerId(kServerHostname, kServerPort, false, | 51 session_.InitializeSession(QuicServerId(kServerHostname, kServerPort, false, |
52 PRIVACY_MODE_DISABLED), | 52 PRIVACY_MODE_DISABLED), |
53 &crypto_config_, NULL); | 53 &crypto_config_, nullptr); |
54 session_.config()->SetDefaults(); | 54 session_.config()->SetDefaults(); |
55 crypto_config_.SetDefaults(); | 55 crypto_config_.SetDefaults(); |
56 } | 56 } |
57 | 57 |
58 virtual void TearDown() OVERRIDE { | 58 virtual void TearDown() OVERRIDE { |
59 session_.CloseSessionOnError(ERR_ABORTED); | 59 session_.CloseSessionOnError(ERR_ABORTED); |
60 } | 60 } |
61 | 61 |
62 scoped_ptr<DatagramClientSocket> GetSocket() { | 62 scoped_ptr<DatagramClientSocket> GetSocket() { |
63 socket_factory_.AddSocketDataProvider(&socket_data_); | 63 socket_factory_.AddSocketDataProvider(&socket_data_); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 QuicClientSession::StreamRequest stream_request; | 124 QuicClientSession::StreamRequest stream_request; |
125 TestCompletionCallback callback; | 125 TestCompletionCallback callback; |
126 ASSERT_EQ(ERR_IO_PENDING, | 126 ASSERT_EQ(ERR_IO_PENDING, |
127 stream_request.StartRequest(session_.GetWeakPtr(), &stream, | 127 stream_request.StartRequest(session_.GetWeakPtr(), &stream, |
128 callback.callback())); | 128 callback.callback())); |
129 | 129 |
130 // Close a stream and ensure I can now open a new one. | 130 // Close a stream and ensure I can now open a new one. |
131 session_.CloseStream(streams[0]->id()); | 131 session_.CloseStream(streams[0]->id()); |
132 ASSERT_TRUE(callback.have_result()); | 132 ASSERT_TRUE(callback.have_result()); |
133 EXPECT_EQ(OK, callback.WaitForResult()); | 133 EXPECT_EQ(OK, callback.WaitForResult()); |
134 EXPECT_TRUE(stream != NULL); | 134 EXPECT_TRUE(stream != nullptr); |
135 } | 135 } |
136 | 136 |
137 TEST_P(QuicClientSessionTest, GoAwayReceived) { | 137 TEST_P(QuicClientSessionTest, GoAwayReceived) { |
138 CompleteCryptoHandshake(); | 138 CompleteCryptoHandshake(); |
139 | 139 |
140 // After receiving a GoAway, I should no longer be able to create outgoing | 140 // After receiving a GoAway, I should no longer be able to create outgoing |
141 // streams. | 141 // streams. |
142 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); | 142 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); |
143 EXPECT_EQ(NULL, session_.CreateOutgoingDataStream()); | 143 EXPECT_EQ(nullptr, session_.CreateOutgoingDataStream()); |
144 } | 144 } |
145 | 145 |
146 TEST_P(QuicClientSessionTest, CanPool) { | 146 TEST_P(QuicClientSessionTest, CanPool) { |
147 // Load a cert that is valid for: | 147 // Load a cert that is valid for: |
148 // www.example.org | 148 // www.example.org |
149 // mail.example.org | 149 // mail.example.org |
150 // www.example.com | 150 // www.example.com |
151 | 151 |
152 ProofVerifyDetailsChromium details; | 152 ProofVerifyDetailsChromium details; |
153 details.cert_verify_result.verified_cert = | 153 details.cert_verify_result.verified_cert = |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 session_.OnProofVerifyDetailsAvailable(details); | 226 session_.OnProofVerifyDetailsAvailable(details); |
227 CompleteCryptoHandshake(); | 227 CompleteCryptoHandshake(); |
228 QuicClientSessionPeer::SetChannelIDSent(&session_, true); | 228 QuicClientSessionPeer::SetChannelIDSent(&session_, true); |
229 | 229 |
230 EXPECT_TRUE(session_.CanPool("mail.example.org")); | 230 EXPECT_TRUE(session_.CanPool("mail.example.org")); |
231 } | 231 } |
232 | 232 |
233 } // namespace | 233 } // namespace |
234 } // namespace test | 234 } // namespace test |
235 } // namespace net | 235 } // namespace net |
OLD | NEW |