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

Side by Side Diff: chrome/browser/prefs/proxy_policy_unittest.cc

Issue 816403003: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "chrome/browser/prefs/browser_prefs.h" 10 #include "chrome/browser/prefs/browser_prefs.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 assertProxyMode(dict, proxy_mode); 74 assertProxyMode(dict, proxy_mode);
75 assertProxyServer(dict, std::string()); 75 assertProxyServer(dict, std::string());
76 assertPacUrl(dict, std::string()); 76 assertPacUrl(dict, std::string());
77 assertBypassList(dict, std::string()); 77 assertBypassList(dict, std::string());
78 } 78 }
79 79
80 } // namespace 80 } // namespace
81 81
82 class ProxyPolicyTest : public testing::Test { 82 class ProxyPolicyTest : public testing::Test {
83 protected: 83 protected:
84 ProxyPolicyTest() 84 ProxyPolicyTest() : command_line_(base::CommandLine::NO_PROGRAM) {}
85 : command_line_(CommandLine::NO_PROGRAM) {}
86 85
87 void SetUp() override { 86 void SetUp() override {
88 EXPECT_CALL(provider_, IsInitializationComplete(_)) 87 EXPECT_CALL(provider_, IsInitializationComplete(_))
89 .WillRepeatedly(Return(true)); 88 .WillRepeatedly(Return(true));
90 89
91 PolicyServiceImpl::Providers providers; 90 PolicyServiceImpl::Providers providers;
92 providers.push_back(&provider_); 91 providers.push_back(&provider_);
93 policy_service_.reset(new PolicyServiceImpl(providers)); 92 policy_service_.reset(new PolicyServiceImpl(providers));
94 provider_.Init(); 93 provider_.Init();
95 } 94 }
96 95
97 void TearDown() override { provider_.Shutdown(); } 96 void TearDown() override { provider_.Shutdown(); }
98 97
99 scoped_ptr<PrefService> CreatePrefService(bool with_managed_policies) { 98 scoped_ptr<PrefService> CreatePrefService(bool with_managed_policies) {
100 PrefServiceMockFactory factory; 99 PrefServiceMockFactory factory;
101 factory.SetCommandLine(&command_line_); 100 factory.SetCommandLine(&command_line_);
102 if (with_managed_policies) 101 if (with_managed_policies)
103 factory.SetManagedPolicies(policy_service_.get()); 102 factory.SetManagedPolicies(policy_service_.get());
104 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( 103 scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
105 new user_prefs::PrefRegistrySyncable); 104 new user_prefs::PrefRegistrySyncable);
106 scoped_ptr<PrefServiceSyncable> prefs = 105 scoped_ptr<PrefServiceSyncable> prefs =
107 factory.CreateSyncable(registry.get()); 106 factory.CreateSyncable(registry.get());
108 chrome::RegisterUserProfilePrefs(registry.get()); 107 chrome::RegisterUserProfilePrefs(registry.get());
109 return prefs.Pass(); 108 return prefs.Pass();
110 } 109 }
111 110
112 base::MessageLoop loop_; 111 base::MessageLoop loop_;
113 CommandLine command_line_; 112 base::CommandLine command_line_;
114 MockConfigurationPolicyProvider provider_; 113 MockConfigurationPolicyProvider provider_;
115 scoped_ptr<PolicyServiceImpl> policy_service_; 114 scoped_ptr<PolicyServiceImpl> policy_service_;
116 }; 115 };
117 116
118 TEST_F(ProxyPolicyTest, OverridesCommandLineOptions) { 117 TEST_F(ProxyPolicyTest, OverridesCommandLineOptions) {
119 command_line_.AppendSwitchASCII(switches::kProxyBypassList, "123"); 118 command_line_.AppendSwitchASCII(switches::kProxyBypassList, "123");
120 command_line_.AppendSwitchASCII(switches::kProxyServer, "789"); 119 command_line_.AppendSwitchASCII(switches::kProxyServer, "789");
121 base::Value* mode_name = 120 base::Value* mode_name =
122 new base::StringValue(ProxyPrefs::kFixedServersProxyModeName); 121 new base::StringValue(ProxyPrefs::kFixedServersProxyModeName);
123 PolicyMap policy; 122 PolicyMap policy;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 222
224 // Try a second time time with the managed PrefStore in place, the 223 // Try a second time time with the managed PrefStore in place, the
225 // auto-detect should be overridden. The default pref store must be 224 // auto-detect should be overridden. The default pref store must be
226 // in place with the appropriate default value for this to work. 225 // in place with the appropriate default value for this to work.
227 prefs = CreatePrefService(true); 226 prefs = CreatePrefService(true);
228 ProxyConfigDictionary dict2(prefs->GetDictionary(prefs::kProxy)); 227 ProxyConfigDictionary dict2(prefs->GetDictionary(prefs::kProxy));
229 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT); 228 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT);
230 } 229 }
231 230
232 } // namespace policy 231 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_service_syncable_factory.cc ('k') | chrome/browser/prefs/tracked/pref_hash_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698