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

Side by Side Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data_unittest.cc

Issue 2922663002: Data Reduction Proxy: Remove duplicate functions (Closed)
Patch Set: megjablon comments Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/core/browser/data_reduction_proxy_io_d ata.h" 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 private: 96 private:
97 base::MessageLoopForIO loop_; 97 base::MessageLoopForIO loop_;
98 net::TestDelegate delegate_; 98 net::TestDelegate delegate_;
99 net::TestURLRequestContext context_; 99 net::TestURLRequestContext context_;
100 net::NetLog net_log_; 100 net::NetLog net_log_;
101 TestingPrefServiceSimple prefs_; 101 TestingPrefServiceSimple prefs_;
102 }; 102 };
103 103
104 TEST_F(DataReductionProxyIODataTest, TestConstruction) { 104 TEST_F(DataReductionProxyIODataTest, TestConstruction) {
105 std::unique_ptr<DataReductionProxyIOData> io_data( 105 std::unique_ptr<DataReductionProxyIOData> io_data(
106 new DataReductionProxyIOData(Client::UNKNOWN, 0, net_log(), task_runner(), 106 new DataReductionProxyIOData(Client::UNKNOWN, net_log(), task_runner(),
107 task_runner(), false /* enabled */, 107 task_runner(), false /* enabled */,
108 std::string() /* user_agent */, 108 std::string() /* user_agent */,
109 std::string() /* channel */)); 109 std::string() /* channel */));
110 110
111 // Check that the SimpleURLRequestContextGetter uses vanilla HTTP. 111 // Check that the SimpleURLRequestContextGetter uses vanilla HTTP.
112 net::URLRequestContext* request_context = 112 net::URLRequestContext* request_context =
113 io_data->basic_url_request_context_getter_.get()->GetURLRequestContext(); 113 io_data->basic_url_request_context_getter_.get()->GetURLRequestContext();
114 const net::HttpNetworkSession::Params* http_params = 114 const net::HttpNetworkSession::Params* http_params =
115 request_context->GetNetworkSessionParams(); 115 request_context->GetNetworkSessionParams();
116 EXPECT_FALSE(http_params->enable_http2); 116 EXPECT_FALSE(http_params->enable_http2);
(...skipping 29 matching lines...) Expand all
146 true); 146 true);
147 EXPECT_NE(nullptr, io_data->bypass_stats()); 147 EXPECT_NE(nullptr, io_data->bypass_stats());
148 148
149 io_data->ShutdownOnUIThread(); 149 io_data->ShutdownOnUIThread();
150 } 150 }
151 151
152 TEST_F(DataReductionProxyIODataTest, TestResetBadProxyListOnDisableDataSaver) { 152 TEST_F(DataReductionProxyIODataTest, TestResetBadProxyListOnDisableDataSaver) {
153 net::TestURLRequestContext context(false); 153 net::TestURLRequestContext context(false);
154 std::unique_ptr<DataReductionProxyTestContext> drp_test_context = 154 std::unique_ptr<DataReductionProxyTestContext> drp_test_context =
155 DataReductionProxyTestContext::Builder() 155 DataReductionProxyTestContext::Builder()
156 .WithParamsFlags(DataReductionProxyParams::kPromoAllowed)
157 .WithURLRequestContext(&context) 156 .WithURLRequestContext(&context)
158 .SkipSettingsInitialization() 157 .SkipSettingsInitialization()
159 .Build(); 158 .Build();
160 159
161 drp_test_context->SetDataReductionProxyEnabled(true); 160 drp_test_context->SetDataReductionProxyEnabled(true);
162 drp_test_context->InitSettings(); 161 drp_test_context->InitSettings();
163 DataReductionProxyIOData* io_data = drp_test_context->io_data(); 162 DataReductionProxyIOData* io_data = drp_test_context->io_data();
164 std::vector<net::ProxyServer> proxies; 163 std::vector<net::ProxyServer> proxies;
165 proxies.push_back(net::ProxyServer::FromURI("http://foo1.com", 164 proxies.push_back(net::ProxyServer::FromURI("http://foo1.com",
166 net::ProxyServer::SCHEME_HTTP)); 165 net::ProxyServer::SCHEME_HTTP));
(...skipping 17 matching lines...) Expand all
184 // Turn Data Saver off. 183 // Turn Data Saver off.
185 drp_test_context->settings()->SetDataReductionProxyEnabled(false); 184 drp_test_context->settings()->SetDataReductionProxyEnabled(false);
186 base::RunLoop().RunUntilIdle(); 185 base::RunLoop().RunUntilIdle();
187 186
188 // Verify that bad proxy list is empty. 187 // Verify that bad proxy list is empty.
189 EXPECT_EQ(0UL, bad_proxy_list.size()); 188 EXPECT_EQ(0UL, bad_proxy_list.size());
190 } 189 }
191 190
192 TEST_F(DataReductionProxyIODataTest, HoldbackConfiguresProxies) { 191 TEST_F(DataReductionProxyIODataTest, HoldbackConfiguresProxies) {
193 net::TestURLRequestContext context(false); 192 net::TestURLRequestContext context(false);
193 base::FieldTrialList field_trial_list(nullptr);
194 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
195 "DataCompressionProxyHoldback", "Enabled"));
194 std::unique_ptr<DataReductionProxyTestContext> drp_test_context = 196 std::unique_ptr<DataReductionProxyTestContext> drp_test_context =
195 DataReductionProxyTestContext::Builder() 197 DataReductionProxyTestContext::Builder()
196 .WithParamsFlags(DataReductionProxyParams::kPromoAllowed |
197 DataReductionProxyParams::kHoldback)
198 .WithURLRequestContext(&context) 198 .WithURLRequestContext(&context)
199 .SkipSettingsInitialization() 199 .SkipSettingsInitialization()
200 .Build(); 200 .Build();
201 201
202 EXPECT_TRUE(drp_test_context->test_params()->proxies_for_http().size() > 0); 202 EXPECT_TRUE(drp_test_context->test_params()->proxies_for_http().size() > 0);
203 EXPECT_FALSE(drp_test_context->test_params() 203 EXPECT_FALSE(drp_test_context->test_params()
204 ->proxies_for_http() 204 ->proxies_for_http()
205 .front() 205 .front()
206 .proxy_server() 206 .proxy_server()
207 .is_direct()); 207 .is_direct());
208 } 208 }
209 209
210 } // namespace data_reduction_proxy 210 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698