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/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "net/base/capturing_net_log.h" | 10 #include "net/base/capturing_net_log.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 namespace net { | 27 namespace net { |
28 namespace test { | 28 namespace test { |
29 namespace { | 29 namespace { |
30 | 30 |
31 const char kServerHostname[] = "www.example.com"; | 31 const char kServerHostname[] = "www.example.com"; |
32 const uint16 kServerPort = 80; | 32 const uint16 kServerPort = 80; |
33 | 33 |
34 class TestPacketWriter : public QuicDefaultPacketWriter { | 34 class TestPacketWriter : public QuicDefaultPacketWriter { |
35 public: | 35 public: |
36 TestPacketWriter(QuicVersion version) : version_(version) { | 36 TestPacketWriter(QuicVersion version) : version_(version) {} |
37 } | |
38 | 37 |
39 // QuicPacketWriter | 38 // QuicPacketWriter |
40 virtual WriteResult WritePacket( | 39 virtual WriteResult WritePacket( |
41 const char* buffer, size_t buf_len, | 40 const char* buffer, size_t buf_len, |
42 const IPAddressNumber& self_address, | 41 const IPAddressNumber& self_address, |
43 const IPEndPoint& peer_address) OVERRIDE { | 42 const IPEndPoint& peer_address) OVERRIDE { |
44 SimpleQuicFramer framer(SupportedVersions(version_)); | 43 SimpleQuicFramer framer(SupportedVersions(version_)); |
45 QuicEncryptedPacket packet(buffer, buf_len); | 44 QuicEncryptedPacket packet(buffer, buf_len); |
46 EXPECT_TRUE(framer.ProcessPacket(packet)); | 45 EXPECT_TRUE(framer.ProcessPacket(packet)); |
47 header_ = framer.header(); | 46 header_ = framer.header(); |
(...skipping 17 matching lines...) Expand all Loading... |
65 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { | 64 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { |
66 protected: | 65 protected: |
67 QuicClientSessionTest() | 66 QuicClientSessionTest() |
68 : writer_(new TestPacketWriter(GetParam())), | 67 : writer_(new TestPacketWriter(GetParam())), |
69 connection_( | 68 connection_( |
70 new PacketSavingConnection(false, SupportedVersions(GetParam()))), | 69 new PacketSavingConnection(false, SupportedVersions(GetParam()))), |
71 session_(connection_, GetSocket().Pass(), writer_.Pass(), NULL, NULL, | 70 session_(connection_, GetSocket().Pass(), writer_.Pass(), NULL, NULL, |
72 make_scoped_ptr((QuicServerInfo*)NULL), | 71 make_scoped_ptr((QuicServerInfo*)NULL), |
73 QuicServerId(kServerHostname, kServerPort, false, | 72 QuicServerId(kServerHostname, kServerPort, false, |
74 PRIVACY_MODE_DISABLED), | 73 PRIVACY_MODE_DISABLED), |
75 DefaultQuicConfig(), kInitialFlowControlWindowForTest, | 74 DefaultQuicConfig(), &crypto_config_, |
76 &crypto_config_, | |
77 base::MessageLoop::current()->message_loop_proxy().get(), | 75 base::MessageLoop::current()->message_loop_proxy().get(), |
78 &net_log_) { | 76 &net_log_) { |
79 session_.config()->SetDefaults(); | 77 session_.config()->SetDefaults(); |
80 crypto_config_.SetDefaults(); | 78 crypto_config_.SetDefaults(); |
81 } | 79 } |
82 | 80 |
83 virtual void TearDown() OVERRIDE { | 81 virtual void TearDown() OVERRIDE { |
84 session_.CloseSessionOnError(ERR_ABORTED); | 82 session_.CloseSessionOnError(ERR_ABORTED); |
85 } | 83 } |
86 | 84 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 162 |
165 // After receiving a GoAway, I should no longer be able to create outgoing | 163 // After receiving a GoAway, I should no longer be able to create outgoing |
166 // streams. | 164 // streams. |
167 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); | 165 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); |
168 EXPECT_EQ(NULL, session_.CreateOutgoingDataStream()); | 166 EXPECT_EQ(NULL, session_.CreateOutgoingDataStream()); |
169 } | 167 } |
170 | 168 |
171 } // namespace | 169 } // namespace |
172 } // namespace test | 170 } // namespace test |
173 } // namespace net | 171 } // namespace net |
OLD | NEW |