summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/base.gyp2
-rw-r--r--base/test/BUILD.gn2
-rw-r--r--base/test/mock_entropy_provider.cc16
-rw-r--r--base/test/mock_entropy_provider.h23
-rw-r--r--chrome/browser/io_thread_unittest.cc13
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc13
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc13
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc13
-rw-r--r--net/disk_cache/backend_unittest.cc19
9 files changed, 56 insertions, 58 deletions
diff --git a/base/base.gyp b/base/base.gyp
index 5fa2094..4c066a6 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -945,6 +945,8 @@
'test/mock_chrome_application_mac.mm',
'test/mock_devices_changed_observer.cc',
'test/mock_devices_changed_observer.h',
+ 'test/mock_entropy_provider.cc',
+ 'test/mock_entropy_provider.h',
'test/mock_log.cc',
'test/mock_log.h',
'test/multiprocess_test.cc',
diff --git a/base/test/BUILD.gn b/base/test/BUILD.gn
index 8baeb14..91456db 100644
--- a/base/test/BUILD.gn
+++ b/base/test/BUILD.gn
@@ -50,6 +50,8 @@ source_set("test_support") {
"mock_chrome_application_mac.mm",
"mock_devices_changed_observer.cc",
"mock_devices_changed_observer.h",
+ "mock_entropy_provider.cc",
+ "mock_entropy_provider.h",
"mock_log.cc",
"mock_log.h",
"multiprocess_test.cc",
diff --git a/base/test/mock_entropy_provider.cc b/base/test/mock_entropy_provider.cc
new file mode 100644
index 0000000..75186a5
--- /dev/null
+++ b/base/test/mock_entropy_provider.cc
@@ -0,0 +1,16 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/test/mock_entropy_provider.h"
+
+namespace base {
+
+MockEntropyProvider::~MockEntropyProvider() {}
+
+double MockEntropyProvider::GetEntropyForTrial(
+ const std::string& trial_name, uint32 randomization_seed) const {
+ return 0.5;
+}
+
+} // namespace base
diff --git a/base/test/mock_entropy_provider.h b/base/test/mock_entropy_provider.h
new file mode 100644
index 0000000..c55bea6
--- /dev/null
+++ b/base/test/mock_entropy_provider.h
@@ -0,0 +1,23 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_TEST_MOCK_ENTROPY_PROVIDER_H_
+#define BASE_TEST_MOCK_ENTROPY_PROVIDER_H_
+
+#include "base/metrics/field_trial.h"
+
+namespace base {
+
+class MockEntropyProvider : public base::FieldTrial::EntropyProvider {
+ public:
+ ~MockEntropyProvider() override;
+
+ // base::FieldTrial::EntropyProvider:
+ double GetEntropyForTrial(const std::string& trial_name,
+ uint32 randomization_seed) const override;
+};
+
+} // namespace base
+
+#endif // BASE_TEST_MOCK_ENTROPY_PROVIDER_H_
diff --git a/chrome/browser/io_thread_unittest.cc b/chrome/browser/io_thread_unittest.cc
index aee6854..f2820d9 100644
--- a/chrome/browser/io_thread_unittest.cc
+++ b/chrome/browser/io_thread_unittest.cc
@@ -4,6 +4,7 @@
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
+#include "base/test/mock_entropy_provider.h"
#include "chrome/browser/io_thread.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
#include "net/http/http_network_session.h"
@@ -16,16 +17,6 @@ namespace test {
using ::testing::ElementsAre;
-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 IOThreadPeer {
public:
static void ConfigureQuicGlobals(
@@ -218,7 +209,7 @@ TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) {
}
TEST_F(IOThreadTest, EnableQuicFromQuicProxyFieldTrialGroup) {
- base::FieldTrialList field_trial_list(new BadEntropyProvider());
+ base::FieldTrialList field_trial_list(new base::MockEntropyProvider());
base::FieldTrialList::CreateFieldTrial(
data_reduction_proxy::DataReductionProxyParams::GetQuicFieldTrialName(),
"Enabled");
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc
index 1753b38..c638bdd 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc
@@ -11,6 +11,7 @@
#include "base/metrics/field_trial.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
+#include "base/test/mock_entropy_provider.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_interceptor.h"
@@ -62,16 +63,6 @@ class SimpleURLRequestInterceptor : public net::URLRequestInterceptor {
}
};
-class BadEntropyProvider : public base::FieldTrial::EntropyProvider {
- public:
- ~BadEntropyProvider() override {}
-
- double GetEntropyForTrial(const std::string& trial_name,
- uint32 randomization_seed) const override {
- return 0.5;
- }
-};
-
// Constructs a |TestURLRequestContext| that uses a |MockSocketFactory| to
// simulate requests and responses.
class DataReductionProxyProtocolTest : public testing::Test {
@@ -784,7 +775,7 @@ TEST_F(DataReductionProxyProtocolTest,
std::string primary = test_context_->config()->test_params()->DefaultOrigin();
std::string fallback =
test_context_->config()->test_params()->DefaultFallbackOrigin();
- base::FieldTrialList field_trial_list(new BadEntropyProvider());
+ base::FieldTrialList field_trial_list(new base::MockEntropyProvider());
base::FieldTrialList::CreateFieldTrial(
"DataReductionProxyRemoveMissingViaHeaderOtherBypass", "Relaxed");
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
index 2556ed2..c96c862 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
@@ -7,6 +7,7 @@
#include "base/metrics/field_trial.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/histogram_tester.h"
+#include "base/test/mock_entropy_provider.h"
#include "base/time/time.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h"
@@ -245,16 +246,6 @@ TEST_F(DataReductionProxyNetworkDelegateTest, NetHistograms) {
kResponseContentLength, 1);
}
-class BadEntropyProvider : public base::FieldTrial::EntropyProvider {
- public:
- ~BadEntropyProvider() override {}
-
- double GetEntropyForTrial(const std::string& trial_name,
- uint32 randomization_seed) const override {
- return 0.5;
- }
-};
-
TEST_F(DataReductionProxyNetworkDelegateTest, OnResolveProxyHandler) {
int load_flags = net::LOAD_NORMAL;
GURL url("http://www.google.com/");
@@ -365,7 +356,7 @@ TEST_F(DataReductionProxyNetworkDelegateTest, OnResolveProxyHandler) {
// 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());
+ base::FieldTrialList field_trial_list(new base::MockEntropyProvider());
base::FieldTrialList::CreateFieldTrial("DataCompressionProxyCriticalBypass",
"Enabled");
EXPECT_TRUE(
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 1d64a4c..2b1a17b 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/metrics/field_trial.h"
+#include "base/test/mock_entropy_provider.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator_test_utils.h"
@@ -23,16 +24,6 @@
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> {
@@ -425,7 +416,7 @@ TEST_F(DataReductionProxySettingsTest, CheckQUICFieldTrials) {
test_context_->pref_service(), test_context_->io_data(),
test_context_->CreateDataReductionProxyService());
- base::FieldTrialList field_trial_list(new BadEntropyProvider());
+ base::FieldTrialList field_trial_list(new base::MockEntropyProvider());
if (enable_quic) {
base::FieldTrialList::CreateFieldTrial(
DataReductionProxyParams::GetQuicFieldTrialName(),
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc
index 5536f37..8755eef 100644
--- a/net/disk_cache/backend_unittest.cc
+++ b/net/disk_cache/backend_unittest.cc
@@ -9,6 +9,7 @@
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "base/test/mock_entropy_provider.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/platform_thread.h"
@@ -1840,16 +1841,6 @@ TEST_F(DiskCacheTest, WrongVersion) {
ASSERT_EQ(net::ERR_FAILED, cb.GetResult(rv));
}
-class BadEntropyProvider : public base::FieldTrial::EntropyProvider {
- public:
- ~BadEntropyProvider() override {}
-
- double GetEntropyForTrial(const std::string& trial_name,
- uint32 randomization_seed) const override {
- return 0.5;
- }
-};
-
// Tests that the disk cache successfully joins the control group, dropping the
// existing cache in favour of a new empty cache.
// Disabled on android since this test requires cache creator to create
@@ -1867,7 +1858,7 @@ TEST_F(DiskCacheTest, SimpleCacheControlJoin) {
// Instantiate the SimpleCacheTrial, forcing this run into the
// ExperimentControl group.
- base::FieldTrialList field_trial_list(new BadEntropyProvider());
+ base::FieldTrialList field_trial_list(new base::MockEntropyProvider());
base::FieldTrialList::CreateFieldTrial("SimpleCacheTrial",
"ExperimentControl");
net::TestCompletionCallback cb;
@@ -1891,7 +1882,7 @@ TEST_F(DiskCacheTest, SimpleCacheControlJoin) {
TEST_F(DiskCacheTest, SimpleCacheControlRestart) {
// Instantiate the SimpleCacheTrial, forcing this run into the
// ExperimentControl group.
- base::FieldTrialList field_trial_list(new BadEntropyProvider());
+ base::FieldTrialList field_trial_list(new base::MockEntropyProvider());
base::FieldTrialList::CreateFieldTrial("SimpleCacheTrial",
"ExperimentControl");
@@ -1931,7 +1922,7 @@ TEST_F(DiskCacheTest, SimpleCacheControlLeave) {
{
// Instantiate the SimpleCacheTrial, forcing this run into the
// ExperimentControl group.
- base::FieldTrialList field_trial_list(new BadEntropyProvider());
+ base::FieldTrialList field_trial_list(new base::MockEntropyProvider());
base::FieldTrialList::CreateFieldTrial("SimpleCacheTrial",
"ExperimentControl");
@@ -1942,7 +1933,7 @@ TEST_F(DiskCacheTest, SimpleCacheControlLeave) {
// Instantiate the SimpleCacheTrial, forcing this run into the
// ExperimentNo group.
- base::FieldTrialList field_trial_list(new BadEntropyProvider());
+ base::FieldTrialList field_trial_list(new base::MockEntropyProvider());
base::FieldTrialList::CreateFieldTrial("SimpleCacheTrial", "ExperimentNo");
net::TestCompletionCallback cb;