Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / components / data_reduction_proxy / browser / data_reduction_proxy_params_unittest.cc
index fac9d2d..69a9ab6 100644 (file)
 
 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
 
+#include <map>
+
 #include "base/command_line.h"
 #include "base/logging.h"
+#include "components/data_reduction_proxy/browser/data_reduction_proxy_params_test_utils.h"
 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h"
+#include "net/proxy/proxy_retry_info.h"
+#include "net/proxy/proxy_server.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
-namespace {
-// Test values to replacethe values specified in preprocessor defines.
-static const char kDefaultKey[] = "test-key";
-static const char kDefaultDevOrigin[] = "https://dev.net:443/";
-static const char kDefaultOrigin[] = "https://origin.net:443/";
-static const char kDefaultFallbackOrigin[] = "http://fallback.net:80/";
-static const char kDefaultSSLOrigin[] = "http://ssl.net:1080/";
-static const char kDefaultAltOrigin[] = "https://alt.net:443/";
-static const char kDefaultAltFallbackOrigin[] = "http://altfallback.net:80/";
-static const char kDefaultProbeURL[] = "http://probe.net/";
-
-static const char kFlagKey[] = "test-flag-key";
-static const char kFlagOrigin[] = "https://origin.org:443/";
-static const char kFlagFallbackOrigin[] = "http://fallback.org:80/";
-static const char kFlagSSLOrigin[] = "http://ssl.org:1080/";
-static const char kFlagAltOrigin[] = "https://alt.org:443/";
-static const char kFlagAltFallbackOrigin[] = "http://altfallback.org:80/";
-static const char kFlagProbeURL[] = "http://probe.org/";
-
-// Used to emulate having constants defined by the preprocessor.
-static const unsigned int HAS_NOTHING = 0x0;
-static const unsigned int HAS_KEY = 0x1;
-static const unsigned int HAS_DEV_ORIGIN = 0x2;
-static const unsigned int HAS_ORIGIN = 0x4;
-static const unsigned int HAS_FALLBACK_ORIGIN = 0x8;
-static const unsigned int HAS_SSL_ORIGIN = 0x10;
-static const unsigned int HAS_ALT_ORIGIN = 0x20;
-static const unsigned int HAS_ALT_FALLBACK_ORIGIN = 0x40;
-static const unsigned int HAS_PROBE_URL = 0x80;
-static const unsigned int HAS_EVERYTHING = 0xff;
-}  // namespace
-
 namespace data_reduction_proxy {
-namespace {
-class TestDataReductionProxyParams : public DataReductionProxyParams {
- public:
-
-  TestDataReductionProxyParams(int flags,
-                               unsigned int has_definitions)
-      : DataReductionProxyParams(flags,
-                                 false),
-        has_definitions_(has_definitions) {
-    init_result_ = Init(flags & DataReductionProxyParams::kAllowed,
-                        flags & DataReductionProxyParams::kFallbackAllowed,
-                        flags & DataReductionProxyParams::kAlternativeAllowed);
-  }
-
-  bool init_result() const {
-    return init_result_;
-  }
-
- protected:
-  virtual std::string GetDefaultKey() const OVERRIDE {
-    return GetDefinition(HAS_KEY, kDefaultKey);
-  }
-
-  virtual std::string GetDefaultDevOrigin() const OVERRIDE {
-    return GetDefinition(HAS_DEV_ORIGIN, kDefaultDevOrigin);
-  }
-
-  virtual std::string GetDefaultOrigin() const OVERRIDE {
-    return GetDefinition(HAS_ORIGIN, kDefaultOrigin);
-  }
-
-  virtual std::string GetDefaultFallbackOrigin() const OVERRIDE {
-    return GetDefinition(HAS_FALLBACK_ORIGIN, kDefaultFallbackOrigin);
-  }
-
-  virtual std::string GetDefaultSSLOrigin() const OVERRIDE {
-    return GetDefinition(HAS_SSL_ORIGIN, kDefaultSSLOrigin);
-  }
-
-  virtual std::string GetDefaultAltOrigin() const OVERRIDE {
-    return GetDefinition(HAS_ALT_ORIGIN, kDefaultAltOrigin);
-  }
-
-  virtual std::string GetDefaultAltFallbackOrigin() const OVERRIDE {
-    return GetDefinition(HAS_ALT_FALLBACK_ORIGIN, kDefaultAltFallbackOrigin);
-  }
-
-  virtual std::string GetDefaultProbeURL() const OVERRIDE {
-    return GetDefinition(HAS_PROBE_URL, kDefaultProbeURL);
-  }
-
- private:
-  std::string GetDefinition(unsigned int has_def,
-                            const std::string& definition) const {
-    return ((has_definitions_ & has_def) ? definition : std::string());
-  }
-
-  unsigned int has_definitions_;
-  bool init_result_;
-};
-}  // namespace
-
 class DataReductionProxyParamsTest : public testing::Test {
  public:
   void CheckParams(const TestDataReductionProxyParams& params,
@@ -119,14 +30,12 @@ class DataReductionProxyParamsTest : public testing::Test {
     EXPECT_EQ(expected_promo_allowed, params.promo_allowed());
   }
   void CheckValues(const TestDataReductionProxyParams& params,
-                   const std::string expected_key,
                    const std::string& expected_origin,
                    const std::string& expected_fallback_origin,
                    const std::string& expected_ssl_origin,
                    const std::string& expected_alt_origin,
                    const std::string& expected_alt_fallback_origin,
                    const std::string& expected_probe_url) {
-    EXPECT_EQ(expected_key, params.key());
     EXPECT_EQ(GURL(expected_origin), params.origin());
     EXPECT_EQ(GURL(expected_fallback_origin), params.fallback_origin());
     EXPECT_EQ(GURL(expected_ssl_origin), params.ssl_origin());
@@ -140,16 +49,16 @@ TEST_F(DataReductionProxyParamsTest, EverythingDefined) {
   TestDataReductionProxyParams params(
       DataReductionProxyParams::kAllowed |
       DataReductionProxyParams::kFallbackAllowed |
-      DataReductionProxyParams::kPromoAllowed, HAS_EVERYTHING);
+      DataReductionProxyParams::kPromoAllowed,
+      TestDataReductionProxyParams::HAS_EVERYTHING);
   CheckParams(params, true, true, true, false, true);
   CheckValues(params,
-              kDefaultKey,
-              kDefaultDevOrigin,
-              kDefaultFallbackOrigin,
-              kDefaultSSLOrigin,
-              kDefaultAltOrigin,
-              kDefaultAltFallbackOrigin,
-              kDefaultProbeURL);
+              TestDataReductionProxyParams::DefaultDevOrigin(),
+              TestDataReductionProxyParams::DefaultFallbackOrigin(),
+              TestDataReductionProxyParams::DefaultSSLOrigin(),
+              TestDataReductionProxyParams::DefaultAltOrigin(),
+              TestDataReductionProxyParams::DefaultAltFallbackOrigin(),
+              TestDataReductionProxyParams::DefaultProbeURL());
 }
 
 TEST_F(DataReductionProxyParamsTest, NoDevOrigin) {
@@ -157,47 +66,51 @@ TEST_F(DataReductionProxyParamsTest, NoDevOrigin) {
       DataReductionProxyParams::kAllowed |
       DataReductionProxyParams::kFallbackAllowed |
       DataReductionProxyParams::kPromoAllowed,
-      HAS_EVERYTHING & ~HAS_DEV_ORIGIN);
+      TestDataReductionProxyParams::HAS_EVERYTHING &
+      ~TestDataReductionProxyParams::HAS_DEV_ORIGIN);
   CheckParams(params, true, true, true, false, true);
   CheckValues(params,
-              kDefaultKey,
-              kDefaultOrigin,
-              kDefaultFallbackOrigin,
-              kDefaultSSLOrigin,
-              kDefaultAltOrigin,
-              kDefaultAltFallbackOrigin,
-              kDefaultProbeURL);
+              TestDataReductionProxyParams::DefaultOrigin(),
+              TestDataReductionProxyParams::DefaultFallbackOrigin(),
+              TestDataReductionProxyParams::DefaultSSLOrigin(),
+              TestDataReductionProxyParams::DefaultAltOrigin(),
+              TestDataReductionProxyParams::DefaultAltFallbackOrigin(),
+              TestDataReductionProxyParams::DefaultProbeURL());
 }
 
 TEST_F(DataReductionProxyParamsTest, Flags) {
   CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-      switches::kDataReductionProxyKey, kFlagKey);
