| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
|
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
|
| index ea4d8c849e832cd0e550ad4ec9bc44fb41210dd5..a5c69fc94e7c4158258a2e4774eb3bca304868d1 100644
|
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
|
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
|
| @@ -28,6 +28,7 @@
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
|
| #include "components/variations/variations_associated_data.h"
|
| #include "net/base/external_estimate_provider.h"
|
| +#include "net/base/host_port_pair.h"
|
| #include "net/base/network_quality_estimator.h"
|
| #include "net/http/http_status_code.h"
|
| #include "net/log/test_net_log.h"
|
| @@ -908,6 +909,71 @@ TEST_F(DataReductionProxyConfigTest, LoFiOn) {
|
| }
|
| }
|
|
|
| +// Tests that the trusted SPDY proxy is set correctly.
|
| +TEST_F(DataReductionProxyConfigTest, TrustedSpdyProxy) {
|
| + const struct {
|
| + bool is_data_reduction_proxy_enabled;
|
| + bool is_in_trusted_spdy_proxy_field_trial;
|
| + net::ProxyServer proxy;
|
| + } tests[] = {
|
| + {false, false, net::ProxyServer::FromURI("http://origin.net:80",
|
| + net::ProxyServer::SCHEME_HTTP)},
|
| + {false, false, net::ProxyServer::FromURI("https://origin.net:443",
|
| + net::ProxyServer::SCHEME_HTTP)},
|
| + {false, true, net::ProxyServer::FromURI("http://origin.net:80",
|
| + net::ProxyServer::SCHEME_HTTP)},
|
| + {false, true, net::ProxyServer::FromURI("https://origin.net:443",
|
| + net::ProxyServer::SCHEME_HTTP)},
|
| + {false, true, net::ProxyServer::FromURI("quic://origin.net:443",
|
| + net::ProxyServer::SCHEME_QUIC)},
|
| + {true, false, net::ProxyServer::FromURI("http://origin.net:80",
|
| + net::ProxyServer::SCHEME_HTTP)},
|
| + {true, false, net::ProxyServer::FromURI("https://origin.net:443",
|
| + net::ProxyServer::SCHEME_HTTP)},
|
| + {true, true, net::ProxyServer::FromURI("http://origin.net:80",
|
| + net::ProxyServer::SCHEME_HTTP)},
|
| + {true, true, net::ProxyServer::FromURI("https://origin.net:443",
|
| + net::ProxyServer::SCHEME_HTTP)},
|
| + {true, true, net::ProxyServer::FromURI("quic://origin.net:443",
|
| + net::ProxyServer::SCHEME_QUIC)},
|
| + };
|
| + for (size_t i = 0; i < arraysize(tests); ++i) {
|
| + bool is_proxy_secure =
|
| + tests[i].proxy.is_https() || tests[i].proxy.is_quic();
|
| +
|
| + net::ProxyServer expected_trusted_spdy_proxy;
|
| + if (tests[i].is_data_reduction_proxy_enabled &&
|
| + tests[i].is_in_trusted_spdy_proxy_field_trial && is_proxy_secure) {
|
| + expected_trusted_spdy_proxy = tests[i].proxy;
|
| + }
|
| +
|
| + std::vector<net::ProxyServer> proxies_for_http;
|
| + proxies_for_http.push_back(tests[i].proxy);
|
| +
|
| + scoped_ptr<DataReductionProxyMutableConfigValues> config_values =
|
| + DataReductionProxyMutableConfigValues::CreateFromParams(params());
|
| + config_values->UpdateValues(proxies_for_http);
|
| + scoped_ptr<DataReductionProxyConfig> config(new DataReductionProxyConfig(
|
| + net_log(), std::move(config_values), configurator(), event_creator()));
|
| +
|
| + if (tests[i].is_data_reduction_proxy_enabled)
|
| + config->enabled_by_user_ = true;
|
| +
|
| + base::FieldTrialList field_trial_list(nullptr);
|
| + if (tests[i].is_in_trusted_spdy_proxy_field_trial) {
|
| + base::FieldTrialList::CreateFieldTrial(
|
| + params::GetTrustedSpdyProxyFieldTrialName(), "Enabled");
|
| + } else {
|
| + base::FieldTrialList::CreateFieldTrial(
|
| + params::GetTrustedSpdyProxyFieldTrialName(), "Control");
|
| + }
|
| +
|
| + net::ProxyServer trusted_spdy_proxy;
|
| + config->GetTrustedSpdyProxy(&trusted_spdy_proxy);
|
| + EXPECT_EQ(expected_trusted_spdy_proxy, trusted_spdy_proxy) << i;
|
| + }
|
| +}
|
| +
|
| // Overrides net::NetworkQualityEstimator for testing.
|
| class TestNetworkQualityEstimator : public net::NetworkQualityEstimator {
|
| public:
|
|
|