Index: chrome/browser/net/pref_proxy_config_tracker_unittest.cc |
=================================================================== |
--- chrome/browser/net/pref_proxy_config_tracker_unittest.cc (revision 104725) |
+++ chrome/browser/net/pref_proxy_config_tracker_unittest.cc (working copy) |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/net/pref_proxy_config_service.h" |
+#include "chrome/browser/net/pref_proxy_config_tracker.h" |
#include "base/command_line.h" |
#include "base/file_path.h" |
@@ -70,44 +70,50 @@ |
}; |
template<typename TESTBASE> |
-class PrefProxyConfigServiceTestBase : public TESTBASE { |
+class PrefProxyConfigTrackerTestBase : public TESTBASE { |
protected: |
- PrefProxyConfigServiceTestBase() |
+ PrefProxyConfigTrackerTestBase() |
: ui_thread_(BrowserThread::UI, &loop_), |
io_thread_(BrowserThread::IO, &loop_) {} |
virtual void Init(PrefService* pref_service) { |
ASSERT_TRUE(pref_service); |
- PrefProxyConfigService::RegisterPrefs(pref_service); |
+ PrefProxyConfigTracker::RegisterPrefs(pref_service); |
fixed_config_.set_pac_url(GURL(kFixedPacUrl)); |
delegate_service_ = |
new TestProxyConfigService(fixed_config_, |
net::ProxyConfigService::CONFIG_VALID); |
- proxy_config_tracker_ = new PrefProxyConfigTracker(pref_service); |
proxy_config_service_.reset( |
- new PrefProxyConfigService(proxy_config_tracker_.get(), |
- delegate_service_)); |
+ new ChromeProxyConfigService(delegate_service_)); |
+ proxy_config_tracker_.reset(new PrefProxyConfigTracker(pref_service)); |
+ proxy_config_tracker_->SetChromeProxyConfigService( |
+ proxy_config_service_.get()); |
+ // SetChromeProxyConfigService triggers update of initial prefs proxy |
+ // config by tracker to chrome proxy config service, so flush all pending |
+ // tasks so that tests start fresh. |
+ loop_.RunAllPending(); |
} |
virtual void TearDown() { |
proxy_config_tracker_->DetachFromPrefService(); |
loop_.RunAllPending(); |
+ proxy_config_tracker_.reset(); |
proxy_config_service_.reset(); |
} |
MessageLoop loop_; |
TestProxyConfigService* delegate_service_; // weak |
- scoped_ptr<PrefProxyConfigService> proxy_config_service_; |
+ scoped_ptr<ChromeProxyConfigService> proxy_config_service_; |
net::ProxyConfig fixed_config_; |
private: |
- scoped_refptr<PrefProxyConfigTracker> proxy_config_tracker_; |
+ scoped_ptr<PrefProxyConfigTracker> proxy_config_tracker_; |
BrowserThread ui_thread_; |
BrowserThread io_thread_; |
}; |
-class PrefProxyConfigServiceTest |
- : public PrefProxyConfigServiceTestBase<testing::Test> { |
+class PrefProxyConfigTrackerTest |
+ : public PrefProxyConfigTrackerTestBase<testing::Test> { |
protected: |
virtual void SetUp() { |
pref_service_.reset(new TestingPrefService()); |
@@ -117,14 +123,14 @@ |
scoped_ptr<TestingPrefService> pref_service_; |
}; |
-TEST_F(PrefProxyConfigServiceTest, BaseConfiguration) { |
+TEST_F(PrefProxyConfigTrackerTest, BaseConfiguration) { |
net::ProxyConfig actual_config; |
EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, |
proxy_config_service_->GetLatestProxyConfig(&actual_config)); |
EXPECT_EQ(GURL(kFixedPacUrl), actual_config.pac_url()); |
} |
-TEST_F(PrefProxyConfigServiceTest, DynamicPrefOverrides) { |
+TEST_F(PrefProxyConfigTrackerTest, DynamicPrefOverrides) { |
pref_service_->SetManagedPref( |
prefs::kProxy, |
ProxyConfigDictionary::CreateFixedServers("http://example.com:3128", "")); |
@@ -156,7 +162,7 @@ |
return reference.Equals(arg); |
} |
-TEST_F(PrefProxyConfigServiceTest, Observers) { |
+TEST_F(PrefProxyConfigTrackerTest, Observers) { |
const net::ProxyConfigService::ConfigAvailability CONFIG_VALID = |
net::ProxyConfigService::CONFIG_VALID; |
MockObserver observer; |
@@ -211,7 +217,7 @@ |
proxy_config_service_->RemoveObserver(&observer); |
} |
-TEST_F(PrefProxyConfigServiceTest, Fallback) { |
+TEST_F(PrefProxyConfigTrackerTest, Fallback) { |
const net::ProxyConfigService::ConfigAvailability CONFIG_VALID = |
net::ProxyConfigService::CONFIG_VALID; |
MockObserver observer; |
@@ -265,7 +271,7 @@ |
proxy_config_service_->RemoveObserver(&observer); |
} |
-TEST_F(PrefProxyConfigServiceTest, ExplicitSystemSettings) { |
+TEST_F(PrefProxyConfigTrackerTest, ExplicitSystemSettings) { |
pref_service_->SetRecommendedPref( |
prefs::kProxy, |
ProxyConfigDictionary::CreateAutoDetect()); |
@@ -315,11 +321,11 @@ |
*os << params.description; |
} |
-class PrefProxyConfigServiceCommandLineTest |
- : public PrefProxyConfigServiceTestBase< |
+class PrefProxyConfigTrackerCommandLineTest |
+ : public PrefProxyConfigTrackerTestBase< |
testing::TestWithParam<CommandLineTestParams> > { |
protected: |
- PrefProxyConfigServiceCommandLineTest() |
+ PrefProxyConfigTrackerCommandLineTest() |
: command_line_(CommandLine::NO_PROGRAM) {} |
virtual void SetUp() { |
@@ -341,7 +347,7 @@ |
scoped_ptr<PrefService> pref_service_; |
}; |
-TEST_P(PrefProxyConfigServiceCommandLineTest, CommandLine) { |
+TEST_P(PrefProxyConfigTrackerCommandLineTest, CommandLine) { |
net::ProxyConfig config; |
EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, |
proxy_config_service_->GetLatestProxyConfig(&config)); |
@@ -467,8 +473,8 @@ |
}; |
INSTANTIATE_TEST_CASE_P( |
- PrefProxyConfigServiceCommandLineTestInstance, |
- PrefProxyConfigServiceCommandLineTest, |
+ PrefProxyConfigTrackerCommandLineTestInstance, |
+ PrefProxyConfigTrackerCommandLineTest, |
testing::ValuesIn(kCommandLineTestParams)); |
} // namespace |