diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-02 22:37:18 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-02 22:37:18 +0000 |
commit | 7dc52f27b89ea2ab8b82a127fc899efef70fc613 (patch) | |
tree | 7ff99224862492b729312a8847f432ea661d635e /net/proxy/proxy_list_unittest.cc | |
parent | c8bab10c787854885375ac3c4d98c0d8b51a94c9 (diff) | |
download | chromium_src-7dc52f27b89ea2ab8b82a127fc899efef70fc613.zip chromium_src-7dc52f27b89ea2ab8b82a127fc899efef70fc613.tar.gz chromium_src-7dc52f27b89ea2ab8b82a127fc899efef70fc613.tar.bz2 |
split up proxy_service into several files (one per class).
Review URL: http://codereview.chromium.org/28278
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_list_unittest.cc')
-rw-r--r-- | net/proxy/proxy_list_unittest.cc | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/net/proxy/proxy_list_unittest.cc b/net/proxy/proxy_list_unittest.cc new file mode 100644 index 0000000..c604d0a --- /dev/null +++ b/net/proxy/proxy_list_unittest.cc @@ -0,0 +1,73 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "net/proxy/proxy_list.h" +#include "testing/gtest/include/gtest/gtest.h" + +// Test parsing from a PAC string. +TEST(ProxyListTest, SetFromPacString) { + const struct { + const char* pac_input; + const char* pac_output; + } tests[] = { + // Valid inputs: + { "PROXY foopy:10", + "PROXY foopy:10", + }, + { " DIRECT", // leading space. + "DIRECT", + }, + { "PROXY foopy1 ; proxy foopy2;\t DIRECT", + "PROXY foopy1:80;PROXY foopy2:80;DIRECT", + }, + { "proxy foopy1 ; SOCKS foopy2", + "PROXY foopy1:80;SOCKS foopy2:1080", + }, + + // Invalid inputs (parts which aren't understood get + // silently discarded): + { "PROXY-foopy:10", + "DIRECT", + }, + { "PROXY", + "DIRECT", + }, + { "PROXY foopy1 ; JUNK ; JUNK ; SOCKS5 foopy2 ; ;", + "PROXY foopy1:80;SOCKS5 foopy2:1080", + }, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { + net::ProxyList list; + list.SetFromPacString(tests[i].pac_input); + EXPECT_EQ(tests[i].pac_output, list.ToPacString()); + } +} + +TEST(ProxyListTest, RemoveProxiesWithoutScheme) { + const struct { + const char* pac_input; + int filter; + const char* filtered_pac_output; + } tests[] = { + { "PROXY foopy:10 ; SOCKS5 foopy2 ; SOCKS foopy11 ; PROXY foopy3 ; DIRECT", + // Remove anything that isn't HTTP or DIRECT. + net::ProxyServer::SCHEME_DIRECT | net::ProxyServer::SCHEME_HTTP, + "PROXY foopy:10;PROXY foopy3:80;DIRECT", + }, + { "PROXY foopy:10 | SOCKS5 foopy2", + // Remove anything that isn't HTTP or SOCKS5. + net::ProxyServer::SCHEME_DIRECT | net::ProxyServer::SCHEME_SOCKS4, + "DIRECT", + }, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { + net::ProxyList list; + list.SetFromPacString(tests[i].pac_input); + list.RemoveProxiesWithoutScheme(tests[i].filter); + EXPECT_EQ(tests[i].filtered_pac_output, list.ToPacString()); + } +} + |