#include "components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.h"
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/prefs/pref_registry_simple.h"
namespace {
-const char kDataReductionProxy[] = "https://foo.com:443/";
-const char kDataReductionProxyFallback[] = "http://bar.com:80/";
-const char kDataReductionProxyKey[] = "12345";
-
const char kProbeURLWithOKResponse[] = "http://ok.org/";
const char kWarmupURLWithNoContentResponse[] = "http://warm.org/";
ssl_origin_ = "";
}
-// static
-void DataReductionProxySettingsTestBase::AddTestProxyToCommandLine() {
- CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kDataReductionProxy, kDataReductionProxy);
- CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kDataReductionProxyFallback, kDataReductionProxyFallback);
- CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kDataReductionProxyKey, kDataReductionProxyKey);
- CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kDataReductionProxyProbeURL, kProbeURLWithOKResponse);
-}
-
DataReductionProxySettingsTestBase::DataReductionProxySettingsTestBase()
: testing::Test() {
}
DataReductionProxySettingsTestBase::~DataReductionProxySettingsTestBase() {}
-void DataReductionProxySettingsTestBase::AddProxyToCommandLine() {
- AddTestProxyToCommandLine();
-}
-
// testing::Test implementation:
void DataReductionProxySettingsTestBase::SetUp() {
PrefRegistrySimple* registry = pref_service_.registry();
registry->RegisterBooleanPref(prefs::kDataReductionProxyAltEnabled, false);
registry->RegisterBooleanPref(prefs::kDataReductionProxyWasEnabledBefore,
false);
- AddProxyToCommandLine();
- ResetSettings(true, true, false, true);
+ //AddProxyToCommandLine();
+ ResetSettings(true, true, false, true, false);
ListPrefUpdate original_update(&pref_service_,
prefs::kDailyHttpOriginalContentLength);
pref_service_.SetInt64(
prefs::kDailyHttpContentLengthLastUpdateDate,
last_update_time_.ToInternalValue());
+ expected_params_.reset(new TestDataReductionProxyParams(
+ DataReductionProxyParams::kAllowed |
+ DataReductionProxyParams::kFallbackAllowed |
+ DataReductionProxyParams::kPromoAllowed,
+ TestDataReductionProxyParams::HAS_EVERYTHING &
+ ~TestDataReductionProxyParams::HAS_DEV_ORIGIN));
}
template <class C>
void DataReductionProxySettingsTestBase::ResetSettings(bool allowed,
bool fallback_allowed,
bool alt_allowed,
- bool promo_allowed) {
+ bool promo_allowed,
+ bool holdback) {
int flags = 0;
if (allowed)
flags |= DataReductionProxyParams::kAllowed;
flags |= DataReductionProxyParams::kAlternativeAllowed;
if (promo_allowed)
flags |= DataReductionProxyParams::kPromoAllowed;
+ if (holdback)
+ flags |= DataReductionProxyParams::kHoldback;
MockDataReductionProxySettings<C>* settings =
new MockDataReductionProxySettings<C>(flags);
EXPECT_CALL(*settings, GetOriginalProfilePrefs())
EXPECT_CALL(*settings, GetURLFetcherForWarmup()).Times(0);
EXPECT_CALL(*settings, LogProxyState(_, _, _)).Times(0);
settings_.reset(settings);
- settings_->configurator_.reset(new TestDataReductionProxyConfig());
+ configurator_.reset(new TestDataReductionProxyConfig());
+ settings_->configurator_ = configurator_.get();
}
// Explicitly generate required instantiations.
template void
DataReductionProxySettingsTestBase::ResetSettings<DataReductionProxySettings>(
- bool allowed, bool fallback_allowed, bool alt_allowed, bool promo_allowed);
+ bool allowed,
+ bool fallback_allowed,
+ bool alt_allowed,
+ bool promo_allowed,
+ bool holdback);
template <class C>
void DataReductionProxySettingsTestBase::SetProbeResult(
bool expected_restricted,
bool expected_fallback_restricted) {
TestDataReductionProxyConfig* config =
- static_cast<TestDataReductionProxyConfig*>(
- settings_->configurator_.get());
+ static_cast<TestDataReductionProxyConfig*>(settings_->configurator_);
ASSERT_EQ(expected_restricted, config->restricted_);
ASSERT_EQ(expected_fallback_restricted, config->fallback_restricted_);
ASSERT_EQ(expected_enabled, config->enabled_);
expected_enabled ? 1 : 0);
if (managed) {
pref_service_.SetManagedPref(prefs::kDataReductionProxyEnabled,
- base::Value::CreateBooleanValue(enabled));
+ new base::FundamentalValue(enabled));
} else {
pref_service_.SetBoolean(prefs::kDataReductionProxyEnabled, enabled);
}
enabled_at_startup ? 1 : 0);
scoped_ptr<DataReductionProxyConfigurator> configurator(
new TestDataReductionProxyConfig());
- settings_->SetProxyConfigurator(configurator.Pass());
+ settings_->SetProxyConfigurator(configurator.get());
scoped_refptr<net::TestURLRequestContextGetter> request_context =
new net::TestURLRequestContextGetter(base::MessageLoopProxy::current());
- settings_->InitDataReductionProxySettings(&pref_service_,
- &pref_service_,
- request_context.get());
+
+ settings_->InitDataReductionProxySettings(
+ &pref_service_,
+ &pref_service_,
+ request_context.get());
+ settings_->SetOnDataReductionEnabledCallback(
+ base::Bind(&DataReductionProxySettingsTestBase::
+ RegisterSyntheticFieldTrialCallback,
+ base::Unretained(this)));
base::MessageLoop::current()->RunUntilIdle();
CheckProxyConfigs(enabled_at_startup, false, false);
+ EXPECT_EQ(enabled_at_startup, proxy_enabled_);
}
} // namespace data_reduction_proxy