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..f3796bdb4c9ccfe8770b64c8b194e66f5e9f1adb 100644 |
--- a/net/url_request/url_request_job_unittest.cc |
+++ b/net/url_request/url_request_job_unittest.cc |
@@ -16,6 +16,12 @@ namespace net { |
namespace { |
+// Data encoded in kBrotliHelloData. |
+const char kBrotliDecodedHelloData[] = "hello, world!\n"; |
+// kBrotliDecodedHelloData encoded with brotli. |
+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 +53,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 +126,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 +296,27 @@ 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::RunLoop().RunUntilIdle(); |
+ |
+ EXPECT_FALSE(d.request_failed()); |
+ EXPECT_EQ(200, req->GetResponseCode()); |
+ EXPECT_EQ(kBrotliDecodedHelloData, d.data_received()); |
+ EXPECT_TRUE(network_layer.done_reading_called()); |
+ |
+ RemoveMockTransaction(&kBrotli_Slow_Transaction); |
+} |
+ |
} // namespace net |