Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Unified Diff: components/data_reduction_proxy/core/common/data_reduction_proxy_params_unittest.cc

Issue 2062963003: Add a flag to disable server experiments in DRP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: kundaji comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 0c20baf3a82cb5e1405bd1bd86685617e0f09f5b..50dcf4068f3edf9a129bdee8304769b998882d32 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
@@ -193,6 +193,90 @@ TEST_F(DataReductionProxyParamsTest, IsClientConfigEnabled) {
}
}
+TEST_F(DataReductionProxyParamsTest, AreServerExperimentsEnabled) {
+ const struct {
+ std::string test_case;
+ std::string trial_group_value;
+ bool disable_flag_set;
+ bool expected;
+ } tests[] = {
+ {
+ "Field trial not set", "", false, true,
+ },
+ {
+ "Field trial not set, flag set", "", true, false,
+ },
+ {
+ "Enabled", "Enabled", false, true,
+ },
+ {
+ "Enabled via field trial but disabled via flag", "Enabled", true,
+ false,
+ },
+ {
+ "Disabled via field trial", "Disabled", false, false,
+ },
+ };
+
+ for (const auto& test : tests) {
+ base::FieldTrialList field_trial_list(nullptr);
+ if (!test.trial_group_value.empty()) {
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
+ "DataReductionProxyServerExperiments", test.trial_group_value));
+ }
+
+ base::CommandLine::ForCurrentProcess()->InitFromArgv(0, NULL);
+ if (test.disable_flag_set) {
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kDataReductionProxyServerExperimentsDisabled, "");
+ }
+ EXPECT_EQ(test.expected, params::IsIncludedInServerExperimentsFieldTrial())
+ << test.test_case;
+ }
+}
+
+TEST_F(DataReductionProxyParamsTest, IsTamperDetectionEnabled) {
+ const struct {
+ std::string test_case;
+ std::string trial_group_value;
+ bool disable_flag_set;
+ bool expected;
+ } tests[] = {
+ {
+ "Field trial not set", "", false, false,
+ },
+ {
+ "Field trial not set, flag set", "", true, false,
+ },
+ {
+ "Enabled", "Enabled", false, false,
+ },
+ {
+ "TamperDetection_Enabled but disabled via flag",
+ "TamperDetection_Enabled", true, false,
+ },
+ {
+ "TamperDetection_Enabled", "TamperDetection_Enabled", false, true,
+ },
+ };
+
+ for (const auto& test : tests) {
+ base::FieldTrialList field_trial_list(nullptr);
+ if (!test.trial_group_value.empty()) {
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
+ "DataReductionProxyServerExperiments", test.trial_group_value));
+ }
+
+ base::CommandLine::ForCurrentProcess()->InitFromArgv(0, NULL);
+ if (test.disable_flag_set) {
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kDataReductionProxyServerExperimentsDisabled, "");
+ }
+ EXPECT_EQ(test.expected, params::IsIncludedInTamperDetectionExperiment())
+ << test.test_case;
+ }
+}
+
TEST_F(DataReductionProxyParamsTest, SecureProxyCheckDefault) {
struct {
bool command_line_set;

Powered by Google App Engine
This is Rietveld 408576698