src/net/third_party/quiche/src/quic/tools/quic_simple_server_session_test.cc
// Tests that after promised stream queued up, when an opened stream is marked
// draining, a queued promised stream will become open and send push response.
Tests that after promised stream queued up, when an opened stream is marked
draining, a queued promised stream will become open and send push response.
Tests that after promised stream queued up when an opened stream is marked draining a queued promised stream will become open and send push response .
TEST_P(QuicSimpleServerSessionServerPushTest,
       HandlePromisedPushRequestsAfterStreamDraining) {
  MaybeConsumeHeadersStreamData();
  if (VersionUsesHttp3(transport_version())) {
    session_->EnableServerPush();
    session_->OnMaxPushIdFrame(kMaxQuicStreamId);
  }
  size_t num_resources = kMaxStreamsForTest + 1;
  QuicByteCount data_frame_header_length = PromisePushResources(num_resources);
  QuicStreamId next_out_going_stream_id;
  if (VersionUsesHttp3(transport_version())) {
    next_out_going_stream_id =
        GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest + 3);
  } else {
    next_out_going_stream_id =
        GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest);
  }
  QuicStreamOffset offset = 0;
  if (VersionUsesHttp3(transport_version())) {
    EXPECT_CALL(*connection_,
                SendStreamData(next_out_going_stream_id, 1, offset, NO_FIN));
    offset++;
  }
  if (VersionUsesHttp3(transport_version())) {
    EXPECT_CALL(*connection_,
                SendStreamData(next_out_going_stream_id,
                               kHeadersFrameHeaderLength, offset, NO_FIN));
    offset += kHeadersFrameHeaderLength;
    EXPECT_CALL(*connection_,
                SendStreamData(next_out_going_stream_id,
                               kHeadersFramePayloadLength, offset, NO_FIN));
    offset += kHeadersFramePayloadLength;
  }
  if (VersionUsesHttp3(transport_version())) {
    EXPECT_CALL(*connection_,
                SendStreamData(next_out_going_stream_id,
                               data_frame_header_length, offset, NO_FIN));
    offset += data_frame_header_length;
  }
  EXPECT_CALL(*connection_,
              SendStreamData(next_out_going_stream_id, _, offset, NO_FIN))
      .WillOnce(Return(
          QuicConsumedData(kStreamFlowControlWindowSize - offset, false)));
  EXPECT_CALL(*session_, SendBlocked(next_out_going_stream_id));
  if (VersionHasIetfQuicFrames(transport_version())) {
    session_->OnMaxStreamsFrame(
        QuicMaxStreamsFrame(0, num_resources + 3, true));
  }
  if (VersionUsesHttp3(transport_version())) {
    session_->StreamDraining(GetNthServerInitiatedUnidirectionalId(3));
  } else {
    session_->StreamDraining(GetNthServerInitiatedUnidirectionalId(0));
  }
  EXPECT_EQ(kMaxStreamsForTest, session_->GetNumOpenOutgoingStreams());
}
TEST_P ( QuicSimpleServerSessionServerPushTest , HandlePromisedPushRequestsAfterStreamDraining ) { MaybeConsumeHeadersStreamData ( ) ; if ( VersionUsesHttp3 ( transport_version ( ) ) ) { session_ -> EnableServerPush ( ) ; session_ -> OnMaxPushIdFrame ( kMaxQuicStreamId ) ; } size_t num_resources = kMaxStreamsForTest + 1 ; QuicByteCount data_frame_header_length = PromisePushResources ( num_resources ) ; QuicStreamId next_out_going_stream_id ; if ( VersionUsesHttp3 ( transport_version ( ) ) ) { next_out_going_stream_id = GetNthServerInitiatedUnidirectionalId ( kMaxStreamsForTest + 3 ) ; } else { next_out_going_stream_id = GetNthServerInitiatedUnidirectionalId ( kMaxStreamsForTest ) ; } QuicStreamOffset offset = 0 ; if ( VersionUsesHttp3 ( transport_version ( ) ) ) { EXPECT_CALL ( * connection_ , SendStreamData ( next_out_going_stream_id , 1 , offset , NO_FIN ) ) ; offset ++ ; } if ( VersionUsesHttp3 ( transport_version ( ) ) ) { EXPECT_CALL ( * connection_ , SendStreamData ( next_out_going_stream_id , kHeadersFrameHeaderLength , offset , NO_FIN ) ) ; offset += kHeadersFrameHeaderLength ; EXPECT_CALL ( * connection_ , SendStreamData ( next_out_going_stream_id , kHeadersFramePayloadLength , offset , NO_FIN ) ) ; offset += kHeadersFramePayloadLength ; } if ( VersionUsesHttp3 ( transport_version ( ) ) ) { EXPECT_CALL ( * connection_ , SendStreamData ( next_out_going_stream_id , data_frame_header_length , offset , NO_FIN ) ) ; offset += data_frame_header_length ; } EXPECT_CALL ( * connection_ , SendStreamData ( next_out_going_stream_id , _ , offset , NO_FIN ) ) . WillOnce ( Return ( QuicConsumedData ( kStreamFlowControlWindowSize - offset , false ) ) ) ; EXPECT_CALL ( * session_ , SendBlocked ( next_out_going_stream_id ) ) ; if ( VersionHasIetfQuicFrames ( transport_version ( ) ) ) { session_ -> OnMaxStreamsFrame ( QuicMaxStreamsFrame ( 0 , num_resources + 3 , true ) ) ; } if ( VersionUsesHttp3 ( transport_version ( ) ) ) { session_ -> StreamDraining ( GetNthServerInitiatedUnidirectionalId ( 3 ) ) ; } else { session_ -> StreamDraining ( GetNthServerInitiatedUnidirectionalId ( 0 ) ) ; } EXPECT_EQ ( kMaxStreamsForTest , session_ -> GetNumOpenOutgoingStreams ( ) ) ; }
Tests that after promised stream queued up, when an opened stream is marked
draining, a queued promised stream will become open and send push response.
Tests that after promised stream queued up when an opened stream is marked draining a queued promised stream will become open and send push response .
// After an open stream is marked draining, a new stream is expected to be // created and a response sent on the stream. // The PromisePushedResources call, above, will have used all available // stream ids.  For version 99, stream ids are not made available until // a MAX_STREAMS frame is received. This emulates the reception of one. // For pre-v-99, the node monitors its own stream usage and makes streams // available as it closes/etc them. // Version 99 also has unidirectional static streams, so we need to send // MaxStreamFrame of the number of resources + number of static streams. /*unidirectional=*/ // Number of open outgoing streams should still be the same, because a new // stream is opened. And the queue should be empty.