| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc
|
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc
|
| index f8be3741a8db30891dc9ec31d91cd2e539cb0ecb..0cbde3afe816caedead72255655624aeb1a869d7 100644
|
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc
|
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc
|
| @@ -7,6 +7,7 @@
|
| #include "base/command_line.h"
|
| #include "base/md5.h"
|
| #include "base/message_loop/message_loop.h"
|
| +#include "base/metrics/field_trial.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/test/test_simple_task_runner.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator_test_utils.h"
|
| @@ -29,6 +30,17 @@ const char kProbeURLWithNoResponse[] = "http://no.org/";
|
|
|
| namespace data_reduction_proxy {
|
|
|
| +class BadEntropyProvider : public base::FieldTrial::EntropyProvider {
|
| + public:
|
| + ~BadEntropyProvider() override {}
|
| +
|
| + double GetEntropyForTrial(const std::string& trial_name,
|
| + uint32 randomization_seed) const override {
|
| + return 0.5;
|
| + }
|
| +};
|
| +
|
| +
|
| class DataReductionProxySettingsTest
|
| : public ConcreteDataReductionProxySettingsTest<
|
| DataReductionProxySettings> {
|
| @@ -434,4 +446,78 @@ TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) {
|
| base::MessageLoop::current()->RunUntilIdle();
|
| }
|
|
|
| +TEST_F(DataReductionProxySettingsTest, CheckQUICFieldTrials) {
|
| + const struct {
|
| + bool enable_quic;
|
| + bool enable_quic_field_trial;
|
| + } tests[] = {
|
| + {
|
| + false,
|
| + false,
|
| + },
|
| + {
|
| + false,
|
| + true,
|
| + },
|
| + {
|
| + true,
|
| + false,
|
| + },
|
| + {
|
| + true,
|
| + true,
|
| + },
|
| + };
|
| +
|
| + for (size_t i = 0; i < arraysize(tests); ++i) {
|
| + // No call to |AddProxyToCommandLine()| was made, so the proxy feature
|
| + // should be unavailable.
|
| + base::MessageLoopForUI loop;
|
| + // Clear the command line. Setting flags can force the proxy to be allowed.
|
| + base::CommandLine::ForCurrentProcess()->InitFromArgv(0, NULL);
|
| +
|
| + ResetSettings(false, false, false, false, false);
|
| + MockSettings* settings = static_cast<MockSettings*>(settings_.get());
|
| + EXPECT_FALSE(settings->params()->allowed());
|
| + EXPECT_CALL(*settings, RecordStartupState(PROXY_NOT_AVAILABLE));
|
| +
|
| + scoped_ptr<DataReductionProxyConfigurator> configurator(
|
| + new TestDataReductionProxyConfigurator(
|
| + scoped_refptr<base::TestSimpleTaskRunner>(
|
| + new base::TestSimpleTaskRunner()),
|
| + &net_log_, event_store_.get()));
|
| + settings_->SetProxyConfigurator(configurator.get());
|
| + scoped_refptr<net::TestURLRequestContextGetter> request_context =
|
| + new net::TestURLRequestContextGetter(base::MessageLoopProxy::current());
|
| +
|
| + settings_->InitDataReductionProxySettings(
|
| + &pref_service_,
|
| + request_context.get(),
|
| + &net_log_,
|
| + event_store_.get());
|
| +
|
| + base::FieldTrialList field_trial_list(new BadEntropyProvider());
|
| + if (tests[i].enable_quic_field_trial){
|
| + base::FieldTrialList::CreateFieldTrial(
|
| + DataReductionProxyParams::GetQuicFieldTrialName(),
|
| + "Enabled");
|
| + } else {
|
| + base::FieldTrialList::CreateFieldTrial(
|
| + DataReductionProxyParams::GetQuicFieldTrialName(),
|
| + "Disabled");
|
| + }
|
| + settings_->EnableQuic(tests[i].enable_quic);
|
| +
|
| + settings_->SetOnDataReductionEnabledCallback(
|
| + base::Bind(&DataReductionProxySettingsTestBase::
|
| + RegisterSyntheticFieldTrialCallback,
|
| + base::Unretained(this)));
|
| +
|
| + EXPECT_EQ(tests[i].enable_quic_field_trial,
|
| + settings->params()->IsIncludedInQuicFieldTrial()) << i;
|
| + EXPECT_EQ(tests[i].enable_quic && tests[i].enable_quic_field_trial,
|
| + settings->params()->origin().is_quic()) << i;
|
| + }
|
| +}
|
| +
|
| } // namespace data_reduction_proxy
|
|
|