+      switches::kDataReductionProxy,
+      TestDataReductionProxyParams::FlagOrigin());
   CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-      switches::kDataReductionProxy, kFlagOrigin);
+      switches::kDataReductionProxyFallback,
+      TestDataReductionProxyParams::FlagFallbackOrigin());
   CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-      switches::kDataReductionProxyFallback, kFlagFallbackOrigin);
+      switches::kDataReductionSSLProxy,
+      TestDataReductionProxyParams::FlagSSLOrigin());
   CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-      switches::kDataReductionSSLProxy, kFlagSSLOrigin);
+      switches::kDataReductionProxyAlt,
+      TestDataReductionProxyParams::FlagAltOrigin());
   CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-      switches::kDataReductionProxyAlt, kFlagAltOrigin);
+      switches::kDataReductionProxyAltFallback,
+      TestDataReductionProxyParams::FlagAltFallbackOrigin());
   CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-      switches::kDataReductionProxyAltFallback, kFlagAltFallbackOrigin);
-  CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-      switches::kDataReductionProxyProbeURL, kFlagProbeURL);
+      switches::kDataReductionProxyProbeURL,
+      TestDataReductionProxyParams::FlagProbeURL());
   TestDataReductionProxyParams params(
       DataReductionProxyParams::kAllowed |
       DataReductionProxyParams::kFallbackAllowed |
       DataReductionProxyParams::kAlternativeAllowed |
-      DataReductionProxyParams::kPromoAllowed, HAS_EVERYTHING);
+      DataReductionProxyParams::kPromoAllowed,
+      TestDataReductionProxyParams::HAS_EVERYTHING);
   CheckParams(params, true, true, true, true, true);
   CheckValues(params,
-              kFlagKey,
-              kFlagOrigin,
-              kFlagFallbackOrigin,
-              kFlagSSLOrigin,
-              kFlagAltOrigin,
-              kFlagAltFallbackOrigin,
-              kFlagProbeURL);
+              TestDataReductionProxyParams::FlagOrigin(),
+              TestDataReductionProxyParams::FlagFallbackOrigin(),
+              TestDataReductionProxyParams::FlagSSLOrigin(),
+              TestDataReductionProxyParams::FlagAltOrigin(),
+              TestDataReductionProxyParams::FlagAltFallbackOrigin(),
+              TestDataReductionProxyParams::FlagProbeURL());
 }
 
 TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
