| 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/tools/quic/quic_client_session.h" | 5 #include "net/tools/quic/quic_client_session.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" | 9 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" |
| 10 #include "net/quic/core/quic_flags.h" | 10 #include "net/quic/core/quic_flags.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 QuicIOVector iovector(&iov, 1, iov.iov_len); | 167 QuicIOVector iovector(&iov, 1, iov.iov_len); |
| 168 QuicConsumedData consumed = | 168 QuicConsumedData consumed = |
| 169 session_->WritevData(stream, stream->id(), iovector, 0, false, nullptr); | 169 session_->WritevData(stream, stream->id(), iovector, 0, false, nullptr); |
| 170 EXPECT_FALSE(consumed.fin_consumed); | 170 EXPECT_FALSE(consumed.fin_consumed); |
| 171 EXPECT_EQ(0u, consumed.bytes_consumed); | 171 EXPECT_EQ(0u, consumed.bytes_consumed); |
| 172 } | 172 } |
| 173 | 173 |
| 174 TEST_P(QuicClientSessionTest, MaxNumStreamsWithNoFinOrRst) { | 174 TEST_P(QuicClientSessionTest, MaxNumStreamsWithNoFinOrRst) { |
| 175 EXPECT_CALL(*connection_, SendRstStream(_, _, _)).Times(AnyNumber()); | 175 EXPECT_CALL(*connection_, SendRstStream(_, _, _)).Times(AnyNumber()); |
| 176 | 176 |
| 177 if (GetParam() <= QUIC_VERSION_34) { | 177 const uint32_t kServerMaxIncomingStreams = 1; |
| 178 session_->config()->SetMaxStreamsPerConnection(1, 1); | 178 CompleteCryptoHandshake(kServerMaxIncomingStreams); |
| 179 | |
| 180 // Initialize crypto before the client session will create a stream. | |
| 181 CompleteCryptoHandshake(); | |
| 182 } else { | |
| 183 const uint32_t kServerMaxIncomingStreams = 1; | |
| 184 CompleteCryptoHandshake(kServerMaxIncomingStreams); | |
| 185 } | |
| 186 | 179 |
| 187 QuicSpdyClientStream* stream = | 180 QuicSpdyClientStream* stream = |
| 188 session_->CreateOutgoingDynamicStream(kDefaultPriority); | 181 session_->CreateOutgoingDynamicStream(kDefaultPriority); |
| 189 ASSERT_TRUE(stream); | 182 ASSERT_TRUE(stream); |
| 190 EXPECT_FALSE(session_->CreateOutgoingDynamicStream(kDefaultPriority)); | 183 EXPECT_FALSE(session_->CreateOutgoingDynamicStream(kDefaultPriority)); |
| 191 | 184 |
| 192 // Close the stream, but without having received a FIN or a RST_STREAM | 185 // Close the stream, but without having received a FIN or a RST_STREAM |
| 193 // and check that a new one can not be created. | 186 // and check that a new one can not be created. |
| 194 session_->CloseStream(stream->id()); | 187 session_->CloseStream(stream->id()); |
| 195 EXPECT_EQ(1u, session_->GetNumOpenOutgoingStreams()); | 188 EXPECT_EQ(1u, session_->GetNumOpenOutgoingStreams()); |
| 196 | 189 |
| 197 stream = session_->CreateOutgoingDynamicStream(kDefaultPriority); | 190 stream = session_->CreateOutgoingDynamicStream(kDefaultPriority); |
| 198 EXPECT_FALSE(stream); | 191 EXPECT_FALSE(stream); |
| 199 } | 192 } |
| 200 | 193 |
| 201 TEST_P(QuicClientSessionTest, MaxNumStreamsWithRst) { | 194 TEST_P(QuicClientSessionTest, MaxNumStreamsWithRst) { |
| 202 EXPECT_CALL(*connection_, SendRstStream(_, _, _)).Times(AnyNumber()); | 195 EXPECT_CALL(*connection_, SendRstStream(_, _, _)).Times(AnyNumber()); |
| 203 | 196 |
| 204 if (GetParam() <= QUIC_VERSION_34) { | 197 const uint32_t kServerMaxIncomingStreams = 1; |
| 205 session_->config()->SetMaxStreamsPerConnection(1, 1); | 198 CompleteCryptoHandshake(kServerMaxIncomingStreams); |
| 206 | |
| 207 // Initialize crypto before the client session will create a stream. | |
| 208 CompleteCryptoHandshake(); | |
| 209 } else { | |
| 210 const uint32_t kServerMaxIncomingStreams = 1; | |
| 211 CompleteCryptoHandshake(kServerMaxIncomingStreams); | |
| 212 } | |
| 213 | 199 |
| 214 QuicSpdyClientStream* stream = | 200 QuicSpdyClientStream* stream = |
| 215 session_->CreateOutgoingDynamicStream(kDefaultPriority); | 201 session_->CreateOutgoingDynamicStream(kDefaultPriority); |
| 216 ASSERT_TRUE(stream); | 202 ASSERT_TRUE(stream); |
| 217 EXPECT_FALSE(session_->CreateOutgoingDynamicStream(kDefaultPriority)); | 203 EXPECT_FALSE(session_->CreateOutgoingDynamicStream(kDefaultPriority)); |
| 218 | 204 |
| 219 // Close the stream and receive an RST frame to remove the unfinished stream | 205 // Close the stream and receive an RST frame to remove the unfinished stream |
| 220 session_->CloseStream(stream->id()); | 206 session_->CloseStream(stream->id()); |
| 221 session_->OnRstStream( | 207 session_->OnRstStream( |
| 222 QuicRstStreamFrame(stream->id(), QUIC_RST_ACKNOWLEDGEMENT, 0)); | 208 QuicRstStreamFrame(stream->id(), QUIC_RST_ACKNOWLEDGEMENT, 0)); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 QuicClientPromisedInfo* promised = | 484 QuicClientPromisedInfo* promised = |
| 499 session_->GetPromisedById(promised_stream_id_); | 485 session_->GetPromisedById(promised_stream_id_); |
| 500 EXPECT_NE(promised, nullptr); | 486 EXPECT_NE(promised, nullptr); |
| 501 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 487 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
| 502 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); | 488 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); |
| 503 } | 489 } |
| 504 | 490 |
| 505 } // namespace | 491 } // namespace |
| 506 } // namespace test | 492 } // namespace test |
| 507 } // namespace net | 493 } // namespace net |
| OLD | NEW |