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 9c23b54433f46b124c34c52029d6609482b71bdb..ab4c6068ed60f88a8316356cf45ce0df7a4718b5 100644 |
--- a/net/spdy/spdy_http_stream_unittest.cc |
+++ b/net/spdy/spdy_http_stream_unittest.cc |
@@ -10,6 +10,8 @@ |
namespace net { |
class SpdyHttpStreamTest : public testing::Test { |
+ public: |
+ OrderedSocketData* data() { return data_; } |
protected: |
SpdyHttpStreamTest() {} |
@@ -49,8 +51,11 @@ TEST_F(SpdyHttpStreamTest, SendRequest) { |
MockWrite writes[] = { |
CreateMockWrite(*req.get(), 1), |
}; |
+ scoped_ptr<spdy::SpdyFrame> resp(ConstructSpdyGetSynReply(NULL, 0, 1)); |
MockRead reads[] = { |
- MockRead(false, 0, 2) // EOF |
+ CreateMockRead(*resp, 2), |
+ MockRead(true, ERR_IO_PENDING, 3), // Force a pause |
+ MockRead(false, 0, 4) // EOF |
}; |
HostPortPair host_port_pair("www.google.com", 80); |
@@ -70,9 +75,17 @@ TEST_F(SpdyHttpStreamTest, SendRequest) { |
EXPECT_EQ(ERR_IO_PENDING, |
http_stream->SendRequest(&response, &callback)); |
- MessageLoop::current()->RunAllPending(); |
EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(host_port_pair)); |
- http_session_->spdy_session_pool()->Remove(session_); |
+ |
+ // This triggers the MockWrite and reads 2 & 3 |
+ callback.WaitForResult(); |
+ |
+ // This triggers read 4. The empty read causes the session to shut down. |
+ data()->CompleteRead(); |
+ |
+ EXPECT_TRUE(!http_session_->spdy_session_pool()->HasSession(host_port_pair)); |
+ 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 |
@@ -80,16 +93,12 @@ TEST_F(SpdyHttpStreamTest, SpdyURLTest) { |
EnableCompression(false); |
SpdySession::SetSSLMode(false); |
- scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); |
- MockWrite writes[] = { |
- CreateMockWrite(*req.get(), 1), |
- }; |
MockRead reads[] = { |
MockRead(false, 0, 2), // EOF |
}; |
HostPortPair host_port_pair("www.google.com", 80); |
- EXPECT_EQ(OK, InitSession(reads, arraysize(reads), writes, arraysize(writes), |
+ EXPECT_EQ(OK, InitSession(reads, arraysize(reads), NULL, 0, |
host_port_pair)); |
HttpRequestInfo request; |
@@ -113,7 +122,8 @@ TEST_F(SpdyHttpStreamTest, SpdyURLTest) { |
MessageLoop::current()->RunAllPending(); |
EXPECT_TRUE(http_session_->spdy_session_pool()->HasSession(host_port_pair)); |
- http_session_->spdy_session_pool()->Remove(session_); |
+ http_session_->spdy_session_pool()->CloseAllSessions(); |
+ EXPECT_TRUE(!data()->at_read_eof()); |
} |
// TODO(willchan): Write a longer test for SpdyStream that exercises all |