Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Unified Diff: net/url_request/url_request_job_unittest.cc

Issue 1431723002: Add brotli content-encoding filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added BrotliSlowRead to u_r_j_unittest Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ec1d3ddd85a4b7e3f3a7acc0b5d74e0a6c8edcbd 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[] =
+ "\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,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::MessageLoop::current()->Run();
+
+ EXPECT_FALSE(d.request_failed());
+ EXPECT_EQ(200, req->GetResponseCode());
+ EXPECT_EQ("hello, world!\n", d.data_received());
+ EXPECT_TRUE(network_layer.done_reading_called());
+
+ RemoveMockTransaction(&kBrotli_Slow_Transaction);
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698