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