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

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

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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) 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 7 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
8 #include "chrome/browser/policy/policy_map.h" 8 #include "chrome/browser/policy/policy_map.h"
9 #include "chrome/browser/policy/policy_service_impl.h" 9 #include "chrome/browser/policy/policy_service_impl.h"
10 #include "chrome/browser/prefs/browser_prefs.h" 10 #include "chrome/browser/prefs/browser_prefs.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 ASSERT_TRUE(dict.GetBypassList(&actual)); 61 ASSERT_TRUE(dict.GetBypassList(&actual));
62 EXPECT_EQ(expected, actual); 62 EXPECT_EQ(expected, actual);
63 } else { 63 } else {
64 EXPECT_FALSE(dict.GetBypassList(&actual)); 64 EXPECT_FALSE(dict.GetBypassList(&actual));
65 } 65 }
66 } 66 }
67 67
68 void assertProxyModeWithoutParams(const ProxyConfigDictionary& dict, 68 void assertProxyModeWithoutParams(const ProxyConfigDictionary& dict,
69 ProxyPrefs::ProxyMode proxy_mode) { 69 ProxyPrefs::ProxyMode proxy_mode) {
70 assertProxyMode(dict, proxy_mode); 70 assertProxyMode(dict, proxy_mode);
71 assertProxyServer(dict, ""); 71 assertProxyServer(dict, std::string());
72 assertPacUrl(dict, ""); 72 assertPacUrl(dict, std::string());
73 assertBypassList(dict, ""); 73 assertBypassList(dict, std::string());
74 } 74 }
75 75
76 } // namespace 76 } // namespace
77 77
78 class ProxyPolicyTest : public testing::Test { 78 class ProxyPolicyTest : public testing::Test {
79 protected: 79 protected:
80 ProxyPolicyTest() 80 ProxyPolicyTest()
81 : command_line_(CommandLine::NO_PROGRAM) {} 81 : command_line_(CommandLine::NO_PROGRAM) {}
82 82
83 virtual void SetUp() OVERRIDE { 83 virtual void SetUp() OVERRIDE {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 policy.Set(key::kProxyServer, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 123 policy.Set(key::kProxyServer, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
124 Value::CreateStringValue("ghi")); 124 Value::CreateStringValue("ghi"));
125 provider_.UpdateChromePolicy(policy); 125 provider_.UpdateChromePolicy(policy);
126 126
127 // First verify that command-line options are set correctly when 127 // First verify that command-line options are set correctly when
128 // there is no policy in effect. 128 // there is no policy in effect.
129 scoped_ptr<PrefService> prefs(CreatePrefService(false)); 129 scoped_ptr<PrefService> prefs(CreatePrefService(false));
130 ProxyConfigDictionary dict(prefs->GetDictionary(prefs::kProxy)); 130 ProxyConfigDictionary dict(prefs->GetDictionary(prefs::kProxy));
131 assertProxyMode(dict, ProxyPrefs::MODE_FIXED_SERVERS); 131 assertProxyMode(dict, ProxyPrefs::MODE_FIXED_SERVERS);
132 assertProxyServer(dict, "789"); 132 assertProxyServer(dict, "789");
133 assertPacUrl(dict, ""); 133 assertPacUrl(dict, std::string());
134 assertBypassList(dict, "123"); 134 assertBypassList(dict, "123");
135 135
136 // Try a second time time with the managed PrefStore in place, the 136 // Try a second time time with the managed PrefStore in place, the
137 // manual proxy policy should have removed all traces of the command 137 // manual proxy policy should have removed all traces of the command
138 // line and replaced them with the policy versions. 138 // line and replaced them with the policy versions.
139 prefs.reset(CreatePrefService(true)); 139 prefs.reset(CreatePrefService(true));
140 ProxyConfigDictionary dict2(prefs->GetDictionary(prefs::kProxy)); 140 ProxyConfigDictionary dict2(prefs->GetDictionary(prefs::kProxy));
141 assertProxyMode(dict2, ProxyPrefs::MODE_FIXED_SERVERS); 141 assertProxyMode(dict2, ProxyPrefs::MODE_FIXED_SERVERS);
142 assertProxyServer(dict2, "ghi"); 142 assertProxyServer(dict2, "ghi");
143 assertPacUrl(dict2, ""); 143 assertPacUrl(dict2, std::string());
144 assertBypassList(dict2, "abc"); 144 assertBypassList(dict2, "abc");
145 } 145 }
146 146
147 TEST_F(ProxyPolicyTest, OverridesUnrelatedCommandLineOptions) { 147 TEST_F(ProxyPolicyTest, OverridesUnrelatedCommandLineOptions) {
148 command_line_.AppendSwitchASCII(switches::kProxyBypassList, "123"); 148 command_line_.AppendSwitchASCII(switches::kProxyBypassList, "123");
149 command_line_.AppendSwitchASCII(switches::kProxyServer, "789"); 149 command_line_.AppendSwitchASCII(switches::kProxyServer, "789");
150 Value* mode_name = Value::CreateStringValue( 150 Value* mode_name = Value::CreateStringValue(
151 ProxyPrefs::kAutoDetectProxyModeName); 151 ProxyPrefs::kAutoDetectProxyModeName);
152 PolicyMap policy; 152 PolicyMap policy;
153 policy.Set(key::kProxyMode, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 153 policy.Set(key::kProxyMode, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
154 mode_name); 154 mode_name);
155 provider_.UpdateChromePolicy(policy); 155 provider_.UpdateChromePolicy(policy);
156 156
157 // First verify that command-line options are set correctly when 157 // First verify that command-line options are set correctly when
158 // there is no policy in effect. 158 // there is no policy in effect.
159 scoped_ptr<PrefService> prefs(CreatePrefService(false)); 159 scoped_ptr<PrefService> prefs(CreatePrefService(false));
160 ProxyConfigDictionary dict(prefs->GetDictionary(prefs::kProxy)); 160 ProxyConfigDictionary dict(prefs->GetDictionary(prefs::kProxy));
161 assertProxyMode(dict, ProxyPrefs::MODE_FIXED_SERVERS); 161 assertProxyMode(dict, ProxyPrefs::MODE_FIXED_SERVERS);
162 assertProxyServer(dict, "789"); 162 assertProxyServer(dict, "789");
163 assertPacUrl(dict, ""); 163 assertPacUrl(dict, std::string());
164 assertBypassList(dict, "123"); 164 assertBypassList(dict, "123");
165 165
166 // Try a second time time with the managed PrefStore in place, the 166 // Try a second time time with the managed PrefStore in place, the
167 // no proxy policy should have removed all traces of the command 167 // no proxy policy should have removed all traces of the command
168 // line proxy settings, even though they were not the specific one 168 // line proxy settings, even though they were not the specific one
169 // set in policy. 169 // set in policy.
170 prefs.reset(CreatePrefService(true)); 170 prefs.reset(CreatePrefService(true));
171 ProxyConfigDictionary dict2(prefs->GetDictionary(prefs::kProxy)); 171 ProxyConfigDictionary dict2(prefs->GetDictionary(prefs::kProxy));
172 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_AUTO_DETECT); 172 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_AUTO_DETECT);
173 } 173 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 // Try a second time time with the managed PrefStore in place, the 213 // Try a second time time with the managed PrefStore in place, the
214 // auto-detect should be overridden. The default pref store must be 214 // auto-detect should be overridden. The default pref store must be
215 // in place with the appropriate default value for this to work. 215 // in place with the appropriate default value for this to work.
216 prefs.reset(CreatePrefService(true)); 216 prefs.reset(CreatePrefService(true));
217 ProxyConfigDictionary dict2(prefs->GetDictionary(prefs::kProxy)); 217 ProxyConfigDictionary dict2(prefs->GetDictionary(prefs::kProxy));
218 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT); 218 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT);
219 } 219 }
220 220
221 } // namespace policy 221 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/prefs/proxy_config_dictionary.cc ('k') | chrome/browser/prefs/session_startup_pref.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698