@@ -209,51 +122,295 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
     unsigned int missing_definitions;
     bool expected_result;
   } tests[]  = {
-    { true, true, true, true, HAS_NOTHING, true },
-    { true, true, true, true, HAS_KEY, true },
-    { true, true, true, true, HAS_DEV_ORIGIN, true },
-    { true, true, true, true, HAS_ORIGIN, true },
-    { true, true, true, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false },
-    { true, true, true, true, HAS_FALLBACK_ORIGIN, false },
-    { true, true, true, true, HAS_SSL_ORIGIN, false },
-    { true, true, true, true, HAS_ALT_ORIGIN, false },
-    { true, true, true, true, HAS_ALT_FALLBACK_ORIGIN, false },
-    { true, true, true, true, HAS_PROBE_URL, false },
-
-    { true, false, true, true, HAS_NOTHING, true },
-    { true, false, true, true, HAS_KEY, true },
-    { true, false, true, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false },
-    { true, false, true, true, HAS_FALLBACK_ORIGIN, true },
-    { true, false, true, true, HAS_SSL_ORIGIN, false },
-    { true, false, true, true, HAS_ALT_ORIGIN, false },
-    { true, false, true, true, HAS_ALT_FALLBACK_ORIGIN, true },
-    { true, false, true, true, HAS_PROBE_URL, false },
-
-    { true, true, false, true, HAS_NOTHING, true },
-    { true, true, false, true, HAS_KEY, true },
-    { true, true, false, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false },
-    { true, true, false, true, HAS_FALLBACK_ORIGIN, false },
-    { true, true, false, true, HAS_SSL_ORIGIN, true },
-    { true, true, false, true, HAS_ALT_ORIGIN, true },
-    { true, true, false, true, HAS_ALT_FALLBACK_ORIGIN, true },
-    { true, true, false, true, HAS_PROBE_URL, false },
-
-    { true, false, false, true, HAS_KEY, true },
-    { true, false, false, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false },
-    { true, false, false, true, HAS_FALLBACK_ORIGIN, true },
-    { true, false, false, true, HAS_SSL_ORIGIN, true },
-    { true, false, false, true, HAS_ALT_ORIGIN, true },
-    { true, false, false, true, HAS_ALT_FALLBACK_ORIGIN, true },
-    { true, false, false, true, HAS_PROBE_URL, false },
+    {
+      true,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_NOTHING,
+      true
+    },
+    {
+      true,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_DEV_ORIGIN,
+      true
+    },
+    {
+      true,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_ORIGIN,
+      true
+    },
+    {
+      true,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_ORIGIN |
+          TestDataReductionProxyParams::HAS_DEV_ORIGIN,
+      false
+    },
+    { true,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN,
+      false
+    },
+    { true,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_SSL_ORIGIN,
+      false
+    },
+    { true,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_ALT_ORIGIN,
+      false
+    },
+    { true,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
+      false
+    },
+    { true,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_PROBE_URL,
+      false
+    },
+    {
+      true,
+      false,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_NOTHING,
+      true
+    },
+    {
+      true,
+      false,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_ORIGIN |
+          TestDataReductionProxyParams::HAS_DEV_ORIGIN,
+      false
+    },
+    {
+      true,
+      false,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN,
+      true
+    },
+    {
+      true,
+      false,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_SSL_ORIGIN,
+      false
+    },
+    {
+      true,
+      false,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_ALT_ORIGIN,
+      false
+    },
+    {
+      true,
+      false,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
+      true
+    },
+    {
+      true,
+      false,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_PROBE_URL,
+      false
+    },
 
-    { false, true, true, true, HAS_NOTHING, false },
-    { false, true, true, true, HAS_KEY, false },
-    { false, true, true, true, HAS_ORIGIN | HAS_DEV_ORIGIN, false },
-    { false, true, true, true, HAS_FALLBACK_ORIGIN, false },
-    { false, true, true, true, HAS_SSL_ORIGIN, false },
-    { false, true, true, true, HAS_ALT_ORIGIN, false },
-    { false, true, true, true, HAS_ALT_FALLBACK_ORIGIN, false },
-    { false, true, true, true, HAS_PROBE_URL, false },
+    {
+      true,
+      true,
+      false,
+      true,
+      TestDataReductionProxyParams::HAS_NOTHING,
+      true
+    },
+    {
+      true,
+      true,
+      false,
+      true,
+      TestDataReductionProxyParams::HAS_ORIGIN |
+          TestDataReductionProxyParams::HAS_DEV_ORIGIN,
+      false
+    },
+    {
+      true,
+      true,
+      false,
+      true,
+      TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN,
+      false
+    },
+    {
+      true,
+      true,
+      false,
+      true,
+      TestDataReductionProxyParams::HAS_SSL_ORIGIN,
+      true
+    },
+    {
+      true,
+      true,
+      false,
+      true,
+      TestDataReductionProxyParams::HAS_ALT_ORIGIN,
+      true
+    },
+    {
+      true,
+      true,
+      false,
+      true,
+      TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
+      true
+    },
+    {
+      true,
+      true,
+      false,
+      true,
+      TestDataReductionProxyParams::HAS_PROBE_URL,
+      false
+    },
+    {
+      true,
+      false,
+      false,
+      true,
+      TestDataReductionProxyParams::HAS_ORIGIN |
+          TestDataReductionProxyParams::HAS_DEV_ORIGIN,
+      false
+    },
+    {
+      true,
+      false,
+      false,
+      true,
+      TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN,
+      true
+    },
+    {
+      true,
+      false,
+      false,
+      true,
+      TestDataReductionProxyParams::HAS_SSL_ORIGIN,
+      true
+    },
+    {
+      true,
+      false,
+      false,
+      true,
+      TestDataReductionProxyParams::HAS_ALT_ORIGIN,
+      true
+    },
+    {
+      true,
+      false,
+      false,
+      true,
+      TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
+      true
+    },
+    {
+      true,
+      false,
+      false,
+      true,
+      TestDataReductionProxyParams::HAS_PROBE_URL,
+      false
+    },
+    {
+      false,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_NOTHING,
+      false
+    },
+    {
+      false,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_ORIGIN |
+          TestDataReductionProxyParams::HAS_DEV_ORIGIN,
+      false
+    },
+    {
+      false,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_FALLBACK_ORIGIN,
+      false
+    },
+    {
+      false,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_SSL_ORIGIN,
+      false
+    },
+    {
+      false,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_ALT_ORIGIN,
+      false
+    },
+    {
+      false,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_ALT_FALLBACK_ORIGIN,
+      false
+    },
+    {
+      false,
+      true,
+      true,
+      true,
+      TestDataReductionProxyParams::HAS_PROBE_URL,
+      false
+    },
   };
 
   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
