Chromium Code Reviews| 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 e7917b1f0133ca1c08e505fba6517d7b8335aa38..0f1784a3341ab13b2a11782dbe9301d607f7c743 100644 |
| --- a/chrome/browser/net/pref_proxy_config_service_unittest.cc |
| +++ b/chrome/browser/net/pref_proxy_config_service_unittest.cc |
| @@ -6,6 +6,8 @@ |
| #include "base/command_line.h" |
| #include "base/file_path.h" |
| +#include "chrome/browser/prefs/command_line_pref_store.h" |
| +#include "chrome/browser/prefs/testing_pref_store.h" |
| #include "chrome/browser/net/chrome_url_request_context.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/pref_names.h" |
| @@ -65,12 +67,12 @@ class PrefProxyConfigServiceTestBase : public TESTBASE { |
| : ui_thread_(BrowserThread::UI, &loop_), |
| io_thread_(BrowserThread::IO, &loop_) {} |
| - virtual void SetUp() { |
| - ASSERT_TRUE(pref_service_.get()); |
| - ChromeURLRequestContextGetter::RegisterUserPrefs(pref_service_.get()); |
| + virtual void Init(PrefService* pref_service) { |
| + ASSERT_TRUE(pref_service); |
| + ChromeURLRequestContextGetter::RegisterUserPrefs(pref_service); |
| fixed_config_.set_pac_url(GURL(kFixedPacUrl)); |
| delegate_service_ = new TestProxyConfigService(fixed_config_); |
| - proxy_config_tracker_ = new PrefProxyConfigTracker(pref_service_.get()); |
| + proxy_config_tracker_ = new PrefProxyConfigTracker(pref_service); |
| proxy_config_service_.reset( |
| new PrefProxyConfigService(proxy_config_tracker_.get(), |
| delegate_service_)); |
| @@ -80,12 +82,10 @@ class PrefProxyConfigServiceTestBase : public TESTBASE { |
| proxy_config_tracker_->DetachFromPrefService(); |
| loop_.RunAllPending(); |
| proxy_config_service_.reset(); |
| - pref_service_.reset(); |
| } |
| MessageLoop loop_; |
| TestProxyConfigService* delegate_service_; // weak |
| - scoped_ptr<TestingPrefService> pref_service_; |
| scoped_ptr<PrefProxyConfigService> proxy_config_service_; |
| net::ProxyConfig fixed_config_; |
| @@ -99,9 +99,11 @@ class PrefProxyConfigServiceTest |
| : public PrefProxyConfigServiceTestBase<testing::Test> { |
| protected: |
| virtual void SetUp() { |
| - pref_service_.reset(new TestingPrefService); |
| - PrefProxyConfigServiceTestBase<testing::Test>::SetUp(); |
| + pref_service_.reset(new TestingPrefService()); |
| + Init(pref_service_.get()); |
| } |
| + |
| + scoped_ptr<TestingPrefService> pref_service_; |
| }; |
| TEST_F(PrefProxyConfigServiceTest, BaseConfiguration) { |
| @@ -240,13 +242,25 @@ class PrefProxyConfigServiceCommandLineTest |
| else if (name) |
| command_line_.AppendSwitch(name); |
| } |
| - pref_service_.reset(new TestingPrefService(NULL, NULL, &command_line_)); |
| - PrefProxyConfigServiceTestBase< |
| - testing::TestWithParam<CommandLineTestParams> >::SetUp(); |
| + pref_service_.reset(new PrefServiceMock(&command_line_)); |
| + Init(pref_service_.get()); |
| } |
| private: |
| + class PrefServiceMock : public PrefService { |
|
danno
2010/12/08 13:08:45
Here it's called a PrefServiceMock, in test_extens
Mattias Nissler (ping if slow)
2010/12/09 10:20:20
Solution: Throw design patterns at it :) I introdu
|
| + public: |
| + explicit PrefServiceMock(const CommandLine* command_line) |
| + : PrefService(NULL, |
| + NULL, |
| + NULL, |
| + new CommandLinePrefStore(command_line), |
| + new TestingPrefStore(), |
| + NULL, |
| + NULL) {} |
| + }; |
| + |
| CommandLine command_line_; |
| + scoped_ptr<PrefServiceMock> pref_service_; |
| }; |
| TEST_P(PrefProxyConfigServiceCommandLineTest, CommandLine) { |