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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_settings_unittest.cc

Issue 388663002: Added data reduction proxy holdback experiment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 5 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 unified diff | Download patch
« no previous file with comments | « components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h" 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/md5.h" 8 #include "base/md5.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 26 matching lines...) Expand all
37 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyOrigin) { 37 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyOrigin) {
38 // SetUp() adds the origin to the command line, which should be returned here. 38 // SetUp() adds the origin to the command line, which should be returned here.
39 std::string result = 39 std::string result =
40 settings_->params()->origin().spec(); 40 settings_->params()->origin().spec();
41 EXPECT_EQ(GURL(expected_params_->DefaultOrigin()), GURL(result)); 41 EXPECT_EQ(GURL(expected_params_->DefaultOrigin()), GURL(result));
42 } 42 }
43 43
44 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyDevOrigin) { 44 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxyDevOrigin) {
45 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 45 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
46 switches::kDataReductionProxyDev, expected_params_->DefaultDevOrigin()); 46 switches::kDataReductionProxyDev, expected_params_->DefaultDevOrigin());
47 ResetSettings(true, true, false, true); 47 ResetSettings(true, true, false, true, false);
48 std::string result = 48 std::string result =
49 settings_->params()->origin().spec(); 49 settings_->params()->origin().spec();
50 EXPECT_EQ(GURL(expected_params_->DefaultDevOrigin()), GURL(result)); 50 EXPECT_EQ(GURL(expected_params_->DefaultDevOrigin()), GURL(result));
51 } 51 }
52 52
53 53
54 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxies) { 54 TEST_F(DataReductionProxySettingsTest, TestGetDataReductionProxies) {
55 DataReductionProxyParams::DataReductionProxyList proxies = 55 DataReductionProxyParams::DataReductionProxyList proxies =
56 expected_params_->GetAllowedProxies(); 56 expected_params_->GetAllowedProxies();
57 57
(...skipping 18 matching lines...) Expand all
76 DataReductionProxyParams::kPromoAllowed, 76 DataReductionProxyParams::kPromoAllowed,
77 TestDataReductionProxyParams::HAS_EVERYTHING & 77 TestDataReductionProxyParams::HAS_EVERYTHING &
78 ~TestDataReductionProxyParams::HAS_DEV_ORIGIN); 78 ~TestDataReductionProxyParams::HAS_DEV_ORIGIN);
79 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 79 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
80 switches::kDataReductionProxyAlt, drp_params.DefaultAltOrigin()); 80 switches::kDataReductionProxyAlt, drp_params.DefaultAltOrigin());
81 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 81 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
82 switches::kDataReductionProxyAltFallback, 82 switches::kDataReductionProxyAltFallback,
83 drp_params.DefaultAltFallbackOrigin()); 83 drp_params.DefaultAltFallbackOrigin());
84 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 84 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
85 switches::kDataReductionSSLProxy, drp_params.DefaultSSLOrigin()); 85 switches::kDataReductionSSLProxy, drp_params.DefaultSSLOrigin());
86 ResetSettings(true, true, true, true); 86 ResetSettings(true, true, true, true, false);
87 TestDataReductionProxyConfig* config = 87 TestDataReductionProxyConfig* config =
88 static_cast<TestDataReductionProxyConfig*>( 88 static_cast<TestDataReductionProxyConfig*>(
89 settings_->configurator()); 89 settings_->configurator());
90 90
91 settings_->SetProxyConfigs(true, true, false, false); 91 settings_->SetProxyConfigs(true, true, false, false);
92 EXPECT_TRUE(config->enabled_); 92 EXPECT_TRUE(config->enabled_);
93 EXPECT_TRUE(net::HostPortPair::FromString( 93 EXPECT_TRUE(net::HostPortPair::FromString(
94 expected_params_->DefaultAltOrigin()).Equals( 94 expected_params_->DefaultAltOrigin()).Equals(
95 net::HostPortPair::FromString(config->origin_))); 95 net::HostPortPair::FromString(config->origin_)));
96 EXPECT_TRUE(net::HostPortPair::FromString( 96 EXPECT_TRUE(net::HostPortPair::FromString(
(...skipping 18 matching lines...) Expand all
115 EXPECT_EQ("", config->fallback_origin_); 115 EXPECT_EQ("", config->fallback_origin_);
116 EXPECT_EQ("", config->ssl_origin_); 116 EXPECT_EQ("", config->ssl_origin_);
117 117
118 settings_->SetProxyConfigs(false, false, false, false); 118 settings_->SetProxyConfigs(false, false, false, false);
119 EXPECT_FALSE(config->enabled_); 119 EXPECT_FALSE(config->enabled_);
120 EXPECT_EQ("", config->origin_); 120 EXPECT_EQ("", config->origin_);
121 EXPECT_EQ("", config->fallback_origin_); 121 EXPECT_EQ("", config->fallback_origin_);
122 EXPECT_EQ("", config->ssl_origin_); 122 EXPECT_EQ("", config->ssl_origin_);
123 } 123 }
124 124
125 TEST_F(DataReductionProxySettingsTest, TestSetProxyConfigsHoldback) {
126 ResetSettings(true, true, true, true, true);
127 TestDataReductionProxyConfig* config =
128 static_cast<TestDataReductionProxyConfig*>(
129 settings_->configurator());
130
131 // Holdback.
132 settings_->SetProxyConfigs(true, true, false, false);
133 EXPECT_FALSE(config->enabled_);
134 EXPECT_EQ("", config->origin_);
135 EXPECT_EQ("", config->fallback_origin_);
136 EXPECT_EQ("", config->ssl_origin_);
137 }
138
125 TEST_F(DataReductionProxySettingsTest, TestIsProxyEnabledOrManaged) { 139 TEST_F(DataReductionProxySettingsTest, TestIsProxyEnabledOrManaged) {
126 settings_->InitPrefMembers(); 140 settings_->InitPrefMembers();
127 base::MessageLoopForUI loop; 141 base::MessageLoopForUI loop;
128 // The proxy is disabled initially. 142 // The proxy is disabled initially.
129 settings_->enabled_by_user_ = false; 143 settings_->enabled_by_user_ = false;
130 settings_->SetProxyConfigs(false, false, false, false); 144 settings_->SetProxyConfigs(false, false, false, false);
131 145
132 EXPECT_FALSE(settings_->IsDataReductionProxyEnabled()); 146 EXPECT_FALSE(settings_->IsDataReductionProxyEnabled());
133 EXPECT_FALSE(settings_->IsDataReductionProxyManaged()); 147 EXPECT_FALSE(settings_->IsDataReductionProxyManaged());
134 148
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 403 }
390 } 404 }
391 405
392 TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) { 406 TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) {
393 // No call to |AddProxyToCommandLine()| was made, so the proxy feature 407 // No call to |AddProxyToCommandLine()| was made, so the proxy feature
394 // should be unavailable. 408 // should be unavailable.
395 base::MessageLoopForUI loop; 409 base::MessageLoopForUI loop;
396 // Clear the command line. Setting flags can force the proxy to be allowed. 410 // Clear the command line. Setting flags can force the proxy to be allowed.
397 CommandLine::ForCurrentProcess()->InitFromArgv(0, NULL); 411 CommandLine::ForCurrentProcess()->InitFromArgv(0, NULL);
398 412
399 ResetSettings(false, false, false, false); 413 ResetSettings(false, false, false, false, false);
400 MockSettings* settings = static_cast<MockSettings*>(settings_.get()); 414 MockSettings* settings = static_cast<MockSettings*>(settings_.get());
401 EXPECT_FALSE(settings->params()->allowed()); 415 EXPECT_FALSE(settings->params()->allowed());
402 EXPECT_CALL(*settings, RecordStartupState(PROXY_NOT_AVAILABLE)); 416 EXPECT_CALL(*settings, RecordStartupState(PROXY_NOT_AVAILABLE));
403 417
404 scoped_ptr<DataReductionProxyConfigurator> configurator( 418 scoped_ptr<DataReductionProxyConfigurator> configurator(
405 new TestDataReductionProxyConfig()); 419 new TestDataReductionProxyConfig());
406 settings_->SetProxyConfigurator(configurator.Pass()); 420 settings_->SetProxyConfigurator(configurator.Pass());
407 scoped_refptr<net::TestURLRequestContextGetter> request_context = 421 scoped_refptr<net::TestURLRequestContextGetter> request_context =
408 new net::TestURLRequestContextGetter(base::MessageLoopProxy::current()); 422 new net::TestURLRequestContextGetter(base::MessageLoopProxy::current());
409 settings_->InitDataReductionProxySettings(&pref_service_, 423 settings_->InitDataReductionProxySettings(&pref_service_,
410 &pref_service_, 424 &pref_service_,
411 request_context.get()); 425 request_context.get());
412 426
413 base::MessageLoop::current()->RunUntilIdle(); 427 base::MessageLoop::current()->RunUntilIdle();
414 } 428 }
415 429
416 } // namespace data_reduction_proxy 430 } // namespace data_reduction_proxy
OLDNEW
« no previous file with comments | « components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698