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" |
11 #include "chrome/browser/prefs/pref_registry_simple.h" | |
11 #include "chrome/browser/prefs/pref_service_mock_builder.h" | 12 #include "chrome/browser/prefs/pref_service_mock_builder.h" |
12 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 13 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
15 #include "chrome/test/base/testing_pref_service.h" | 16 #include "chrome/test/base/testing_pref_service.h" |
16 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread.h" |
17 #include "net/proxy/proxy_config_service_common_unittest.h" | 18 #include "net/proxy/proxy_config_service_common_unittest.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 | 21 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 net::ProxyConfigService::ConfigAvailability)); | 71 net::ProxyConfigService::ConfigAvailability)); |
71 }; | 72 }; |
72 | 73 |
73 template<typename TESTBASE> | 74 template<typename TESTBASE> |
74 class PrefProxyConfigTrackerImplTestBase : public TESTBASE { | 75 class PrefProxyConfigTrackerImplTestBase : public TESTBASE { |
75 protected: | 76 protected: |
76 PrefProxyConfigTrackerImplTestBase() | 77 PrefProxyConfigTrackerImplTestBase() |
77 : ui_thread_(BrowserThread::UI, &loop_), | 78 : ui_thread_(BrowserThread::UI, &loop_), |
78 io_thread_(BrowserThread::IO, &loop_) {} | 79 io_thread_(BrowserThread::IO, &loop_) {} |
79 | 80 |
80 virtual void Init(PrefServiceSimple* pref_service) { | 81 virtual void Init(PrefService* pref_service) { |
Mattias Nissler (ping if slow)
2013/01/31 13:06:25
Just change the parameter type to TestingPrefServi
Jói
2013/01/31 13:43:42
Done.
| |
81 ASSERT_TRUE(pref_service); | 82 ASSERT_TRUE(pref_service); |
82 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_service); | 83 PrefRegistrySimple* registry = static_cast<PrefRegistrySimple*>( |
84 pref_service->DeprecatedGetPrefRegistry()); | |
85 PrefProxyConfigTrackerImpl::RegisterPrefs(registry); | |
83 fixed_config_.set_pac_url(GURL(kFixedPacUrl)); | 86 fixed_config_.set_pac_url(GURL(kFixedPacUrl)); |
84 delegate_service_ = | 87 delegate_service_ = |
85 new TestProxyConfigService(fixed_config_, | 88 new TestProxyConfigService(fixed_config_, |
86 net::ProxyConfigService::CONFIG_VALID); | 89 net::ProxyConfigService::CONFIG_VALID); |
87 proxy_config_service_.reset( | 90 proxy_config_service_.reset( |
88 new ChromeProxyConfigService(delegate_service_)); | 91 new ChromeProxyConfigService(delegate_service_)); |
89 proxy_config_tracker_.reset(new PrefProxyConfigTrackerImpl(pref_service)); | 92 proxy_config_tracker_.reset(new PrefProxyConfigTrackerImpl(pref_service)); |
90 proxy_config_tracker_->SetChromeProxyConfigService( | 93 proxy_config_tracker_->SetChromeProxyConfigService( |
91 proxy_config_service_.get()); | 94 proxy_config_service_.get()); |
92 // SetChromeProxyConfigService triggers update of initial prefs proxy | 95 // SetChromeProxyConfigService triggers update of initial prefs proxy |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 for (size_t i = 0; i < arraysize(GetParam().switches); i++) { | 336 for (size_t i = 0; i < arraysize(GetParam().switches); i++) { |
334 const char* name = GetParam().switches[i].name; | 337 const char* name = GetParam().switches[i].name; |
335 const char* value = GetParam().switches[i].value; | 338 const char* value = GetParam().switches[i].value; |
336 if (name && value) | 339 if (name && value) |
337 command_line_.AppendSwitchASCII(name, value); | 340 command_line_.AppendSwitchASCII(name, value); |
338 else if (name) | 341 else if (name) |
339 command_line_.AppendSwitch(name); | 342 command_line_.AppendSwitch(name); |
340 } | 343 } |
341 pref_service_.reset( | 344 pref_service_.reset( |
342 PrefServiceMockBuilder().WithCommandLine( | 345 PrefServiceMockBuilder().WithCommandLine( |
343 &command_line_).CreateSimple()); | 346 &command_line_).Create(new PrefRegistrySimple)); |
344 Init(pref_service_.get()); | 347 Init(pref_service_.get()); |
345 } | 348 } |
346 | 349 |
347 private: | 350 private: |
348 CommandLine command_line_; | 351 CommandLine command_line_; |
349 scoped_ptr<PrefServiceSimple> pref_service_; | 352 scoped_ptr<PrefService> pref_service_; |
350 }; | 353 }; |
351 | 354 |
352 TEST_P(PrefProxyConfigTrackerImplCommandLineTest, CommandLine) { | 355 TEST_P(PrefProxyConfigTrackerImplCommandLineTest, CommandLine) { |
353 net::ProxyConfig config; | 356 net::ProxyConfig config; |
354 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, | 357 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, |
355 proxy_config_service_->GetLatestProxyConfig(&config)); | 358 proxy_config_service_->GetLatestProxyConfig(&config)); |
356 | 359 |
357 if (GetParam().is_null) { | 360 if (GetParam().is_null) { |
358 EXPECT_EQ(GURL(kFixedPacUrl), config.pac_url()); | 361 EXPECT_EQ(GURL(kFixedPacUrl), config.pac_url()); |
359 } else { | 362 } else { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
473 net::ProxyRulesExpectation::Empty(), | 476 net::ProxyRulesExpectation::Empty(), |
474 }, | 477 }, |
475 }; | 478 }; |
476 | 479 |
477 INSTANTIATE_TEST_CASE_P( | 480 INSTANTIATE_TEST_CASE_P( |
478 PrefProxyConfigTrackerImplCommandLineTestInstance, | 481 PrefProxyConfigTrackerImplCommandLineTestInstance, |
479 PrefProxyConfigTrackerImplCommandLineTest, | 482 PrefProxyConfigTrackerImplCommandLineTest, |
480 testing::ValuesIn(kCommandLineTestParams)); | 483 testing::ValuesIn(kCommandLineTestParams)); |
481 | 484 |
482 } // namespace | 485 } // namespace |
OLD | NEW |