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..9dd5411ba709184dffa2e8a636da85635a0d8c4e 100644 |
| --- a/net/url_request/url_request_job_unittest.cc |
| +++ b/net/url_request/url_request_job_unittest.cc |
| @@ -16,6 +16,10 @@ namespace net { |
| namespace { |
| +// Brotli compressed data that contains "hello world!" with a newline character. |
| +const char kBrotliHelloData[] = |
| + "\033\015\0\0\244\024\102\152\020\111\152\072\235\126\034"; |
| + |
| // This is a header that signals the end of the data. |
| const char kGzipData[] = "\x1f\x08b\x08\0\0\0\0\0\0\3\3\0\0\0\0\0\0\0\0"; |
| const char kGzipDataWithName[] = |
| @@ -47,6 +51,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 +124,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 +294,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) |
| + EXPECT_EQ("hello, world!\n", d.data_received()); |
| +#endif |
|
Ryan Sleevi
2015/12/17 01:04:40
What's the expected result if brotli is disabled?
eustas
2015/12/17 16:44:55
Ideally it would be "request failed, no data" (see
|
| + |
| + EXPECT_TRUE(network_layer.done_reading_called()); |
| + |
| + RemoveMockTransaction(&kBrotli_Slow_Transaction); |
| +} |
| + |
| } // namespace net |