| Index: components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc
|
| diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc
|
| index 3057899fe128804af57815293ed54283ee971b67..53b7d41ee6d45f37335257249ea2a8a76d349506 100644
|
| --- a/components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc
|
| +++ b/components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc
|
| @@ -8,14 +8,17 @@
|
|
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/metrics/field_trial.h"
|
| #include "base/run_loop.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "components/data_reduction_proxy/browser/data_reduction_proxy_params_test_utils.h"
|
| #include "net/base/completion_callback.h"
|
| #include "net/base/host_port_pair.h"
|
| +#include "net/base/load_flags.h"
|
| #include "net/base/network_delegate.h"
|
| #include "net/http/http_response_headers.h"
|
| #include "net/http/http_transaction_test_util.h"
|
| +#include "net/proxy/proxy_service.h"
|
| #include "net/socket/socket_test_util.h"
|
| #include "net/url_request/static_http_user_agent_settings.h"
|
| #include "net/url_request/url_request.h"
|
| @@ -611,4 +614,75 @@ TEST_F(DataReductionProxyProtocolTest,
|
| TestBadProxies(0, -1, "", "");
|
| }
|
|
|
| +class BadEntropyProvider : public base::FieldTrial::EntropyProvider {
|
| + public:
|
| + virtual ~BadEntropyProvider() {}
|
| +
|
| + virtual double GetEntropyForTrial(const std::string& trial_name,
|
| + uint32 randomization_seed) const OVERRIDE {
|
| + return 0.5;
|
| + }
|
| +};
|
| +
|
| +TEST_F(DataReductionProxyProtocolTest, OnResolveProxyHandler) {
|
| + int load_flags = 0;
|
| + GURL url("http://www.google.com/");
|
| +
|
| + // Data reduction proxy
|
| + ProxyInfo info1;
|
| + data_reduction_proxy.UseNamedProxy("proxy.googlezip.net:443");
|
| +
|
| + // Other proxy
|
| + ProxyInfo info2;
|
| + data_reduction_proxy.UseNamedProxy("proxy.com");
|
| +
|
| + // Without DataCompressionProxyCriticalBypass Finch trial set, should never
|
| + // bypass.
|
| + OnResolveProxyHandler(url, load_flags, &info1);
|
| + EXPECT_FALSE(info1.is_direct());
|
| + EXPECT_FALSE(info1.did_bypass_proxy());
|
| +
|
| + OnResolveProxyHandler(url, load_flags, &info2);
|
| + EXPECT_FALSE(info2.is_direct());
|
| + EXPECT_FALSE(info2.did_bypass_proxy());
|
| +
|
| + load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
|
| +
|
| + OnResolveProxyHandler(url, load_flags, &info1);
|
| + EXPECT_FALSE(info1.is_direct());
|
| + EXPECT_FALSE(info1.did_bypass_proxy());
|
| +
|
| + OnResolveProxyHandler(url, load_flags, &info2);
|
| + EXPECT_FALSE(info2.is_direct());
|
| + EXPECT_FALSE(info2.did_bypass_proxy());
|
| +
|
| + // With Finch trial set, should only bypass if LOAD flag is set and the
|
| + // effective proxy is the data compression proxy.
|
| + base::FieldTrialList field_trial_list(new BadEntropyProvider());
|
| + ASSERT_TRUE(base::FieldTrialList::CreateTrialsFromString(
|
| + "DataCompressionProxyCriticalBypass/Enabled/",
|
| + base::FieldTrialList::ACTIVATE_TRIALS,
|
| + std::set<std::string>()));
|
| +
|
| + load_flags = 0;
|
| +
|
| + OnResolveProxyHandler(url, load_flags, &info1);
|
| + EXPECT_FALSE(info1.is_direct());
|
| + EXPECT_FALSE(info1.did_bypass_proxy());
|
| +
|
| + OnResolveProxyHandler(url, load_flags, &info2);
|
| + EXPECT_FALSE(info2.is_direct());
|
| + EXPECT_FALSE(info2.did_bypass_proxy());
|
| +
|
| + load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
|
| +
|
| + OnResolveProxyHandler(url, load_flags, &info2);
|
| + EXPECT_FALSE(info2.is_direct());
|
| + EXPECT_FALSE(info2.did_bypass_proxy());
|
| +
|
| + OnResolveProxyHandler(url, load_flags, &info1);
|
| + EXPECT_TRUE(info1.is_direct());
|
| + EXPECT_TRUE(info1.did_bypass_proxy());
|
| +}
|
| +
|
| } // namespace data_reduction_proxy
|
|
|