| 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/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 private: | 189 private: |
| 190 StrictMock<TestCryptoStream> crypto_stream_; | 190 StrictMock<TestCryptoStream> crypto_stream_; |
| 191 | 191 |
| 192 bool writev_consumes_all_data_; | 192 bool writev_consumes_all_data_; |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 class QuicSessionTestBase : public ::testing::TestWithParam<QuicVersion> { | 195 class QuicSessionTestBase : public ::testing::TestWithParam<QuicVersion> { |
| 196 protected: | 196 protected: |
| 197 explicit QuicSessionTestBase(Perspective perspective) | 197 explicit QuicSessionTestBase(Perspective perspective) |
| 198 : connection_( | 198 : connection_( |
| 199 new StrictMock<MockConnection>(&helper_, | 199 new StrictMock<MockQuicConnection>(&helper_, |
| 200 &alarm_factory_, | 200 &alarm_factory_, |
| 201 perspective, | 201 perspective, |
| 202 SupportedVersions(GetParam()))), | 202 SupportedVersions(GetParam()))), |
| 203 session_(connection_) { | 203 session_(connection_) { |
| 204 FLAGS_quic_always_log_bugs_for_tests = true; | 204 FLAGS_quic_always_log_bugs_for_tests = true; |
| 205 session_.config()->SetInitialStreamFlowControlWindowToSend( | 205 session_.config()->SetInitialStreamFlowControlWindowToSend( |
| 206 kInitialStreamFlowControlWindowForTest); | 206 kInitialStreamFlowControlWindowForTest); |
| 207 session_.config()->SetInitialSessionFlowControlWindowToSend( | 207 session_.config()->SetInitialSessionFlowControlWindowToSend( |
| 208 kInitialSessionFlowControlWindowForTest); | 208 kInitialSessionFlowControlWindowForTest); |
| 209 headers_[":host"] = "www.google.com"; | 209 headers_[":host"] = "www.google.com"; |
| 210 headers_[":path"] = "/index.hml"; | 210 headers_[":path"] = "/index.hml"; |
| 211 headers_[":scheme"] = "http"; | 211 headers_[":scheme"] = "http"; |
| 212 headers_["cookie"] = | 212 headers_["cookie"] = |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 250 } |
| 251 | 251 |
| 252 void CloseStream(QuicStreamId id) { | 252 void CloseStream(QuicStreamId id) { |
| 253 EXPECT_CALL(*connection_, SendRstStream(id, _, _)); | 253 EXPECT_CALL(*connection_, SendRstStream(id, _, _)); |
| 254 session_.CloseStream(id); | 254 session_.CloseStream(id); |
| 255 closed_streams_.insert(id); | 255 closed_streams_.insert(id); |
| 256 } | 256 } |
| 257 | 257 |
| 258 QuicVersion version() const { return connection_->version(); } | 258 QuicVersion version() const { return connection_->version(); } |
| 259 | 259 |
| 260 MockConnectionHelper helper_; | 260 MockQuicConnectionHelper helper_; |
| 261 MockAlarmFactory alarm_factory_; | 261 MockAlarmFactory alarm_factory_; |
| 262 StrictMock<MockConnection>* connection_; | 262 StrictMock<MockQuicConnection>* connection_; |
| 263 TestSession session_; | 263 TestSession session_; |
| 264 set<QuicStreamId> closed_streams_; | 264 set<QuicStreamId> closed_streams_; |
| 265 SpdyHeaderBlock headers_; | 265 SpdyHeaderBlock headers_; |
| 266 }; | 266 }; |
| 267 | 267 |
| 268 class QuicSessionTestServer : public QuicSessionTestBase { | 268 class QuicSessionTestServer : public QuicSessionTestBase { |
| 269 protected: | 269 protected: |
| 270 QuicSessionTestServer() : QuicSessionTestBase(Perspective::IS_SERVER) {} | 270 QuicSessionTestServer() : QuicSessionTestBase(Perspective::IS_SERVER) {} |
| 271 }; | 271 }; |
| 272 | 272 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 session_.OnCanWrite(); | 668 session_.OnCanWrite(); |
| 669 EXPECT_FALSE(session_.WillingAndAbleToWrite()); | 669 EXPECT_FALSE(session_.WillingAndAbleToWrite()); |
| 670 } | 670 } |
| 671 | 671 |
| 672 TEST_P(QuicSessionTestServer, SendGoAway) { | 672 TEST_P(QuicSessionTestServer, SendGoAway) { |
| 673 MockPacketWriter* writer = static_cast<MockPacketWriter*>( | 673 MockPacketWriter* writer = static_cast<MockPacketWriter*>( |
| 674 QuicConnectionPeer::GetWriter(session_.connection())); | 674 QuicConnectionPeer::GetWriter(session_.connection())); |
| 675 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _)) | 675 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _)) |
| 676 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0))); | 676 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0))); |
| 677 EXPECT_CALL(*connection_, SendGoAway(_, _, _)) | 677 EXPECT_CALL(*connection_, SendGoAway(_, _, _)) |
| 678 .WillOnce(Invoke(connection_, &MockConnection::ReallySendGoAway)); | 678 .WillOnce(Invoke(connection_, &MockQuicConnection::ReallySendGoAway)); |
| 679 session_.SendGoAway(QUIC_PEER_GOING_AWAY, "Going Away."); | 679 session_.SendGoAway(QUIC_PEER_GOING_AWAY, "Going Away."); |
| 680 EXPECT_TRUE(session_.goaway_sent()); | 680 EXPECT_TRUE(session_.goaway_sent()); |
| 681 | 681 |
| 682 const QuicStreamId kTestStreamId = 5u; | 682 const QuicStreamId kTestStreamId = 5u; |
| 683 EXPECT_CALL(*connection_, | 683 EXPECT_CALL(*connection_, |
| 684 SendRstStream(kTestStreamId, QUIC_STREAM_PEER_GOING_AWAY, 0)) | 684 SendRstStream(kTestStreamId, QUIC_STREAM_PEER_GOING_AWAY, 0)) |
| 685 .Times(0); | 685 .Times(0); |
| 686 EXPECT_TRUE(session_.GetOrCreateDynamicStream(kTestStreamId)); | 686 EXPECT_TRUE(session_.GetOrCreateDynamicStream(kTestStreamId)); |
| 687 } | 687 } |
| 688 | 688 |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 session_.OnConfigNegotiated(); | 1181 session_.OnConfigNegotiated(); |
| 1182 EXPECT_LT(session_.max_open_outgoing_streams(), | 1182 EXPECT_LT(session_.max_open_outgoing_streams(), |
| 1183 session_.max_open_incoming_streams()); | 1183 session_.max_open_incoming_streams()); |
| 1184 EXPECT_EQ(session_.max_open_outgoing_streams(), | 1184 EXPECT_EQ(session_.max_open_outgoing_streams(), |
| 1185 kDefaultMaxStreamsPerConnection); | 1185 kDefaultMaxStreamsPerConnection); |
| 1186 } | 1186 } |
| 1187 | 1187 |
| 1188 } // namespace | 1188 } // namespace |
| 1189 } // namespace test | 1189 } // namespace test |
| 1190 } // namespace net | 1190 } // namespace net |
| OLD | NEW |