| OLD | NEW |
| 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 #ifndef NET_PROXY_PROXY_CONFIG_SERVICE_COMMON_UNITTEST_H_ | 5 #ifndef NET_PROXY_PROXY_CONFIG_SERVICE_COMMON_UNITTEST_H_ |
| 6 #define NET_PROXY_PROXY_CONFIG_SERVICE_COMMON_UNITTEST_H_ | 6 #define NET_PROXY_PROXY_CONFIG_SERVICE_COMMON_UNITTEST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "net/proxy/proxy_config.h" | 9 #include "net/proxy/proxy_config.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 // Helper functions to describe the expected value of a | 12 // Helper functions to describe the expected value of a |
| 13 // ProxyConfig::ProxyRules, and to check for a match. | 13 // ProxyConfig::ProxyRules, and to check for a match. |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 // This structure contains our expectations on what values the ProxyRules | 17 // This structure contains our expectations on what values the ProxyRules |
| 18 // should have. | 18 // should have. |
| 19 struct ProxyRulesExpectation { | 19 struct ProxyRulesExpectation { |
| 20 ProxyRulesExpectation(ProxyConfig::ProxyRules::Type type, | 20 ProxyRulesExpectation(ProxyConfig::ProxyRules::Type type, |
| 21 const char* single_proxy, | 21 const char* single_proxy, |
| 22 const char* proxy_for_http, | 22 const char* proxy_for_http, |
| 23 const char* proxy_for_https, | 23 const char* proxy_for_https, |
| 24 const char* proxy_for_ftp, | 24 const char* proxy_for_ftp, |
| 25 const char* socks_proxy, | 25 const char* fallback_proxy, |
| 26 const char* flattened_bypass_rules, | 26 const char* flattened_bypass_rules, |
| 27 bool reverse_bypass) | 27 bool reverse_bypass) |
| 28 : type(type), | 28 : type(type), |
| 29 single_proxy(single_proxy), | 29 single_proxy(single_proxy), |
| 30 proxy_for_http(proxy_for_http), | 30 proxy_for_http(proxy_for_http), |
| 31 proxy_for_https(proxy_for_https), | 31 proxy_for_https(proxy_for_https), |
| 32 proxy_for_ftp(proxy_for_ftp), | 32 proxy_for_ftp(proxy_for_ftp), |
| 33 socks_proxy(socks_proxy), | 33 fallback_proxy(fallback_proxy), |
| 34 flattened_bypass_rules(flattened_bypass_rules), | 34 flattened_bypass_rules(flattened_bypass_rules), |
| 35 reverse_bypass(reverse_bypass) { | 35 reverse_bypass(reverse_bypass) { |
| 36 } | 36 } |
| 37 | 37 |
| 38 | 38 |
| 39 // Call this within an EXPECT_TRUE(), to assert that |rules| matches | 39 // Call this within an EXPECT_TRUE(), to assert that |rules| matches |
| 40 // our expected values |*this|. | 40 // our expected values |*this|. |
| 41 ::testing::AssertionResult Matches( | 41 ::testing::AssertionResult Matches( |
| 42 const ProxyConfig::ProxyRules& rules) const; | 42 const ProxyConfig::ProxyRules& rules) const; |
| 43 | 43 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 59 static ProxyRulesExpectation PerScheme(const char* proxy_http, | 59 static ProxyRulesExpectation PerScheme(const char* proxy_http, |
| 60 const char* proxy_https, | 60 const char* proxy_https, |
| 61 const char* proxy_ftp, | 61 const char* proxy_ftp, |
| 62 const char* flattened_bypass_rules); | 62 const char* flattened_bypass_rules); |
| 63 | 63 |
| 64 // Same as above, but additionally with a SOCKS fallback. | 64 // Same as above, but additionally with a SOCKS fallback. |
| 65 static ProxyRulesExpectation PerSchemeWithSocks( | 65 static ProxyRulesExpectation PerSchemeWithSocks( |
| 66 const char* proxy_http, | 66 const char* proxy_http, |
| 67 const char* proxy_https, | 67 const char* proxy_https, |
| 68 const char* proxy_ftp, | 68 const char* proxy_ftp, |
| 69 const char* socks_proxy, | 69 const char* fallback_proxy, |
| 70 const char* flattened_bypass_rules); | 70 const char* flattened_bypass_rules); |
| 71 | 71 |
| 72 // Same as PerScheme, but with the bypass rules reversed | 72 // Same as PerScheme, but with the bypass rules reversed |
| 73 static ProxyRulesExpectation PerSchemeWithBypassReversed( | 73 static ProxyRulesExpectation PerSchemeWithBypassReversed( |
| 74 const char* proxy_http, | 74 const char* proxy_http, |
| 75 const char* proxy_https, | 75 const char* proxy_https, |
| 76 const char* proxy_ftp, | 76 const char* proxy_ftp, |
| 77 const char* flattened_bypass_rules); | 77 const char* flattened_bypass_rules); |
| 78 | 78 |
| 79 ProxyConfig::ProxyRules::Type type; | 79 ProxyConfig::ProxyRules::Type type; |
| 80 const char* single_proxy; | 80 const char* single_proxy; |
| 81 const char* proxy_for_http; | 81 const char* proxy_for_http; |
| 82 const char* proxy_for_https; | 82 const char* proxy_for_https; |
| 83 const char* proxy_for_ftp; | 83 const char* proxy_for_ftp; |
| 84 const char* socks_proxy; | 84 const char* fallback_proxy; |
| 85 const char* flattened_bypass_rules; | 85 const char* flattened_bypass_rules; |
| 86 bool reverse_bypass; | 86 bool reverse_bypass; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 } // namespace net | 89 } // namespace net |
| 90 | 90 |
| 91 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_COMMON_UNITTEST_H_ | 91 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_COMMON_UNITTEST_H_ |
| OLD | NEW |