Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: net/tools/quic/quic_client_session_test.cc

Issue 2856243003: Revert of Landing Recent QUIC changes until Sat Apr 29 00:22:04 2017 +0000 (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/tools/quic/quic_client_session.cc ('k') | net/tools/quic/quic_dispatcher_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
61 MockQuicSpdyClientStream* CreateIncomingDynamicStream( 57 MockQuicSpdyClientStream* CreateIncomingDynamicStream(
62 QuicStreamId id) override { 58 QuicStreamId id) override {
63 MockQuicSpdyClientStream* stream = new MockQuicSpdyClientStream(id, this); 59 MockQuicSpdyClientStream* stream = new MockQuicSpdyClientStream(id, this);
64 ActivateStream(QuicWrapUnique(stream)); 60 ActivateStream(QuicWrapUnique(stream));
65 return stream; 61 return stream;
66 } 62 }
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 }
74 }; 63 };
75 64
76 class QuicClientSessionTest : public QuicTestWithParam<QuicVersion> { 65 class QuicClientSessionTest : public QuicTestWithParam<QuicVersion> {
77 protected: 66 protected:
78 QuicClientSessionTest() 67 QuicClientSessionTest()
79 : crypto_config_(crypto_test_utils::ProofVerifierForTesting()), 68 : crypto_config_(crypto_test_utils::ProofVerifierForTesting()),
80 promised_stream_id_(kInvalidStreamId), 69 promised_stream_id_(kServerDataStreamId1),
81 associated_stream_id_(kInvalidStreamId) { 70 associated_stream_id_(kClientDataStreamId1) {
82 Initialize(); 71 Initialize();
83 // Advance the time, because timers do not like uninitialized times. 72 // Advance the time, because timers do not like uninitialized times.
84 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 73 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
85 } 74 }
86 75
87 ~QuicClientSessionTest() override { 76 ~QuicClientSessionTest() override {
88 // Session must be destroyed before promised_by_url_ 77 // Session must be destroyed before promised_by_url_
89 session_.reset(nullptr); 78 session_.reset(nullptr);
90 } 79 }
91 80
92 void Initialize() { 81 void Initialize() {
93 session_.reset(); 82 session_.reset();
94 connection_ = new PacketSavingConnection(&helper_, &alarm_factory_, 83 connection_ = new PacketSavingConnection(&helper_, &alarm_factory_,
95 Perspective::IS_CLIENT, 84 Perspective::IS_CLIENT,
96 SupportedVersions(GetParam())); 85 SupportedVersions(GetParam()));
97 session_.reset(new TestQuicClientSession( 86 session_.reset(new TestQuicClientSession(
98 DefaultQuicConfig(), connection_, 87 DefaultQuicConfig(), connection_,
99 QuicServerId(kServerHostname, kPort, PRIVACY_MODE_DISABLED), 88 QuicServerId(kServerHostname, kPort, PRIVACY_MODE_DISABLED),
100 &crypto_config_, &push_promise_index_)); 89 &crypto_config_, &push_promise_index_));
101 session_->Initialize(); 90 session_->Initialize();
102 push_promise_[":path"] = "/bar"; 91 push_promise_[":path"] = "/bar";
103 push_promise_[":authority"] = "www.google.com"; 92 push_promise_[":authority"] = "www.google.com";
104 push_promise_[":version"] = "HTTP/1.1"; 93 push_promise_[":version"] = "HTTP/1.1";
105 push_promise_[":method"] = "GET"; 94 push_promise_[":method"] = "GET";
106 push_promise_[":scheme"] = "https"; 95 push_promise_[":scheme"] = "https";
107 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); 96 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_);
108 promised_stream_id_ =
109 QuicSpdySessionPeer::GetNthServerInitiatedStreamId(*session_, 0);
110 associated_stream_id_ =
111 QuicSpdySessionPeer::GetNthClientInitiatedStreamId(*session_, 0);
112 } 97 }
113 98
114 void CompleteCryptoHandshake() { 99 void CompleteCryptoHandshake() {
115 CompleteCryptoHandshake(kDefaultMaxStreamsPerConnection); 100 CompleteCryptoHandshake(kDefaultMaxStreamsPerConnection);
116 } 101 }
117 102
118 void CompleteCryptoHandshake(uint32_t server_max_incoming_streams) { 103 void CompleteCryptoHandshake(uint32_t server_max_incoming_streams) {
119 session_->CryptoConnect(); 104 session_->CryptoConnect();
120 QuicCryptoClientStream* stream = static_cast<QuicCryptoClientStream*>( 105 QuicCryptoClientStream* stream = static_cast<QuicCryptoClientStream*>(
121 session_->GetMutableCryptoStream()); 106 session_->GetMutableCryptoStream());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // at NONE. 152 // at NONE.
168 CryptoHandshakeMessage rej; 153 CryptoHandshakeMessage rej;
169 crypto_test_utils::FillInDummyReject(&rej, /* stateless */ false); 154 crypto_test_utils::FillInDummyReject(&rej, /* stateless */ false);
170 EXPECT_TRUE(session_->IsEncryptionEstablished()); 155 EXPECT_TRUE(session_->IsEncryptionEstablished());
171 session_->GetMutableCryptoStream()->OnHandshakeMessage(rej); 156 session_->GetMutableCryptoStream()->OnHandshakeMessage(rej);
172 EXPECT_FALSE(session_->IsEncryptionEstablished()); 157 EXPECT_FALSE(session_->IsEncryptionEstablished());
173 EXPECT_EQ(ENCRYPTION_NONE, 158 EXPECT_EQ(ENCRYPTION_NONE,
174 QuicPacketCreatorPeer::GetEncryptionLevel( 159 QuicPacketCreatorPeer::GetEncryptionLevel(
175 QuicConnectionPeer::GetPacketCreator(connection_))); 160 QuicConnectionPeer::GetPacketCreator(connection_)));
176 // Verify that no new streams may be created. 161 // Verify that no new streams may be created.
177 if (FLAGS_quic_reloadable_flag_quic_refactor_stream_creation) { 162 EXPECT_TRUE(session_->CreateOutgoingDynamicStream(kDefaultPriority) ==
178 EXPECT_EQ(nullptr, session_->CreateOutgoingDynamicStream(kDefaultPriority)); 163 nullptr);
179 } else {
180 EXPECT_TRUE(session_->CreateOutgoingDynamicStream(kDefaultPriority) ==
181 nullptr);
182 }
183 // Verify that no data may be send on existing streams. 164 // Verify that no data may be send on existing streams.
184 char data[] = "hello world"; 165 char data[] = "hello world";
185 struct iovec iov = {data, arraysize(data)}; 166 struct iovec iov = {data, arraysize(data)};
186 QuicIOVector iovector(&iov, 1, iov.iov_len); 167 QuicIOVector iovector(&iov, 1, iov.iov_len);
187 QuicConsumedData consumed = 168 QuicConsumedData consumed =
188 session_->WritevData(stream, stream->id(), iovector, 0, NO_FIN, nullptr); 169 session_->WritevData(stream, stream->id(), iovector, 0, NO_FIN, nullptr);
189 EXPECT_FALSE(consumed.fin_consumed); 170 EXPECT_FALSE(consumed.fin_consumed);
190 EXPECT_EQ(0u, consumed.bytes_consumed); 171 EXPECT_EQ(0u, consumed.bytes_consumed);
191 } 172 }
192 173
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 QuicClientPromisedInfo* promised = 558 QuicClientPromisedInfo* promised =
578 session_->GetPromisedById(promised_stream_id_); 559 session_->GetPromisedById(promised_stream_id_);
579 EXPECT_NE(promised, nullptr); 560 EXPECT_NE(promised, nullptr);
580 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); 561 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr);
581 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); 562 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr);
582 } 563 }
583 564
584 } // namespace 565 } // namespace
585 } // namespace test 566 } // namespace test
586 } // namespace net 567 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client_session.cc ('k') | net/tools/quic/quic_dispatcher_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698