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

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

Issue 1839783002: Revert of Enable DRP config service by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 cbc77cd072dbdc591d9a7be23b32db8bd5931487..b668207a6d411314dfe7c6d6387a6ce673404179 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
@@ -19,6 +19,13 @@
#include "net/proxy/proxy_server.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+const char kConfigServiceFieldTrial[] = "DataReductionProxyConfigService";
+const char kConfigServiceURLParam[] = "url";
+
+} // namespace
namespace data_reduction_proxy {
class DataReductionProxyParamsTest : public testing::Test {
@@ -229,6 +236,52 @@
"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, params::IsConfigClientEnabled()) << test.test_case;
+ }
+}
+
TEST_F(DataReductionProxyParamsTest, SecureProxyCheckDefault) {
struct {
bool command_line_set;
@@ -375,17 +428,58 @@
TEST_F(DataReductionProxyParamsTest, GetConfigServiceURL) {
const struct {
+ std::string trial_group_value;
+ std::string trial_url_param;
+ } variations[] = {
+ {
+ "Enabled", "http://enabled.config-service/",
+ },
+ {
+ "Disabled", "http://disabled.config-service/",
+ },
+ {
+ "EnabledOther", "http://other.config-service/",
+ },
+ };
+
+ variations::testing::ClearAllVariationParams();
+ for (const auto& variation : variations) {
+ std::map<std::string, std::string> variation_params;
+ variation_params[kConfigServiceURLParam] = variation.trial_url_param;
+ ASSERT_TRUE(variations::AssociateVariationParams(
+ kConfigServiceFieldTrial, variation.trial_group_value,
+ variation_params));
+ }
+
+ const struct {
std::string test_case;
std::string flag_value;
+ std::string trial_group_value;
GURL expected;
} tests[] = {
{
- "Nothing set", "",
+ "Nothing set", "", "",
GURL("https://datasaver.googleapis.com/v1/clientConfigs"),
},
{
- "Only command line set", "http://commandline.config-service/",
+ "Only command line set", "http://commandline.config-service/", "",
GURL("http://commandline.config-service/"),
+ },
+ {
+ "Enabled group", "", "Enabled",
+ GURL("http://enabled.config-service/"),
+ },
+ {
+ "Disabled group", "", "Disabled",
+ GURL("http://disabled.config-service/"),
+ },
+ {
+ "Alternate enabled group", "", "EnabledOther",
+ GURL("http://other.config-service/"),
+ },
+ {
+ "Command line precedence", "http://commandline.config-service/",
+ "Enabled", GURL("http://commandline.config-service/"),
},
};
@@ -396,6 +490,11 @@
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kDataReductionProxyConfigURL, test.flag_value);
}
+ base::FieldTrialList field_trial_list(nullptr);
+ if (!test.trial_group_value.empty()) {
+ base::FieldTrialList::CreateFieldTrial(kConfigServiceFieldTrial,
+ test.trial_group_value);
+ }
EXPECT_EQ(test.expected, params::GetConfigServiceURL()) << test.test_case;
}
}

Powered by Google App Engine
This is Rietveld 408576698