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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_mutable_config_values_unittest.cc

Issue 1834373002: Override DRP proxies from command line switches (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed sclittle comment Created 4 years, 9 months 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 | « no previous file | components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698