| 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/spdy_utils.h" | 10 #include "net/quic/core/spdy_utils.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 connection, | 47 connection, |
| 48 server_id, | 48 server_id, |
| 49 crypto_config, | 49 crypto_config, |
| 50 push_promise_index) {} | 50 push_promise_index) {} |
| 51 | 51 |
| 52 std::unique_ptr<QuicSpdyClientStream> CreateClientStream() override { | 52 std::unique_ptr<QuicSpdyClientStream> CreateClientStream() override { |
| 53 return QuicMakeUnique<MockQuicSpdyClientStream>(GetNextOutgoingStreamId(), | 53 return QuicMakeUnique<MockQuicSpdyClientStream>(GetNextOutgoingStreamId(), |
| 54 this); | 54 this); |
| 55 } | 55 } |
| 56 | 56 |
| 57 std::unique_ptr<QuicStream> CreateStream(QuicStreamId id) override { |
| 58 return QuicMakeUnique<MockQuicSpdyClientStream>(id, this); |
| 59 } |
| 60 |
| 57 MockQuicSpdyClientStream* CreateIncomingDynamicStream( | 61 MockQuicSpdyClientStream* CreateIncomingDynamicStream( |
| 58 QuicStreamId id) override { | 62 QuicStreamId id) override { |
| 59 MockQuicSpdyClientStream* stream = new MockQuicSpdyClientStream(id, this); | 63 MockQuicSpdyClientStream* stream = new MockQuicSpdyClientStream(id, this); |
| 60 ActivateStream(QuicWrapUnique(stream)); | 64 ActivateStream(QuicWrapUnique(stream)); |
| 61 return stream; | 65 return stream; |
| 62 } | 66 } |
| 67 |
| 68 QuicSpdyClientStream* CreateOutgoingDynamicStream( |
| 69 SpdyPriority priority) override { |
| 70 return FLAGS_quic_reloadable_flag_quic_refactor_stream_creation |
| 71 ? MaybeCreateOutgoingDynamicStream(priority) |
| 72 : QuicClientSession::CreateOutgoingDynamicStream(priority); |
| 73 } |
| 63 }; | 74 }; |
| 64 | 75 |
| 65 class QuicClientSessionTest : public QuicTestWithParam<QuicVersion> { | 76 class QuicClientSessionTest : public QuicTestWithParam<QuicVersion> { |
| 66 protected: | 77 protected: |
| 67 QuicClientSessionTest() | 78 QuicClientSessionTest() |
| 68 : crypto_config_(crypto_test_utils::ProofVerifierForTesting()), | 79 : crypto_config_(crypto_test_utils::ProofVerifierForTesting()), |
| 69 promised_stream_id_(kInvalidStreamId), | 80 promised_stream_id_(kInvalidStreamId), |
| 70 associated_stream_id_(kInvalidStreamId) { | 81 associated_stream_id_(kInvalidStreamId) { |
| 71 Initialize(); | 82 Initialize(); |
| 72 // Advance the time, because timers do not like uninitialized times. | 83 // Advance the time, because timers do not like uninitialized times. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // at NONE. | 167 // at NONE. |
| 157 CryptoHandshakeMessage rej; | 168 CryptoHandshakeMessage rej; |
| 158 crypto_test_utils::FillInDummyReject(&rej, /* stateless */ false); | 169 crypto_test_utils::FillInDummyReject(&rej, /* stateless */ false); |
| 159 EXPECT_TRUE(session_->IsEncryptionEstablished()); | 170 EXPECT_TRUE(session_->IsEncryptionEstablished()); |
| 160 session_->GetMutableCryptoStream()->OnHandshakeMessage(rej); | 171 session_->GetMutableCryptoStream()->OnHandshakeMessage(rej); |
| 161 EXPECT_FALSE(session_->IsEncryptionEstablished()); | 172 EXPECT_FALSE(session_->IsEncryptionEstablished()); |
| 162 EXPECT_EQ(ENCRYPTION_NONE, | 173 EXPECT_EQ(ENCRYPTION_NONE, |
| 163 QuicPacketCreatorPeer::GetEncryptionLevel( | 174 QuicPacketCreatorPeer::GetEncryptionLevel( |
| 164 QuicConnectionPeer::GetPacketCreator(connection_))); | 175 QuicConnectionPeer::GetPacketCreator(connection_))); |
| 165 // Verify that no new streams may be created. | 176 // Verify that no new streams may be created. |
| 166 EXPECT_TRUE(session_->CreateOutgoingDynamicStream(kDefaultPriority) == | 177 if (FLAGS_quic_reloadable_flag_quic_refactor_stream_creation) { |
| 167 nullptr); | 178 EXPECT_EQ(nullptr, session_->CreateOutgoingDynamicStream(kDefaultPriority)); |
| 179 } else { |
| 180 EXPECT_TRUE(session_->CreateOutgoingDynamicStream(kDefaultPriority) == |
| 181 nullptr); |
| 182 } |
| 168 // Verify that no data may be send on existing streams. | 183 // Verify that no data may be send on existing streams. |
| 169 char data[] = "hello world"; | 184 char data[] = "hello world"; |
| 170 struct iovec iov = {data, arraysize(data)}; | 185 struct iovec iov = {data, arraysize(data)}; |
| 171 QuicIOVector iovector(&iov, 1, iov.iov_len); | 186 QuicIOVector iovector(&iov, 1, iov.iov_len); |
| 172 QuicConsumedData consumed = | 187 QuicConsumedData consumed = |
| 173 session_->WritevData(stream, stream->id(), iovector, 0, NO_FIN, nullptr); | 188 session_->WritevData(stream, stream->id(), iovector, 0, NO_FIN, nullptr); |
| 174 EXPECT_FALSE(consumed.fin_consumed); | 189 EXPECT_FALSE(consumed.fin_consumed); |
| 175 EXPECT_EQ(0u, consumed.bytes_consumed); | 190 EXPECT_EQ(0u, consumed.bytes_consumed); |
| 176 } | 191 } |
| 177 | 192 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 QuicClientPromisedInfo* promised = | 577 QuicClientPromisedInfo* promised = |
| 563 session_->GetPromisedById(promised_stream_id_); | 578 session_->GetPromisedById(promised_stream_id_); |
| 564 EXPECT_NE(promised, nullptr); | 579 EXPECT_NE(promised, nullptr); |
| 565 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 580 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
| 566 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); | 581 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); |
| 567 } | 582 } |
| 568 | 583 |
| 569 } // namespace | 584 } // namespace |
| 570 } // namespace test | 585 } // namespace test |
| 571 } // namespace net | 586 } // namespace net |
| OLD | NEW |