Chromium Code Reviews| Index: net/url_request/url_request_job_unittest.cc |
| diff --git a/net/url_request/url_request_job_unittest.cc b/net/url_request/url_request_job_unittest.cc |
| index 62b09f1c97a9bcad4b76e0add1b207e6b0a1273e..c06fa5b2450fb06f048b1ab1f66d5575e4b375a3 100644 |
| --- a/net/url_request/url_request_job_unittest.cc |
| +++ b/net/url_request/url_request_job_unittest.cc |
| @@ -24,6 +24,8 @@ const char kGzipDataWithName[] = |
| const char kGzipHelloData[] = |
| "\x1f\x8b\x08\x08\x46\x7d\x4e\x56\x00\x03\x67\x7a\x69\x70\x2e\x74\x78\x74" |
| "\x00\xcb\x48\xcd\xc9\xc9\xe7\x02\x00\x20\x30\x3a\x36\x06\x00\x00\x00"; |
| +const char kBrotliHelloData[] = |
|
xunjieli
2015/12/07 16:27:20
Maybe add a comment here. Something like:
// Brot
eustas
2015/12/08 11:31:31
Done.
|
| + "\033\015\0\0\244\024\102\152\020\111\152\072\235\126\034"; |
| void GZipServer(const HttpRequestInfo* request, |
| std::string* response_status, |
| @@ -47,6 +49,13 @@ void BigGZipServer(const HttpRequestInfo* request, |
| response_data->insert(10, 64 * 1024, 'a'); |
| } |
| +void BrotliHelloServer(const HttpRequestInfo* request, |
| + std::string* response_status, |
| + std::string* response_headers, |
| + std::string* response_data) { |
| + response_data->assign(kBrotliHelloData, sizeof(kBrotliHelloData) - 1); |
| +} |
| + |
| const MockTransaction kGZip_Transaction = { |
| "http://www.google.com/gzyp", |
| "GET", |
| @@ -113,6 +122,15 @@ const MockTransaction kEmptyBodyGzip_Transaction = { |
| OK, |
| }; |
| +const MockTransaction kBrotli_Slow_Transaction = { |
| + "http://www.google.com/brotli", "GET", base::Time(), "", LOAD_NORMAL, |
| + "HTTP/1.1 200 OK", |
| + "Cache-Control: max-age=10000\n" |
| + "Content-Encoding: br\n", |
| + base::Time(), "", TEST_MODE_SLOW_READ, &BrotliHelloServer, nullptr, 0, 0, |
| + OK, |
| +}; |
| + |
| } // namespace |
| TEST(URLRequestJob, TransactionNotifiedWhenDone) { |
| @@ -274,4 +292,31 @@ TEST(URLRequestJob, SlowFilterRead) { |
| RemoveMockTransaction(&kGzip_Slow_Transaction); |
| } |
| +TEST(URLRequestJob, SlowBrotliRead) { |
| + MockNetworkLayer network_layer; |
| + TestURLRequestContext context; |
| + context.set_http_transaction_factory(&network_layer); |
| + |
| + TestDelegate d; |
| + scoped_ptr<URLRequest> req(context.CreateRequest( |
| + GURL(kBrotli_Slow_Transaction.url), DEFAULT_PRIORITY, &d)); |
| + AddMockTransaction(&kBrotli_Slow_Transaction); |
| + |
| + req->set_method("GET"); |
| + req->Start(); |
| + |
| + base::MessageLoop::current()->Run(); |
| + |
| + EXPECT_FALSE(d.request_failed()); |
| + EXPECT_EQ(200, req->GetResponseCode()); |
| + |
| +#if !defined(DISABLE_BROTLI_SUPPORT) |
|
Randy Smith (Not in Mondays)
2015/12/07 22:27:28
I don't think it's relevant to this CL (yet :-}) b
eustas
2015/12/08 11:31:31
Yes, I've noted this also... And one more (specula
|
| + EXPECT_EQ("hello, world!\n", d.data_received()); |
| +#endif |
| + |
| + EXPECT_TRUE(network_layer.done_reading_called()); |
| + |
| + RemoveMockTransaction(&kBrotli_Slow_Transaction); |
| +} |
| + |
| } // namespace net |