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

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

Issue 2534313002: Rewriting the headers stream test to not use SYN_STREAM/SYN_REPLY (Closed)
Patch Set: Created 4 years 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 | « no previous file | 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/quic/core/quic_headers_stream.h" 5 #include "net/quic/core/quic_headers_stream.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "net/quic/core/quic_bug_tracker.h" 10 #include "net/quic/core/quic_bug_tracker.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 307
308 void SaveToHandler(size_t size, const QuicHeaderList& header_list) { 308 void SaveToHandler(size_t size, const QuicHeaderList& header_list) {
309 headers_handler_.reset(new TestHeadersHandler); 309 headers_handler_.reset(new TestHeadersHandler);
310 headers_handler_->OnHeaderBlockStart(); 310 headers_handler_->OnHeaderBlockStart();
311 for (const auto& p : header_list) { 311 for (const auto& p : header_list) {
312 headers_handler_->OnHeader(p.first, p.second); 312 headers_handler_->OnHeader(p.first, p.second);
313 } 313 }
314 headers_handler_->OnHeaderBlockEnd(size); 314 headers_handler_->OnHeaderBlockEnd(size);
315 } 315 }
316 316
317 void WriteHeadersAndExpectSynStream(QuicStreamId stream_id, 317 void WriteAndExpectRequestHeaders(QuicStreamId stream_id,
318 bool fin, 318 bool fin,
319 SpdyPriority priority) { 319 SpdyPriority priority) {
320 WriteHeadersAndCheckData(stream_id, fin, priority, SYN_STREAM); 320 WriteHeadersAndCheckData(stream_id, fin, priority, true /*is_request*/);
321 } 321 }
322 322
323 void WriteHeadersAndExpectSynReply(QuicStreamId stream_id, bool fin) { 323 void WriteAndExpectResponseHeaders(QuicStreamId stream_id, bool fin) {
324 WriteHeadersAndCheckData(stream_id, fin, 0, SYN_REPLY); 324 WriteHeadersAndCheckData(stream_id, fin, 0, false /*is_request*/);
325 } 325 }
326 326
327 void WriteHeadersAndCheckData(QuicStreamId stream_id, 327 void WriteHeadersAndCheckData(QuicStreamId stream_id,
328 bool fin, 328 bool fin,
329 SpdyPriority priority, 329 SpdyPriority priority,
330 SpdyFrameType type) { 330 bool is_request) {
331 // Write the headers and capture the outgoing data 331 // Write the headers and capture the outgoing data
332 EXPECT_CALL(session_, WritevData(headers_stream_, kHeadersStreamId, _, _, 332 EXPECT_CALL(session_, WritevData(headers_stream_, kHeadersStreamId, _, _,
333 false, nullptr)) 333 false, nullptr))
334 .WillOnce(WithArgs<2>(Invoke(this, &QuicHeadersStreamTest::SaveIov))); 334 .WillOnce(WithArgs<2>(Invoke(this, &QuicHeadersStreamTest::SaveIov)));
335 headers_stream_->WriteHeaders(stream_id, headers_.Clone(), fin, priority, 335 headers_stream_->WriteHeaders(stream_id, headers_.Clone(), fin, priority,
336 nullptr); 336 nullptr);
337 337
338 // Parse the outgoing data and check that it matches was was written. 338 // Parse the outgoing data and check that it matches was was written.
339 if (type == SYN_STREAM) { 339 if (is_request) {
340 EXPECT_CALL(visitor_, 340 EXPECT_CALL(visitor_,
341 OnHeaders(stream_id, kHasPriority, 341 OnHeaders(stream_id, kHasPriority,
342 Spdy3PriorityToHttp2Weight(priority), 342 Spdy3PriorityToHttp2Weight(priority),
343 /*parent_stream_id=*/0, 343 /*parent_stream_id=*/0,
344 /*exclusive=*/false, fin, kFrameComplete)); 344 /*exclusive=*/false, fin, kFrameComplete));
345 } else { 345 } else {
346 EXPECT_CALL(visitor_, 346 EXPECT_CALL(visitor_,
347 OnHeaders(stream_id, !kHasPriority, 347 OnHeaders(stream_id, !kHasPriority,
348 /*priority=*/0, 348 /*priority=*/0,
349 /*parent_stream_id=*/0, 349 /*parent_stream_id=*/0,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 424
425 TEST_P(QuicHeadersStreamTest, StreamId) { 425 TEST_P(QuicHeadersStreamTest, StreamId) {
426 EXPECT_EQ(3u, headers_stream_->id()); 426 EXPECT_EQ(3u, headers_stream_->id());
427 } 427 }
428 428
429 TEST_P(QuicHeadersStreamTest, WriteHeaders) { 429 TEST_P(QuicHeadersStreamTest, WriteHeaders) {
430 for (QuicStreamId stream_id = kClientDataStreamId1; 430 for (QuicStreamId stream_id = kClientDataStreamId1;
431 stream_id < kClientDataStreamId3; stream_id += 2) { 431 stream_id < kClientDataStreamId3; stream_id += 2) {
432 for (bool fin : kFins) { 432 for (bool fin : kFins) {
433 if (perspective() == Perspective::IS_SERVER) { 433 if (perspective() == Perspective::IS_SERVER) {
434 WriteHeadersAndExpectSynReply(stream_id, fin); 434 WriteAndExpectResponseHeaders(stream_id, fin);
435 } else { 435 } else {
436 for (SpdyPriority priority = 0; priority < 7; ++priority) { 436 for (SpdyPriority priority = 0; priority < 7; ++priority) {
437 // TODO(rch): implement priorities correctly. 437 // TODO(rch): implement priorities correctly.
438 WriteHeadersAndExpectSynStream(stream_id, fin, 0); 438 WriteAndExpectRequestHeaders(stream_id, fin, 0);
439 } 439 }
440 } 440 }
441 } 441 }
442 } 442 }
443 } 443 }
444 444
445 TEST_P(QuicHeadersStreamTest, WritePushPromises) { 445 TEST_P(QuicHeadersStreamTest, WritePushPromises) {
446 for (QuicStreamId stream_id = kClientDataStreamId1; 446 for (QuicStreamId stream_id = kClientDataStreamId1;
447 stream_id < kClientDataStreamId3; stream_id += 2) { 447 stream_id < kClientDataStreamId3; stream_id += 2) {
448 QuicStreamId promised_stream_id = NextPromisedStreamId(); 448 QuicStreamId promised_stream_id = NextPromisedStreamId();
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 testing::InSequence seq; 925 testing::InSequence seq;
926 for (int i = 1; i < 28; i++) { 926 for (int i = 1; i < 28; i++) {
927 EXPECT_CALL(*hpack_encoder_visitor, 927 EXPECT_CALL(*hpack_encoder_visitor,
928 OnUseEntry(QuicTime::Delta::FromMilliseconds(i))); 928 OnUseEntry(QuicTime::Delta::FromMilliseconds(i)));
929 } 929 }
930 } 930 }
931 for (QuicStreamId stream_id = kClientDataStreamId1; 931 for (QuicStreamId stream_id = kClientDataStreamId1;
932 stream_id < kClientDataStreamId3; stream_id += 2) { 932 stream_id < kClientDataStreamId3; stream_id += 2) {
933 for (bool fin : {false, true}) { 933 for (bool fin : {false, true}) {
934 if (perspective() == Perspective::IS_SERVER) { 934 if (perspective() == Perspective::IS_SERVER) {
935 WriteHeadersAndExpectSynReply(stream_id, fin); 935 WriteAndExpectResponseHeaders(stream_id, fin);
936 connection_->AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); 936 connection_->AdvanceTime(QuicTime::Delta::FromMilliseconds(1));
937 } else { 937 } else {
938 for (SpdyPriority priority = 0; priority < 7; ++priority) { 938 for (SpdyPriority priority = 0; priority < 7; ++priority) {
939 // TODO(rch): implement priorities correctly. 939 // TODO(rch): implement priorities correctly.
940 WriteHeadersAndExpectSynStream(stream_id, fin, 0); 940 WriteAndExpectRequestHeaders(stream_id, fin, 0);
941 connection_->AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); 941 connection_->AdvanceTime(QuicTime::Delta::FromMilliseconds(1));
942 } 942 }
943 } 943 }
944 } 944 }
945 } 945 }
946 } 946 }
947 947
948 TEST_P(QuicHeadersStreamTest, WritevStreamData) { 948 TEST_P(QuicHeadersStreamTest, WritevStreamData) {
949 QuicStreamId id = kClientDataStreamId1; 949 QuicStreamId id = kClientDataStreamId1;
950 QuicStreamOffset offset = 0; 950 QuicStreamOffset offset = 0;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 consumed_data = headers_stream_->WritevStreamData( 1056 consumed_data = headers_stream_->WritevStreamData(
1057 id, MakeIOVector(data, &iov), offset, fin, nullptr); 1057 id, MakeIOVector(data, &iov), offset, fin, nullptr);
1058 1058
1059 EXPECT_EQ(consumed_data.bytes_consumed, 0u); 1059 EXPECT_EQ(consumed_data.bytes_consumed, 0u);
1060 EXPECT_EQ(consumed_data.fin_consumed, false); 1060 EXPECT_EQ(consumed_data.fin_consumed, false);
1061 } 1061 }
1062 1062
1063 } // namespace 1063 } // namespace
1064 } // namespace test 1064 } // namespace test
1065 } // namespace net 1065 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698