diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 00:20:48 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-24 00:20:48 +0000 |
commit | ed4ed0fa4e964e416cd3ac65df64bc238f65461c (patch) | |
tree | 83a492355815043301313a6cced9fb96a033c37f /net/proxy/proxy_config_service_common_unittest.h | |
parent | b07408332337cd6f10b31e87cbed0886e872fa93 (diff) | |
download | chromium_src-ed4ed0fa4e964e416cd3ac65df64bc238f65461c.zip chromium_src-ed4ed0fa4e964e416cd3ac65df64bc238f65461c.tar.gz chromium_src-ed4ed0fa4e964e416cd3ac65df64bc238f65461c.tar.bz2 |
ProxyConfig behaved like a struct, but was defined as a class.
Changed it to be a proper class with hidden implementation variables, setters etc.
Also seized this opportunity to move the bypass list from being a member of ProxyConfig, to being a member of ProxyRules. This is a more correct hiearchy, since the bypass rules only apply to the manual settings. Lastly, this makes it possible to have the manual rules evaluation be a method on ProxyRules, and shift some more code out of proxy_service.
Review URL: http://codereview.chromium.org/651070
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39818 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_config_service_common_unittest.h')
-rw-r--r-- | net/proxy/proxy_config_service_common_unittest.h | 88 |
1 files changed, 64 insertions, 24 deletions
diff --git a/net/proxy/proxy_config_service_common_unittest.h b/net/proxy/proxy_config_service_common_unittest.h index 66ddfa6..c6f14b7 100644 --- a/net/proxy/proxy_config_service_common_unittest.h +++ b/net/proxy/proxy_config_service_common_unittest.h @@ -9,36 +9,76 @@ #include <vector> #include "net/proxy/proxy_config.h" +#include "testing/gtest/include/gtest/gtest.h" -// A few small helper functions common to the win and linux unittests. +// Helper functions to describe the expected value of a +// ProxyConfig::ProxyRules, and to check for a match. namespace net { class ProxyBypassRules; -ProxyConfig::ProxyRules MakeProxyRules( - ProxyConfig::ProxyRules::Type type, - const char* single_proxy, - const char* proxy_for_http, - const char* proxy_for_https, - const char* proxy_for_ftp, - const char* socks_proxy); - -ProxyConfig::ProxyRules MakeSingleProxyRules(const char* single_proxy); - -ProxyConfig::ProxyRules MakeProxyPerSchemeRules( - const char* proxy_http, - const char* proxy_https, - const char* proxy_ftp); - -ProxyConfig::ProxyRules MakeProxyPerSchemeRules( - const char* proxy_http, - const char* proxy_https, - const char* proxy_ftp, - const char* socks_proxy); - -// Joins the proxy bypass list using "\n" to make it into a single string. -std::string FlattenProxyBypass(const ProxyBypassRules& bypass_rules); +// This structure contains our expectations on what values the ProxyRules +// should have. +struct ProxyRulesExpectation { + ProxyRulesExpectation(ProxyConfig::ProxyRules::Type type, + const char* single_proxy, + const char* proxy_for_http, + const char* proxy_for_https, + const char* proxy_for_ftp, + const char* socks_proxy, + const char* flattened_bypass_rules) + : type(type), + single_proxy(single_proxy), + proxy_for_http(proxy_for_http), + proxy_for_https(proxy_for_https), + proxy_for_ftp(proxy_for_ftp), + socks_proxy(socks_proxy), + flattened_bypass_rules(flattened_bypass_rules) { + } + + + // Call this within an EXPECT_TRUE(), to assert that |rules| matches + // our expected values |*this|. + ::testing::AssertionResult Matches( + const ProxyConfig::ProxyRules& rules) const; + + // Creates an expectation that the ProxyRules has no rules. + static ProxyRulesExpectation Empty(); + + // Creates an expectation that the ProxyRules has nothing other than + // the specified bypass rules. + static ProxyRulesExpectation EmptyWithBypass( + const char* flattened_bypass_rules); + + // Creates an expectation that the ProxyRules is for a single proxy + // server for all schemes. + static ProxyRulesExpectation Single(const char* single_proxy, + const char* flattened_bypass_rules); + + // Creates an expectation that the ProxyRules specifies a different + // proxy server for each URL scheme. + static ProxyRulesExpectation PerScheme(const char* proxy_http, + const char* proxy_https, + const char* proxy_ftp, + const char* flattened_bypass_rules); + + // Same as above, but additionally with a SOCKS fallback. + static ProxyRulesExpectation PerSchemeWithSocks( + const char* proxy_http, + const char* proxy_https, + const char* proxy_ftp, + const char* socks_proxy, + const char* flattened_bypass_rules); + + ProxyConfig::ProxyRules::Type type; + const char* single_proxy; + const char* proxy_for_http; + const char* proxy_for_https; + const char* proxy_for_ftp; + const char* socks_proxy; + const char* flattened_bypass_rules; +}; } // namespace net |