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

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

Issue 2718603002: Enable bidi streaming in QUIC by default. Protected by FLAGS_quic_reloadable_flag_quic_always_enabl… (Closed)
Patch Set: Created 3 years, 10 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_simple_server_stream_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_spdy_client_stream.h" 5 #include "net/tools/quic/quic_spdy_client_stream.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "net/quic/core/quic_utils.h" 10 #include "net/quic/core/quic_utils.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 EXPECT_CALL(*connection_, 162 EXPECT_CALL(*connection_,
163 SendRstStream(stream_->id(), QUIC_BAD_APPLICATION_PAYLOAD, 0)); 163 SendRstStream(stream_->id(), QUIC_BAD_APPLICATION_PAYLOAD, 0));
164 stream_->OnStreamFrame( 164 stream_->OnStreamFrame(
165 QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, large_body)); 165 QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, large_body));
166 166
167 EXPECT_NE(QUIC_STREAM_NO_ERROR, stream_->stream_error()); 167 EXPECT_NE(QUIC_STREAM_NO_ERROR, stream_->stream_error());
168 } 168 }
169 169
170 TEST_F(QuicSpdyClientStreamTest, TestNoBidirectionalStreaming) { 170 TEST_F(QuicSpdyClientStreamTest, TestNoBidirectionalStreaming) {
171 if (FLAGS_quic_reloadable_flag_quic_always_enable_bidi_streaming) {
172 return;
173 }
171 QuicStreamFrame frame(kClientDataStreamId1, false, 3, StringPiece("asd")); 174 QuicStreamFrame frame(kClientDataStreamId1, false, 3, StringPiece("asd"));
172 175
173 EXPECT_FALSE(stream_->write_side_closed()); 176 EXPECT_FALSE(stream_->write_side_closed());
174 stream_->OnStreamFrame(frame); 177 stream_->OnStreamFrame(frame);
175 EXPECT_TRUE(stream_->write_side_closed()); 178 EXPECT_TRUE(stream_->write_side_closed());
176 } 179 }
177 180
178 TEST_F(QuicSpdyClientStreamTest, ReceivingTrailers) { 181 TEST_F(QuicSpdyClientStreamTest, ReceivingTrailers) {
179 // Test that receiving trailing headers, containing a final offset, results in 182 // Test that receiving trailing headers, containing a final offset, results in
180 // the stream being closed at that byte offset. 183 // the stream being closed at that byte offset.
181 // Send headers as usual. 184 // Send headers as usual.
182 auto headers = AsHeaderList(headers_); 185 auto headers = AsHeaderList(headers_);
183 stream_->OnStreamHeaderList(false, headers.uncompressed_header_bytes(), 186 stream_->OnStreamHeaderList(false, headers.uncompressed_header_bytes(),
184 headers); 187 headers);
185 188
186 // Send trailers before sending the body. Even though a FIN has been received 189 // Send trailers before sending the body. Even though a FIN has been received
187 // the stream should not be closed, as it does not yet have all the data bytes 190 // the stream should not be closed, as it does not yet have all the data bytes
188 // promised by the final offset field. 191 // promised by the final offset field.
189 SpdyHeaderBlock trailer_block; 192 SpdyHeaderBlock trailer_block;
190 trailer_block["trailer key"] = "trailer value"; 193 trailer_block["trailer key"] = "trailer value";
191 trailer_block[kFinalOffsetHeaderKey] = 194 trailer_block[kFinalOffsetHeaderKey] =
192 QuicTextUtils::Uint64ToString(body_.size()); 195 QuicTextUtils::Uint64ToString(body_.size());
193 auto trailers = AsHeaderList(trailer_block); 196 auto trailers = AsHeaderList(trailer_block);
194 stream_->OnStreamHeaderList(true, trailers.uncompressed_header_bytes(), 197 stream_->OnStreamHeaderList(true, trailers.uncompressed_header_bytes(),
195 trailers); 198 trailers);
196 199
197 // Now send the body, which should close the stream as the FIN has been 200 // Now send the body, which should close the stream as the FIN has been
198 // received, as well as all data. 201 // received, as well as all data.
199 EXPECT_CALL(session_, CloseStream(stream_->id())); 202 if (!FLAGS_quic_reloadable_flag_quic_always_enable_bidi_streaming) {
203 EXPECT_CALL(session_, CloseStream(stream_->id()));
204 }
200 stream_->OnStreamFrame( 205 stream_->OnStreamFrame(
201 QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, body_)); 206 QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, body_));
207 if (FLAGS_quic_reloadable_flag_quic_always_enable_bidi_streaming) {
208 EXPECT_TRUE(stream_->reading_stopped());
209 }
202 } 210 }
203 211
204 } // namespace 212 } // namespace
205 } // namespace test 213 } // namespace test
206 } // namespace net 214 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_server_stream_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698