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

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: Exclude brotli_filter_unittest on ios - needs to read input data files 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
« no previous file with comments | « net/url_request/url_request_http_job_unittest.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « net/url_request/url_request_http_job_unittest.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698