Chromium Code Reviews| Index: net/http/http_network_transaction_unittest.cc |
| diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc |
| index 44b6759be57a0da0c5235aac8319eafbfe2745c3..6d09f0172d6ef0d0abe24d53a0966157946cdbb5 100644 |
| --- a/net/http/http_network_transaction_unittest.cc |
| +++ b/net/http/http_network_transaction_unittest.cc |
| @@ -8981,4 +8981,106 @@ TEST_F(HttpNetworkTransactionTest, |
| HttpStreamFactory::set_use_alternate_protocols(false); |
| } |
| +TEST_F(HttpNetworkTransactionTest, ReadPipelineEvictionFallback) { |
| + MockRead data_reads1[] = { |
| + MockRead(false, ERR_PIPELINE_EVICTION), |
| + }; |
| + MockRead data_reads2[] = { |
| + MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
| + MockRead("hello world"), |
| + MockRead(false, OK), |
| + }; |
| + SimpleGetHelperResult out; |
| + |
| + HttpRequestInfo request; |
| + request.method = "GET"; |
| + request.url = GURL("http://www.google.com/"); |
| + request.load_flags = 0; |
| + |
| + SessionDependencies session_deps; |
| + scoped_ptr<HttpTransaction> trans( |
| + new HttpNetworkTransaction(CreateSession(&session_deps))); |
| + |
| + StaticSocketDataProvider data1(data_reads1, arraysize(data_reads1), NULL, 0); |
| + StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), NULL, 0); |
| + session_deps.socket_factory.AddSocketDataProvider(&data1); |
| + session_deps.socket_factory.AddSocketDataProvider(&data2); |
| + |
| + TestCompletionCallback callback; |
|
mmenke
2011/09/15 19:28:16
You're duplicating a fair bit of code here. I thi
James Simonsen
2011/09/17 01:23:02
Done.
|
| + |
| + CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
| + EXPECT_TRUE(log.bound().IsLoggingAllEvents()); |
|
mmenke
2011/09/15 19:28:16
nit: Not needed, since you aren't validating even
James Simonsen
2011/09/17 01:23:02
Removed.
|
| + int rv = trans->Start(&request, &callback, log.bound()); |
| + EXPECT_EQ(ERR_IO_PENDING, rv); |
| + |
| + out.rv = callback.WaitForResult(); |
| + |
| + const HttpResponseInfo* response = trans->GetResponseInfo(); |
| + EXPECT_TRUE(response != NULL); |
| + |
| + EXPECT_TRUE(response->headers != NULL); |
| + out.status_line = response->headers->GetStatusLine(); |
| + |
| + rv = ReadTransaction(trans.get(), &out.response_data); |
| + EXPECT_EQ(OK, rv); |
| + |
| + EXPECT_EQ(OK, out.rv); |
| + EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); |
| + EXPECT_EQ("hello world", out.response_data); |
| +} |
| + |
| +TEST_F(HttpNetworkTransactionTest, SendPipelineEvictionFallback) { |
| + MockWrite data_writes1[] = { |
| + MockWrite(false, ERR_PIPELINE_EVICTION), |
| + }; |
| + MockWrite data_writes2[] = { |
| + MockWrite("GET / HTTP/1.1\r\n" |
| + "Host: www.google.com\r\n" |
| + "Connection: keep-alive\r\n\r\n"), |
| + }; |
| + MockRead data_reads2[] = { |
| + MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
| + MockRead("hello world"), |
| + MockRead(false, OK), |
| + }; |
| + SimpleGetHelperResult out; |
| + |
| + HttpRequestInfo request; |
| + request.method = "GET"; |
| + request.url = GURL("http://www.google.com/"); |
| + request.load_flags = 0; |
| + |
| + SessionDependencies session_deps; |
| + scoped_ptr<HttpTransaction> trans( |
| + new HttpNetworkTransaction(CreateSession(&session_deps))); |
| + |
| + StaticSocketDataProvider data1(NULL, 0, |
| + data_writes1, arraysize(data_writes1)); |
| + StaticSocketDataProvider data2(data_reads2, arraysize(data_reads2), |
| + data_writes2, arraysize(data_writes2)); |
| + session_deps.socket_factory.AddSocketDataProvider(&data1); |
| + session_deps.socket_factory.AddSocketDataProvider(&data2); |
| + |
| + TestCompletionCallback callback; |
| + |
| + CapturingBoundNetLog log(CapturingNetLog::kUnbounded); |
| + EXPECT_TRUE(log.bound().IsLoggingAllEvents()); |
|
mmenke
2011/09/15 19:28:16
nit: Not needed, since you aren't validating even
James Simonsen
2011/09/17 01:23:02
Removed.
|
| + int rv = trans->Start(&request, &callback, log.bound()); |
| + EXPECT_EQ(ERR_IO_PENDING, rv); |
| + |
| + out.rv = callback.WaitForResult(); |
| + |
| + const HttpResponseInfo* response = trans->GetResponseInfo(); |
| + EXPECT_TRUE(response != NULL); |
| + EXPECT_TRUE(response->headers != NULL); |
| + out.status_line = response->headers->GetStatusLine(); |
| + |
| + rv = ReadTransaction(trans.get(), &out.response_data); |
| + EXPECT_EQ(OK, rv); |
| + |
| + EXPECT_EQ(OK, out.rv); |
| + EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); |
| + EXPECT_EQ("hello world", out.response_data); |
| +} |
| + |
| } // namespace net |