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

Side by Side Diff: chrome/browser/net/pref_proxy_config_tracker_impl_unittest.cc

Issue 11741003: Remove PrefServiceSimple, replacing it with PrefService and PrefRegistrySimple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Fix Clang build and fix bug shown by trybots. Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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(TestingPrefServiceSimple* pref_service) {
Jói 2013/01/31 16:23:37 Actually, this wasn't so simple because PrefProxyC
81 ASSERT_TRUE(pref_service); 82 ASSERT_TRUE(pref_service);
82 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_service); 83 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_service->registry());
83 fixed_config_.set_pac_url(GURL(kFixedPacUrl)); 84 fixed_config_.set_pac_url(GURL(kFixedPacUrl));
84 delegate_service_ = 85 delegate_service_ =
85 new TestProxyConfigService(fixed_config_, 86 new TestProxyConfigService(fixed_config_,
86 net::ProxyConfigService::CONFIG_VALID); 87 net::ProxyConfigService::CONFIG_VALID);
87 proxy_config_service_.reset( 88 proxy_config_service_.reset(
88 new ChromeProxyConfigService(delegate_service_)); 89 new ChromeProxyConfigService(delegate_service_));
89 proxy_config_tracker_.reset(new PrefProxyConfigTrackerImpl(pref_service)); 90 proxy_config_tracker_.reset(new PrefProxyConfigTrackerImpl(pref_service));
90 proxy_config_tracker_->SetChromeProxyConfigService( 91 proxy_config_tracker_->SetChromeProxyConfigService(
91 proxy_config_service_.get()); 92 proxy_config_service_.get());
92 // SetChromeProxyConfigService triggers update of initial prefs proxy 93 // SetChromeProxyConfigService triggers update of initial prefs proxy
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 for (size_t i = 0; i < arraysize(GetParam().switches); i++) { 334 for (size_t i = 0; i < arraysize(GetParam().switches); i++) {
334 const char* name = GetParam().switches[i].name; 335 const char* name = GetParam().switches[i].name;
335 const char* value = GetParam().switches[i].value; 336 const char* value = GetParam().switches[i].value;
336 if (name && value) 337 if (name && value)
337 command_line_.AppendSwitchASCII(name, value); 338 command_line_.AppendSwitchASCII(name, value);
338 else if (name) 339 else if (name)
339 command_line_.AppendSwitch(name); 340 command_line_.AppendSwitch(name);
340 } 341 }
341 pref_service_.reset( 342 pref_service_.reset(
342 PrefServiceMockBuilder().WithCommandLine( 343 PrefServiceMockBuilder().WithCommandLine(
343 &command_line_).CreateSimple()); 344 &command_line_).Create(new PrefRegistrySimple));
344 Init(pref_service_.get()); 345 Init(pref_service_.get());
345 } 346 }
346 347
347 private: 348 private:
348 CommandLine command_line_; 349 CommandLine command_line_;
349 scoped_ptr<PrefServiceSimple> pref_service_; 350 scoped_ptr<PrefService> pref_service_;
350 }; 351 };
351 352
352 TEST_P(PrefProxyConfigTrackerImplCommandLineTest, CommandLine) { 353 TEST_P(PrefProxyConfigTrackerImplCommandLineTest, CommandLine) {
353 net::ProxyConfig config; 354 net::ProxyConfig config;
354 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, 355 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID,
355 proxy_config_service_->GetLatestProxyConfig(&config)); 356 proxy_config_service_->GetLatestProxyConfig(&config));
356 357
357 if (GetParam().is_null) { 358 if (GetParam().is_null) {
358 EXPECT_EQ(GURL(kFixedPacUrl), config.pac_url()); 359 EXPECT_EQ(GURL(kFixedPacUrl), config.pac_url());
359 } else { 360 } else {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 net::ProxyRulesExpectation::Empty(), 474 net::ProxyRulesExpectation::Empty(),
474 }, 475 },
475 }; 476 };
476 477
477 INSTANTIATE_TEST_CASE_P( 478 INSTANTIATE_TEST_CASE_P(
478 PrefProxyConfigTrackerImplCommandLineTestInstance, 479 PrefProxyConfigTrackerImplCommandLineTestInstance,
479 PrefProxyConfigTrackerImplCommandLineTest, 480 PrefProxyConfigTrackerImplCommandLineTest,
480 testing::ValuesIn(kCommandLineTestParams)); 481 testing::ValuesIn(kCommandLineTestParams));
481 482
482 } // namespace 483 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698