net/spdy/spdy_stream_unittest.cc
// Test calculation of amount of bytes received from network.
Test calculation of amount of bytes received from network.
Test calculation of amount of bytes received from network .
TEST_F(SpdyStreamTest, ReceivedBytes) {
  spdy::SpdySerializedFrame req(
      spdy_util_.ConstructSpdyGet(nullptr, 0, 1, LOWEST));
  AddWrite(req);
  AddReadPause();
  spdy::SpdySerializedFrame reply(
      spdy_util_.ConstructSpdyGetReply(nullptr, 0, 1));
  AddRead(reply);
  AddReadPause();
  spdy::SpdySerializedFrame msg(
      spdy_util_.ConstructSpdyDataFrame(1, kPostBodyStringPiece, false));
  AddRead(msg);
  AddReadPause();
  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());
  StreamDelegateDoNothing delegate(stream);
  stream->SetDelegate(&delegate);
  spdy::SpdyHeaderBlock headers(
      spdy_util_.ConstructGetHeaderBlock(kDefaultUrl));
  EXPECT_THAT(
      stream->SendRequestHeaders(std::move(headers), NO_MORE_DATA_TO_SEND),
      IsError(ERR_IO_PENDING));
  int64_t reply_frame_len = reply.size();
  int64_t data_header_len = spdy::kDataFrameMinimumSize;
  int64_t data_frame_len = data_header_len + kPostBodyLength;
  int64_t response_len = reply_frame_len + data_frame_len;
  EXPECT_EQ(0, stream->raw_received_bytes());
  data.RunUntilPaused();
  EXPECT_EQ(0, stream->raw_received_bytes());
  data.Resume();
  data.RunUntilPaused();
  EXPECT_EQ(reply_frame_len, stream->raw_received_bytes());
  data.Resume();
  data.RunUntilPaused();
  EXPECT_EQ(response_len, stream->raw_received_bytes());
  data.Resume();
  EXPECT_THAT(delegate.WaitForClose(), IsError(ERR_CONNECTION_CLOSED));
}
TEST_F ( SpdyStreamTest , ReceivedBytes ) { spdy :: SpdySerializedFrame req ( spdy_util_ . ConstructSpdyGet ( nullptr , 0 , 1 , LOWEST ) ) ; AddWrite ( req ) ; AddReadPause ( ) ; spdy :: SpdySerializedFrame reply ( spdy_util_ . ConstructSpdyGetReply ( nullptr , 0 , 1 ) ) ; AddRead ( reply ) ; AddReadPause ( ) ; spdy :: SpdySerializedFrame msg ( spdy_util_ . ConstructSpdyDataFrame ( 1 , kPostBodyStringPiece , false ) ) ; AddRead ( msg ) ; AddReadPause ( ) ; 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 ( ) ) ; StreamDelegateDoNothing delegate ( stream ) ; stream -> SetDelegate ( & delegate ) ; spdy :: SpdyHeaderBlock headers ( spdy_util_ . ConstructGetHeaderBlock ( kDefaultUrl ) ) ; EXPECT_THAT ( stream -> SendRequestHeaders ( std :: move ( headers ) , NO_MORE_DATA_TO_SEND ) , IsError ( ERR_IO_PENDING ) ) ; int64_t reply_frame_len = reply . size ( ) ; int64_t data_header_len = spdy :: kDataFrameMinimumSize ; int64_t data_frame_len = data_header_len + kPostBodyLength ; int64_t response_len = reply_frame_len + data_frame_len ; EXPECT_EQ ( 0 , stream -> raw_received_bytes ( ) ) ; data . RunUntilPaused ( ) ; EXPECT_EQ ( 0 , stream -> raw_received_bytes ( ) ) ; data . Resume ( ) ; data . RunUntilPaused ( ) ; EXPECT_EQ ( reply_frame_len , stream -> raw_received_bytes ( ) ) ; data . Resume ( ) ; data . RunUntilPaused ( ) ; EXPECT_EQ ( response_len , stream -> raw_received_bytes ( ) ) ; data . Resume ( ) ; EXPECT_THAT ( delegate . WaitForClose ( ) , IsError ( ERR_CONNECTION_CLOSED ) ) ; }
Test calculation of amount of bytes received from network.
Test calculation of amount of bytes received from network .
// REQUEST // REPLY // DATA // FIN