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

Side by Side Diff: chrome/browser/configuration_policy_pref_store_unittest.cc

Issue 3069014: Convert a bunch of easy AppendSwitchWithValue to *ASCII. (Closed)
Patch Set: fix Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <gtest/gtest.h> 5 #include <gtest/gtest.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 "chrome/browser/configuration_policy_pref_store.h" 9 #include "chrome/browser/configuration_policy_pref_store.h"
10 #include "chrome/browser/mock_configuration_policy_provider.h" 10 #include "chrome/browser/mock_configuration_policy_provider.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 TEST_F(ConfigurationPolicyPrefStoreTest, TestSettingProxyBypassList) { 190 TEST_F(ConfigurationPolicyPrefStoreTest, TestSettingProxyBypassList) {
191 TestStringPolicy(prefs::kProxyBypassList, 191 TestStringPolicy(prefs::kProxyBypassList,
192 ConfigurationPolicyPrefStore::kPolicyProxyBypassList); 192 ConfigurationPolicyPrefStore::kPolicyProxyBypassList);
193 } 193 }
194 194
195 TEST_F(ConfigurationPolicyPrefStoreTest, TestSettingsProxyConfig) { 195 TEST_F(ConfigurationPolicyPrefStoreTest, TestSettingsProxyConfig) {
196 FilePath unused_path(FILE_PATH_LITERAL("foo.exe")); 196 FilePath unused_path(FILE_PATH_LITERAL("foo.exe"));
197 CommandLine command_line(unused_path); 197 CommandLine command_line(unused_path);
198 command_line.AppendSwitch(switches::kNoProxyServer); 198 command_line.AppendSwitch(switches::kNoProxyServer);
199 command_line.AppendSwitch(switches::kProxyAutoDetect); 199 command_line.AppendSwitch(switches::kProxyAutoDetect);
200 command_line.AppendSwitchWithValue(switches::kProxyPacUrl, 200 command_line.AppendSwitchASCII(switches::kProxyPacUrl,
201 "http://chromium.org/test.pac"); 201 "http://chromium.org/test.pac");
202 command_line.AppendSwitchWithValue(switches::kProxyServer, 202 command_line.AppendSwitchASCII(switches::kProxyServer,
203 "http://chromium2.org"); 203 "http://chromium2.org");
204 command_line.AppendSwitchWithValue(switches::kProxyBypassList, 204 command_line.AppendSwitchASCII(switches::kProxyBypassList,
205 "http://chromium3.org"); 205 "http://chromium3.org");
206 206
207 ConfigurationPolicyPrefStore store(&command_line, NULL); 207 ConfigurationPolicyPrefStore store(&command_line, NULL);
208 EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE); 208 EXPECT_EQ(store.ReadPrefs(), PrefStore::PREF_READ_ERROR_NONE);
209 209
210 // Ensure that all traces of the command-line specified proxy 210 // Ensure that all traces of the command-line specified proxy
211 // switches have been overriden. 211 // switches have been overriden.
212 std::wstring string_result; 212 std::wstring string_result;
213 EXPECT_TRUE(store.prefs()->GetString(prefs::kProxyBypassList, 213 EXPECT_TRUE(store.prefs()->GetString(prefs::kProxyBypassList,
214 &string_result)); 214 &string_result));
215 EXPECT_EQ(string_result, L"http://chromium3.org"); 215 EXPECT_EQ(string_result, L"http://chromium3.org");
216 216
217 EXPECT_TRUE(store.prefs()->GetString(prefs::kProxyPacUrl, &string_result)); 217 EXPECT_TRUE(store.prefs()->GetString(prefs::kProxyPacUrl, &string_result));
218 EXPECT_EQ(string_result, L"http://chromium.org/test.pac"); 218 EXPECT_EQ(string_result, L"http://chromium.org/test.pac");
219 EXPECT_TRUE(store.prefs()->GetString(prefs::kProxyServer, &string_result)); 219 EXPECT_TRUE(store.prefs()->GetString(prefs::kProxyServer, &string_result));
220 EXPECT_EQ(string_result, L"http://chromium2.org"); 220 EXPECT_EQ(string_result, L"http://chromium2.org");
221 bool bool_result; 221 bool bool_result;
222 EXPECT_TRUE(store.prefs()->GetBoolean(prefs::kNoProxyServer, &bool_result)); 222 EXPECT_TRUE(store.prefs()->GetBoolean(prefs::kNoProxyServer, &bool_result));
223 EXPECT_TRUE(bool_result); 223 EXPECT_TRUE(bool_result);
224 EXPECT_TRUE(store.prefs()->GetBoolean(prefs::kProxyAutoDetect, 224 EXPECT_TRUE(store.prefs()->GetBoolean(prefs::kProxyAutoDetect,
225 &bool_result)); 225 &bool_result));
226 EXPECT_TRUE(bool_result); 226 EXPECT_TRUE(bool_result);
227 } 227 }
228 228
229 TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyProxyConfigManualOverride) { 229 TEST_F(ConfigurationPolicyPrefStoreTest, TestPolicyProxyConfigManualOverride) {
230 FilePath unused_path(FILE_PATH_LITERAL("foo.exe")); 230 FilePath unused_path(FILE_PATH_LITERAL("foo.exe"));
231 CommandLine command_line(unused_path); 231 CommandLine command_line(unused_path);
232 command_line.AppendSwitch(switches::kNoProxyServer); 232 command_line.AppendSwitch(switches::kNoProxyServer);
233 command_line.AppendSwitch(switches::kProxyAutoDetect); 233 command_line.AppendSwitch(switches::kProxyAutoDetect);
234 command_line.AppendSwitchWithValue(switches::kProxyPacUrl, 234 command_line.AppendSwitchASCII(switches::kProxyPacUrl,
235 "http://chromium.org/test.pac"); 235 "http://chromium.org/test.pac");
236 command_line.AppendSwitchWithValue(switches::kProxyServer, 236 command_line.AppendSwitchASCII(switches::kProxyServer,
237 "http://chromium.org"); 237 "http://chromium.org");
238 command_line.AppendSwitchWithValue(switches::kProxyBypassList, 238 command_line.AppendSwitchASCII(switches::kProxyBypassList,
239 "http://chromium.org"); 239 "http://chromium.org");
240 240
241 scoped_ptr<MockConfigurationPolicyProvider> provider( 241 scoped_ptr<MockConfigurationPolicyProvider> provider(
242 new MockConfigurationPolicyProvider()); 242 new MockConfigurationPolicyProvider());
243 provider->AddPolicy(ConfigurationPolicyStore::kPolicyProxyServerMode, 243 provider->AddPolicy(ConfigurationPolicyStore::kPolicyProxyServerMode,
244 Value::CreateIntegerValue( 244 Value::CreateIntegerValue(
245 ConfigurationPolicyStore::kPolicyManuallyConfiguredProxyMode)); 245 ConfigurationPolicyStore::kPolicyManuallyConfiguredProxyMode));
246 provider->AddPolicy(ConfigurationPolicyStore::kPolicyProxyBypassList, 246 provider->AddPolicy(ConfigurationPolicyStore::kPolicyProxyBypassList,
247 Value::CreateStringValue(L"http://chromium.org/override")); 247 Value::CreateStringValue(L"http://chromium.org/override"));
248 248
249 ConfigurationPolicyPrefStore store(&command_line, 249 ConfigurationPolicyPrefStore store(&command_line,
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 (*current)->GetAsString(&plugin_name); 461 (*current)->GetAsString(&plugin_name);
462 EXPECT_EQ("plugin1", plugin_name); 462 EXPECT_EQ("plugin1", plugin_name);
463 ++current; 463 ++current;
464 ASSERT_TRUE(current != end); 464 ASSERT_TRUE(current != end);
465 (*current)->GetAsString(&plugin_name); 465 (*current)->GetAsString(&plugin_name);
466 EXPECT_EQ("plugin2,", plugin_name); 466 EXPECT_EQ("plugin2,", plugin_name);
467 ++current; 467 ++current;
468 EXPECT_TRUE(current == end); 468 EXPECT_TRUE(current == end);
469 } 469 }
470 470
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698