Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Unified Diff: chrome/browser/net/pref_proxy_config_service_unittest.cc

Issue 6597070: Allow ProxyConfigService to report "no configuration set" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cosmetics. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/pref_proxy_config_service_unittest.cc
diff --git a/chrome/browser/net/pref_proxy_config_service_unittest.cc b/chrome/browser/net/pref_proxy_config_service_unittest.cc
index 75b6f82e09824025835b9319c59d6dcac0007b38..8299e2e9620a222e4fbfa204fd2f9589b4faed0b 100644
--- a/chrome/browser/net/pref_proxy_config_service_unittest.cc
+++ b/chrome/browser/net/pref_proxy_config_service_unittest.cc
@@ -33,7 +33,7 @@ class TestProxyConfigService : public net::ProxyConfigService {
void SetProxyConfig(const net::ProxyConfig config) {
config_ = config;
FOR_EACH_OBSERVER(net::ProxyConfigService::Observer, observers_,
- OnProxyConfigChanged(config_));
+ OnProxyConfigChanged(config, CONFIG_VALID));
}
private:
@@ -45,9 +45,10 @@ class TestProxyConfigService : public net::ProxyConfigService {
observers_.RemoveObserver(observer);
}
- virtual bool GetLatestProxyConfig(net::ProxyConfig* config) {
+ virtual net::ProxyConfigService::ConfigAvailability GetLatestProxyConfig(
+ net::ProxyConfig* config) {
*config = config_;
- return true;
+ return CONFIG_VALID;
}
net::ProxyConfig config_;
@@ -57,7 +58,9 @@ class TestProxyConfigService : public net::ProxyConfigService {
// A mock observer for capturing callbacks.
class MockObserver : public net::ProxyConfigService::Observer {
public:
- MOCK_METHOD1(OnProxyConfigChanged, void(const net::ProxyConfig&));
+ MOCK_METHOD2(OnProxyConfigChanged,
+ void(const net::ProxyConfig&,
+ net::ProxyConfigService::ConfigAvailability));
};
template<typename TESTBASE>
@@ -108,7 +111,8 @@ class PrefProxyConfigServiceTest
TEST_F(PrefProxyConfigServiceTest, BaseConfiguration) {
net::ProxyConfig actual_config;
- proxy_config_service_->GetLatestProxyConfig(&actual_config);
+ EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID,
+ proxy_config_service_->GetLatestProxyConfig(&actual_config));
EXPECT_EQ(GURL(kFixedPacUrl), actual_config.pac_url());
}
@@ -119,7 +123,8 @@ TEST_F(PrefProxyConfigServiceTest, DynamicPrefOverrides) {
loop_.RunAllPending();
net::ProxyConfig actual_config;
- proxy_config_service_->GetLatestProxyConfig(&actual_config);
+ EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID,
+ proxy_config_service_->GetLatestProxyConfig(&actual_config));
EXPECT_FALSE(actual_config.auto_detect());
EXPECT_EQ(net::ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY,
actual_config.proxy_rules().type);
@@ -131,7 +136,8 @@ TEST_F(PrefProxyConfigServiceTest, DynamicPrefOverrides) {
ProxyConfigDictionary::CreateAutoDetect());
loop_.RunAllPending();
- proxy_config_service_->GetLatestProxyConfig(&actual_config);
+ EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID,
+ proxy_config_service_->GetLatestProxyConfig(&actual_config));
EXPECT_TRUE(actual_config.auto_detect());
}
@@ -143,14 +149,16 @@ MATCHER_P(ProxyConfigMatches, config, "") {
}
TEST_F(PrefProxyConfigServiceTest, Observers) {
+ const net::ProxyConfigService::ConfigAvailability CONFIG_VALID =
+ net::ProxyConfigService::CONFIG_VALID;
MockObserver observer;
proxy_config_service_->AddObserver(&observer);
// Firing the observers in the delegate should trigger a notification.
net::ProxyConfig config2;
config2.set_auto_detect(true);
- EXPECT_CALL(observer,
- OnProxyConfigChanged(ProxyConfigMatches(config2))).Times(1);
+ EXPECT_CALL(observer, OnProxyConfigChanged(ProxyConfigMatches(config2),
+ CONFIG_VALID)).Times(1);
delegate_service_->SetProxyConfig(config2);
loop_.RunAllPending();
Mock::VerifyAndClearExpectations(&observer);
@@ -159,8 +167,8 @@ TEST_F(PrefProxyConfigServiceTest, Observers) {
net::ProxyConfig pref_config;
pref_config.set_pac_url(GURL(kFixedPacUrl));
- EXPECT_CALL(observer,
- OnProxyConfigChanged(ProxyConfigMatches(pref_config))).Times(1);
+ EXPECT_CALL(observer, OnProxyConfigChanged(ProxyConfigMatches(pref_config),
+ CONFIG_VALID)).Times(1);
pref_service_->SetManagedPref(
prefs::kProxy,
ProxyConfigDictionary::CreatePacScript(kFixedPacUrl));
@@ -170,15 +178,15 @@ TEST_F(PrefProxyConfigServiceTest, Observers) {
// Since there are pref overrides, delegate changes should be ignored.
net::ProxyConfig config3;
config3.proxy_rules().ParseFromString("http=config3:80");
- EXPECT_CALL(observer, OnProxyConfigChanged(_)).Times(0);
+ EXPECT_CALL(observer, OnProxyConfigChanged(_, _)).Times(0);
fixed_config_.set_auto_detect(true);
delegate_service_->SetProxyConfig(config3);
loop_.RunAllPending();
Mock::VerifyAndClearExpectations(&observer);
// Clear the override should switch back to the fixed configuration.
- EXPECT_CALL(observer,
- OnProxyConfigChanged(ProxyConfigMatches(config3))).Times(1);
+ EXPECT_CALL(observer, OnProxyConfigChanged(ProxyConfigMatches(config3),
+ CONFIG_VALID)).Times(1);
pref_service_->RemoveManagedPref(prefs::kProxy);
loop_.RunAllPending();
Mock::VerifyAndClearExpectations(&observer);
@@ -186,8 +194,8 @@ TEST_F(PrefProxyConfigServiceTest, Observers) {
// Delegate service notifications should show up again.
net::ProxyConfig config4;
config4.proxy_rules().ParseFromString("socks:config4");
- EXPECT_CALL(observer,
- OnProxyConfigChanged(ProxyConfigMatches(config4))).Times(1);
+ EXPECT_CALL(observer, OnProxyConfigChanged(ProxyConfigMatches(config4),
+ CONFIG_VALID)).Times(1);
delegate_service_->SetProxyConfig(config4);
loop_.RunAllPending();
Mock::VerifyAndClearExpectations(&observer);
@@ -257,7 +265,8 @@ class PrefProxyConfigServiceCommandLineTest
TEST_P(PrefProxyConfigServiceCommandLineTest, CommandLine) {
net::ProxyConfig config;
- proxy_config_service_->GetLatestProxyConfig(&config);
+ EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID,
+ proxy_config_service_->GetLatestProxyConfig(&config));
if (GetParam().is_null) {
EXPECT_EQ(GURL(kFixedPacUrl), config.pac_url());

Powered by Google App Engine
This is Rietveld 408576698