OLD | NEW |
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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 using ::testing::ReturnRef; | 47 using ::testing::ReturnRef; |
48 | 48 |
49 // Class used for accessing IOThread methods (friend of IOThread). | 49 // Class used for accessing IOThread methods (friend of IOThread). |
50 class IOThreadPeer { | 50 class IOThreadPeer { |
51 public: | 51 public: |
52 static net::HttpAuthPreferences* GetAuthPreferences(IOThread* io_thread) { | 52 static net::HttpAuthPreferences* GetAuthPreferences(IOThread* io_thread) { |
53 return io_thread->globals()->http_auth_preferences.get(); | 53 return io_thread->globals()->http_auth_preferences.get(); |
54 } | 54 } |
55 }; | 55 }; |
56 | 56 |
57 class NetworkSessionConfiguratorTest : public testing::Test { | |
58 public: | |
59 NetworkSessionConfiguratorTest() | |
60 : is_spdy_allowed_by_policy_(true), is_quic_allowed_by_policy_(true) { | |
61 field_trial_list_.reset( | |
62 new base::FieldTrialList(new base::MockEntropyProvider())); | |
63 variations::testing::ClearAllVariationParams(); | |
64 } | |
65 | |
66 void ParseFieldTrials() { | |
67 network_session_configurator_.ParseFieldTrials( | |
68 is_spdy_allowed_by_policy_, is_quic_allowed_by_policy_, ¶ms_); | |
69 } | |
70 | |
71 void ParseFieldTrialsAndCommandLine() { | |
72 network_session_configurator_.ParseFieldTrialsAndCommandLine( | |
73 is_spdy_allowed_by_policy_, is_quic_allowed_by_policy_, ¶ms_); | |
74 } | |
75 | |
76 bool is_spdy_allowed_by_policy_; | |
77 bool is_quic_allowed_by_policy_; | |
78 std::unique_ptr<base::FieldTrialList> field_trial_list_; | |
79 net::HttpNetworkSession::Params params_; | |
80 | |
81 private: | |
82 IOThread::NetworkSessionConfigurator network_session_configurator_; | |
83 }; | |
84 | |
85 TEST_F(NetworkSessionConfiguratorTest, Defaults) { | |
86 ParseFieldTrialsAndCommandLine(); | |
87 | |
88 EXPECT_FALSE(params_.ignore_certificate_errors); | |
89 EXPECT_EQ(0u, params_.testing_fixed_http_port); | |
90 EXPECT_EQ(0u, params_.testing_fixed_https_port); | |
91 EXPECT_FALSE(params_.enable_spdy31); | |
92 EXPECT_TRUE(params_.enable_http2); | |
93 EXPECT_FALSE(params_.enable_tcp_fast_open_for_ssl); | |
94 EXPECT_FALSE(params_.parse_alternative_services); | |
95 EXPECT_FALSE(params_.enable_alternative_service_with_different_host); | |
96 EXPECT_FALSE(params_.enable_npn); | |
97 EXPECT_TRUE(params_.enable_priority_dependencies); | |
98 EXPECT_FALSE(params_.enable_quic); | |
99 EXPECT_FALSE(params_.enable_quic_for_proxies); | |
100 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); | |
101 } | |
102 | |
103 TEST_F(NetworkSessionConfiguratorTest, IgnoreCertificateErrors) { | |
104 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
105 "ignore-certificate-errors"); | |
106 | |
107 ParseFieldTrialsAndCommandLine(); | |
108 | |
109 EXPECT_TRUE(params_.ignore_certificate_errors); | |
110 } | |
111 | |
112 TEST_F(NetworkSessionConfiguratorTest, TestingFixedPort) { | |
113 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
114 "testing-fixed-http-port", "42"); | |
115 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
116 "testing-fixed-https-port", "1234"); | |
117 | |
118 ParseFieldTrialsAndCommandLine(); | |
119 | |
120 EXPECT_EQ(42u, params_.testing_fixed_http_port); | |
121 EXPECT_EQ(1234u, params_.testing_fixed_https_port); | |
122 } | |
123 | |
124 TEST_F(NetworkSessionConfiguratorTest, AltSvcFieldTrialEnabled) { | |
125 base::FieldTrialList::CreateFieldTrial("ParseAltSvc", "AltSvcEnabled"); | |
126 | |
127 ParseFieldTrials(); | |
128 | |
129 EXPECT_TRUE(params_.parse_alternative_services); | |
130 EXPECT_FALSE(params_.enable_alternative_service_with_different_host); | |
131 } | |
132 | |
133 TEST_F(NetworkSessionConfiguratorTest, AltSvcFieldTrialDisabled) { | |
134 base::FieldTrialList::CreateFieldTrial("ParseAltSvc", "AltSvcDisabled"); | |
135 | |
136 ParseFieldTrials(); | |
137 | |
138 EXPECT_FALSE(params_.parse_alternative_services); | |
139 EXPECT_FALSE(params_.enable_alternative_service_with_different_host); | |
140 } | |
141 | |
142 TEST_F(NetworkSessionConfiguratorTest, SpdyFieldTrialHoldbackEnabled) { | |
143 net::HttpStreamFactory::set_spdy_enabled(true); | |
144 base::FieldTrialList::CreateFieldTrial("SPDY", "SpdyDisabled"); | |
145 | |
146 ParseFieldTrials(); | |
147 | |
148 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled()); | |
149 } | |
150 | |
151 TEST_F(NetworkSessionConfiguratorTest, SpdyFieldTrialSpdy31Enabled) { | |
152 base::FieldTrialList::CreateFieldTrial("SPDY", "Spdy31Enabled"); | |
153 | |
154 ParseFieldTrials(); | |
155 | |
156 EXPECT_TRUE(params_.enable_spdy31); | |
157 EXPECT_FALSE(params_.enable_http2); | |
158 } | |
159 | |
160 TEST_F(NetworkSessionConfiguratorTest, SpdyFieldTrialSpdy4Enabled) { | |
161 base::FieldTrialList::CreateFieldTrial("SPDY", "Spdy4Enabled"); | |
162 | |
163 ParseFieldTrials(); | |
164 | |
165 EXPECT_TRUE(params_.enable_spdy31); | |
166 EXPECT_TRUE(params_.enable_http2); | |
167 } | |
168 | |
169 TEST_F(NetworkSessionConfiguratorTest, SpdyFieldTrialParametrized) { | |
170 std::map<std::string, std::string> field_trial_params; | |
171 field_trial_params["enable_spdy31"] = "false"; | |
172 field_trial_params["enable_http2"] = "true"; | |
173 variations::AssociateVariationParams("SPDY", "ParametrizedHTTP2Only", | |
174 field_trial_params); | |
175 base::FieldTrialList::CreateFieldTrial("SPDY", "ParametrizedHTTP2Only"); | |
176 | |
177 ParseFieldTrials(); | |
178 | |
179 EXPECT_FALSE(params_.enable_spdy31); | |
180 EXPECT_TRUE(params_.enable_http2); | |
181 } | |
182 | |
183 TEST_F(NetworkSessionConfiguratorTest, SpdyCommandLineDisableHttp2) { | |
184 // Command line should overwrite field trial group. | |
185 base::CommandLine::ForCurrentProcess()->AppendSwitch("disable-http2"); | |
186 base::FieldTrialList::CreateFieldTrial("SPDY", "Spdy4Enabled"); | |
187 | |
188 ParseFieldTrialsAndCommandLine(); | |
189 | |
190 EXPECT_FALSE(params_.enable_spdy31); | |
191 EXPECT_FALSE(params_.enable_http2); | |
192 } | |
193 | |
194 TEST_F(NetworkSessionConfiguratorTest, SpdyDisallowedByPolicy) { | |
195 is_spdy_allowed_by_policy_ = false; | |
196 | |
197 ParseFieldTrialsAndCommandLine(); | |
198 | |
199 EXPECT_FALSE(params_.enable_spdy31); | |
200 EXPECT_FALSE(params_.enable_http2); | |
201 } | |
202 | |
203 TEST_F(NetworkSessionConfiguratorTest, NPNFieldTrialEnabled) { | |
204 base::FieldTrialList::CreateFieldTrial("NPN", "Enable-experiment"); | |
205 | |
206 ParseFieldTrials(); | |
207 | |
208 EXPECT_TRUE(params_.enable_npn); | |
209 } | |
210 | |
211 TEST_F(NetworkSessionConfiguratorTest, NPNFieldTrialDisabled) { | |
212 base::FieldTrialList::CreateFieldTrial("NPN", "Disable-holdback"); | |
213 | |
214 ParseFieldTrials(); | |
215 | |
216 EXPECT_FALSE(params_.enable_npn); | |
217 } | |
218 | |
219 TEST_F(NetworkSessionConfiguratorTest, PriorityDependenciesTrialEnabled) { | |
220 base::FieldTrialList::CreateFieldTrial("SpdyEnableDependencies", | |
221 "Enable-experiment"); | |
222 | |
223 ParseFieldTrials(); | |
224 | |
225 EXPECT_TRUE(params_.enable_priority_dependencies); | |
226 } | |
227 | |
228 TEST_F(NetworkSessionConfiguratorTest, PriorityDependenciesTrialDisabled) { | |
229 base::FieldTrialList::CreateFieldTrial("SpdyEnableDependencies", | |
230 "Disable-holdback"); | |
231 | |
232 ParseFieldTrials(); | |
233 | |
234 EXPECT_FALSE(params_.enable_priority_dependencies); | |
235 } | |
236 | |
237 TEST_F(NetworkSessionConfiguratorTest, EnableQuicFromFieldTrialGroup) { | |
238 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
239 | |
240 ParseFieldTrials(); | |
241 | |
242 EXPECT_TRUE(params_.enable_quic); | |
243 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); | |
246 EXPECT_EQ(net::QuicTagVector(), params_.quic_connection_options); | |
247 EXPECT_FALSE(params_.quic_always_require_handshake_confirmation); | |
248 EXPECT_FALSE(params_.quic_disable_connection_pooling); | |
249 EXPECT_EQ(0.25f, params_.quic_load_server_info_timeout_srtt_multiplier); | |
250 EXPECT_FALSE(params_.quic_enable_connection_racing); | |
251 EXPECT_FALSE(params_.quic_enable_non_blocking_io); | |
252 EXPECT_FALSE(params_.quic_disable_disk_cache); | |
253 EXPECT_FALSE(params_.quic_prefer_aes); | |
254 EXPECT_FALSE(params_.parse_alternative_services); | |
255 EXPECT_FALSE(params_.enable_alternative_service_with_different_host); | |
256 EXPECT_EQ(0, params_.quic_max_number_of_lossy_connections); | |
257 EXPECT_EQ(1.0f, params_.quic_packet_loss_threshold); | |
258 EXPECT_FALSE(params_.quic_close_sessions_on_ip_change); | |
259 EXPECT_EQ(net::kIdleConnectionTimeoutSeconds, | |
260 params_.quic_idle_connection_timeout_seconds); | |
261 EXPECT_FALSE(params_.quic_disable_preconnect_if_0rtt); | |
262 EXPECT_FALSE(params_.quic_migrate_sessions_on_network_change); | |
263 EXPECT_FALSE(params_.quic_migrate_sessions_early); | |
264 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); | |
265 EXPECT_TRUE(params_.quic_host_whitelist.empty()); | |
266 | |
267 net::HttpNetworkSession::Params default_params; | |
268 EXPECT_EQ(default_params.quic_supported_versions, | |
269 params_.quic_supported_versions); | |
270 } | |
271 | |
272 TEST_F(NetworkSessionConfiguratorTest, | |
273 DisableQuicWhenConnectionTimesOutWithOpenStreamsFromFieldTrialParams) { | |
274 std::map<std::string, std::string> field_trial_params; | |
275 field_trial_params["disable_quic_on_timeout_with_open_streams"] = "true"; | |
276 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
277 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
278 | |
279 ParseFieldTrials(); | |
280 | |
281 EXPECT_TRUE(params_.disable_quic_on_timeout_with_open_streams); | |
282 } | |
283 | |
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) { | |
328 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
329 | |
330 ParseFieldTrialsAndCommandLine(); | |
331 | |
332 EXPECT_TRUE(params_.enable_quic); | |
333 EXPECT_TRUE(params_.enable_quic_for_proxies); | |
334 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); | |
335 } | |
336 | |
337 TEST_F(NetworkSessionConfiguratorTest, | |
338 EnableAlternativeServicesFromCommandLineWithQuicDisabled) { | |
339 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
340 "enable-alternative-services"); | |
341 | |
342 ParseFieldTrialsAndCommandLine(); | |
343 | |
344 EXPECT_FALSE(params_.enable_quic); | |
345 EXPECT_TRUE(params_.parse_alternative_services); | |
346 EXPECT_TRUE(params_.enable_alternative_service_with_different_host); | |
347 } | |
348 | |
349 TEST_F(NetworkSessionConfiguratorTest, | |
350 EnableAlternativeServicesFromCommandLineWithQuicEnabled) { | |
351 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
352 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
353 "enable-alternative-services"); | |
354 | |
355 ParseFieldTrialsAndCommandLine(); | |
356 | |
357 EXPECT_TRUE(params_.enable_quic); | |
358 EXPECT_TRUE(params_.parse_alternative_services); | |
359 EXPECT_TRUE(params_.enable_alternative_service_with_different_host); | |
360 } | |
361 | |
362 TEST_F(NetworkSessionConfiguratorTest, PacketLengthFromCommandLine) { | |
363 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
364 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
365 "quic-max-packet-length", "1450"); | |
366 | |
367 ParseFieldTrialsAndCommandLine(); | |
368 | |
369 EXPECT_EQ(1450u, params_.quic_max_packet_length); | |
370 } | |
371 | |
372 TEST_F(NetworkSessionConfiguratorTest, | |
373 QuicCloseSessionsOnIpChangeFromFieldTrialParams) { | |
374 std::map<std::string, std::string> field_trial_params; | |
375 field_trial_params["close_sessions_on_ip_change"] = "true"; | |
376 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
377 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
378 | |
379 ParseFieldTrials(); | |
380 | |
381 EXPECT_TRUE(params_.quic_close_sessions_on_ip_change); | |
382 } | |
383 | |
384 TEST_F(NetworkSessionConfiguratorTest, | |
385 QuicIdleConnectionTimeoutSecondsFieldTrialParams) { | |
386 std::map<std::string, std::string> field_trial_params; | |
387 field_trial_params["idle_connection_timeout_seconds"] = "300"; | |
388 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
389 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
390 | |
391 ParseFieldTrials(); | |
392 | |
393 EXPECT_EQ(300, params_.quic_idle_connection_timeout_seconds); | |
394 } | |
395 | |
396 TEST_F(NetworkSessionConfiguratorTest, QuicDisablePreConnectIfZeroRtt) { | |
397 std::map<std::string, std::string> field_trial_params; | |
398 field_trial_params["disable_preconnect_if_0rtt"] = "true"; | |
399 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
400 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
401 | |
402 ParseFieldTrials(); | |
403 | |
404 EXPECT_TRUE(params_.quic_disable_preconnect_if_0rtt); | |
405 } | |
406 | |
407 TEST_F(NetworkSessionConfiguratorTest, | |
408 QuicMigrateSessionsOnNetworkChangeFromFieldTrialParams) { | |
409 std::map<std::string, std::string> field_trial_params; | |
410 field_trial_params["migrate_sessions_on_network_change"] = "true"; | |
411 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
412 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
413 | |
414 ParseFieldTrials(); | |
415 | |
416 EXPECT_TRUE(params_.quic_migrate_sessions_on_network_change); | |
417 } | |
418 | |
419 TEST_F(NetworkSessionConfiguratorTest, | |
420 QuicMigrateSessionsEarlyFromFieldTrialParams) { | |
421 std::map<std::string, std::string> field_trial_params; | |
422 field_trial_params["migrate_sessions_early"] = "true"; | |
423 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
424 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
425 | |
426 ParseFieldTrials(); | |
427 | |
428 EXPECT_TRUE(params_.quic_migrate_sessions_early); | |
429 } | |
430 | |
431 TEST_F(NetworkSessionConfiguratorTest, PacketLengthFromFieldTrialParams) { | |
432 std::map<std::string, std::string> field_trial_params; | |
433 field_trial_params["max_packet_length"] = "1450"; | |
434 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
435 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
436 | |
437 ParseFieldTrials(); | |
438 | |
439 EXPECT_EQ(1450u, params_.quic_max_packet_length); | |
440 } | |
441 | |
442 TEST_F(NetworkSessionConfiguratorTest, QuicVersionFromCommandLine) { | |
443 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
444 std::string version = | |
445 net::QuicVersionToString(net::QuicSupportedVersions().back()); | |
446 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII("quic-version", | |
447 version); | |
448 | |
449 ParseFieldTrialsAndCommandLine(); | |
450 | |
451 net::QuicVersionVector supported_versions; | |
452 supported_versions.push_back(net::QuicSupportedVersions().back()); | |
453 EXPECT_EQ(supported_versions, params_.quic_supported_versions); | |
454 } | |
455 | |
456 TEST_F(NetworkSessionConfiguratorTest, QuicVersionFromFieldTrialParams) { | |
457 std::map<std::string, std::string> field_trial_params; | |
458 field_trial_params["quic_version"] = | |
459 net::QuicVersionToString(net::QuicSupportedVersions().back()); | |
460 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
461 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
462 | |
463 ParseFieldTrials(); | |
464 | |
465 net::QuicVersionVector supported_versions; | |
466 supported_versions.push_back(net::QuicSupportedVersions().back()); | |
467 EXPECT_EQ(supported_versions, params_.quic_supported_versions); | |
468 } | |
469 | |
470 TEST_F(NetworkSessionConfiguratorTest, QuicConnectionOptionsFromCommandLine) { | |
471 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
472 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
473 "quic-connection-options", "TIME,TBBR,REJ"); | |
474 | |
475 ParseFieldTrialsAndCommandLine(); | |
476 | |
477 net::QuicTagVector options; | |
478 options.push_back(net::kTIME); | |
479 options.push_back(net::kTBBR); | |
480 options.push_back(net::kREJ); | |
481 EXPECT_EQ(options, params_.quic_connection_options); | |
482 } | |
483 | |
484 TEST_F(NetworkSessionConfiguratorTest, | |
485 QuicConnectionOptionsFromFieldTrialParams) { | |
486 std::map<std::string, std::string> field_trial_params; | |
487 field_trial_params["connection_options"] = "TIME,TBBR,REJ"; | |
488 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
489 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
490 | |
491 ParseFieldTrials(); | |
492 | |
493 net::QuicTagVector options; | |
494 options.push_back(net::kTIME); | |
495 options.push_back(net::kTBBR); | |
496 options.push_back(net::kREJ); | |
497 EXPECT_EQ(options, params_.quic_connection_options); | |
498 } | |
499 | |
500 TEST_F(NetworkSessionConfiguratorTest, | |
501 QuicAlwaysRequireHandshakeConfirmationFromFieldTrialParams) { | |
502 std::map<std::string, std::string> field_trial_params; | |
503 field_trial_params["always_require_handshake_confirmation"] = "true"; | |
504 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
505 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
506 | |
507 ParseFieldTrials(); | |
508 | |
509 EXPECT_TRUE(params_.quic_always_require_handshake_confirmation); | |
510 } | |
511 | |
512 TEST_F(NetworkSessionConfiguratorTest, | |
513 QuicDisableConnectionPoolingFromFieldTrialParams) { | |
514 std::map<std::string, std::string> field_trial_params; | |
515 field_trial_params["disable_connection_pooling"] = "true"; | |
516 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
517 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
518 | |
519 ParseFieldTrials(); | |
520 | |
521 EXPECT_TRUE(params_.quic_disable_connection_pooling); | |
522 } | |
523 | |
524 TEST_F(NetworkSessionConfiguratorTest, | |
525 QuicLoadServerInfoTimeToSmoothedRttFromFieldTrialParams) { | |
526 std::map<std::string, std::string> field_trial_params; | |
527 field_trial_params["load_server_info_time_to_srtt"] = "0.5"; | |
528 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
529 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
530 | |
531 ParseFieldTrials(); | |
532 | |
533 EXPECT_EQ(0.5f, params_.quic_load_server_info_timeout_srtt_multiplier); | |
534 } | |
535 | |
536 TEST_F(NetworkSessionConfiguratorTest, QuicEnableConnectionRacing) { | |
537 std::map<std::string, std::string> field_trial_params; | |
538 field_trial_params["enable_connection_racing"] = "true"; | |
539 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
540 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
541 | |
542 ParseFieldTrials(); | |
543 | |
544 EXPECT_TRUE(params_.quic_enable_connection_racing); | |
545 } | |
546 | |
547 TEST_F(NetworkSessionConfiguratorTest, QuicEnableNonBlockingIO) { | |
548 std::map<std::string, std::string> field_trial_params; | |
549 field_trial_params["enable_non_blocking_io"] = "true"; | |
550 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
551 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
552 | |
553 ParseFieldTrials(); | |
554 | |
555 EXPECT_TRUE(params_.quic_enable_non_blocking_io); | |
556 } | |
557 | |
558 TEST_F(NetworkSessionConfiguratorTest, QuicDisableDiskCache) { | |
559 std::map<std::string, std::string> field_trial_params; | |
560 field_trial_params["disable_disk_cache"] = "true"; | |
561 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
562 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
563 | |
564 ParseFieldTrials(); | |
565 | |
566 EXPECT_TRUE(params_.quic_disable_disk_cache); | |
567 } | |
568 | |
569 TEST_F(NetworkSessionConfiguratorTest, QuicPreferAes) { | |
570 std::map<std::string, std::string> field_trial_params; | |
571 field_trial_params["prefer_aes"] = "true"; | |
572 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
573 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
574 | |
575 ParseFieldTrials(); | |
576 | |
577 EXPECT_TRUE(params_.quic_prefer_aes); | |
578 } | |
579 | |
580 TEST_F(NetworkSessionConfiguratorTest, | |
581 QuicEnableAlternativeServicesFromFieldTrialParams) { | |
582 std::map<std::string, std::string> field_trial_params; | |
583 field_trial_params["enable_alternative_service_with_different_host"] = "true"; | |
584 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
585 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
586 | |
587 ParseFieldTrials(); | |
588 | |
589 EXPECT_TRUE(params_.enable_alternative_service_with_different_host); | |
590 // QUIC AltSvc pooling parameter should also enable AltSvc parsing. | |
591 EXPECT_TRUE(params_.parse_alternative_services); | |
592 } | |
593 | |
594 TEST_F(NetworkSessionConfiguratorTest, | |
595 QuicMaxNumberOfLossyConnectionsFieldTrialParams) { | |
596 std::map<std::string, std::string> field_trial_params; | |
597 field_trial_params["max_number_of_lossy_connections"] = "5"; | |
598 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
599 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
600 | |
601 ParseFieldTrials(); | |
602 | |
603 EXPECT_EQ(5, params_.quic_max_number_of_lossy_connections); | |
604 } | |
605 | |
606 TEST_F(NetworkSessionConfiguratorTest, | |
607 QuicPacketLossThresholdFieldTrialParams) { | |
608 std::map<std::string, std::string> field_trial_params; | |
609 field_trial_params["packet_loss_threshold"] = "0.5"; | |
610 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
611 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
612 | |
613 ParseFieldTrials(); | |
614 | |
615 EXPECT_EQ(0.5f, params_.quic_packet_loss_threshold); | |
616 } | |
617 | |
618 TEST_F(NetworkSessionConfiguratorTest, QuicReceiveBufferSize) { | |
619 std::map<std::string, std::string> field_trial_params; | |
620 field_trial_params["receive_buffer_size"] = "2097152"; | |
621 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
622 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
623 | |
624 ParseFieldTrials(); | |
625 | |
626 EXPECT_EQ(2097152, params_.quic_socket_receive_buffer_size); | |
627 } | |
628 | |
629 TEST_F(NetworkSessionConfiguratorTest, QuicOriginsToForceQuicOn) { | |
630 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
631 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
632 "origin-to-force-quic-on", "www.example.com:443, www.example.org:443"); | |
633 | |
634 ParseFieldTrialsAndCommandLine(); | |
635 | |
636 EXPECT_EQ(2u, params_.origins_to_force_quic_on.size()); | |
637 EXPECT_TRUE( | |
638 ContainsKey(params_.origins_to_force_quic_on, | |
639 net::HostPortPair::FromString("www.example.com:443"))); | |
640 EXPECT_TRUE( | |
641 ContainsKey(params_.origins_to_force_quic_on, | |
642 net::HostPortPair::FromString("www.example.org:443"))); | |
643 } | |
644 | |
645 TEST_F(NetworkSessionConfiguratorTest, QuicWhitelistFromCommandLinet) { | |
646 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
647 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
648 "quic-host-whitelist", "www.example.org, www.example.com"); | |
649 | |
650 ParseFieldTrialsAndCommandLine(); | |
651 | |
652 EXPECT_EQ(2u, params_.quic_host_whitelist.size()); | |
653 EXPECT_TRUE(ContainsKey(params_.quic_host_whitelist, "www.example.org")); | |
654 EXPECT_TRUE(ContainsKey(params_.quic_host_whitelist, "www.example.com")); | |
655 } | |
656 | |
657 TEST_F(NetworkSessionConfiguratorTest, QuicWhitelistFromParams) { | |
658 std::map<std::string, std::string> field_trial_params; | |
659 field_trial_params["quic_host_whitelist"] = | |
660 "www.example.org, www.example.com"; | |
661 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
662 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
663 | |
664 ParseFieldTrials(); | |
665 | |
666 EXPECT_EQ(2u, params_.quic_host_whitelist.size()); | |
667 EXPECT_TRUE(ContainsKey(params_.quic_host_whitelist, "www.example.org")); | |
668 EXPECT_TRUE(ContainsKey(params_.quic_host_whitelist, "www.example.com")); | |
669 } | |
670 | |
671 TEST_F(NetworkSessionConfiguratorTest, QuicDisallowedByPolicy) { | |
672 base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableQuic); | |
673 is_quic_allowed_by_policy_ = false; | |
674 | |
675 ParseFieldTrialsAndCommandLine(); | |
676 | |
677 EXPECT_FALSE(params_.enable_quic); | |
678 } | |
679 | |
680 TEST_F(NetworkSessionConfiguratorTest, TCPFastOpenHttpsEnabled) { | |
681 base::FieldTrialList::CreateFieldTrial("TCPFastOpen", "HttpsEnabled"); | |
682 | |
683 ParseFieldTrials(); | |
684 | |
685 EXPECT_TRUE(params_.enable_tcp_fast_open_for_ssl); | |
686 } | |
687 | |
688 class IOThreadTestWithIOThreadObject : public testing::Test { | 57 class IOThreadTestWithIOThreadObject : public testing::Test { |
689 public: | 58 public: |
690 // These functions need to be public, since it is difficult to bind to | 59 // These functions need to be public, since it is difficult to bind to |
691 // protected functions in a test (the code would need to explicitly contain | 60 // protected functions in a test (the code would need to explicitly contain |
692 // the name of the actual test class). | 61 // the name of the actual test class). |
693 void CheckCnameLookup(bool expected) { | 62 void CheckCnameLookup(bool expected) { |
694 auto http_auth_preferences = | 63 auto http_auth_preferences = |
695 IOThreadPeer::GetAuthPreferences(io_thread_.get()); | 64 IOThreadPeer::GetAuthPreferences(io_thread_.get()); |
696 ASSERT_NE(nullptr, http_auth_preferences); | 65 ASSERT_NE(nullptr, http_auth_preferences); |
697 EXPECT_EQ(expected, http_auth_preferences->NegotiateDisableCnameLookup()); | 66 EXPECT_EQ(expected, http_auth_preferences->NegotiateDisableCnameLookup()); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType, | 233 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType, |
865 base::Unretained(this), "acc1")); | 234 base::Unretained(this), "acc1")); |
866 pref_service()->SetString(prefs::kAuthAndroidNegotiateAccountType, "acc2"); | 235 pref_service()->SetString(prefs::kAuthAndroidNegotiateAccountType, "acc2"); |
867 RunOnIOThreadBlocking(base::Bind( | 236 RunOnIOThreadBlocking(base::Bind( |
868 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType, | 237 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType, |
869 base::Unretained(this), "acc2")); | 238 base::Unretained(this), "acc2")); |
870 } | 239 } |
871 #endif | 240 #endif |
872 | 241 |
873 } // namespace test | 242 } // namespace test |
OLD | NEW |