| Index: net/tools/quic/quic_spdy_server_stream_test.cc
|
| diff --git a/net/tools/quic/quic_spdy_server_stream_test.cc b/net/tools/quic/quic_spdy_server_stream_test.cc
|
| index 7d67b2ec49bc91df447788e0862708a2e8edcb95..b1ed3550853257e42a843b131598ae0e33b59207 100644
|
| --- a/net/tools/quic/quic_spdy_server_stream_test.cc
|
| +++ b/net/tools/quic/quic_spdy_server_stream_test.cc
|
| @@ -39,15 +39,12 @@ namespace test {
|
| class QuicSpdyServerStreamPeer : public QuicSpdyServerStream {
|
| public:
|
| QuicSpdyServerStreamPeer(QuicStreamId stream_id, QuicSession* session)
|
| - : QuicSpdyServerStream(stream_id, session) {
|
| - }
|
| + : QuicSpdyServerStream(stream_id, session) {}
|
|
|
| using QuicSpdyServerStream::SendResponse;
|
| using QuicSpdyServerStream::SendErrorResponse;
|
|
|
| - BalsaHeaders* mutable_headers() {
|
| - return &headers_;
|
| - }
|
| + BalsaHeaders* mutable_headers() { return &headers_; }
|
|
|
| static void SendResponse(QuicSpdyServerStream* stream) {
|
| stream->SendResponse();
|
| @@ -71,8 +68,9 @@ namespace {
|
| class QuicSpdyServerStreamTest : public ::testing::TestWithParam<QuicVersion> {
|
| public:
|
| QuicSpdyServerStreamTest()
|
| - : connection_(new StrictMock<MockConnection>(
|
| - true, SupportedVersions(GetParam()))),
|
| + : connection_(
|
| + new StrictMock<MockConnection>(true,
|
| + SupportedVersions(GetParam()))),
|
| session_(connection_),
|
| body_("hello world") {
|
| BalsaHeaders request_headers;
|
| @@ -85,14 +83,11 @@ class QuicSpdyServerStreamTest : public ::testing::TestWithParam<QuicVersion> {
|
| // New streams rely on having the peer's flow control receive window
|
| // negotiated in the config.
|
| const uint32 kInitialWindow = 10 * kMaxPacketSize;
|
| - session_.config()->SetInitialFlowControlWindowToSend(
|
| - kInitialWindow);
|
| + session_.config()->SetInitialFlowControlWindowToSend(kInitialWindow);
|
| stream_.reset(new QuicSpdyServerStreamPeer(3, &session_));
|
| }
|
|
|
| - static void SetUpTestCase() {
|
| - QuicInMemoryCachePeer::ResetForTests();
|
| - }
|
| + static void SetUpTestCase() { QuicInMemoryCachePeer::ResetForTests(); }
|
|
|
| virtual void SetUp() {
|
| QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance();
|
| @@ -100,12 +95,9 @@ class QuicSpdyServerStreamTest : public ::testing::TestWithParam<QuicVersion> {
|
| BalsaHeaders request_headers, response_headers;
|
| StringPiece body("Yum");
|
| request_headers.SetRequestFirstlineFromStringPieces(
|
| - "GET",
|
| - "https://www.google.com/foo",
|
| - "HTTP/1.1");
|
| - response_headers.SetRequestFirstlineFromStringPieces("HTTP/1.1",
|
| - "200",
|
| - "OK");
|
| + "GET", "https://www.google.com/foo", "HTTP/1.1");
|
| + response_headers.SetRequestFirstlineFromStringPieces(
|
| + "HTTP/1.1", "200", "OK");
|
| response_headers.AppendHeader("content-length",
|
| base::IntToString(body.length()));
|
|
|
| @@ -150,15 +142,18 @@ QuicConsumedData ConsumeAllData(
|
| return QuicConsumedData(data.TotalBufferSize(), fin);
|
| }
|
|
|
| -INSTANTIATE_TEST_CASE_P(Tests, QuicSpdyServerStreamTest,
|
| +INSTANTIATE_TEST_CASE_P(Tests,
|
| + QuicSpdyServerStreamTest,
|
| ::testing::ValuesIn(QuicSupportedVersions()));
|
|
|
| TEST_P(QuicSpdyServerStreamTest, TestFraming) {
|
| - EXPECT_CALL(session_, WritevData(_, _, _, _, _)).Times(AnyNumber()).
|
| - WillRepeatedly(Invoke(ConsumeAllData));
|
| + EXPECT_CALL(session_, WritevData(_, _, _, _, _))
|
| + .Times(AnyNumber())
|
| + .WillRepeatedly(Invoke(ConsumeAllData));
|
|
|
| - EXPECT_EQ(headers_string_.size(), stream_->ProcessData(
|
| - headers_string_.c_str(), headers_string_.size()));
|
| + EXPECT_EQ(
|
| + headers_string_.size(),
|
| + stream_->ProcessData(headers_string_.c_str(), headers_string_.size()));
|
| EXPECT_EQ(body_.size(), stream_->ProcessData(body_.c_str(), body_.size()));
|
| EXPECT_EQ(11u, StreamHeaders().content_length());
|
| EXPECT_EQ("https://www.google.com/", StreamHeaders().request_uri());
|
| @@ -167,13 +162,14 @@ TEST_P(QuicSpdyServerStreamTest, TestFraming) {
|
| }
|
|
|
| TEST_P(QuicSpdyServerStreamTest, TestFramingOnePacket) {
|
| - EXPECT_CALL(session_, WritevData(_, _, _, _, _)).Times(AnyNumber()).
|
| - WillRepeatedly(Invoke(ConsumeAllData));
|
| + EXPECT_CALL(session_, WritevData(_, _, _, _, _))
|
| + .Times(AnyNumber())
|
| + .WillRepeatedly(Invoke(ConsumeAllData));
|
|
|
| string message = headers_string_ + body_;
|
|
|
| - EXPECT_EQ(message.size(), stream_->ProcessData(
|
| - message.c_str(), message.size()));
|
| + EXPECT_EQ(message.size(),
|
| + stream_->ProcessData(message.c_str(), message.size()));
|
| EXPECT_EQ(11u, StreamHeaders().content_length());
|
| EXPECT_EQ("https://www.google.com/", StreamHeaders().request_uri());
|
| EXPECT_EQ("POST", StreamHeaders().request_method());
|
| @@ -184,11 +180,13 @@ TEST_P(QuicSpdyServerStreamTest, TestFramingExtraData) {
|
| string large_body = "hello world!!!!!!";
|
|
|
| // We'll automatically write out an error (headers + body)
|
| - EXPECT_CALL(session_, WritevData(_, _, _, _, _)).Times(AnyNumber()).
|
| - WillRepeatedly(Invoke(ConsumeAllData));
|
| + EXPECT_CALL(session_, WritevData(_, _, _, _, _))
|
| + .Times(AnyNumber())
|
| + .WillRepeatedly(Invoke(ConsumeAllData));
|
|
|
| - EXPECT_EQ(headers_string_.size(), stream_->ProcessData(
|
| - headers_string_.c_str(), headers_string_.size()));
|
| + EXPECT_EQ(
|
| + headers_string_.size(),
|
| + stream_->ProcessData(headers_string_.c_str(), headers_string_.size()));
|
| // Content length is still 11. This will register as an error and we won't
|
| // accept the bytes.
|
| stream_->ProcessData(large_body.c_str(), large_body.size());
|
| @@ -200,21 +198,17 @@ TEST_P(QuicSpdyServerStreamTest, TestFramingExtraData) {
|
| TEST_P(QuicSpdyServerStreamTest, TestSendResponse) {
|
| BalsaHeaders* request_headers = stream_->mutable_headers();
|
| request_headers->SetRequestFirstlineFromStringPieces(
|
| - "GET",
|
| - "https://www.google.com/foo",
|
| - "HTTP/1.1");
|
| + "GET", "https://www.google.com/foo", "HTTP/1.1");
|
|
|
| response_headers_.SetResponseFirstlineFromStringPieces(
|
| "HTTP/1.1", "200", "OK");
|
| response_headers_.ReplaceOrAppendHeader("content-length", "3");
|
|
|
| InSequence s;
|
| - EXPECT_CALL(session_,
|
| - WritevData(kHeadersStreamId, _, 0, false, NULL));
|
| -
|
| + EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, 0, false, NULL));
|
|
|
| - EXPECT_CALL(session_, WritevData(_, _, _, _, _)).Times(1).
|
| - WillOnce(Return(QuicConsumedData(3, true)));
|
| + EXPECT_CALL(session_, WritevData(_, _, _, _, _)).Times(1).WillOnce(
|
| + Return(QuicConsumedData(3, true)));
|
|
|
| QuicSpdyServerStreamPeer::SendResponse(stream_.get());
|
| EXPECT_TRUE(stream_->read_side_closed());
|
| @@ -227,11 +221,10 @@ TEST_P(QuicSpdyServerStreamTest, TestSendErrorResponse) {
|
| response_headers_.ReplaceOrAppendHeader("content-length", "3");
|
|
|
| InSequence s;
|
| - EXPECT_CALL(session_,
|
| - WritevData(kHeadersStreamId, _, 0, false, NULL));
|
| + EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, 0, false, NULL));
|
|
|
| - EXPECT_CALL(session_, WritevData(_, _, _, _, _)).Times(1).
|
| - WillOnce(Return(QuicConsumedData(3, true)));
|
| + EXPECT_CALL(session_, WritevData(_, _, _, _, _)).Times(1).WillOnce(
|
| + Return(QuicConsumedData(3, true)));
|
|
|
| QuicSpdyServerStreamPeer::SendErrorResponse(stream_.get());
|
| EXPECT_TRUE(stream_->read_side_closed());
|
| @@ -240,27 +233,27 @@ TEST_P(QuicSpdyServerStreamTest, TestSendErrorResponse) {
|
|
|
| TEST_P(QuicSpdyServerStreamTest, InvalidHeadersWithFin) {
|
| char arr[] = {
|
| - 0x3a, 0x68, 0x6f, 0x73, // :hos
|
| - 0x74, 0x00, 0x00, 0x00, // t...
|
| - 0x00, 0x00, 0x00, 0x00, // ....
|
| - 0x07, 0x3a, 0x6d, 0x65, // .:me
|
| - 0x74, 0x68, 0x6f, 0x64, // thod
|
| - 0x00, 0x00, 0x00, 0x03, // ....
|
| - 0x47, 0x45, 0x54, 0x00, // GET.
|
| - 0x00, 0x00, 0x05, 0x3a, // ...:
|
| - 0x70, 0x61, 0x74, 0x68, // path
|
| - 0x00, 0x00, 0x00, 0x04, // ....
|
| - 0x2f, 0x66, 0x6f, 0x6f, // /foo
|
| - 0x00, 0x00, 0x00, 0x07, // ....
|
| - 0x3a, 0x73, 0x63, 0x68, // :sch
|
| - 0x65, 0x6d, 0x65, 0x00, // eme.
|
| - 0x00, 0x00, 0x00, 0x00, // ....
|
| - 0x00, 0x00, 0x08, 0x3a, // ...:
|
| - 0x76, 0x65, 0x72, 0x73, // vers
|
| - '\x96', 0x6f, 0x6e, 0x00, // <i(69)>on.
|
| - 0x00, 0x00, 0x08, 0x48, // ...H
|
| - 0x54, 0x54, 0x50, 0x2f, // TTP/
|
| - 0x31, 0x2e, 0x31, // 1.1
|
| + 0x3a, 0x68, 0x6f, 0x73, // :hos
|
| + 0x74, 0x00, 0x00, 0x00, // t...
|
| + 0x00, 0x00, 0x00, 0x00, // ....
|
| + 0x07, 0x3a, 0x6d, 0x65, // .:me
|
| + 0x74, 0x68, 0x6f, 0x64, // thod
|
| + 0x00, 0x00, 0x00, 0x03, // ....
|
| + 0x47, 0x45, 0x54, 0x00, // GET.
|
| + 0x00, 0x00, 0x05, 0x3a, // ...:
|
| + 0x70, 0x61, 0x74, 0x68, // path
|
| + 0x00, 0x00, 0x00, 0x04, // ....
|
| + 0x2f, 0x66, 0x6f, 0x6f, // /foo
|
| + 0x00, 0x00, 0x00, 0x07, // ....
|
| + 0x3a, 0x73, 0x63, 0x68, // :sch
|
| + 0x65, 0x6d, 0x65, 0x00, // eme.
|
| + 0x00, 0x00, 0x00, 0x00, // ....
|
| + 0x00, 0x00, 0x08, 0x3a, // ...:
|
| + 0x76, 0x65, 0x72, 0x73, // vers
|
| + '\x96', 0x6f, 0x6e, 0x00, // <i(69)>on.
|
| + 0x00, 0x00, 0x08, 0x48, // ...H
|
| + 0x54, 0x54, 0x50, 0x2f, // TTP/
|
| + 0x31, 0x2e, 0x31, // 1.1
|
| };
|
| StringPiece data(arr, arraysize(arr));
|
| QuicStreamFrame frame(stream_->id(), true, 0, MakeIOVector(data));
|
|
|