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..b4165989a1915c8c27ffdd7b3bc351a8727677bc 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 {} |
bengr
2015/02/11 23:57:28
Move close curly to new line.
tbansal1
2015/02/12 02:27:22
I don't understand the comment.
bengr
2015/02/12 17:14:46
I mean, style afaik is to do:
~BadEntopyProvider()
tbansal1
2015/02/13 17:10:39
Not sure, see: https://code.google.com/p/chromium/
|
+ |
+ 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, |
bengr
2015/02/11 23:57:28
Indentation is off. See other examples in our tes
tbansal1
2015/02/12 02:27:22
Done.
|
+ 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("DataReductionProxyUseQuic", |
+ "Enabled"); |
+ } else { |
+ base::FieldTrialList::CreateFieldTrial("DataReductionProxyUseQuic", |
+ "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()->IsIncludedInUseQUICFieldTrial()) << i; |
+ EXPECT_EQ(tests[i].enable_quic && tests[i].enable_quic_field_trial, |
+ settings->params()->origin().is_quic()) << i; |
+ |
+ base::MessageLoop::current()->RunUntilIdle(); |
bengr
2015/02/11 23:57:28
This can be part of the test harness.
tbansal1
2015/02/12 02:27:22
removed since it was not useful for this test.
|
+ } |
+} |
+ |
} // namespace data_reduction_proxy |