Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.h |
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.h |
index c364706e8cde4963f22e3403e2afb210357b87d7..5ed4bd69cec6c154b544a0f92967b712909d758a 100644 |
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.h |
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.h |
@@ -23,52 +23,16 @@ namespace data_reduction_proxy { |
class DataReductionProxyConfigurator; |
class DataReductionProxyStatisticsPrefs; |
+class MockDataReductionProxyConfig; |
template <class C> |
class MockDataReductionProxySettings : public C { |
public: |
- MockDataReductionProxySettings<C>() : DataReductionProxySettings( |
- scoped_ptr<TestDataReductionProxyParams>(new TestDataReductionProxyParams( |
- DataReductionProxyParams::kAllowed | |
- DataReductionProxyParams::kFallbackAllowed | |
- DataReductionProxyParams::kPromoAllowed, |
- TestDataReductionProxyParams::HAS_EVERYTHING & |
- ~TestDataReductionProxyParams::HAS_DEV_ORIGIN & |
- ~TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN)).Pass()) {} |
- MockDataReductionProxySettings<C>(int flags) |
- : C(scoped_ptr<TestDataReductionProxyParams>( |
- new TestDataReductionProxyParams(flags, |
- TestDataReductionProxyParams::HAS_EVERYTHING & |
- ~TestDataReductionProxyParams::HAS_DEV_ORIGIN & |
- ~TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN)) |
- .Pass()) {} |
- MOCK_METHOD0(GetURLFetcherForAvailabilityCheck, net::URLFetcher*()); |
+ MockDataReductionProxySettings<C>() : C() {} |
MOCK_METHOD0(GetOriginalProfilePrefs, PrefService*()); |
MOCK_METHOD0(GetLocalStatePrefs, PrefService*()); |
- MOCK_METHOD3(LogProxyState, void( |
- bool enabled, bool restricted, bool at_startup)); |
- MOCK_METHOD1(RecordProbeURLFetchResult, |
- void(ProbeURLFetchResult result)); |
MOCK_METHOD1(RecordStartupState, |
void(ProxyStartupState state)); |
- |
- // SetProxyConfigs should always call LogProxyState exactly once. |
- virtual void SetProxyConfigs(bool enabled, |
- bool alternative_enabled, |
- bool restricted, |
- bool at_startup) override { |
- EXPECT_CALL(*this, LogProxyState(enabled, restricted, at_startup)).Times(1); |
- C::SetProxyConfigs(enabled, alternative_enabled, restricted, at_startup); |
- } |
- virtual void GetNetworkList(net::NetworkInterfaceList* interfaces, |
- int policy) override { |
- if (!network_interfaces_.get()) |
- return; |
- for (size_t i = 0; i < network_interfaces_->size(); ++i) |
- interfaces->push_back(network_interfaces_->at(i)); |
- } |
- |
- scoped_ptr<net::NetworkInterfaceList> network_interfaces_; |
}; |
class DataReductionProxySettingsTestBase : public testing::Test { |
@@ -97,33 +61,15 @@ class DataReductionProxySettingsTestBase : public testing::Test { |
bool promo_allowed, |
bool holdback) = 0; |
- template <class C> void SetProbeResult( |
- const std::string& test_url, |
- const std::string& response, |
- ProbeURLFetchResult state, |
- bool success, |
- int expected_calls); |
- virtual void SetProbeResult(const std::string& test_url, |
- const std::string& response, |
- ProbeURLFetchResult result, |
- bool success, |
- int expected_calls) = 0; |
- |
- void CheckProxyConfigs(bool expected_enabled, |
- bool expected_restricted, |
- bool expected_fallback_restricted); |
- void CheckProbe(bool initially_enabled, |
- const std::string& probe_url, |
- const std::string& response, |
- bool request_success, |
- bool expected_enabled, |
- bool expected_restricted, |
- bool expected_fallback_restricted); |
- void CheckProbeOnIPChange(const std::string& probe_url, |
- const std::string& response, |
- bool request_success, |
- bool expected_enabled, |
- bool expected_fallback_restricted); |
+ void ExpectSetProxyPrefs(bool expected_enabled, |
+ bool expected_alternate_enabled, |
+ bool expected_at_startup); |
+ void CheckMaybeActivateDataReductionProxy( |
+ bool initially_enabled, |
+ bool request_succeeded, |
+ bool expected_enabled, |
+ bool expected_restricted, |
+ bool expected_fallback_restricted); |
void CheckOnPrefChange(bool enabled, bool expected_enabled, bool managed); |
void CheckInitDataReductionProxy(bool enabled_at_startup); |
void RegisterSyntheticFieldTrialCallback(bool proxy_enabled) { |
@@ -133,7 +79,7 @@ class DataReductionProxySettingsTestBase : public testing::Test { |
TestingPrefServiceSimple pref_service_; |
scoped_ptr<DataReductionProxyConfigurator> configurator_; |
scoped_ptr<DataReductionProxySettings> settings_; |
- scoped_ptr<TestDataReductionProxyParams> expected_params_; |
+ scoped_ptr<MockDataReductionProxyConfig> config_; |
base::Time last_update_time_; |
bool proxy_enabled_; |
scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs_; |
@@ -157,19 +103,6 @@ class ConcreteDataReductionProxySettingsTest |
return DataReductionProxySettingsTestBase::ResetSettings<C>( |
allowed, fallback_allowed, alt_allowed, promo_allowed, holdback); |
} |
- |
- virtual void SetProbeResult(const std::string& test_url, |
- const std::string& response, |
- ProbeURLFetchResult result, |
- bool success, |
- int expected_calls) override { |
- return DataReductionProxySettingsTestBase::SetProbeResult<C>( |
- test_url, |
- response, |
- result, |
- success, |
- expected_calls); |
- } |
}; |
} // namespace data_reduction_proxy |