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..689436c7dc827830a7301cc297e6cd8861e3362e 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(); |
+ |
+ 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 = |
bengr
2016/01/11 22:29:35
#include "base/memory/scoped_ptr.h"
tbansal1
2016/01/12 20:50:51
Done.
|
+ 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; |
bengr
2016/01/11 22:29:35
What is supposed to happen with QUIC?
tbansal1
2016/01/12 20:50:51
With QUIC, trusted proxy should not be set (both e
|
+ } |
+} |
+ |
// Overrides net::NetworkQualityEstimator for testing. |
class TestNetworkQualityEstimator : public net::NetworkQualityEstimator { |
public: |