| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h
" | 9 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h
" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 CheckValues(params, | 193 CheckValues(params, |
| 194 kFlagKey, | 194 kFlagKey, |
| 195 kFlagOrigin, | 195 kFlagOrigin, |
| 196 kFlagFallbackOrigin, | 196 kFlagFallbackOrigin, |
| 197 kFlagSSLOrigin, | 197 kFlagSSLOrigin, |
| 198 kFlagAltOrigin, | 198 kFlagAltOrigin, |
| 199 kFlagAltFallbackOrigin, | 199 kFlagAltFallbackOrigin, |
| 200 kFlagProbeURL); | 200 kFlagProbeURL); |
| 201 } | 201 } |
| 202 | 202 |
| 203 TEST_F(DataReductionProxyParamsTest, FlagsNoKey) { | |
| 204 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 205 switches::kDataReductionProxy, kFlagOrigin); | |
| 206 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 207 switches::kDataReductionProxyFallback, kFlagFallbackOrigin); | |
| 208 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 209 switches::kDataReductionSSLProxy, kFlagSSLOrigin); | |
| 210 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 211 switches::kDataReductionProxyAlt, kFlagAltOrigin); | |
| 212 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 213 switches::kDataReductionProxyAltFallback, kFlagAltFallbackOrigin); | |
| 214 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 215 switches::kDataReductionProxyProbeURL, kFlagProbeURL); | |
| 216 TestDataReductionProxyParams params( | |
| 217 DataReductionProxyParams::kAllowed | | |
| 218 DataReductionProxyParams::kFallbackAllowed | | |
| 219 DataReductionProxyParams::kAlternativeAllowed | | |
| 220 DataReductionProxyParams::kPromoAllowed, HAS_EVERYTHING); | |
| 221 EXPECT_FALSE(params.init_result()); | |
| 222 } | |
| 223 | |
| 224 TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { | 203 TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) { |
| 225 const struct { | 204 const struct { |
| 226 bool allowed; | 205 bool allowed; |
| 227 bool fallback_allowed; | 206 bool fallback_allowed; |
| 228 bool alternative_allowed; | 207 bool alternative_allowed; |
| 229 bool promo_allowed; | 208 bool promo_allowed; |
| 230 unsigned int missing_definitions; | 209 unsigned int missing_definitions; |
| 231 bool expected_result; | 210 bool expected_result; |
| 232 } tests[] = { | 211 } tests[] = { |
| 233 { true, true, true, true, HAS_NOTHING, true }, | 212 { true, true, true, true, HAS_NOTHING, true }, |
| 234 { true, true, true, true, HAS_KEY, false }, | 213 { true, true, true, true, HAS_KEY, true }, |
| 235 { true, true, true, true, HAS_DEV_ORIGIN, true }, | 214 { true, true, true, true, HAS_DEV_ORIGIN, true }, |
| 236 { true, true, true, true, HAS_ORIGIN, true }, | 215 { true, true, true, true, HAS_ORIGIN, true }, |
| 237 { true, true, true, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false }, | 216 { true, true, true, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false }, |
| 238 { true, true, true, true, HAS_FALLBACK_ORIGIN, false }, | 217 { true, true, true, true, HAS_FALLBACK_ORIGIN, false }, |
| 239 { true, true, true, true, HAS_SSL_ORIGIN, false }, | 218 { true, true, true, true, HAS_SSL_ORIGIN, false }, |
| 240 { true, true, true, true, HAS_ALT_ORIGIN, false }, | 219 { true, true, true, true, HAS_ALT_ORIGIN, false }, |
| 241 { true, true, true, true, HAS_ALT_FALLBACK_ORIGIN, false }, | 220 { true, true, true, true, HAS_ALT_FALLBACK_ORIGIN, false }, |
| 242 { true, true, true, true, HAS_PROBE_URL, false }, | 221 { true, true, true, true, HAS_PROBE_URL, false }, |
| 243 | 222 |
| 244 { true, false, true, true, HAS_NOTHING, true }, | 223 { true, false, true, true, HAS_NOTHING, true }, |
| 245 { true, false, true, true, HAS_KEY, false }, | 224 { true, false, true, true, HAS_KEY, true }, |
| 246 { true, false, true, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false }, | 225 { true, false, true, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false }, |
| 247 { true, false, true, true, HAS_FALLBACK_ORIGIN, true }, | 226 { true, false, true, true, HAS_FALLBACK_ORIGIN, true }, |
| 248 { true, false, true, true, HAS_SSL_ORIGIN, false }, | 227 { true, false, true, true, HAS_SSL_ORIGIN, false }, |
| 249 { true, false, true, true, HAS_ALT_ORIGIN, false }, | 228 { true, false, true, true, HAS_ALT_ORIGIN, false }, |
| 250 { true, false, true, true, HAS_ALT_FALLBACK_ORIGIN, true }, | 229 { true, false, true, true, HAS_ALT_FALLBACK_ORIGIN, true }, |
| 251 { true, false, true, true, HAS_PROBE_URL, false }, | 230 { true, false, true, true, HAS_PROBE_URL, false }, |
| 252 | 231 |
| 253 { true, true, false, true, HAS_NOTHING, true }, | 232 { true, true, false, true, HAS_NOTHING, true }, |
| 254 { true, true, false, true, HAS_KEY, false }, | 233 { true, true, false, true, HAS_KEY, true }, |
| 255 { true, true, false, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false }, | 234 { true, true, false, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false }, |
| 256 { true, true, false, true, HAS_FALLBACK_ORIGIN, false }, | 235 { true, true, false, true, HAS_FALLBACK_ORIGIN, false }, |
| 257 { true, true, false, true, HAS_SSL_ORIGIN, true }, | 236 { true, true, false, true, HAS_SSL_ORIGIN, true }, |
| 258 { true, true, false, true, HAS_ALT_ORIGIN, true }, | 237 { true, true, false, true, HAS_ALT_ORIGIN, true }, |
| 259 { true, true, false, true, HAS_ALT_FALLBACK_ORIGIN, true }, | 238 { true, true, false, true, HAS_ALT_FALLBACK_ORIGIN, true }, |
| 260 { true, true, false, true, HAS_PROBE_URL, false }, | 239 { true, true, false, true, HAS_PROBE_URL, false }, |
| 261 | 240 |
| 262 { true, false, false, true, HAS_KEY, false }, | 241 { true, false, false, true, HAS_KEY, true }, |
| 263 { true, false, false, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false }, | 242 { true, false, false, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false }, |
| 264 { true, false, false, true, HAS_FALLBACK_ORIGIN, true }, | 243 { true, false, false, true, HAS_FALLBACK_ORIGIN, true }, |
| 265 { true, false, false, true, HAS_SSL_ORIGIN, true }, | 244 { true, false, false, true, HAS_SSL_ORIGIN, true }, |
| 266 { true, false, false, true, HAS_ALT_ORIGIN, true }, | 245 { true, false, false, true, HAS_ALT_ORIGIN, true }, |
| 267 { true, false, false, true, HAS_ALT_FALLBACK_ORIGIN, true }, | 246 { true, false, false, true, HAS_ALT_FALLBACK_ORIGIN, true }, |
| 268 { true, false, false, true, HAS_PROBE_URL, false }, | 247 { true, false, false, true, HAS_PROBE_URL, false }, |
| 269 | 248 |
| 270 { false, true, true, true, HAS_NOTHING, false }, | 249 { false, true, true, true, HAS_NOTHING, false }, |
| 271 { false, true, true, true, HAS_KEY, false }, | 250 { false, true, true, true, HAS_KEY, false }, |
| 272 { false, true, true, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false }, | 251 { false, true, true, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false }, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 params.IsDataReductionProxy( | 348 params.IsDataReductionProxy( |
| 370 tests[i].host_port_pair, &proxy_servers)); | 349 tests[i].host_port_pair, &proxy_servers)); |
| 371 EXPECT_TRUE(tests[i].expected_first.Equals( | 350 EXPECT_TRUE(tests[i].expected_first.Equals( |
| 372 net::HostPortPair::FromURL(proxy_servers.first))); | 351 net::HostPortPair::FromURL(proxy_servers.first))); |
| 373 EXPECT_TRUE(tests[i].expected_second.Equals( | 352 EXPECT_TRUE(tests[i].expected_second.Equals( |
| 374 net::HostPortPair::FromURL(proxy_servers.second))); | 353 net::HostPortPair::FromURL(proxy_servers.second))); |
| 375 } | 354 } |
| 376 } | 355 } |
| 377 | 356 |
| 378 } // namespace data_reduction_proxy | 357 } // namespace data_reduction_proxy |
| OLD | NEW |