@@ -268,7 +425,8 @@ TEST_F(DataReductionProxyParamsTest, InvalidConfigurations) {
       flags |= DataReductionProxyParams::kPromoAllowed;
     TestDataReductionProxyParams params(
         flags,
-        HAS_EVERYTHING & ~(tests[i].missing_definitions));
+        TestDataReductionProxyParams::HAS_EVERYTHING &
+            ~(tests[i].missing_definitions));
     EXPECT_EQ(tests[i].expected_result, params.init_result());
   }
 }
@@ -277,63 +435,147 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) {
   const struct {
     net::HostPortPair host_port_pair;
     bool fallback_allowed;
+    bool set_dev_origin;
     bool expected_result;
     net::HostPortPair expected_first;
     net::HostPortPair expected_second;
+    bool expected_is_fallback;
+    bool expected_is_alternative;
+    bool expected_is_ssl;
   } tests[]  = {
-      { net::HostPortPair::FromURL(GURL(kDefaultOrigin)),
+      { net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultOrigin())),
         true,
+        false,
         true,
-        net::HostPortPair::FromURL(GURL(kDefaultOrigin)),
-        net::HostPortPair::FromURL(GURL(kDefaultFallbackOrigin))
+        net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultOrigin())),
+        net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultFallbackOrigin())),
+        false,
+        false,
+        false
       },
-      { net::HostPortPair::FromURL(GURL(kDefaultOrigin)),
+      { net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultOrigin())),
+        false,
         false,
         true,
-        net::HostPortPair::FromURL(GURL(kDefaultOrigin)),
-        net::HostPortPair::FromURL(GURL())
+        net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultOrigin())),
+        net::HostPortPair::FromURL(GURL()),
+        false,
+        false,
+        false
       },
-      { net::HostPortPair::FromURL(GURL(kDefaultFallbackOrigin)),
+      { net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultFallbackOrigin())),
+        true,
+        false,
         true,
+        net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultFallbackOrigin())),
+        net::HostPortPair::FromURL(GURL()),
         true,
-        net::HostPortPair::FromURL(GURL(kDefaultFallbackOrigin)),
-        net::HostPortPair::FromURL(GURL())
+        false,
+        false
       },
-      { net::HostPortPair::FromURL(GURL(kDefaultFallbackOrigin)),
+      { net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultFallbackOrigin())),
         false,
         false,
+        false,
+        net::HostPortPair::FromURL(GURL()),
         net::HostPortPair::FromURL(GURL()),
-        net::HostPortPair::FromURL(GURL())
+        false,
+        false,
+        false
       },
-      { net::HostPortPair::FromURL(GURL(kDefaultAltOrigin)),
+      { net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultAltOrigin())),
         true,
