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

Side by Side Diff: chrome/browser/extensions/api/proxy/proxy_api_helpers_unittest.cc

Issue 12315019: Change ProxyRules to handle ProxyLists rather than just single ProxyServer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 9 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) 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 // Unit tests for helper functions for the Chrome Extensions Proxy Settings API. 5 // Unit tests for helper functions for the Chrome Extensions Proxy Settings API.
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/api/proxy/proxy_api_constants.h" 9 #include "chrome/browser/extensions/api/proxy/proxy_api_constants.h"
10 #include "chrome/browser/extensions/api/proxy/proxy_api_helpers.h" 10 #include "chrome/browser/extensions/api/proxy/proxy_api_helpers.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 CreateTestProxyServerDict("http", "proxy3", 80)); 321 CreateTestProxyServerDict("http", "proxy3", 80));
322 expected->Set("fallbackProxy", 322 expected->Set("fallbackProxy",
323 CreateTestProxyServerDict("socks4", "proxy4", 80)); 323 CreateTestProxyServerDict("socks4", "proxy4", 80));
324 ListValue* bypass_list = new ListValue; 324 ListValue* bypass_list = new ListValue;
325 bypass_list->Append(Value::CreateStringValue("localhost")); 325 bypass_list->Append(Value::CreateStringValue("localhost"));
326 expected->Set(keys::kProxyConfigBypassList, bypass_list); 326 expected->Set(keys::kProxyConfigBypassList, bypass_list);
327 327
328 EXPECT_TRUE(Value::Equals(expected.get(), extension_pref.get())); 328 EXPECT_TRUE(Value::Equals(expected.get(), extension_pref.get()));
329 } 329 }
330 330
331 // Test multiple proxies per scheme -- expect that only the first is returned.
332 TEST(ExtensionProxyApiHelpers, CreateProxyRulesDictMultipleProxies) {
333 scoped_ptr<DictionaryValue> browser_pref(
334 ProxyConfigDictionary::CreateFixedServers(
335 "http=proxy1:80,default://;https=proxy2:80,proxy1:80;ftp=proxy3:80,"
336 "https://proxy5:443;socks=proxy4:80,proxy1:80",
337 "localhost"));
338 ProxyConfigDictionary config(browser_pref.get());
339 scoped_ptr<DictionaryValue> extension_pref(CreateProxyRulesDict(config));
340 ASSERT_TRUE(extension_pref.get());
341
342 scoped_ptr<DictionaryValue> expected(new DictionaryValue);
343 expected->Set("proxyForHttp",
344 CreateTestProxyServerDict("http", "proxy1", 80));
345 expected->Set("proxyForHttps",
346 CreateTestProxyServerDict("http", "proxy2", 80));
347 expected->Set("proxyForFtp",
348 CreateTestProxyServerDict("http", "proxy3", 80));
349 expected->Set("fallbackProxy",
350 CreateTestProxyServerDict("socks4", "proxy4", 80));
351 ListValue* bypass_list = new ListValue;
352 bypass_list->Append(Value::CreateStringValue("localhost"));
353 expected->Set(keys::kProxyConfigBypassList, bypass_list);
354
355 EXPECT_TRUE(Value::Equals(expected.get(), extension_pref.get()));
356 }
357
331 // Test if a PAC script URL is specified. 358 // Test if a PAC script URL is specified.
332 TEST(ExtensionProxyApiHelpers, CreatePacScriptDictWithUrl) { 359 TEST(ExtensionProxyApiHelpers, CreatePacScriptDictWithUrl) {
333 scoped_ptr<DictionaryValue> browser_pref( 360 scoped_ptr<DictionaryValue> browser_pref(
334 ProxyConfigDictionary::CreatePacScript(kSamplePacScriptUrl, false)); 361 ProxyConfigDictionary::CreatePacScript(kSamplePacScriptUrl, false));
335 ProxyConfigDictionary config(browser_pref.get()); 362 ProxyConfigDictionary config(browser_pref.get());
336 scoped_ptr<DictionaryValue> extension_pref(CreatePacScriptDict(config)); 363 scoped_ptr<DictionaryValue> extension_pref(CreatePacScriptDict(config));
337 ASSERT_TRUE(extension_pref.get()); 364 ASSERT_TRUE(extension_pref.get());
338 365
339 scoped_ptr<DictionaryValue> expected(new DictionaryValue); 366 scoped_ptr<DictionaryValue> expected(new DictionaryValue);
340 expected->SetString(keys::kProxyConfigPacScriptUrl, kSamplePacScriptUrl); 367 expected->SetString(keys::kProxyConfigPacScriptUrl, kSamplePacScriptUrl);
(...skipping 22 matching lines...) Expand all
363 expected.Append(Value::CreateStringValue("s1")); 390 expected.Append(Value::CreateStringValue("s1"));
364 expected.Append(Value::CreateStringValue("s2")); 391 expected.Append(Value::CreateStringValue("s2"));
365 expected.Append(Value::CreateStringValue("s3")); 392 expected.Append(Value::CreateStringValue("s3"));
366 393
367 scoped_ptr<ListValue> out(TokenizeToStringList("s1;s2;s3", ";")); 394 scoped_ptr<ListValue> out(TokenizeToStringList("s1;s2;s3", ";"));
368 EXPECT_TRUE(Value::Equals(&expected, out.get())); 395 EXPECT_TRUE(Value::Equals(&expected, out.get()));
369 } 396 }
370 397
371 } // namespace proxy_api_helpers 398 } // namespace proxy_api_helpers
372 } // namespace extensions 399 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/proxy/proxy_api_helpers.cc ('k') | chrome/browser/importer/firefox_proxy_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698