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

Side by Side Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.cc

Issue 30883003: Simple fallback implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patched
Patch Set: Created 7 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.h" 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/prefs/testing_pref_service.h" 11 #include "base/prefs/testing_pref_service.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h" 13 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings.h"
14 #include "chrome/browser/prefs/proxy_prefs.h" 14 #include "chrome/browser/prefs/proxy_prefs.h"
15 #include "chrome/browser/prefs/scoped_user_pref_update.h" 15 #include "chrome/browser/prefs/scoped_user_pref_update.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/metrics/variations/variations_util.h" 17 #include "chrome/common/metrics/variations/variations_util.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "components/variations/entropy_provider.h" 19 #include "components/variations/entropy_provider.h"
20 #include "net/url_request/test_url_fetcher_factory.h" 20 #include "net/url_request/test_url_fetcher_factory.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "url/gurl.h" 22 #include "url/gurl.h"
23 23
24 const char kDataReductionProxyOrigin[] = "https://foo:443/"; 24 const char kDataReductionProxyOrigin[] = "https://foo:443/";
25 const char kDataReductionProxyOriginHostPort[] = "foo:443"; 25 const char kDataReductionProxyFallback[] = "http://bar:80";
26 const char kDataReductionProxyAuth[] = "12345"; 26 const char kDataReductionProxyAuth[] = "12345";
27 27
28 const char kProbeURLWithOKResponse[] = "http://ok.org/"; 28 const char kProbeURLWithOKResponse[] = "http://ok.org/";
29 const char kProbeURLWithBadResponse[] = "http://bad.org/"; 29 const char kProbeURLWithBadResponse[] = "http://bad.org/";
30 const char kProbeURLWithNoResponse[] = "http://no.org/"; 30 const char kProbeURLWithNoResponse[] = "http://no.org/";
31 31
32 class TestDataReductionProxySettings 32 class TestDataReductionProxySettings
33 : public DataReductionProxySettings { 33 : public DataReductionProxySettings {
34 public: 34 public:
35 TestDataReductionProxySettings(PrefService* profile_prefs, 35 TestDataReductionProxySettings(PrefService* profile_prefs,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 DataReductionProxySettingsTestBase::DataReductionProxySettingsTestBase() 83 DataReductionProxySettingsTestBase::DataReductionProxySettingsTestBase()
84 : testing::Test() { 84 : testing::Test() {
85 } 85 }
86 86
87 DataReductionProxySettingsTestBase::~DataReductionProxySettingsTestBase() {} 87 DataReductionProxySettingsTestBase::~DataReductionProxySettingsTestBase() {}
88 88
89 void DataReductionProxySettingsTestBase::AddProxyToCommandLine() { 89 void DataReductionProxySettingsTestBase::AddProxyToCommandLine() {
90 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 90 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
91 switches::kSpdyProxyAuthOrigin, kDataReductionProxyOrigin); 91 switches::kSpdyProxyAuthOrigin, kDataReductionProxyOrigin);
92 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 92 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
93 switches::kSpdyProxyAuthFallback, kDataReductionProxyFallback);
94 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
93 switches::kSpdyProxyAuthValue, kDataReductionProxyAuth); 95 switches::kSpdyProxyAuthValue, kDataReductionProxyAuth);
94 } 96 }
95 97
96 // testing::Test implementation: 98 // testing::Test implementation:
97 void DataReductionProxySettingsTestBase::SetUp() { 99 void DataReductionProxySettingsTestBase::SetUp() {
98 PrefRegistrySimple* registry = pref_service_.registry(); 100 PrefRegistrySimple* registry = pref_service_.registry();
99 registry->RegisterListPref(prefs::kDailyHttpOriginalContentLength); 101 registry->RegisterListPref(prefs::kDailyHttpOriginalContentLength);
100 registry->RegisterListPref(prefs::kDailyHttpReceivedContentLength); 102 registry->RegisterListPref(prefs::kDailyHttpReceivedContentLength);
101 registry->RegisterInt64Pref( 103 registry->RegisterInt64Pref(
102 prefs::kDailyHttpContentLengthLastUpdateDate, 0L); 104 prefs::kDailyHttpContentLengthLastUpdateDate, 0L);
(...skipping 24 matching lines...) Expand all
127 std::string server; 129 std::string server;
128 dict->GetString("mode", &mode); 130 dict->GetString("mode", &mode);
129 ASSERT_EQ(expected_mode, mode); 131 ASSERT_EQ(expected_mode, mode);
130 dict->GetString("server", &server); 132 dict->GetString("server", &server);
131 ASSERT_EQ(expected_servers, server); 133 ASSERT_EQ(expected_servers, server);
132 } 134 }
133 135
134 void DataReductionProxySettingsTestBase::CheckProxyConfigs( 136 void DataReductionProxySettingsTestBase::CheckProxyConfigs(
135 bool expected_enabled) { 137 bool expected_enabled) {
136 if (expected_enabled) { 138 if (expected_enabled) {
139 std::string main_proxy = kDataReductionProxyOrigin;
140 std::string fallback_proxy = kDataReductionProxyFallback;
137 std::string servers = 141 std::string servers =
138 "http=" + Settings()->GetDataReductionProxyOrigin() + ",direct://;"; 142 "http=" + main_proxy + "," + fallback_proxy + ",direct://;";
139 CheckProxyPref(servers, 143 CheckProxyPref(servers,
140 ProxyModeToString(ProxyPrefs::MODE_FIXED_SERVERS)); 144 ProxyModeToString(ProxyPrefs::MODE_FIXED_SERVERS));
141 } else { 145 } else {
142 CheckProxyPref(std::string(), ProxyModeToString(ProxyPrefs::MODE_SYSTEM)); 146 CheckProxyPref(std::string(), ProxyModeToString(ProxyPrefs::MODE_SYSTEM));
143 } 147 }
144 } 148 }
145 149
146 void DataReductionProxySettingsTestBase::CheckProbe(bool initially_enabled, 150 void DataReductionProxySettingsTestBase::CheckProbe(bool initially_enabled,
147 const std::string& probe_url, 151 const std::string& probe_url,
148 const std::string& response, 152 const std::string& response,
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 }; 414 };
411 415
412 ASSERT_EQ(settings_->bypass_rules_.size(), 6u); 416 ASSERT_EQ(settings_->bypass_rules_.size(), 6u);
413 int i = 0; 417 int i = 0;
414 for (std::vector<std::string>::iterator it = settings_->bypass_rules_.begin(); 418 for (std::vector<std::string>::iterator it = settings_->bypass_rules_.begin();
415 it != settings_->bypass_rules_.end(); ++it) { 419 it != settings_->bypass_rules_.end(); ++it) {
416 EXPECT_EQ(expected[i++], *it); 420 EXPECT_EQ(expected[i++], *it);
417 } 421 }
418 } 422 }
419 423
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698