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

Side by Side Diff: net/quic/core/quic_session_test.cc

Issue 2322233004: Landing Recent QUIC changes until Sun Sep 4 03:41:00 (Closed)
Patch Set: Remove simulation files from the build. Created 4 years, 3 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/quic/core/quic_server_session_base_test.cc ('k') | net/quic/core/quic_spdy_stream.h » ('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/quic/core/quic_session.h" 5 #include "net/quic/core/quic_session.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "net/quic/core/crypto/crypto_protocol.h" 14 #include "net/quic/core/crypto/crypto_protocol.h"
15 #include "net/quic/core/crypto/null_encrypter.h"
15 #include "net/quic/core/quic_crypto_stream.h" 16 #include "net/quic/core/quic_crypto_stream.h"
16 #include "net/quic/core/quic_flags.h" 17 #include "net/quic/core/quic_flags.h"
17 #include "net/quic/core/quic_protocol.h" 18 #include "net/quic/core/quic_protocol.h"
18 #include "net/quic/core/quic_utils.h" 19 #include "net/quic/core/quic_utils.h"
19 #include "net/quic/core/reliable_quic_stream.h" 20 #include "net/quic/core/reliable_quic_stream.h"
20 #include "net/quic/test_tools/quic_config_peer.h" 21 #include "net/quic/test_tools/quic_config_peer.h"
21 #include "net/quic/test_tools/quic_connection_peer.h" 22 #include "net/quic/test_tools/quic_connection_peer.h"
22 #include "net/quic/test_tools/quic_flow_controller_peer.h" 23 #include "net/quic/test_tools/quic_flow_controller_peer.h"
23 #include "net/quic/test_tools/quic_headers_stream_peer.h" 24 #include "net/quic/test_tools/quic_headers_stream_peer.h"
24 #include "net/quic/test_tools/quic_session_peer.h" 25 #include "net/quic/test_tools/quic_session_peer.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 const QuicStreamId stream_id_; 111 const QuicStreamId stream_id_;
111 }; 112 };
112 113
113 class TestSession : public QuicSpdySession { 114 class TestSession : public QuicSpdySession {
114 public: 115 public:
115 explicit TestSession(QuicConnection* connection) 116 explicit TestSession(QuicConnection* connection)
116 : QuicSpdySession(connection, DefaultQuicConfig()), 117 : QuicSpdySession(connection, DefaultQuicConfig()),
117 crypto_stream_(this), 118 crypto_stream_(this),
118 writev_consumes_all_data_(false) { 119 writev_consumes_all_data_(false) {
119 Initialize(); 120 Initialize();
121 this->connection()->SetEncrypter(ENCRYPTION_FORWARD_SECURE,
122 new NullEncrypter());
120 } 123 }
121 124
122 ~TestSession() override { delete connection(); } 125 ~TestSession() override { delete connection(); }
123 126
124 TestCryptoStream* GetCryptoStream() override { return &crypto_stream_; } 127 TestCryptoStream* GetCryptoStream() override { return &crypto_stream_; }
125 128
126 TestStream* CreateOutgoingDynamicStream(SpdyPriority priority) override { 129 TestStream* CreateOutgoingDynamicStream(SpdyPriority priority) override {
127 TestStream* stream = new TestStream(GetNextOutgoingStreamId(), this); 130 TestStream* stream = new TestStream(GetNextOutgoingStreamId(), this);
128 stream->SetPriority(priority); 131 stream->SetPriority(priority);
129 ActivateStream(stream); 132 ActivateStream(stream);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 id, consumed.bytes_consumed); 177 id, consumed.bytes_consumed);
175 return consumed; 178 return consumed;
176 } 179 }
177 180
178 void set_writev_consumes_all_data(bool val) { 181 void set_writev_consumes_all_data(bool val) {
179 writev_consumes_all_data_ = val; 182 writev_consumes_all_data_ = val;
180 } 183 }
181 184
182 QuicConsumedData SendStreamData(ReliableQuicStream* stream) { 185 QuicConsumedData SendStreamData(ReliableQuicStream* stream) {
183 struct iovec iov; 186 struct iovec iov;
187 if (stream->id() != kCryptoStreamId) {
188 this->connection()->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
189 }
184 return WritevData(stream, stream->id(), MakeIOVector("not empty", &iov), 0, 190 return WritevData(stream, stream->id(), MakeIOVector("not empty", &iov), 0,
185 true, nullptr); 191 true, nullptr);
186 } 192 }
187 193
188 QuicConsumedData SendLargeFakeData(ReliableQuicStream* stream, int bytes) { 194 QuicConsumedData SendLargeFakeData(ReliableQuicStream* stream, int bytes) {
189 DCHECK(writev_consumes_all_data_); 195 DCHECK(writev_consumes_all_data_);
190 struct iovec iov; 196 struct iovec iov;
191 iov.iov_base = nullptr; // should not be read. 197 iov.iov_base = nullptr; // should not be read.
192 iov.iov_len = static_cast<size_t>(bytes); 198 iov.iov_len = static_cast<size_t>(bytes);
193 return WritevData(stream, stream->id(), QuicIOVector(&iov, 1, bytes), 0, 199 return WritevData(stream, stream->id(), QuicIOVector(&iov, 1, bytes), 0,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 "3Rs1UKCuBAF9g8rWNOFbxt8PSNSHFuIhOo2t6bJAVpCsMU5Laa6lewuTMYI8MzdQP" 242 "3Rs1UKCuBAF9g8rWNOFbxt8PSNSHFuIhOo2t6bJAVpCsMU5Laa6lewuTMYI8MzdQP"
237 "ARHKyW-koxuhMZHUnGBJAM1gJODe0cATO_KGoX4pbbFxxJ5IicRxOrWK_5rU3cdy6" 243 "ARHKyW-koxuhMZHUnGBJAM1gJODe0cATO_KGoX4pbbFxxJ5IicRxOrWK_5rU3cdy6"
238 "edlR9FsEdH6iujMcHkbE5l18ehJDwTWmBKBzVD87naobhMMrF6VvnDGxQVGp9Ir_b" 244 "edlR9FsEdH6iujMcHkbE5l18ehJDwTWmBKBzVD87naobhMMrF6VvnDGxQVGp9Ir_b"
239 "Rgj3RWUoPumQVCxtSOBdX0GlJOEcDTNCzQIm9BSfetog_eP_TfYubKudt5eMsXmN6" 245 "Rgj3RWUoPumQVCxtSOBdX0GlJOEcDTNCzQIm9BSfetog_eP_TfYubKudt5eMsXmN6"
240 "QnyXHeGeK2UINUzJ-D30AFcpqYgH9_1BvYSpi7fc7_ydBU8TaD8ZRxvtnzXqj0RfG" 246 "QnyXHeGeK2UINUzJ-D30AFcpqYgH9_1BvYSpi7fc7_ydBU8TaD8ZRxvtnzXqj0RfG"
241 "tuHghmv3aD-uzSYJ75XDdzKdizZ86IG6Fbn1XFhYZM-fbHhm3mVEXnyRW4ZuNOLFk" 247 "tuHghmv3aD-uzSYJ75XDdzKdizZ86IG6Fbn1XFhYZM-fbHhm3mVEXnyRW4ZuNOLFk"
242 "Fas6LMcVC6Q8QLlHYbXBpdNFuGbuZGUnav5C-2I_-46lL0NGg3GewxGKGHvHEfoyn" 248 "Fas6LMcVC6Q8QLlHYbXBpdNFuGbuZGUnav5C-2I_-46lL0NGg3GewxGKGHvHEfoyn"
243 "EFFlEYHsBQ98rXImL8ySDycdLEFvBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr" 249 "EFFlEYHsBQ98rXImL8ySDycdLEFvBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr"
244 "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo "; 250 "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo ";
245 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 251 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
246 // TODO(ianswett): Fix QuicSessionTests so they don't attempt to write
247 // non-crypto stream data at ENCRYPTION_NONE.
248 FLAGS_quic_never_write_unencrypted_data = false;
249 } 252 }
250 253
251 void CheckClosedStreams() { 254 void CheckClosedStreams() {
252 for (QuicStreamId i = kCryptoStreamId; i < 100; i++) { 255 for (QuicStreamId i = kCryptoStreamId; i < 100; i++) {
253 if (!base::ContainsKey(closed_streams_, i)) { 256 if (!base::ContainsKey(closed_streams_, i)) {
254 EXPECT_FALSE(session_.IsClosedStream(i)) << " stream id: " << i; 257 EXPECT_FALSE(session_.IsClosedStream(i)) << " stream id: " << i;
255 } else { 258 } else {
256 EXPECT_TRUE(session_.IsClosedStream(i)) << " stream id: " << i; 259 EXPECT_TRUE(session_.IsClosedStream(i)) << " stream id: " << i;
257 } 260 }
258 } 261 }
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 if (version() <= QUIC_VERSION_35) { 1256 if (version() <= QUIC_VERSION_35) {
1254 EXPECT_FALSE(session_.force_hol_blocking()); 1257 EXPECT_FALSE(session_.force_hol_blocking());
1255 } else { 1258 } else {
1256 EXPECT_TRUE(session_.force_hol_blocking()); 1259 EXPECT_TRUE(session_.force_hol_blocking());
1257 } 1260 }
1258 } 1261 }
1259 1262
1260 } // namespace 1263 } // namespace
1261 } // namespace test 1264 } // namespace test
1262 } // namespace net 1265 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_server_session_base_test.cc ('k') | net/quic/core/quic_spdy_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698