Commit 9eb6253e authored by rtenneti's avatar rtenneti Committed by Commit bot

test-only change - Squelch a variety of "GMOCK WARNING" messages in

quic_session_test by using a StrictMock, and adding the necessary
EXPECT_CALL()s.

Merge internal change: 83469149

R=rch@chromium.org

Review URL: https://codereview.chromium.org/1010893002

Cr-Commit-Position: refs/heads/master@{#320869}
parent e269e7af
...@@ -184,8 +184,9 @@ class TestSession : public QuicSession { ...@@ -184,8 +184,9 @@ class TestSession : public QuicSession {
class QuicSessionTest : public ::testing::TestWithParam<QuicVersion> { class QuicSessionTest : public ::testing::TestWithParam<QuicVersion> {
protected: protected:
QuicSessionTest() QuicSessionTest()
: connection_(new MockConnection(Perspective::IS_SERVER, : connection_(
SupportedVersions(GetParam()))), new StrictMock<MockConnection>(Perspective::IS_SERVER,
SupportedVersions(GetParam()))),
session_(connection_) { session_(connection_) {
session_.config()->SetInitialStreamFlowControlWindowToSend( session_.config()->SetInitialStreamFlowControlWindowToSend(
kInitialStreamFlowControlWindowForTest); kInitialStreamFlowControlWindowForTest);
...@@ -232,13 +233,14 @@ class QuicSessionTest : public ::testing::TestWithParam<QuicVersion> { ...@@ -232,13 +233,14 @@ class QuicSessionTest : public ::testing::TestWithParam<QuicVersion> {
} }
void CloseStream(QuicStreamId id) { void CloseStream(QuicStreamId id) {
EXPECT_CALL(*connection_, SendRstStream(id, _, _));
session_.CloseStream(id); session_.CloseStream(id);
closed_streams_.insert(id); closed_streams_.insert(id);
} }
QuicVersion version() const { return connection_->version(); } QuicVersion version() const { return connection_->version(); }
MockConnection* connection_; StrictMock<MockConnection>* connection_;
TestSession session_; TestSession session_;
set<QuicStreamId> closed_streams_; set<QuicStreamId> closed_streams_;
SpdyHeaderBlock headers_; SpdyHeaderBlock headers_;
...@@ -338,15 +340,13 @@ TEST_P(QuicSessionTest, DecompressionError) { ...@@ -338,15 +340,13 @@ TEST_P(QuicSessionTest, DecompressionError) {
TEST_P(QuicSessionTest, DebugDFatalIfMarkingClosedStreamWriteBlocked) { TEST_P(QuicSessionTest, DebugDFatalIfMarkingClosedStreamWriteBlocked) {
TestStream* stream2 = session_.CreateOutgoingDataStream(); TestStream* stream2 = session_.CreateOutgoingDataStream();
QuicStreamId kClosedStreamId = stream2->id();
// Close the stream. // Close the stream.
EXPECT_CALL(*connection_, SendRstStream(kClosedStreamId, _, _));
stream2->Reset(QUIC_BAD_APPLICATION_PAYLOAD); stream2->Reset(QUIC_BAD_APPLICATION_PAYLOAD);
// TODO(rtenneti): enable when chromium supports EXPECT_DEBUG_DFATAL.
/*
QuicStreamId kClosedStreamId = stream2->id();
EXPECT_DEBUG_DFATAL( EXPECT_DEBUG_DFATAL(
session_.MarkWriteBlocked(kClosedStreamId, kSomeMiddlePriority), session_.MarkWriteBlocked(kClosedStreamId, kSomeMiddlePriority),
"Marking unknown stream 2 blocked."); "Marking unknown stream 2 blocked.");
*/
} }
TEST_P(QuicSessionTest, DebugDFatalIfMarkWriteBlockedCalledWithWrongPriority) { TEST_P(QuicSessionTest, DebugDFatalIfMarkWriteBlockedCalledWithWrongPriority) {
...@@ -354,12 +354,9 @@ TEST_P(QuicSessionTest, DebugDFatalIfMarkWriteBlockedCalledWithWrongPriority) { ...@@ -354,12 +354,9 @@ TEST_P(QuicSessionTest, DebugDFatalIfMarkWriteBlockedCalledWithWrongPriority) {
TestStream* stream2 = session_.CreateOutgoingDataStream(); TestStream* stream2 = session_.CreateOutgoingDataStream();
EXPECT_NE(kDifferentPriority, stream2->EffectivePriority()); EXPECT_NE(kDifferentPriority, stream2->EffectivePriority());
// TODO(rtenneti): enable when chromium supports EXPECT_DEBUG_DFATAL.
/*
EXPECT_DEBUG_DFATAL( EXPECT_DEBUG_DFATAL(
session_.MarkWriteBlocked(stream2->id(), kDifferentPriority), session_.MarkWriteBlocked(stream2->id(), kDifferentPriority),
"Priorities do not match. Got: 0 Expected: 3"); "Priorities do not match. Got: 0 Expected: 3");
*/
} }
TEST_P(QuicSessionTest, OnCanWrite) { TEST_P(QuicSessionTest, OnCanWrite) {
...@@ -594,6 +591,7 @@ TEST_P(QuicSessionTest, RstStreamBeforeHeadersDecompressed) { ...@@ -594,6 +591,7 @@ TEST_P(QuicSessionTest, RstStreamBeforeHeadersDecompressed) {
session_.OnStreamFrames(frames); session_.OnStreamFrames(frames);
EXPECT_EQ(1u, session_.GetNumOpenStreams()); EXPECT_EQ(1u, session_.GetNumOpenStreams());
EXPECT_CALL(*connection_, SendRstStream(kClientDataStreamId1, _, _));
QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0); QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0);
session_.OnRstStream(rst1); session_.OnRstStream(rst1);
EXPECT_EQ(0u, session_.GetNumOpenStreams()); EXPECT_EQ(0u, session_.GetNumOpenStreams());
...@@ -642,6 +640,8 @@ TEST_P(QuicSessionTest, HandshakeUnblocksFlowControlBlockedStream) { ...@@ -642,6 +640,8 @@ TEST_P(QuicSessionTest, HandshakeUnblocksFlowControlBlockedStream) {
EXPECT_FALSE(stream2->flow_controller()->IsBlocked()); EXPECT_FALSE(stream2->flow_controller()->IsBlocked());
EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
EXPECT_CALL(*connection_, SendBlocked(stream2->id()));
EXPECT_CALL(*connection_, SendBlocked(0));
stream2->SendBody(body, false); stream2->SendBody(body, false);
EXPECT_TRUE(stream2->flow_controller()->IsBlocked()); EXPECT_TRUE(stream2->flow_controller()->IsBlocked());
EXPECT_TRUE(session_.IsConnectionFlowControlBlocked()); EXPECT_TRUE(session_.IsConnectionFlowControlBlocked());
...@@ -675,6 +675,7 @@ TEST_P(QuicSessionTest, HandshakeUnblocksFlowControlBlockedCryptoStream) { ...@@ -675,6 +675,7 @@ TEST_P(QuicSessionTest, HandshakeUnblocksFlowControlBlockedCryptoStream) {
EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
// Write until the crypto stream is flow control blocked. // Write until the crypto stream is flow control blocked.
EXPECT_CALL(*connection_, SendBlocked(kCryptoStreamId));
int i = 0; int i = 0;
while (!crypto_stream->flow_controller()->IsBlocked() && i < 1000) { while (!crypto_stream->flow_controller()->IsBlocked() && i < 1000) {
EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
...@@ -721,6 +722,7 @@ TEST_P(QuicSessionTest, HandshakeUnblocksFlowControlBlockedHeadersStream) { ...@@ -721,6 +722,7 @@ TEST_P(QuicSessionTest, HandshakeUnblocksFlowControlBlockedHeadersStream) {
EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
QuicStreamId stream_id = 5; QuicStreamId stream_id = 5;
// Write until the header stream is flow control blocked. // Write until the header stream is flow control blocked.
EXPECT_CALL(*connection_, SendBlocked(kHeadersStreamId));
SpdyHeaderBlock headers; SpdyHeaderBlock headers;
while (!headers_stream->flow_controller()->IsBlocked() && stream_id < 2000) { while (!headers_stream->flow_controller()->IsBlocked() && stream_id < 2000) {
EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
...@@ -771,6 +773,7 @@ TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstOutOfOrder) { ...@@ -771,6 +773,7 @@ TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstOutOfOrder) {
SendWindowUpdate(0, kInitialSessionFlowControlWindowForTest + SendWindowUpdate(0, kInitialSessionFlowControlWindowForTest +
kByteOffset)).Times(1); kByteOffset)).Times(1);
EXPECT_CALL(*connection_, SendRstStream(stream->id(), _, _));
QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED, QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED,
kByteOffset); kByteOffset);
session_.OnRstStream(rst_frame); session_.OnRstStream(rst_frame);
...@@ -787,18 +790,20 @@ TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAndLocalReset) { ...@@ -787,18 +790,20 @@ TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAndLocalReset) {
TestStream* stream = session_.CreateOutgoingDataStream(); TestStream* stream = session_.CreateOutgoingDataStream();
const QuicStreamOffset kByteOffset = const QuicStreamOffset kByteOffset =
1 + kInitialSessionFlowControlWindowForTest / 2; kInitialSessionFlowControlWindowForTest / 2;
QuicStreamFrame frame(stream->id(), true, kByteOffset, IOVector()); QuicStreamFrame frame(stream->id(), true, kByteOffset, IOVector());
vector<QuicStreamFrame> frames; vector<QuicStreamFrame> frames;
frames.push_back(frame); frames.push_back(frame);
session_.OnStreamFrames(frames); session_.OnStreamFrames(frames);
session_.PostProcessAfterData(); session_.PostProcessAfterData();
EXPECT_TRUE(connection_->connected());
EXPECT_EQ(0u, stream->flow_controller()->bytes_consumed()); EXPECT_EQ(0u, stream->flow_controller()->bytes_consumed());
EXPECT_EQ(kByteOffset, EXPECT_EQ(kByteOffset,
stream->flow_controller()->highest_received_byte_offset()); stream->flow_controller()->highest_received_byte_offset());
// Reset stream locally. // Reset stream locally.
EXPECT_CALL(*connection_, SendRstStream(stream->id(), _, _));
stream->Reset(QUIC_STREAM_CANCELLED); stream->Reset(QUIC_STREAM_CANCELLED);
EXPECT_EQ(kByteOffset, session_.flow_controller()->bytes_consumed()); EXPECT_EQ(kByteOffset, session_.flow_controller()->bytes_consumed());
} }
...@@ -820,6 +825,7 @@ TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAfterRst) { ...@@ -820,6 +825,7 @@ TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAfterRst) {
// Reset our stream: this results in the stream being closed locally. // Reset our stream: this results in the stream being closed locally.
TestStream* stream = session_.CreateOutgoingDataStream(); TestStream* stream = session_.CreateOutgoingDataStream();
EXPECT_CALL(*connection_, SendRstStream(stream->id(), _, _));
stream->Reset(QUIC_STREAM_CANCELLED); stream->Reset(QUIC_STREAM_CANCELLED);
// Now receive a response from the peer with a FIN. We should handle this by // Now receive a response from the peer with a FIN. We should handle this by
...@@ -859,6 +865,7 @@ TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstAfterRst) { ...@@ -859,6 +865,7 @@ TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstAfterRst) {
// Reset our stream: this results in the stream being closed locally. // Reset our stream: this results in the stream being closed locally.
TestStream* stream = session_.CreateOutgoingDataStream(); TestStream* stream = session_.CreateOutgoingDataStream();
EXPECT_CALL(*connection_, SendRstStream(stream->id(), _, _));
stream->Reset(QUIC_STREAM_CANCELLED); stream->Reset(QUIC_STREAM_CANCELLED);
// Now receive a RST from the peer. We should handle this by adjusting the // Now receive a RST from the peer. We should handle this by adjusting the
...@@ -909,6 +916,7 @@ TEST_P(QuicSessionTest, FlowControlWithInvalidFinalOffset) { ...@@ -909,6 +916,7 @@ TEST_P(QuicSessionTest, FlowControlWithInvalidFinalOffset) {
// Check that stream frame + FIN results in connection close. // Check that stream frame + FIN results in connection close.
TestStream* stream = session_.CreateOutgoingDataStream(); TestStream* stream = session_.CreateOutgoingDataStream();
EXPECT_CALL(*connection_, SendRstStream(stream->id(), _, _));
stream->Reset(QUIC_STREAM_CANCELLED); stream->Reset(QUIC_STREAM_CANCELLED);
QuicStreamFrame frame(stream->id(), true, kLargeOffset, IOVector()); QuicStreamFrame frame(stream->id(), true, kLargeOffset, IOVector());
vector<QuicStreamFrame> frames; vector<QuicStreamFrame> frames;
...@@ -964,6 +972,7 @@ TEST_P(QuicSessionTest, TooManyUnfinishedStreamsCauseConnectionClose) { ...@@ -964,6 +972,7 @@ TEST_P(QuicSessionTest, TooManyUnfinishedStreamsCauseConnectionClose) {
frames.push_back(data1); frames.push_back(data1);
session_.OnStreamFrames(frames); session_.OnStreamFrames(frames);
EXPECT_EQ(1u, session_.GetNumOpenStreams()); EXPECT_EQ(1u, session_.GetNumOpenStreams());
EXPECT_CALL(*connection_, SendRstStream(i, _, _));
session_.CloseStream(i); session_.CloseStream(i);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment