Index: components/data_reduction_proxy/core/common/data_reduction_proxy_params_unittest.cc |
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_params_unittest.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_params_unittest.cc |
index 467e3be75367393c38ea87b67b5f882fa2adfe58..1de54cfef96ba195798b1b5267aeb9d386dd8856 100644 |
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_params_unittest.cc |
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_params_unittest.cc |
@@ -5,6 +5,7 @@ |
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" |
#include <map> |
+#include <string> |
#include <vector> |
#include "base/command_line.h" |
@@ -16,6 +17,10 @@ |
#include "testing/gmock/include/gmock/gmock.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+namespace { |
+const char kConfigServiceFieldTrial[] = "DataReductionProxyConfigService"; |
+} |
+ |
namespace data_reduction_proxy { |
class DataReductionProxyParamsTest : public testing::Test { |
public: |
@@ -576,6 +581,53 @@ TEST_F(DataReductionProxyParamsTest, AndroidOnePromoFieldTrial) { |
"google/hammerhead/hammerhead:5.0/LRX210/1570415:user/release-keys")); |
} |
+TEST_F(DataReductionProxyParamsTest, IsClientConfigEnabled) { |
+ const struct { |
+ std::string test_case; |
+ bool command_line_set; |
+ std::string trial_group_value; |
+ bool expected; |
+ } tests[] = { |
+ { |
+ "Nothing set", false, "", false, |
+ }, |
+ { |
+ "Command line set", true, "", true, |
+ }, |
+ { |
+ "Enabled in experiment", false, "Enabled", true, |
+ }, |
+ { |
+ "Alternate enabled in experiment", false, "EnabledOther", true, |
+ }, |
+ { |
+ "Disabled in experiment", false, "Disabled", false, |
+ }, |
+ { |
+ "Command line set, enabled in experiment", true, "Enabled", true, |
+ }, |
+ { |
+ "Command line set, disabled in experiment", true, "Disabled", true, |
+ }, |
+ }; |
+ |
+ for (const auto& test : tests) { |
+ // Reset all flags. |
+ base::CommandLine::ForCurrentProcess()->InitFromArgv(0, NULL); |
+ if (test.command_line_set) { |
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
+ switches::kEnableDataReductionProxyConfigClient, ""); |
+ } |
+ base::FieldTrialList field_trial_list(nullptr); |
+ if (!test.trial_group_value.empty()) { |
+ base::FieldTrialList::CreateFieldTrial(kConfigServiceFieldTrial, |
+ test.trial_group_value); |
+ } |
+ EXPECT_EQ(test.expected, DataReductionProxyParams::IsConfigClientEnabled()) |
+ << test.test_case; |
+ } |
+} |
+ |
TEST_F(DataReductionProxyParamsTest, SecureProxyCheckDefault) { |
struct { |
bool command_line_set; |