Index: net/http/http_pipelined_connection_impl_unittest.cc |
diff --git a/net/http/http_pipelined_connection_impl_unittest.cc b/net/http/http_pipelined_connection_impl_unittest.cc |
index 420d8dc401ba8096c78082ac6590c8259cbc24cc..f6720f4056e86a5b2d2bedc075ccfe4843e3c00e 100644 |
--- a/net/http/http_pipelined_connection_impl_unittest.cc |
+++ b/net/http/http_pipelined_connection_impl_unittest.cc |
@@ -1025,6 +1025,57 @@ TEST_F(HttpPipelinedConnectionImplTest, CloseOtherDuringReadCallback) { |
data_->RunFor(1); |
} |
+TEST_F(HttpPipelinedConnectionImplTest, CloseBeforeSendCallbackRuns) { |
+ MockWrite writes[] = { |
+ MockWrite(true, 0, "GET /close.html HTTP/1.1\r\n\r\n"), |
+ MockWrite(true, 1, "GET /dummy.html HTTP/1.1\r\n\r\n"), |
+ }; |
+ Initialize(NULL, 0, writes, arraysize(writes)); |
+ |
+ scoped_ptr<HttpStream> close_stream(NewTestStream("close.html")); |
+ scoped_ptr<HttpStream> dummy_stream(NewTestStream("dummy.html")); |
+ |
+ TestOldCompletionCallback close_callback; |
+ HttpRequestHeaders headers; |
+ HttpResponseInfo response; |
+ EXPECT_EQ(ERR_IO_PENDING, close_stream->SendRequest( |
+ headers, NULL, &response, &close_callback)); |
+ |
+ data_->RunFor(1); |
+ EXPECT_FALSE(close_callback.have_result()); |
+ |
+ close_stream->Close(false); |
mmenke
2011/10/28 00:54:09
Add "MessageLoop::current()->RunAllPending();" to
|
+} |
+ |
+TEST_F(HttpPipelinedConnectionImplTest, CloseBeforeReadCallbackRuns) { |
+ MockWrite writes[] = { |
+ MockWrite(false, 0, "GET /close.html HTTP/1.1\r\n\r\n"), |
+ MockWrite(false, 3, "GET /dummy.html HTTP/1.1\r\n\r\n"), |
+ }; |
+ MockRead reads[] = { |
+ MockRead(false, 1, "HTTP/1.1 200 OK\r\n"), |
+ MockRead(true, 2, "Content-Length: 7\r\n\r\n"), |
+ }; |
+ Initialize(reads, arraysize(reads), writes, arraysize(writes)); |
+ |
+ scoped_ptr<HttpStream> close_stream(NewTestStream("close.html")); |
+ scoped_ptr<HttpStream> dummy_stream(NewTestStream("dummy.html")); |
+ |
+ HttpRequestHeaders headers; |
+ HttpResponseInfo response; |
+ EXPECT_EQ(OK, |
+ close_stream->SendRequest(headers, NULL, &response, &callback_)); |
+ |
+ TestOldCompletionCallback close_callback; |
+ EXPECT_EQ(ERR_IO_PENDING, |
+ close_stream->ReadResponseHeaders(&close_callback)); |
+ |
+ data_->RunFor(1); |
+ EXPECT_FALSE(close_callback.have_result()); |
+ |
+ close_stream->Close(false); |
+} |
+ |
TEST_F(HttpPipelinedConnectionImplTest, OnPipelineHasCapacity) { |
MockWrite writes[] = { |
MockWrite(false, 0, "GET /ok.html HTTP/1.1\r\n\r\n"), |