+        false,
         true,
-        net::HostPortPair::FromURL(GURL(kDefaultAltOrigin)),
-        net::HostPortPair::FromURL(GURL(kDefaultAltFallbackOrigin))
+        net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultAltOrigin())),
+        net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultAltFallbackOrigin())),
+        false,
+        true,
+        false
       },
-      { net::HostPortPair::FromURL(GURL(kDefaultAltOrigin)),
+      { net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultAltOrigin())),
+        false,
+        false,
+        true,
+        net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultAltOrigin())),
+        net::HostPortPair::FromURL(GURL()),
         false,
         true,
-        net::HostPortPair::FromURL(GURL(kDefaultAltOrigin)),
-        net::HostPortPair::FromURL(GURL())
+        false
       },
-      { net::HostPortPair::FromURL(GURL(kDefaultAltFallbackOrigin)),
+      { net::HostPortPair::FromURL(
+            GURL(TestDataReductionProxyParams::DefaultAltFallbackOrigin())),
+        true,
+        false,
+        true,
+        net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultAltFallbackOrigin())),
+        net::HostPortPair::FromURL(GURL()),
         true,
         true,
-        net::HostPortPair::FromURL(GURL(kDefaultAltFallbackOrigin)),
-        net::HostPortPair::FromURL(GURL())
+        false
       },
-      { net::HostPortPair::FromURL(GURL(kDefaultAltFallbackOrigin)),
+      { net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultAltFallbackOrigin())),
         false,
         false,
+        false,
+        net::HostPortPair::FromURL(GURL()),
+        net::HostPortPair::FromURL(GURL()),
+        false,
+        false,
+        false
+      },
+      { net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultSSLOrigin())),
+        true,
+        false,
+        true,
+        net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultSSLOrigin())),
         net::HostPortPair::FromURL(GURL()),
-        net::HostPortPair::FromURL(GURL())
+        false,
+        false,
+        true
+      },
+      { net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultDevOrigin())),
+        true,
+        true,
+        true,
+        net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultDevOrigin())),
+        net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultFallbackOrigin())),
+        false,
+        false,
+        false
       },
-      { net::HostPortPair::FromURL(GURL(kDefaultSSLOrigin)),
+      { net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultOrigin())),
+        true,
         true,
         true,
-        net::HostPortPair::FromURL(GURL(kDefaultSSLOrigin)),
-        net::HostPortPair::FromURL(GURL())
+        net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultOrigin())),
+        net::HostPortPair::FromURL(GURL(
+            TestDataReductionProxyParams::DefaultFallbackOrigin())),
+        false,
+        false,
+        false
       },
   };
   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
@@ -341,17 +583,395 @@ TEST_F(DataReductionProxyParamsTest, IsDataReductionProxy) {
                 DataReductionProxyParams::kAlternativeAllowed;
     if (tests[i].fallback_allowed)
       flags |= DataReductionProxyParams::kFallbackAllowed;
-    TestDataReductionProxyParams params(flags,
-                                        HAS_EVERYTHING & ~HAS_DEV_ORIGIN);
-    std::pair<GURL, GURL> proxy_servers;
+    unsigned int has_definitions = TestDataReductionProxyParams::HAS_EVERYTHING;
+    if (!tests[i].set_dev_origin) {
+      has_definitions &= ~TestDataReductionProxyParams::HAS_DEV_ORIGIN;
+    }
+    TestDataReductionProxyParams params(flags, has_definitions);
+    DataReductionProxyTypeInfo proxy_type_info;
     EXPECT_EQ(tests[i].expected_result,
               params.IsDataReductionProxy(
-                  tests[i].host_port_pair, &proxy_servers));
+                  tests[i].host_port_pair, &proxy_type_info));
     EXPECT_TRUE(tests[i].expected_first.Equals(
-        net::HostPortPair::FromURL(proxy_servers.first)));
+        net::HostPortPair::FromURL(proxy_type_info.proxy_servers.first)));
     EXPECT_TRUE(tests[i].expected_second.Equals(
-        net::HostPortPair::FromURL(proxy_servers.second)));
+        net::HostPortPair::FromURL(proxy_type_info.proxy_servers.second)));
+    EXPECT_EQ(tests[i].expected_is_fallback, proxy_type_info.is_fallback);
+    EXPECT_EQ(tests[i].expected_is_alternative, proxy_type_info.is_alternative);
+    EXPECT_EQ(tests[i].expected_is_ssl, proxy_type_info.is_ssl);
   }
 }
 
