| Index: net/url_request/url_request_http_job_unittest.cc
|
| diff --git a/net/url_request/url_request_http_job_unittest.cc b/net/url_request/url_request_http_job_unittest.cc
|
| index dca3e8e979e7c2daa3801960b541255a5e1c7ef9..0b49dfc77bd882887c078ab4f12856c082f33f9d 100644
|
| --- a/net/url_request/url_request_http_job_unittest.cc
|
| +++ b/net/url_request/url_request_http_job_unittest.cc
|
| @@ -17,6 +17,7 @@
|
| #include "net/base/request_priority.h"
|
| #include "net/base/test_data_directory.h"
|
| #include "net/cookies/cookie_store_test_helpers.h"
|
| +#include "net/http/http_server_properties_impl.h"
|
| #include "net/http/http_transaction_factory.h"
|
| #include "net/http/http_transaction_test_util.h"
|
| #include "net/socket/socket_test_util.h"
|
| @@ -61,7 +62,7 @@ class URLRequestHttpJobTest : public ::testing::Test {
|
| context_.set_http_transaction_factory(&network_layer_);
|
| }
|
|
|
| - bool TransactionAcceptsSdchEncoding() {
|
| + bool TransactionAcceptsSpecificEncoding(const std::string encoding) {
|
| base::WeakPtr<MockNetworkTransaction> transaction(
|
| network_layer_.last_transaction());
|
| EXPECT_TRUE(transaction);
|
| @@ -82,16 +83,34 @@ class URLRequestHttpJobTest : public ::testing::Test {
|
| for (const std::string& token :
|
| base::SplitString(encoding_headers, ", ", base::KEEP_WHITESPACE,
|
| base::SPLIT_WANT_NONEMPTY)) {
|
| - if (base::EqualsCaseInsensitiveASCII(token, "sdch"))
|
| + if (base::EqualsCaseInsensitiveASCII(token, encoding))
|
| return true;
|
| }
|
| return false;
|
| }
|
|
|
| + bool TransactionAcceptsSdchEncoding() {
|
| + return TransactionAcceptsSpecificEncoding("sdch");
|
| + }
|
| +
|
| + bool TransactionAcceptsBrotliEncoding() {
|
| + return TransactionAcceptsSpecificEncoding("br");
|
| + }
|
| +
|
| void EnableSdch() {
|
| context_.SetSdchManager(scoped_ptr<SdchManager>(new SdchManager).Pass());
|
| }
|
|
|
| + void EnableBrotli() {
|
| + HttpNetworkSession::Params params;
|
| + params.enable_brotli = true;
|
| + params.http_server_properties = http_server_properties_.GetWeakPtr();
|
| + network_session_.reset(new HttpNetworkSession(params));
|
| + network_layer_.set_network_session(network_session_.get());
|
| + }
|
| +
|
| + HttpServerPropertiesImpl http_server_properties_;
|
| + scoped_ptr<HttpNetworkSession> network_session_;
|
| MockNetworkLayer network_layer_;
|
| TestURLRequestContext context_;
|
| TestDelegate delegate_;
|
| @@ -629,6 +648,26 @@ TEST_F(URLRequestHttpJobTest, SdchAdvertisementPost) {
|
| EXPECT_FALSE(TransactionAcceptsSdchEncoding());
|
| }
|
|
|
| +TEST_F(URLRequestHttpJobTest, NoBrotliAdvertisementOverHttp) {
|
| + EnableBrotli();
|
| + req_->set_method("GET"); // Redundant with default.
|
| + scoped_refptr<TestURLRequestHttpJob> job(
|
| + new TestURLRequestHttpJob(req_.get()));
|
| + job->Start();
|
| + EXPECT_FALSE(TransactionAcceptsBrotliEncoding());
|
| +}
|
| +
|
| +TEST_F(URLRequestHttpJobTest, BrotliAdvertisement) {
|
| + EnableBrotli();
|
| + req_ = context_.CreateRequest(GURL("https://www.example.com"),
|
| + DEFAULT_PRIORITY, &delegate_);
|
| + req_->set_method("GET"); // Redundant with default.
|
| + scoped_refptr<TestURLRequestHttpJob> job(
|
| + new TestURLRequestHttpJob(req_.get()));
|
| + job->Start();
|
| + EXPECT_TRUE(TransactionAcceptsBrotliEncoding());
|
| +}
|
| +
|
| // This base class just serves to set up some things before the TestURLRequest
|
| // constructor is called.
|
| class URLRequestHttpJobWebSocketTestBase : public ::testing::Test {
|
|
|