src/net/spdy/spdy_stream_unittest.cc
// Given an unstall function, runs a test to make sure that a
// request/response (i.e., an HTTP-like) stream resumes after a stall
// and unstall.
Given an unstall function, runs a test to make sure that a
request/response  stream resumes after a stall
and unstall.
Given an unstall function runs a test to make sure that a request / response stream resumes after a stall and unstall .
void SpdyStreamTest::RunResumeAfterUnstallRequestResponseTest(
    UnstallFunction unstall_function) {
  spdy::SpdySerializedFrame req(spdy_util_.ConstructSpdyPost(
      kDefaultUrl, 1, kPostBodyLength, LOWEST, nullptr, 0));
  AddWrite(req);
  spdy::SpdySerializedFrame body(
      spdy_util_.ConstructSpdyDataFrame(1, kPostBodyStringPiece, true));
  AddWrite(body);
  spdy::SpdySerializedFrame resp(
      spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1));
  AddRead(resp);
  AddReadEOF();
  SequencedSocketData data(GetReads(), GetWrites());
  MockConnect connect_data(SYNCHRONOUS, OK);
  data.set_connect_data(connect_data);
  session_deps_.socket_factory->AddSocketDataProvider(&data);
  AddSSLSocketData();
  base::WeakPtr<SpdySession> session(CreateDefaultSpdySession());
  base::WeakPtr<SpdyStream> stream = CreateStreamSynchronously(
      SPDY_REQUEST_RESPONSE_STREAM, session, url_, LOWEST, NetLogWithSource());
  ASSERT_TRUE(stream);
  EXPECT_EQ(kDefaultUrl, stream->url().spec());
  StreamDelegateWithBody delegate(stream, kPostBodyStringPiece);
  stream->SetDelegate(&delegate);
  EXPECT_FALSE(stream->send_stalled_by_flow_control());
  spdy::SpdyHeaderBlock headers(
      spdy_util_.ConstructPostHeaderBlock(kDefaultUrl, kPostBodyLength));
  EXPECT_THAT(stream->SendRequestHeaders(std::move(headers), MORE_DATA_TO_SEND),
              IsError(ERR_IO_PENDING));
  StallStream(stream);
  base::RunLoop().RunUntilIdle();
  EXPECT_TRUE(stream->send_stalled_by_flow_control());
  std::move(unstall_function).Run(stream, kPostBodyLength);
  EXPECT_FALSE(stream->send_stalled_by_flow_control());
  EXPECT_THAT(delegate.WaitForClose(), IsError(ERR_CONNECTION_CLOSED));
  EXPECT_TRUE(delegate.send_headers_completed());
  EXPECT_EQ("200", delegate.GetResponseHeaderValue(":status"));
  EXPECT_EQ(std::string(), delegate.TakeReceivedData());
  EXPECT_TRUE(data.AllWriteDataConsumed());
}
void SpdyStreamTest :: RunResumeAfterUnstallRequestResponseTest ( UnstallFunction unstall_function ) { spdy :: SpdySerializedFrame req ( spdy_util_ . ConstructSpdyPost ( kDefaultUrl , 1 , kPostBodyLength , LOWEST , nullptr , 0 ) ) ; AddWrite ( req ) ; spdy :: SpdySerializedFrame body ( spdy_util_ . ConstructSpdyDataFrame ( 1 , kPostBodyStringPiece , true ) ) ; AddWrite ( body ) ; spdy :: SpdySerializedFrame resp ( spdy_util_ . ConstructSpdyGetReply ( nullptr , 0 , 1 ) ) ; AddRead ( resp ) ; AddReadEOF ( ) ; SequencedSocketData data ( GetReads ( ) , GetWrites ( ) ) ; MockConnect connect_data ( SYNCHRONOUS , OK ) ; data . set_connect_data ( connect_data ) ; session_deps_ . socket_factory -> AddSocketDataProvider ( & data ) ; AddSSLSocketData ( ) ; base :: WeakPtr < SpdySession > session ( CreateDefaultSpdySession ( ) ) ; base :: WeakPtr < SpdyStream > stream = CreateStreamSynchronously ( SPDY_REQUEST_RESPONSE_STREAM , session , url_ , LOWEST , NetLogWithSource ( ) ) ; ASSERT_TRUE ( stream ) ; EXPECT_EQ ( kDefaultUrl , stream -> url ( ) . spec ( ) ) ; StreamDelegateWithBody delegate ( stream , kPostBodyStringPiece ) ; stream -> SetDelegate ( & delegate ) ; EXPECT_FALSE ( stream -> send_stalled_by_flow_control ( ) ) ; spdy :: SpdyHeaderBlock headers ( spdy_util_ . ConstructPostHeaderBlock ( kDefaultUrl , kPostBodyLength ) ) ; EXPECT_THAT ( stream -> SendRequestHeaders ( std :: move ( headers ) , MORE_DATA_TO_SEND ) , IsError ( ERR_IO_PENDING ) ) ; StallStream ( stream ) ; base :: RunLoop ( ) . RunUntilIdle ( ) ; EXPECT_TRUE ( stream -> send_stalled_by_flow_control ( ) ) ; std :: move ( unstall_function ) . Run ( stream , kPostBodyLength ) ; EXPECT_FALSE ( stream -> send_stalled_by_flow_control ( ) ) ; EXPECT_THAT ( delegate . WaitForClose ( ) , IsError ( ERR_CONNECTION_CLOSED ) ) ; EXPECT_TRUE ( delegate . send_headers_completed ( ) ) ; EXPECT_EQ ( " " , delegate . GetResponseHeaderValue ( " " ) ) ; EXPECT_EQ ( std :: string ( ) , delegate . TakeReceivedData ( ) ) ; EXPECT_TRUE ( data . AllWriteDataConsumed ( ) ) ; }
Given an unstall function, runs a test to make sure that a
request/response (i.e., an HTTP-like) stream resumes after a stall
and unstall.
Given an unstall function runs a test to make sure that a request / response ( i . e . an HTTP - like ) stream resumes after a stall and unstall .