+std::string GetRetryMapKeyFromOrigin(std::string origin) {
+  // The retry map has the scheme prefix for https but not for http
+  return net::ProxyServer(GURL(origin).SchemeIs(url::kHttpsScheme) ?
+      net::ProxyServer::SCHEME_HTTPS : net::ProxyServer::SCHEME_HTTP,
+      net::HostPortPair::FromURL(GURL(origin))).ToURI();
+}
+
+TEST_F(DataReductionProxyParamsTest, AreProxiesBypassed) {
+  const struct {
+    // proxy flags
+    bool allowed;
+    bool fallback_allowed;
+    bool alt_allowed;
+    // is https request
+    bool is_https;
+    // proxies in retry map
+    bool origin;
+    bool fallback_origin;
+    bool alt_origin;
+    bool alt_fallback_origin;
+    bool ssl_origin;
+
+    bool expected_result;
+  } tests[]  = {
+      { // proxy flags
+        false,
+        false,
+        false,
+        // is https request
+        false,
+        // proxies in retry map
+        false,
+        false,
+        false,
+        false,
+        false,
+        // expected result
+        false,
+      },
+      { // proxy flags
+        true,
+        false,
+        false,
+        // is https request
+        false,
+        // proxies in retry map
+        false,
+        false,
+        false,
+        false,
+        false,
+        // expected result
+        false,
+      },
+      { // proxy flags
+        true,
+        true,
+        false,
+        // is https request
+        false,
+        // proxies in retry map
+        false,
+        false,
+        false,
+        false,
+        false,
+        // expected result
+        false,
+      },
+      { // proxy flags
+        true,
+        true,
+        true,
+        // is https request
+        false,
+        // proxies in retry map
+        false,
+        false,
+        false,
+        false,
+        false,
+        // expected result
+        false,
+      },
+      { // proxy flags
+        true,
+        true,
+        true,
+        // is https request
+        true,
+        // proxies in retry map
+        false,
+        false,
+        false,
+        false,
+        false,
+        // expected result
+        false,
+      },
+      { // proxy flags
+        false,
+        false,
+        false,
+        // is https request
+        true,
+        // proxies in retry map
+        false,
+        false,
+        false,
+        false,
+        true,
+        // expected result
+        false,
+      },
+      { // proxy flags
+        false,
+        false,
+        true,
+        // is https request
+        true,
+        // proxies in retry map
+        false,
+        false,
+        false,
+        false,
+        true,
+        // expected result
+        true,
+      },
+      { // proxy flags
+        true,
+        true,
+        true,
+        // is https request
+        true,
+        // proxies in retry map
+        false,
+        false,
+        false,
+        false,
+        true,
+        // expected result
+        true,
+      },
+      { // proxy flags
+        true,
+        false,
+        false,
+        // is https request
+        false,
+        // proxies in retry map
+        true,
+        false,
+        false,
+        false,
+        false,
+        // expected result
+        true,
+      },
+      { // proxy flags
+        true,
+        true,
+        false,
+        // is https request
+        false,
+        // proxies in retry map
+        true,
+        false,
+        false,
+        false,
+        false,
+        // expected result
+        false,
+      },
+      { // proxy flags
+        true,
+        true,
+        false,
+        // is https request
+        false,
+        // proxies in retry map
+        true,
+        true,
+        false,
+        false,
+        false,
+        // expected result
+        true,
+      },
+      { // proxy flags
+        true,
+        true,
+        true,
+        // is https request
+        false,
+        // proxies in retry map
+        true,
+        true,
+        false,
+        false,
+        false,
+        // expected result
+        true,
+      },
+      { // proxy flags
+        true,
+        true,
+        true,
+        // is https request
+        false,
+        // proxies in retry map
+        true,
+        false,
+        true,
+        false,
+        false,
+        // expected result
+        false,
+      },
+      { // proxy flags
+        true,
+        true,
+        true,
+        // is https request
+        false,
+        // proxies in retry map
+        false,
+        false,
+        true,
+        true,
+        false,
+        // expected result
+        true,
+      },
+      { // proxy flags
+        false,
+        true,
+        true,
+        // is https request
+        false,
+        // proxies in retry map
+        false,
+        false,
+        true,
+        true,
+        false,
+        // expected result
+        true,
+      },
+      { // proxy flags
+        false,
+        true,
+        false,
+        // is https request
+        false,
+        // proxies in retry map
+        false,
+        false,
+        true,
+        false,
+        false,
+        // expected result
+        false,
+      },
+      { // proxy flags
+        true,
+        true,
+        true,
+        // is https request
+        false,
+        // proxies in retry map
+        true,
+        false,
+        true,
+        true,
+        false,
+        // expected result
+        true,
+      },
+      { // proxy flags
+        true,
+        true,
+        true,
+        // is https request
+        false,
+        // proxies in retry map
+        true,
+        true,
+        true,
+        true,
+        true,
+        // expected result
+        true,
+      },
+      { // proxy flags
+        true,
+        true,
+        true,
+        // is https request
+        true,
+        // proxies in retry map
+        true,
+        true,
+        true,
+        true,
+        true,
+        // expected result
+        true,
+      },
+      { // proxy flags
+        true,
+        true,
+        true,
+        // is https request
+        true,
+        // proxies in retry map
+        true,
+        true,
+        true,
+        true,
+        false,
+        // expected result
+        false,
+      },
+  };
+
+  // The retry map has the scheme prefix for https but not for http.
+  std::string origin = GetRetryMapKeyFromOrigin(
+      TestDataReductionProxyParams::DefaultOrigin());
+  std::string fallback_origin =GetRetryMapKeyFromOrigin(
+      TestDataReductionProxyParams::DefaultFallbackOrigin());
+  std::string alt_origin = GetRetryMapKeyFromOrigin(
+      TestDataReductionProxyParams::DefaultAltOrigin());
+  std::string alt_fallback_origin = GetRetryMapKeyFromOrigin(
+      TestDataReductionProxyParams::DefaultAltFallbackOrigin());
+  std::string ssl_origin = GetRetryMapKeyFromOrigin(
+      TestDataReductionProxyParams::DefaultSSLOrigin());
+
+  for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
+    int flags = 0;
+    if (tests[i].allowed)
+      flags |= DataReductionProxyParams::kAllowed;
+    if (tests[i].alt_allowed)
+      flags |= DataReductionProxyParams::kAlternativeAllowed;
+    if (tests[i].fallback_allowed)
+      flags |= DataReductionProxyParams::kFallbackAllowed;
+    unsigned int has_definitions =
+        TestDataReductionProxyParams::HAS_EVERYTHING &
+        ~TestDataReductionProxyParams::HAS_DEV_ORIGIN;
+    TestDataReductionProxyParams params(flags, has_definitions);
+
+    net::ProxyRetryInfoMap retry_map;
+    net::ProxyRetryInfo retry_info;
+
+    if (tests[i].origin)
+      retry_map[origin] = retry_info;
+    if (tests[i].fallback_origin)
+      retry_map[fallback_origin] = retry_info;
+    if (tests[i].alt_origin)
+      retry_map[alt_origin] = retry_info;
+    if (tests[i].alt_fallback_origin)
+      retry_map[alt_fallback_origin] = retry_info;
+    if (tests[i].ssl_origin)
+      retry_map[ssl_origin] = retry_info;
+
+    bool was_bypassed = params.AreProxiesBypassed(retry_map,
+                                                  tests[i].is_https,
+                                                  NULL);
+
+    EXPECT_EQ(tests[i].expected_result, was_bypassed);
+  }
+}
 }  // namespace data_reduction_proxy