| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc
|
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc
|
| index e9fc3d1ffcca4f59094d706453795ab077619bec..0e952d7dc63dc1356f7009ec07722eafbfc825b7 100644
|
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc
|
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc
|
| @@ -4,11 +4,13 @@
|
|
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.h"
|
|
|
| +#include <map>
|
| #include <string>
|
| #include <vector>
|
|
|
| #include "base/command_line.h"
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/metrics/field_trial.h"
|
| #include "base/time/tick_clock.h"
|
| #include "base/values.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h"
|
| @@ -20,6 +22,7 @@
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h"
|
| #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
|
| #include "components/data_reduction_proxy/proto/client_config.pb.h"
|
| +#include "components/variations/variations_associated_data.h"
|
| #include "net/http/http_response_headers.h"
|
| #include "net/proxy/proxy_server.h"
|
| #include "net/socket/socket_test_util.h"
|
| @@ -68,6 +71,9 @@ const char kSerializedOrigin[] = "https://serialized.net:443";
|
| const char kSerializedFallback[] = "serialized.net:80";
|
| const char kSerializedSessionKey[] = "SerializedSessionKey";
|
|
|
| +const char kConfigServiceFieldTrial[] = "DataReductionProxyConfigService";
|
| +const char kConfigServiceURLParam[] = "url";
|
| +
|
| } // namespace
|
|
|
| namespace data_reduction_proxy {
|
| @@ -326,26 +332,81 @@ TEST_F(DataReductionProxyConfigServiceClientTest, ConfigDisabled) {
|
|
|
| TEST_F(DataReductionProxyConfigServiceClientTest, 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[] = {
|
| {
|
| - "", GURL(),
|
| + "Nothing set", "", "", GURL(),
|
| + },
|
| + {
|
| + "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/"),
|
| },
|
| {
|
| - "http://configservice.chrome-test.com",
|
| - GURL("http://configservice.chrome-test.com"),
|
| + "Command line precedence",
|
| + "http://commandline.config-service/",
|
| + "Enabled",
|
| + GURL("http://commandline.config-service/"),
|
| },
|
| };
|
|
|
| for (const auto& test : tests) {
|
| // Reset all flags.
|
| base::CommandLine::ForCurrentProcess()->InitFromArgv(0, NULL);
|
| - base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
| - switches::kDataReductionProxyConfigURL, test.flag_value);
|
| - EXPECT_EQ(test.expected,
|
| - DataReductionProxyConfigServiceClient::GetConfigServiceURL(
|
| - *base::CommandLine::ForCurrentProcess()));
|
| + if (!test.flag_value.empty()) {
|
| + 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, DataReductionProxyParams::GetConfigServiceURL())
|
| + << test.test_case;
|
| }
|
| }
|
|
|
|
|