| 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_session.h" | 5 #include "net/quic/quic_session.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
| 10 #include "net/quic/crypto/crypto_handshake.h" | 10 #include "net/quic/crypto/crypto_handshake.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 virtual uint32 ProcessData(const char* data, uint32 data_len) { | 53 virtual uint32 ProcessData(const char* data, uint32 data_len) { |
| 54 return data_len; | 54 return data_len; |
| 55 } | 55 } |
| 56 | 56 |
| 57 MOCK_METHOD0(OnCanWrite, void()); | 57 MOCK_METHOD0(OnCanWrite, void()); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 class TestSession : public QuicSession { | 60 class TestSession : public QuicSession { |
| 61 public: | 61 public: |
| 62 TestSession(QuicConnection* connection, bool is_server) | 62 TestSession(QuicConnection* connection, bool is_server) |
| 63 : QuicSession(connection, QuicConfig(), is_server), | 63 : QuicSession(connection, DefaultQuicConfig(), is_server), |
| 64 crypto_stream_(this) { | 64 crypto_stream_(this) { |
| 65 config()->SetDefaults(); | |
| 66 } | 65 } |
| 67 | 66 |
| 68 virtual QuicCryptoStream* GetCryptoStream() OVERRIDE { | 67 virtual QuicCryptoStream* GetCryptoStream() OVERRIDE { |
| 69 return &crypto_stream_; | 68 return &crypto_stream_; |
| 70 } | 69 } |
| 71 | 70 |
| 72 virtual TestStream* CreateOutgoingReliableStream() OVERRIDE { | 71 virtual TestStream* CreateOutgoingReliableStream() OVERRIDE { |
| 73 TestStream* stream = new TestStream(GetNextStreamId(), this); | 72 TestStream* stream = new TestStream(GetNextStreamId(), this); |
| 74 ActivateStream(stream); | 73 ActivateStream(stream); |
| 75 return stream; | 74 return stream; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 86 ReliableQuicStream* GetIncomingReliableStream(QuicStreamId stream_id) { | 85 ReliableQuicStream* GetIncomingReliableStream(QuicStreamId stream_id) { |
| 87 return QuicSession::GetIncomingReliableStream(stream_id); | 86 return QuicSession::GetIncomingReliableStream(stream_id); |
| 88 } | 87 } |
| 89 | 88 |
| 90 // Helper method for gmock | 89 // Helper method for gmock |
| 91 void MarkTwoWriteBlocked() { | 90 void MarkTwoWriteBlocked() { |
| 92 this->MarkWriteBlocked(2); | 91 this->MarkWriteBlocked(2); |
| 93 } | 92 } |
| 94 | 93 |
| 95 TestCryptoStream crypto_stream_; | 94 TestCryptoStream crypto_stream_; |
| 96 QuicConfig config_; | |
| 97 }; | 95 }; |
| 98 | 96 |
| 99 class QuicSessionTest : public ::testing::Test { | 97 class QuicSessionTest : public ::testing::Test { |
| 100 protected: | 98 protected: |
| 101 QuicSessionTest() | 99 QuicSessionTest() |
| 102 : guid_(1), | 100 : guid_(1), |
| 103 connection_(new MockConnection(guid_, IPEndPoint(), false)), | 101 connection_(new MockConnection(guid_, IPEndPoint(), false)), |
| 104 session_(connection_, true) { | 102 session_(connection_, true) { |
| 105 } | 103 } |
| 106 | 104 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 SendGoAway(QUIC_PEER_GOING_AWAY, 0u, "Going Away.")); | 226 SendGoAway(QUIC_PEER_GOING_AWAY, 0u, "Going Away.")); |
| 229 session_.SendGoAway(QUIC_PEER_GOING_AWAY, "Going Away."); | 227 session_.SendGoAway(QUIC_PEER_GOING_AWAY, "Going Away."); |
| 230 EXPECT_TRUE(session_.goaway_sent()); | 228 EXPECT_TRUE(session_.goaway_sent()); |
| 231 | 229 |
| 232 EXPECT_CALL(*connection_, SendRstStream(3u, QUIC_STREAM_PEER_GOING_AWAY)); | 230 EXPECT_CALL(*connection_, SendRstStream(3u, QUIC_STREAM_PEER_GOING_AWAY)); |
| 233 EXPECT_FALSE(session_.GetIncomingReliableStream(3u)); | 231 EXPECT_FALSE(session_.GetIncomingReliableStream(3u)); |
| 234 } | 232 } |
| 235 | 233 |
| 236 TEST_F(QuicSessionTest, IncreasedTimeoutAfterCryptoHandshake) { | 234 TEST_F(QuicSessionTest, IncreasedTimeoutAfterCryptoHandshake) { |
| 237 EXPECT_EQ(kDefaultInitialTimeoutSecs, | 235 EXPECT_EQ(kDefaultInitialTimeoutSecs, |
| 238 QuicConnectionPeer::GetTimeout(connection_).ToSeconds()); | 236 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds()); |
| 239 CryptoHandshakeMessage msg; | 237 CryptoHandshakeMessage msg; |
| 240 session_.crypto_stream_.OnHandshakeMessage(msg); | 238 session_.crypto_stream_.OnHandshakeMessage(msg); |
| 241 EXPECT_EQ(kDefaultTimeoutSecs, | 239 EXPECT_EQ(kDefaultTimeoutSecs, |
| 242 QuicConnectionPeer::GetTimeout(connection_).ToSeconds()); | 240 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds()); |
| 243 } | 241 } |
| 244 | 242 |
| 245 } // namespace | 243 } // namespace |
| 246 } // namespace test | 244 } // namespace test |
| 247 } // namespace net | 245 } // namespace net |
| OLD | NEW |