Chromium Code Reviews| Index: net/spdy/spdy_http_stream_unittest.cc |
| diff --git a/net/spdy/spdy_http_stream_unittest.cc b/net/spdy/spdy_http_stream_unittest.cc |
| index 1688871d38440ecc706871e74e3bf6dc068c707f..5e4adafe77d10193d31934b450c3be3b9788f23c 100644 |
| --- a/net/spdy/spdy_http_stream_unittest.cc |
| +++ b/net/spdy/spdy_http_stream_unittest.cc |
| @@ -98,6 +98,69 @@ TEST_F(SpdyHttpStreamTest, SendRequest) { |
| EXPECT_TRUE(data()->at_write_eof()); |
| } |
| +TEST_F(SpdyHttpStreamTest, SendChunkedPost) { |
| + EnableCompression(false); |
| + SpdySession::SetSSLMode(false); |
| + |
| + scoped_ptr<spdy::SpdyFrame> req(ConstructChunkedSpdyPost(NULL, 0)); |
| + scoped_ptr<spdy::SpdyFrame> body(ConstructSpdyBodyFrame(1, false)); |
| + scoped_ptr<spdy::SpdyFrame> lastchunk(ConstructSpdyBodyFrame(1, NULL, 0, |
| + true)); |
| + MockWrite writes[] = { |
| + CreateMockWrite(*req.get(), 1), |
| + CreateMockWrite(*body, 2), // POST upload frame |
| + CreateMockWrite(*lastchunk, 3), |
| + }; |
| + scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyPostSynReply(NULL, 0)); |
| + MockRead reads[] = { |
| + CreateMockRead(*resp, 4), |
| + CreateMockRead(*body, 5), |
| + CreateMockRead(*lastchunk, 6), |
| + MockRead(false, 0, 7) // EOF |
| + }; |
| + |
| + HostPortPair host_port_pair("www.google.com", 80); |
| + HostPortProxyPair pair(host_port_pair, ProxyServer::Direct()); |
| + EXPECT_EQ(OK, InitSession(reads, arraysize(reads), writes, arraysize(writes), |
| + host_port_pair)); |
|
willchan no longer on Chromium
2011/03/02 18:44:40
host_port_pair must align with reads a la http://g
Satish
2011/03/03 13:50:10
Done.
|
| + |
| + HttpRequestInfo request; |
| + request.method = "POST"; |
| + request.url = GURL("http://www.google.com/"); |
| + request.upload_data = new UploadData(); |
| + request.upload_data->set_is_chunked(true); |
| + request.upload_data->AppendChunk(kUploadData, kUploadDataSize); |
| + request.upload_data->AppendChunk(NULL, 0); |
| + TestCompletionCallback callback; |
| + HttpResponseInfo response; |
| + HttpRequestHeaders headers; |
| + BoundNetLog net_log; |
| + scoped_ptr<SpdyHttpStream> http_stream( |
|
willchan no longer on Chromium
2011/03/02 18:44:40
How about just instantiating this on the stack? Is
Satish
2011/03/03 13:50:10
Done.
|
| + new SpdyHttpStream(session_.get(), true)); |
| + ASSERT_EQ( |
| + OK, |
| + http_stream->InitializeStream(&request, net_log, NULL)); |
| + |
| + UploadDataStream* upload_stream = |
| + UploadDataStream::Create(request.upload_data, NULL); |
| + EXPECT_EQ(ERR_IO_PENDING, http_stream->SendRequest( |
| + headers, upload_stream, &response, &callback)); |
| + EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(pair)); |
| + |
| + // This triggers the MockWrite and read 2 |
| + callback.WaitForResult(); |
| + |
| + // This triggers read 3. The empty read causes the session to shut down. |
| + data()->CompleteRead(); |
| + MessageLoop::current()->RunAllPending(); |
| + |
| + // Because we abandoned the stream, we don't expect to find a session in the |
| + // pool anymore. |
| + EXPECT_TRUE(!http_session_->spdy_session_pool()->HasSession(pair)); |
|
willchan no longer on Chromium
2011/03/02 18:44:40
This should be EXPECT_FALSE instead of EXPECT_TRUE
Satish
2011/03/03 13:50:10
Done.
|
| + EXPECT_TRUE(data()->at_read_eof()); |
| + EXPECT_TRUE(data()->at_write_eof()); |
| +} |
| + |
| // Test case for bug: http://code.google.com/p/chromium/issues/detail?id=50058 |
| TEST_F(SpdyHttpStreamTest, SpdyURLTest) { |
| EnableCompression(false); |