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

Side by Side Diff: chrome/browser/io_thread_unittest.cc

Issue 1862193002: Enable QUIC for proxies only when QUIC is enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed sclittle comments Created 4 years, 7 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 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/test/mock_entropy_provider.h" 12 #include "base/test/mock_entropy_provider.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/io_thread.h" 14 #include "chrome/browser/io_thread.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h"
18 #include "components/policy/core/common/mock_policy_service.h" 17 #include "components/policy/core/common/mock_policy_service.h"
19 #include "components/prefs/pref_registry_simple.h" 18 #include "components/prefs/pref_registry_simple.h"
20 #include "components/prefs/pref_service.h" 19 #include "components/prefs/pref_service.h"
21 #include "components/prefs/testing_pref_service.h" 20 #include "components/prefs/testing_pref_service.h"
22 #include "components/proxy_config/pref_proxy_config_tracker_impl.h" 21 #include "components/proxy_config/pref_proxy_config_tracker_impl.h"
23 #include "components/proxy_config/proxy_config_pref_names.h" 22 #include "components/proxy_config/proxy_config_pref_names.h"
24 #include "components/variations/variations_associated_data.h" 23 #include "components/variations/variations_associated_data.h"
25 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
26 #include "content/public/test/test_browser_thread_bundle.h" 25 #include "content/public/test/test_browser_thread_bundle.h"
27 #include "net/cert_net/nss_ocsp.h" 26 #include "net/cert_net/nss_ocsp.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 EXPECT_EQ(0u, params_.testing_fixed_http_port); 88 EXPECT_EQ(0u, params_.testing_fixed_http_port);
90 EXPECT_EQ(0u, params_.testing_fixed_https_port); 89 EXPECT_EQ(0u, params_.testing_fixed_https_port);
91 EXPECT_FALSE(params_.enable_spdy31); 90 EXPECT_FALSE(params_.enable_spdy31);
92 EXPECT_TRUE(params_.enable_http2); 91 EXPECT_TRUE(params_.enable_http2);
93 EXPECT_FALSE(params_.enable_tcp_fast_open_for_ssl); 92 EXPECT_FALSE(params_.enable_tcp_fast_open_for_ssl);
94 EXPECT_TRUE(params_.parse_alternative_services); 93 EXPECT_TRUE(params_.parse_alternative_services);
95 EXPECT_FALSE(params_.enable_alternative_service_with_different_host); 94 EXPECT_FALSE(params_.enable_alternative_service_with_different_host);
96 EXPECT_FALSE(params_.enable_npn); 95 EXPECT_FALSE(params_.enable_npn);
97 EXPECT_TRUE(params_.enable_priority_dependencies); 96 EXPECT_TRUE(params_.enable_priority_dependencies);
98 EXPECT_FALSE(params_.enable_quic); 97 EXPECT_FALSE(params_.enable_quic);
99 EXPECT_FALSE(params_.enable_quic_for_proxies);
100 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy());
101 } 98 }
102 99
103 TEST_F(NetworkSessionConfiguratorTest, IgnoreCertificateErrors) { 100 TEST_F(NetworkSessionConfiguratorTest, IgnoreCertificateErrors) {
104 base::CommandLine::ForCurrentProcess()->AppendSwitch( 101 base::CommandLine::ForCurrentProcess()->AppendSwitch(
105 "ignore-certificate-errors"); 102 "ignore-certificate-errors");
106 103
107 ParseFieldTrialsAndCommandLine(); 104 ParseFieldTrialsAndCommandLine();
108 105
109 EXPECT_TRUE(params_.ignore_certificate_errors); 106 EXPECT_TRUE(params_.ignore_certificate_errors);
110 } 107 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 EXPECT_FALSE(params_.enable_priority_dependencies); 231 EXPECT_FALSE(params_.enable_priority_dependencies);
235 } 232 }
236 233
237 TEST_F(NetworkSessionConfiguratorTest, EnableQuicFromFieldTrialGroup) { 234 TEST_F(NetworkSessionConfiguratorTest, EnableQuicFromFieldTrialGroup) {
238 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); 235 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled");
239 236
240 ParseFieldTrials(); 237 ParseFieldTrials();
241 238
242 EXPECT_TRUE(params_.enable_quic); 239 EXPECT_TRUE(params_.enable_quic);
243 EXPECT_FALSE(params_.disable_quic_on_timeout_with_open_streams); 240 EXPECT_FALSE(params_.disable_quic_on_timeout_with_open_streams);
244 EXPECT_TRUE(params_.enable_quic_for_proxies);
245 EXPECT_EQ(1350u, params_.quic_max_packet_length); 241 EXPECT_EQ(1350u, params_.quic_max_packet_length);
246 EXPECT_EQ(net::QuicTagVector(), params_.quic_connection_options); 242 EXPECT_EQ(net::QuicTagVector(), params_.quic_connection_options);
247 EXPECT_FALSE(params_.quic_always_require_handshake_confirmation); 243 EXPECT_FALSE(params_.quic_always_require_handshake_confirmation);
248 EXPECT_FALSE(params_.quic_disable_connection_pooling); 244 EXPECT_FALSE(params_.quic_disable_connection_pooling);
249 EXPECT_EQ(0.25f, params_.quic_load_server_info_timeout_srtt_multiplier); 245 EXPECT_EQ(0.25f, params_.quic_load_server_info_timeout_srtt_multiplier);
250 EXPECT_FALSE(params_.quic_enable_connection_racing); 246 EXPECT_FALSE(params_.quic_enable_connection_racing);
251 EXPECT_FALSE(params_.quic_enable_non_blocking_io); 247 EXPECT_FALSE(params_.quic_enable_non_blocking_io);
252 EXPECT_FALSE(params_.quic_disable_disk_cache); 248 EXPECT_FALSE(params_.quic_disable_disk_cache);
253 EXPECT_FALSE(params_.quic_prefer_aes); 249 EXPECT_FALSE(params_.quic_prefer_aes);
254 EXPECT_TRUE(params_.parse_alternative_services); 250 EXPECT_TRUE(params_.parse_alternative_services);
255 EXPECT_FALSE(params_.enable_alternative_service_with_different_host); 251 EXPECT_FALSE(params_.enable_alternative_service_with_different_host);
256 EXPECT_EQ(0, params_.quic_max_number_of_lossy_connections); 252 EXPECT_EQ(0, params_.quic_max_number_of_lossy_connections);
257 EXPECT_EQ(1.0f, params_.quic_packet_loss_threshold); 253 EXPECT_EQ(1.0f, params_.quic_packet_loss_threshold);
258 EXPECT_FALSE(params_.quic_close_sessions_on_ip_change); 254 EXPECT_FALSE(params_.quic_close_sessions_on_ip_change);
259 EXPECT_EQ(net::kIdleConnectionTimeoutSeconds, 255 EXPECT_EQ(net::kIdleConnectionTimeoutSeconds,
260 params_.quic_idle_connection_timeout_seconds); 256 params_.quic_idle_connection_timeout_seconds);
261 EXPECT_FALSE(params_.quic_disable_preconnect_if_0rtt); 257 EXPECT_FALSE(params_.quic_disable_preconnect_if_0rtt);
262 EXPECT_FALSE(params_.quic_migrate_sessions_on_network_change); 258 EXPECT_FALSE(params_.quic_migrate_sessions_on_network_change);
263 EXPECT_FALSE(params_.quic_migrate_sessions_early); 259 EXPECT_FALSE(params_.quic_migrate_sessions_early);
264 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy());
265 EXPECT_TRUE(params_.quic_host_whitelist.empty()); 260 EXPECT_TRUE(params_.quic_host_whitelist.empty());
266 261
267 net::HttpNetworkSession::Params default_params; 262 net::HttpNetworkSession::Params default_params;
268 EXPECT_EQ(default_params.quic_supported_versions, 263 EXPECT_EQ(default_params.quic_supported_versions,
269 params_.quic_supported_versions); 264 params_.quic_supported_versions);
270 } 265 }
271 266
272 TEST_F(NetworkSessionConfiguratorTest, 267 TEST_F(NetworkSessionConfiguratorTest,
273 DisableQuicWhenConnectionTimesOutWithOpenStreamsFromFieldTrialParams) { 268 DisableQuicWhenConnectionTimesOutWithOpenStreamsFromFieldTrialParams) {
274 std::map<std::string, std::string> field_trial_params; 269 std::map<std::string, std::string> field_trial_params;
275 field_trial_params["disable_quic_on_timeout_with_open_streams"] = "true"; 270 field_trial_params["disable_quic_on_timeout_with_open_streams"] = "true";
276 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); 271 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params);
277 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); 272 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled");
278 273
279 ParseFieldTrials(); 274 ParseFieldTrials();
280 275
281 EXPECT_TRUE(params_.disable_quic_on_timeout_with_open_streams); 276 EXPECT_TRUE(params_.disable_quic_on_timeout_with_open_streams);
282 } 277 }
283 278
284 TEST_F(NetworkSessionConfiguratorTest, EnableQuicFromQuicProxyFieldTrialGroup) {
285 const struct {
286 std::string field_trial_group_name;
287 bool expect_enable_quic;
288 } tests[] = {
289 {
290 std::string(), false,
291 },
292 {
293 "NotEnabled", false,
294 },
295 {
296 "Control", false,
297 },
298 {
299 "Disabled", false,
300 },
301 {
302 "EnabledControl", true,
303 },
304 {
305 "Enabled", true,
306 },
307 };
308
309 field_trial_list_.reset();
310 for (size_t i = 0; i < arraysize(tests); ++i) {
311 base::FieldTrialList field_trial_list(new base::MockEntropyProvider());
312 base::FieldTrialList::CreateFieldTrial(
313 data_reduction_proxy::params::GetQuicFieldTrialName(),
314 tests[i].field_trial_group_name);
315
316 ParseFieldTrials();
317
318 EXPECT_FALSE(params_.enable_quic) << i;
319 EXPECT_EQ(tests[i].expect_enable_quic, params_.enable_quic_for_proxies)
320 << i;
321 EXPECT_EQ(tests[i].expect_enable_quic,
322 IOThread::ShouldEnableQuicForDataReductionProxy())
323 << i;
324 }
325 }
326
327 TEST_F(NetworkSessionConfiguratorTest, EnableQuicFromCommandLine) { 279 TEST_F(NetworkSessionConfiguratorTest, EnableQuicFromCommandLine) {
328 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); 280 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic");
329 281
330 ParseFieldTrialsAndCommandLine(); 282 ParseFieldTrialsAndCommandLine();
331 283
332 EXPECT_TRUE(params_.enable_quic); 284 EXPECT_TRUE(params_.enable_quic);
333 EXPECT_TRUE(params_.enable_quic_for_proxies);
334 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy());
335 } 285 }
336 286
337 TEST_F(NetworkSessionConfiguratorTest, 287 TEST_F(NetworkSessionConfiguratorTest,
338 EnableAlternativeServicesFromCommandLineWithQuicDisabled) { 288 EnableAlternativeServicesFromCommandLineWithQuicDisabled) {
339 base::CommandLine::ForCurrentProcess()->AppendSwitch( 289 base::CommandLine::ForCurrentProcess()->AppendSwitch(
340 "enable-alternative-services"); 290 "enable-alternative-services");
341 291
342 ParseFieldTrialsAndCommandLine(); 292 ParseFieldTrialsAndCommandLine();
343 293
344 EXPECT_FALSE(params_.enable_quic); 294 EXPECT_FALSE(params_.enable_quic);
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType, 814 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType,
865 base::Unretained(this), "acc1")); 815 base::Unretained(this), "acc1"));
866 pref_service()->SetString(prefs::kAuthAndroidNegotiateAccountType, "acc2"); 816 pref_service()->SetString(prefs::kAuthAndroidNegotiateAccountType, "acc2");
867 RunOnIOThreadBlocking(base::Bind( 817 RunOnIOThreadBlocking(base::Bind(
868 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType, 818 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType,
869 base::Unretained(this), "acc2")); 819 base::Unretained(this), "acc2"));
870 } 820 }
871 #endif 821 #endif
872 822
873 } // namespace test 823 } // namespace test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698