OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h" | 5 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/net/chrome_url_request_context.h" | 10 #include "chrome/browser/net/chrome_url_request_context.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 net::ProxyConfigService::ConfigAvailability)); | 70 net::ProxyConfigService::ConfigAvailability)); |
71 }; | 71 }; |
72 | 72 |
73 template<typename TESTBASE> | 73 template<typename TESTBASE> |
74 class PrefProxyConfigTrackerImplTestBase : public TESTBASE { | 74 class PrefProxyConfigTrackerImplTestBase : public TESTBASE { |
75 protected: | 75 protected: |
76 PrefProxyConfigTrackerImplTestBase() | 76 PrefProxyConfigTrackerImplTestBase() |
77 : ui_thread_(BrowserThread::UI, &loop_), | 77 : ui_thread_(BrowserThread::UI, &loop_), |
78 io_thread_(BrowserThread::IO, &loop_) {} | 78 io_thread_(BrowserThread::IO, &loop_) {} |
79 | 79 |
80 virtual void Init(PrefService* pref_service) { | 80 virtual void Init(PrefServiceSimple* pref_service) { |
81 ASSERT_TRUE(pref_service); | 81 ASSERT_TRUE(pref_service); |
82 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_service); | 82 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_service); |
83 fixed_config_.set_pac_url(GURL(kFixedPacUrl)); | 83 fixed_config_.set_pac_url(GURL(kFixedPacUrl)); |
84 delegate_service_ = | 84 delegate_service_ = |
85 new TestProxyConfigService(fixed_config_, | 85 new TestProxyConfigService(fixed_config_, |
86 net::ProxyConfigService::CONFIG_VALID); | 86 net::ProxyConfigService::CONFIG_VALID); |
87 proxy_config_service_.reset( | 87 proxy_config_service_.reset( |
88 new ChromeProxyConfigService(delegate_service_, true)); | 88 new ChromeProxyConfigService(delegate_service_, true)); |
89 proxy_config_tracker_.reset(new PrefProxyConfigTrackerImpl(pref_service)); | 89 proxy_config_tracker_.reset(new PrefProxyConfigTrackerImpl(pref_service)); |
90 proxy_config_tracker_->SetChromeProxyConfigService( | 90 proxy_config_tracker_->SetChromeProxyConfigService( |
(...skipping 19 matching lines...) Expand all Loading... |
110 private: | 110 private: |
111 scoped_ptr<PrefProxyConfigTrackerImpl> proxy_config_tracker_; | 111 scoped_ptr<PrefProxyConfigTrackerImpl> proxy_config_tracker_; |
112 content::TestBrowserThread ui_thread_; | 112 content::TestBrowserThread ui_thread_; |
113 content::TestBrowserThread io_thread_; | 113 content::TestBrowserThread io_thread_; |
114 }; | 114 }; |
115 | 115 |
116 class PrefProxyConfigTrackerImplTest | 116 class PrefProxyConfigTrackerImplTest |
117 : public PrefProxyConfigTrackerImplTestBase<testing::Test> { | 117 : public PrefProxyConfigTrackerImplTestBase<testing::Test> { |
118 protected: | 118 protected: |
119 virtual void SetUp() { | 119 virtual void SetUp() { |
120 pref_service_.reset(new TestingPrefService()); | 120 pref_service_.reset(new TestingPrefServiceSimple()); |
121 Init(pref_service_.get()); | 121 Init(pref_service_.get()); |
122 } | 122 } |
123 | 123 |
124 scoped_ptr<TestingPrefService> pref_service_; | 124 scoped_ptr<TestingPrefServiceSimple> pref_service_; |
125 }; | 125 }; |
126 | 126 |
127 TEST_F(PrefProxyConfigTrackerImplTest, BaseConfiguration) { | 127 TEST_F(PrefProxyConfigTrackerImplTest, BaseConfiguration) { |
128 net::ProxyConfig actual_config; | 128 net::ProxyConfig actual_config; |
129 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, | 129 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, |
130 proxy_config_service_->GetLatestProxyConfig(&actual_config)); | 130 proxy_config_service_->GetLatestProxyConfig(&actual_config)); |
131 EXPECT_EQ(GURL(kFixedPacUrl), actual_config.pac_url()); | 131 EXPECT_EQ(GURL(kFixedPacUrl), actual_config.pac_url()); |
132 } | 132 } |
133 | 133 |
134 TEST_F(PrefProxyConfigTrackerImplTest, DynamicPrefOverrides) { | 134 TEST_F(PrefProxyConfigTrackerImplTest, DynamicPrefOverrides) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 virtual void SetUp() { | 332 virtual void SetUp() { |
333 for (size_t i = 0; i < arraysize(GetParam().switches); i++) { | 333 for (size_t i = 0; i < arraysize(GetParam().switches); i++) { |
334 const char* name = GetParam().switches[i].name; | 334 const char* name = GetParam().switches[i].name; |
335 const char* value = GetParam().switches[i].value; | 335 const char* value = GetParam().switches[i].value; |
336 if (name && value) | 336 if (name && value) |
337 command_line_.AppendSwitchASCII(name, value); | 337 command_line_.AppendSwitchASCII(name, value); |
338 else if (name) | 338 else if (name) |
339 command_line_.AppendSwitch(name); | 339 command_line_.AppendSwitch(name); |
340 } | 340 } |
341 pref_service_.reset( | 341 pref_service_.reset( |
342 PrefServiceMockBuilder().WithCommandLine(&command_line_).Create()); | 342 PrefServiceMockBuilder().WithCommandLine( |
| 343 &command_line_).CreateSimple()); |
343 Init(pref_service_.get()); | 344 Init(pref_service_.get()); |
344 } | 345 } |
345 | 346 |
346 private: | 347 private: |
347 CommandLine command_line_; | 348 CommandLine command_line_; |
348 scoped_ptr<PrefService> pref_service_; | 349 scoped_ptr<PrefServiceSimple> pref_service_; |
349 }; | 350 }; |
350 | 351 |
351 TEST_P(PrefProxyConfigTrackerImplCommandLineTest, CommandLine) { | 352 TEST_P(PrefProxyConfigTrackerImplCommandLineTest, CommandLine) { |
352 net::ProxyConfig config; | 353 net::ProxyConfig config; |
353 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, | 354 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, |
354 proxy_config_service_->GetLatestProxyConfig(&config)); | 355 proxy_config_service_->GetLatestProxyConfig(&config)); |
355 | 356 |
356 if (GetParam().is_null) { | 357 if (GetParam().is_null) { |
357 EXPECT_EQ(GURL(kFixedPacUrl), config.pac_url()); | 358 EXPECT_EQ(GURL(kFixedPacUrl), config.pac_url()); |
358 } else { | 359 } else { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 net::ProxyRulesExpectation::Empty(), | 473 net::ProxyRulesExpectation::Empty(), |
473 }, | 474 }, |
474 }; | 475 }; |
475 | 476 |
476 INSTANTIATE_TEST_CASE_P( | 477 INSTANTIATE_TEST_CASE_P( |
477 PrefProxyConfigTrackerImplCommandLineTestInstance, | 478 PrefProxyConfigTrackerImplCommandLineTestInstance, |
478 PrefProxyConfigTrackerImplCommandLineTest, | 479 PrefProxyConfigTrackerImplCommandLineTest, |
479 testing::ValuesIn(kCommandLineTestParams)); | 480 testing::ValuesIn(kCommandLineTestParams)); |
480 | 481 |
481 } // namespace | 482 } // namespace |
OLD | NEW |