| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values_unittest.cc
|
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values_unittest.cc
|
| index e11fb72f4fb77f61bc6d10e12a02c28a499ef0a1..a8b409a82e94e9d3c91db10c6866ebc56aa7a6ec 100644
|
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values_unittest.cc
|
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values_unittest.cc
|
| @@ -57,6 +57,8 @@ TEST_F(DataReductionProxyMutableConfigValuesTest, UpdateValuesAndInvalidate) {
|
| mutable_config_values()->proxies_for_http());
|
| }
|
|
|
| +// Tests if HTTP proxies are overridden when |kDataReductionProxyHttpProxies|
|
| +// switch is specified.
|
| TEST_F(DataReductionProxyMutableConfigValuesTest, OverrideProxiesForHttp) {
|
| base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
| switches::kDataReductionProxyHttpProxies,
|
| @@ -88,6 +90,63 @@ TEST_F(DataReductionProxyMutableConfigValuesTest, OverrideProxiesForHttp) {
|
| mutable_config_values()->proxies_for_http());
|
| }
|
|
|
| +// Tests if HTTP proxies are overridden when |kDataReductionProxy| or
|
| +// |kDataReductionProxyFallback| switches are specified.
|
| +TEST_F(DataReductionProxyMutableConfigValuesTest, OverrideDataReductionProxy) {
|
| + const struct {
|
| + bool set_primary;
|
| + bool set_fallback;
|
| + } tests[] = {
|
| + {false, false}, {true, false}, {false, true}, {true, true},
|
| + };
|
| +
|
| + for (const auto& test : tests) {
|
| + // Reset all flags.
|
| + base::CommandLine::ForCurrentProcess()->InitFromArgv(0, NULL);
|
| + if (test.set_primary) {
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
| + switches::kDataReductionProxy, "http://override-first.net");
|
| + }
|
| + if (test.set_fallback) {
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
| + switches::kDataReductionProxyFallback, "http://override-second.net");
|
| + }
|
| + Init();
|
| +
|
| + EXPECT_EQ(std::vector<net::ProxyServer>(),
|
| + mutable_config_values()->proxies_for_http());
|
| +
|
| + std::vector<net::ProxyServer> proxies_for_http;
|
| + if (test.set_primary) {
|
| + proxies_for_http.push_back(net::ProxyServer::FromURI(
|
| + "http://first.net", net::ProxyServer::SCHEME_HTTP));
|
| + }
|
| + if (test.set_fallback) {
|
| + proxies_for_http.push_back(net::ProxyServer::FromURI(
|
| + "http://second.net", net::ProxyServer::SCHEME_HTTP));
|
| + }
|
| +
|
| + mutable_config_values()->UpdateValues(proxies_for_http);
|
| +
|
| + std::vector<net::ProxyServer> expected_override_proxies_for_http;
|
| + if (test.set_primary) {
|
| + expected_override_proxies_for_http.push_back(net::ProxyServer::FromURI(
|
| + "http://override-first.net", net::ProxyServer::SCHEME_HTTP));
|
| + }
|
| + if (test.set_fallback) {
|
| + expected_override_proxies_for_http.push_back(net::ProxyServer::FromURI(
|
| + "http://override-second.net", net::ProxyServer::SCHEME_HTTP));
|
| + }
|
| +
|
| + EXPECT_EQ(expected_override_proxies_for_http,
|
| + mutable_config_values()->proxies_for_http());
|
| +
|
| + mutable_config_values()->Invalidate();
|
| + EXPECT_EQ(std::vector<net::ProxyServer>(),
|
| + mutable_config_values()->proxies_for_http());
|
| + }
|
| +}
|
| +
|
| } // namespace
|
|
|
| } // namespace data_reduction_proxy
|
|
|