#define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_TEST_UTILS_H_
+#include "base/memory/scoped_ptr.h"
#include "base/prefs/testing_pref_service.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_configurator.h"
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_params_test_utils.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.h"
+#include "net/base/net_util.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace data_reduction_proxy {
+class DataReductionProxyStatisticsPrefs;
+
class TestDataReductionProxyConfig : public DataReductionProxyConfigurator {
public:
TestDataReductionProxyConfig();
class MockDataReductionProxySettings : public C {
public:
MockDataReductionProxySettings<C>() : DataReductionProxySettings(
- new DataReductionProxyParams(
+ new TestDataReductionProxyParams(
DataReductionProxyParams::kAllowed |
DataReductionProxyParams::kFallbackAllowed |
- DataReductionProxyParams::kPromoAllowed)) {}
+ DataReductionProxyParams::kPromoAllowed,
+ TestDataReductionProxyParams::HAS_EVERYTHING &
+ ~TestDataReductionProxyParams::HAS_DEV_ORIGIN &
+ ~TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN)) {}
MockDataReductionProxySettings<C>(int flags)
- : C(new DataReductionProxyParams(flags)) {}
+ : C(new TestDataReductionProxyParams(flags,
+ TestDataReductionProxyParams::HAS_EVERYTHING &
+ ~TestDataReductionProxyParams::HAS_DEV_ORIGIN &
+ ~TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN)) {}
MOCK_METHOD0(GetURLFetcherForAvailabilityCheck, net::URLFetcher*());
- MOCK_METHOD0(GetURLFetcherForWarmup, net::URLFetcher*());
MOCK_METHOD0(GetOriginalProfilePrefs, PrefService*());
MOCK_METHOD0(GetLocalStatePrefs, PrefService*());
MOCK_METHOD3(LogProxyState, void(
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 {
template <class C> void ResetSettings(bool allowed,
bool fallback_allowed,
bool alt_allowed,
- bool promo_allowed);
+ bool promo_allowed,
+ bool holdback);
virtual void ResetSettings(bool allowed,
bool fallback_allowed,
bool alt_allowed,
- bool promo_allowed) = 0;
+ bool promo_allowed,
+ bool holdback) = 0;
template <class C> void SetProbeResult(
const std::string& test_url,
- const std::string& warmup_test_url,
const std::string& response,
ProbeURLFetchResult state,
bool success,
int expected_calls);
virtual void SetProbeResult(const std::string& test_url,
- const std::string& warmup_test_url,
const std::string& response,
ProbeURLFetchResult result,
bool success,
bool expected_fallback_restricted);
void CheckProbe(bool initially_enabled,
const std::string& probe_url,
- const std::string& warmup_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& warmup_url,
const std::string& response,
bool request_success,
bool expected_enabled,
bool expected_fallback_restricted);
void CheckOnPrefChange(bool enabled, bool expected_enabled, bool managed);
void CheckInitDataReductionProxy(bool enabled_at_startup);
+ void RegisterSyntheticFieldTrialCallback(bool proxy_enabled) {
+ proxy_enabled_ = proxy_enabled;
+ }
TestingPrefServiceSimple pref_service_;
+ scoped_ptr<DataReductionProxyConfigurator> configurator_;
scoped_ptr<DataReductionProxySettings> settings_;
+ scoped_ptr<TestDataReductionProxyParams> expected_params_;
base::Time last_update_time_;
+ bool proxy_enabled_;
+ scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs_;
};
// Test implementations should be subclasses of an instantiation of this
virtual void ResetSettings(bool allowed,
bool fallback_allowed,
bool alt_allowed,
- bool promo_allowed) OVERRIDE {
+ bool promo_allowed,
+ bool holdback) OVERRIDE {
return DataReductionProxySettingsTestBase::ResetSettings<C>(
- allowed, fallback_allowed, alt_allowed, promo_allowed);
+ allowed, fallback_allowed, alt_allowed, promo_allowed, holdback);
}
virtual void SetProbeResult(const std::string& test_url,
- const std::string& warmup_test_url,
const std::string& response,
ProbeURLFetchResult result,
bool success,
int expected_calls) OVERRIDE {
return DataReductionProxySettingsTestBase::SetProbeResult<C>(
test_url,
- warmup_test_url,
response,
result,
success,