OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tools/quic/quic_simple_server_session.h" | 5 #include "net/tools/quic/quic_simple_server_session.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 class QuicSimpleServerSessionTest | 176 class QuicSimpleServerSessionTest |
177 : public ::testing::TestWithParam<QuicVersion> { | 177 : public ::testing::TestWithParam<QuicVersion> { |
178 protected: | 178 protected: |
179 QuicSimpleServerSessionTest() | 179 QuicSimpleServerSessionTest() |
180 : crypto_config_(QuicCryptoServerConfig::TESTING, | 180 : crypto_config_(QuicCryptoServerConfig::TESTING, |
181 QuicRandom::GetInstance(), | 181 QuicRandom::GetInstance(), |
182 CryptoTestUtils::ProofSourceForTesting()), | 182 CryptoTestUtils::ProofSourceForTesting()), |
183 compressed_certs_cache_( | 183 compressed_certs_cache_( |
184 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) { | 184 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) { |
185 FLAGS_quic_always_log_bugs_for_tests = true; | |
186 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest); | 185 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest); |
187 config_.SetMaxIncomingDynamicStreamsToSend(kMaxStreamsForTest); | 186 config_.SetMaxIncomingDynamicStreamsToSend(kMaxStreamsForTest); |
188 QuicConfigPeer::SetReceivedMaxIncomingDynamicStreams(&config_, | 187 QuicConfigPeer::SetReceivedMaxIncomingDynamicStreams(&config_, |
189 kMaxStreamsForTest); | 188 kMaxStreamsForTest); |
190 config_.SetInitialStreamFlowControlWindowToSend( | 189 config_.SetInitialStreamFlowControlWindowToSend( |
191 kInitialStreamFlowControlWindowForTest); | 190 kInitialStreamFlowControlWindowForTest); |
192 config_.SetInitialSessionFlowControlWindowToSend( | 191 config_.SetInitialSessionFlowControlWindowToSend( |
193 kInitialSessionFlowControlWindowForTest); | 192 kInitialSessionFlowControlWindowForTest); |
194 | 193 |
195 connection_ = new StrictMock<MockQuicConnectionWithSendStreamData>( | 194 connection_ = new StrictMock<MockQuicConnectionWithSendStreamData>( |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 visitor_->OnStreamFrame(frame4); | 293 visitor_->OnStreamFrame(frame4); |
295 // The stream should never be opened, now that the reset is received. | 294 // The stream should never be opened, now that the reset is received. |
296 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); | 295 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); |
297 EXPECT_TRUE(connection_->connected()); | 296 EXPECT_TRUE(connection_->connected()); |
298 } | 297 } |
299 | 298 |
300 TEST_P(QuicSimpleServerSessionTest, CreateIncomingDynamicStreamDisconnected) { | 299 TEST_P(QuicSimpleServerSessionTest, CreateIncomingDynamicStreamDisconnected) { |
301 // Tests that incoming stream creation fails when connection is not connected. | 300 // Tests that incoming stream creation fails when connection is not connected. |
302 size_t initial_num_open_stream = session_->GetNumOpenIncomingStreams(); | 301 size_t initial_num_open_stream = session_->GetNumOpenIncomingStreams(); |
303 QuicConnectionPeer::TearDownLocalConnectionState(connection_); | 302 QuicConnectionPeer::TearDownLocalConnectionState(connection_); |
304 EXPECT_DFATAL(QuicSimpleServerSessionPeer::CreateIncomingDynamicStream( | 303 EXPECT_QUIC_BUG(QuicSimpleServerSessionPeer::CreateIncomingDynamicStream( |
305 session_.get(), kClientDataStreamId1), | 304 session_.get(), kClientDataStreamId1), |
306 "ShouldCreateIncomingDynamicStream called when disconnected"); | 305 "ShouldCreateIncomingDynamicStream called when disconnected"); |
307 EXPECT_EQ(initial_num_open_stream, session_->GetNumOpenIncomingStreams()); | 306 EXPECT_EQ(initial_num_open_stream, session_->GetNumOpenIncomingStreams()); |
308 } | 307 } |
309 | 308 |
310 TEST_P(QuicSimpleServerSessionTest, CreateEvenIncomingDynamicStream) { | 309 TEST_P(QuicSimpleServerSessionTest, CreateEvenIncomingDynamicStream) { |
311 // Tests that incoming stream creation fails when given stream id is even. | 310 // Tests that incoming stream creation fails when given stream id is even. |
312 size_t initial_num_open_stream = session_->GetNumOpenIncomingStreams(); | 311 size_t initial_num_open_stream = session_->GetNumOpenIncomingStreams(); |
313 EXPECT_CALL(*connection_, | 312 EXPECT_CALL(*connection_, |
314 CloseConnection(QUIC_INVALID_STREAM_ID, | 313 CloseConnection(QUIC_INVALID_STREAM_ID, |
315 "Client created even numbered stream", _)); | 314 "Client created even numbered stream", _)); |
316 QuicSimpleServerSessionPeer::CreateIncomingDynamicStream(session_.get(), 2); | 315 QuicSimpleServerSessionPeer::CreateIncomingDynamicStream(session_.get(), 2); |
317 EXPECT_EQ(initial_num_open_stream, session_->GetNumOpenIncomingStreams()); | 316 EXPECT_EQ(initial_num_open_stream, session_->GetNumOpenIncomingStreams()); |
318 } | 317 } |
319 | 318 |
320 TEST_P(QuicSimpleServerSessionTest, CreateIncomingDynamicStream) { | 319 TEST_P(QuicSimpleServerSessionTest, CreateIncomingDynamicStream) { |
321 QuicSpdyStream* stream = | 320 QuicSpdyStream* stream = |
322 QuicSimpleServerSessionPeer::CreateIncomingDynamicStream( | 321 QuicSimpleServerSessionPeer::CreateIncomingDynamicStream( |
323 session_.get(), kClientDataStreamId1); | 322 session_.get(), kClientDataStreamId1); |
324 EXPECT_NE(nullptr, stream); | 323 EXPECT_NE(nullptr, stream); |
325 EXPECT_EQ(kClientDataStreamId1, stream->id()); | 324 EXPECT_EQ(kClientDataStreamId1, stream->id()); |
326 } | 325 } |
327 | 326 |
328 TEST_P(QuicSimpleServerSessionTest, CreateOutgoingDynamicStreamDisconnected) { | 327 TEST_P(QuicSimpleServerSessionTest, CreateOutgoingDynamicStreamDisconnected) { |
329 // Tests that outgoing stream creation fails when connection is not connected. | 328 // Tests that outgoing stream creation fails when connection is not connected. |
330 size_t initial_num_open_stream = session_->GetNumOpenOutgoingStreams(); | 329 size_t initial_num_open_stream = session_->GetNumOpenOutgoingStreams(); |
331 QuicConnectionPeer::TearDownLocalConnectionState(connection_); | 330 QuicConnectionPeer::TearDownLocalConnectionState(connection_); |
332 EXPECT_DFATAL(QuicSimpleServerSessionPeer::CreateOutgoingDynamicStream( | 331 EXPECT_QUIC_BUG(QuicSimpleServerSessionPeer::CreateOutgoingDynamicStream( |
333 session_.get(), kDefaultPriority), | 332 session_.get(), kDefaultPriority), |
334 "ShouldCreateOutgoingDynamicStream called when disconnected"); | 333 "ShouldCreateOutgoingDynamicStream called when disconnected"); |
335 | 334 |
336 EXPECT_EQ(initial_num_open_stream, session_->GetNumOpenOutgoingStreams()); | 335 EXPECT_EQ(initial_num_open_stream, session_->GetNumOpenOutgoingStreams()); |
337 } | 336 } |
338 | 337 |
339 TEST_P(QuicSimpleServerSessionTest, CreateOutgoingDynamicStreamUnencrypted) { | 338 TEST_P(QuicSimpleServerSessionTest, CreateOutgoingDynamicStreamUnencrypted) { |
340 // Tests that outgoing stream creation fails when encryption has not yet been | 339 // Tests that outgoing stream creation fails when encryption has not yet been |
341 // established. | 340 // established. |
342 size_t initial_num_open_stream = session_->GetNumOpenOutgoingStreams(); | 341 size_t initial_num_open_stream = session_->GetNumOpenOutgoingStreams(); |
343 EXPECT_DFATAL(QuicSimpleServerSessionPeer::CreateOutgoingDynamicStream( | 342 EXPECT_QUIC_BUG(QuicSimpleServerSessionPeer::CreateOutgoingDynamicStream( |
344 session_.get(), kDefaultPriority), | 343 session_.get(), kDefaultPriority), |
345 "Encryption not established so no outgoing stream created."); | 344 "Encryption not established so no outgoing stream created."); |
346 EXPECT_EQ(initial_num_open_stream, session_->GetNumOpenOutgoingStreams()); | 345 EXPECT_EQ(initial_num_open_stream, session_->GetNumOpenOutgoingStreams()); |
347 } | 346 } |
348 | 347 |
349 TEST_P(QuicSimpleServerSessionTest, CreateOutgoingDynamicStreamUptoLimit) { | 348 TEST_P(QuicSimpleServerSessionTest, CreateOutgoingDynamicStreamUptoLimit) { |
350 // Tests that outgoing stream creation should not be affected by existing | 349 // Tests that outgoing stream creation should not be affected by existing |
351 // incoming stream and vice-versa. But when reaching the limit of max outgoing | 350 // incoming stream and vice-versa. But when reaching the limit of max outgoing |
352 // stream allowed, creation should fail. | 351 // stream allowed, creation should fail. |
353 | 352 |
354 // Receive some data to initiate a incoming stream which should not effect | 353 // Receive some data to initiate a incoming stream which should not effect |
355 // creating outgoing streams. | 354 // creating outgoing streams. |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 .WillOnce(Return(QuicConsumedData(kStreamFlowControlWindowSize, false))); | 623 .WillOnce(Return(QuicConsumedData(kStreamFlowControlWindowSize, false))); |
625 | 624 |
626 EXPECT_CALL(*connection_, SendBlocked(stream_to_open)); | 625 EXPECT_CALL(*connection_, SendBlocked(stream_to_open)); |
627 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0); | 626 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0); |
628 visitor_->OnRstStream(rst); | 627 visitor_->OnRstStream(rst); |
629 } | 628 } |
630 | 629 |
631 } // namespace | 630 } // namespace |
632 } // namespace test | 631 } // namespace test |
633 } // namespace net | 632 } // namespace net |
OLD | NEW |