1 // Copyright 2014 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 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params_test_utils.h" 6 7 namespace { 8 // Test values to replace the values specified in preprocessor defines. 9 static const char kDefaultDevOrigin[] = "https://dev.net:443/"; 10 static const char kDefaultDevFallbackOrigin[] = "http://dev.net:80/"; 11 static const char kDefaultOrigin[] = "https://origin.net:443/"; 12 static const char kDefaultFallbackOrigin[] = "http://fallback.net:80/"; 13 static const char kDefaultSSLOrigin[] = "http://ssl.net:1080/"; 14 static const char kDefaultAltOrigin[] = "https://alt.net:443/"; 15 static const char kDefaultAltFallbackOrigin[] = "http://altfallback.net:80/"; 16 static const char kDefaultProbeURL[] = "http://probe.net/"; 17 18 static const char kFlagOrigin[] = "https://origin.org:443/"; 19 static const char kFlagFallbackOrigin[] = "http://fallback.org:80/"; 20 static const char kFlagSSLOrigin[] = "http://ssl.org:1080/"; 21 static const char kFlagAltOrigin[] = "https://alt.org:443/"; 22 static const char kFlagAltFallbackOrigin[] = "http://altfallback.org:80/"; 23 static const char kFlagProbeURL[] = "http://probe.org/"; 24 } 25 26 namespace data_reduction_proxy { 27 TestDataReductionProxyParams::TestDataReductionProxyParams( 28 int flags, unsigned int has_definitions) 29 : DataReductionProxyParams(flags, false), 30 has_definitions_(has_definitions) { 31 init_result_ = Init( 32 flags & DataReductionProxyParams::kAllowed, 33 flags & DataReductionProxyParams::kFallbackAllowed, 34 flags & DataReductionProxyParams::kAlternativeAllowed, 35 flags & DataReductionProxyParams::kAlternativeFallbackAllowed); 36 } 37 38 bool TestDataReductionProxyParams::init_result() const { 39 return init_result_; 40 } 41 42 // Test values to replace the values specified in preprocessor defines. 43 std::string TestDataReductionProxyParams::DefaultDevOrigin() { 44 return kDefaultDevOrigin; 45 } 46 47 std::string TestDataReductionProxyParams::DefaultDevFallbackOrigin() { 48 return kDefaultDevFallbackOrigin; 49 } 50 51 std::string TestDataReductionProxyParams::DefaultOrigin() { 52 return kDefaultOrigin; 53 } 54 55 std::string TestDataReductionProxyParams::DefaultFallbackOrigin() { 56 return kDefaultFallbackOrigin; 57 } 58 59 std::string TestDataReductionProxyParams::DefaultSSLOrigin() { 60 return kDefaultSSLOrigin; 61 } 62 63 std::string TestDataReductionProxyParams::DefaultAltOrigin() { 64 return kDefaultAltOrigin; 65 } 66 67 std::string TestDataReductionProxyParams::DefaultAltFallbackOrigin() { 68 return kDefaultAltFallbackOrigin; 69 } 70 71 std::string TestDataReductionProxyParams::DefaultProbeURL() { 72 return kDefaultProbeURL; 73 } 74 75 std::string TestDataReductionProxyParams::FlagOrigin() { 76 return kFlagOrigin; 77 } 78 79 std::string TestDataReductionProxyParams::FlagFallbackOrigin() { 80 return kFlagFallbackOrigin; 81 } 82 83 std::string TestDataReductionProxyParams::FlagSSLOrigin() { 84 return kFlagSSLOrigin; 85 } 86 87 std::string TestDataReductionProxyParams::FlagAltOrigin() { 88 return kFlagAltOrigin; 89 } 90 91 std::string TestDataReductionProxyParams::FlagAltFallbackOrigin() { 92 return kFlagAltFallbackOrigin; 93 } 94 95 std::string TestDataReductionProxyParams::FlagProbeURL() { 96 return kFlagProbeURL; 97 } 98 99 std::string TestDataReductionProxyParams::GetDefaultDevOrigin() const { 100 return GetDefinition( 101 TestDataReductionProxyParams::HAS_DEV_ORIGIN, kDefaultDevOrigin); 102 } 103 104 std::string TestDataReductionProxyParams::GetDefaultDevFallbackOrigin() const { 105 return GetDefinition( 106 TestDataReductionProxyParams::HAS_DEV_FALLBACK_ORIGIN, 107 kDefaultDevFallbackOrigin); 108 } 109 110 std::string TestDataReductionProxyParams::GetDefaultOrigin() const { 111 return GetDefinition( 112 TestDataReductionProxyParams::HAS_ORIGIN, kDefaultOrigin); 113 } 114 115 std::string TestDataReductionProxyParams::GetDefaultFallbackOrigin() const { 116 return GetDefinition( 117 TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN, 118 kDefaultFallbackOrigin); 119 } 120 121 std::string TestDataReductionProxyParams::GetDefaultSSLOrigin() const { 122 return GetDefinition( 123 TestDataReductionProxyParams::HAS_SSL_ORIGIN, kDefaultSSLOrigin); 124 } 125 126 std::string TestDataReductionProxyParams::GetDefaultAltOrigin() const { 127 return GetDefinition( 128 TestDataReductionProxyParams::HAS_ALT_ORIGIN, kDefaultAltOrigin); 129 } 130 131 std::string TestDataReductionProxyParams::GetDefaultAltFallbackOrigin() const { 132 return GetDefinition( 133 TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN, 134 kDefaultAltFallbackOrigin); 135 } 136 137 std::string TestDataReductionProxyParams::GetDefaultProbeURL() const { 138 return GetDefinition( 139 TestDataReductionProxyParams::HAS_PROBE_URL, kDefaultProbeURL); 140 } 141 142 std::string TestDataReductionProxyParams::GetDefinition( 143 unsigned int has_def, 144 const std::string& definition) const { 145 return ((has_definitions_ & has_def) ? definition : std::string()); 146 } 147 } // namespace data_reduction_proxy 148