| 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 10 matching lines...) Expand all Loading... |
| 21 #include "net/socket/socket_test_util.h" | 21 #include "net/socket/socket_test_util.h" |
| 22 #include "net/udp/datagram_client_socket.h" | 22 #include "net/udp/datagram_client_socket.h" |
| 23 | 23 |
| 24 using testing::_; | 24 using testing::_; |
| 25 | 25 |
| 26 namespace net { | 26 namespace net { |
| 27 namespace test { | 27 namespace test { |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 const char kServerHostname[] = "www.example.com"; | 30 const char kServerHostname[] = "www.example.com"; |
| 31 const uint16 kServerPort = 80; |
| 31 | 32 |
| 32 class TestPacketWriter : public QuicDefaultPacketWriter { | 33 class TestPacketWriter : public QuicDefaultPacketWriter { |
| 33 public: | 34 public: |
| 34 TestPacketWriter() { | 35 TestPacketWriter() { |
| 35 } | 36 } |
| 36 | 37 |
| 37 // QuicPacketWriter | 38 // QuicPacketWriter |
| 38 virtual WriteResult WritePacket( | 39 virtual WriteResult WritePacket( |
| 39 const char* buffer, size_t buf_len, | 40 const char* buffer, size_t buf_len, |
| 40 const IPAddressNumber& self_address, | 41 const IPAddressNumber& self_address, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 62 }; | 63 }; |
| 63 | 64 |
| 64 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { | 65 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { |
| 65 protected: | 66 protected: |
| 66 QuicClientSessionTest() | 67 QuicClientSessionTest() |
| 67 : writer_(new TestPacketWriter()), | 68 : writer_(new TestPacketWriter()), |
| 68 connection_( | 69 connection_( |
| 69 new PacketSavingConnection(false, SupportedVersions(GetParam()))), | 70 new PacketSavingConnection(false, SupportedVersions(GetParam()))), |
| 70 session_(connection_, GetSocket().Pass(), writer_.Pass(), NULL, | 71 session_(connection_, GetSocket().Pass(), writer_.Pass(), NULL, |
| 71 make_scoped_ptr((QuicServerInfo*)NULL), NULL, | 72 make_scoped_ptr((QuicServerInfo*)NULL), NULL, |
| 72 kServerHostname, DefaultQuicConfig(), &crypto_config_, | 73 QuicSessionKey(kServerHostname, kServerPort, false), |
| 73 &net_log_) { | 74 DefaultQuicConfig(), &crypto_config_, &net_log_) { |
| 74 session_.config()->SetDefaults(); | 75 session_.config()->SetDefaults(); |
| 75 crypto_config_.SetDefaults(); | 76 crypto_config_.SetDefaults(); |
| 76 } | 77 } |
| 77 | 78 |
| 78 virtual void TearDown() OVERRIDE { | 79 virtual void TearDown() OVERRIDE { |
| 79 session_.CloseSessionOnError(ERR_ABORTED); | 80 session_.CloseSessionOnError(ERR_ABORTED); |
| 80 } | 81 } |
| 81 | 82 |
| 82 scoped_ptr<DatagramClientSocket> GetSocket() { | 83 scoped_ptr<DatagramClientSocket> GetSocket() { |
| 83 socket_factory_.AddSocketDataProvider(&socket_data_); | 84 socket_factory_.AddSocketDataProvider(&socket_data_); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 160 |
| 160 // After receiving a GoAway, I should no longer be able to create outgoing | 161 // After receiving a GoAway, I should no longer be able to create outgoing |
| 161 // streams. | 162 // streams. |
| 162 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); | 163 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); |
| 163 EXPECT_EQ(NULL, session_.CreateOutgoingDataStream()); | 164 EXPECT_EQ(NULL, session_.CreateOutgoingDataStream()); |
| 164 } | 165 } |
| 165 | 166 |
| 166 } // namespace | 167 } // namespace |
| 167 } // namespace test | 168 } // namespace test |
| 168 } // namespace net | 169 } // namespace net |
| OLD | NEW |