proxy_config_service_common_unittest.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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
  3. // found in the LICENSE file.
  4. #ifndef NET_PROXY_RESOLUTION_PROXY_CONFIG_SERVICE_COMMON_UNITTEST_H_
  5. #define NET_PROXY_RESOLUTION_PROXY_CONFIG_SERVICE_COMMON_UNITTEST_H_
  6. #include "net/proxy_resolution/proxy_config.h"
  7. #include "testing/gtest/include/gtest/gtest.h"
  8. // Helper functions to describe the expected value of a
  9. // ProxyConfig::ProxyRules, and to check for a match.
  10. namespace net {
  11. // This structure contains our expectations on what values the ProxyRules
  12. // should have.
  13. struct ProxyRulesExpectation {
  14. ProxyRulesExpectation(ProxyConfig::ProxyRules::Type type,
  15. const char* single_proxy,
  16. const char* proxy_for_http,
  17. const char* proxy_for_https,
  18. const char* proxy_for_ftp,
  19. const char* fallback_proxy,
  20. const char* flattened_bypass_rules,
  21. bool reverse_bypass);
  22. // Call this within an EXPECT_TRUE(), to assert that |rules| matches
  23. // our expected values |*this|.
  24. ::testing::AssertionResult Matches(
  25. const ProxyConfig::ProxyRules& rules) const;
  26. // Creates an expectation that the ProxyRules has no rules.
  27. static ProxyRulesExpectation Empty();
  28. // Creates an expectation that the ProxyRules has nothing other than
  29. // the specified bypass rules.
  30. static ProxyRulesExpectation EmptyWithBypass(
  31. const char* flattened_bypass_rules);
  32. // Creates an expectation that the ProxyRules is for a single proxy
  33. // server for all schemes.
  34. static ProxyRulesExpectation Single(const char* single_proxy,
  35. const char* flattened_bypass_rules);
  36. // Creates an expectation that the ProxyRules specifies a different
  37. // proxy server for each URL scheme.
  38. static ProxyRulesExpectation PerScheme(const char* proxy_http,
  39. const char* proxy_https,
  40. const char* proxy_ftp,
  41. const char* flattened_bypass_rules);
  42. // Same as above, but additionally with a SOCKS fallback.
  43. static ProxyRulesExpectation PerSchemeWithSocks(
  44. const char* proxy_http,
  45. const char* proxy_https,
  46. const char* proxy_ftp,
  47. const char* fallback_proxy,
  48. const char* flattened_bypass_rules);
  49. // Same as PerScheme, but with the bypass rules reversed
  50. static ProxyRulesExpectation PerSchemeWithBypassReversed(
  51. const char* proxy_http,
  52. const char* proxy_https,
  53. const char* proxy_ftp,
  54. const char* flattened_bypass_rules);
  55. ProxyConfig::ProxyRules::Type type;
  56. const char* single_proxy;
  57. const char* proxy_for_http;
  58. const char* proxy_for_https;
  59. const char* proxy_for_ftp;
  60. const char* fallback_proxy;
  61. const char* flattened_bypass_rules;
  62. bool reverse_bypass;
  63. };
  64. } // namespace net
  65. #endif // NET_PROXY_RESOLUTION_PROXY_CONFIG_SERVICE_COMMON_UNITTEST_H_