| 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_delay_tcp_race); | |
| 259 EXPECT_FALSE(params_.quic_close_sessions_on_ip_change); | |
| 260 EXPECT_EQ(net::kIdleConnectionTimeoutSeconds, | |
| 261 params_.quic_idle_connection_timeout_seconds); | |
| 262 EXPECT_FALSE(params_.quic_disable_preconnect_if_0rtt); | |
| 263 EXPECT_FALSE(params_.quic_migrate_sessions_on_network_change); | |
| 264 EXPECT_FALSE(params_.quic_migrate_sessions_early); | |
| 265 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); | |
| 266 EXPECT_TRUE(params_.quic_host_whitelist.empty()); | |
| 267 | |
| 268 net::HttpNetworkSession::Params default_params; | |
| 269 EXPECT_EQ(default_params.quic_supported_versions, | |
| 270 params_.quic_supported_versions); | |
| 271 } | |
| 272 | |
| 273 TEST_F(NetworkSessionConfiguratorTest, | |
| 274 DisableQuicWhenConnectionTimesOutWithOpenStreamsFromFieldTrialParams) { | |
| 275 std::map<std::string, std::string> field_trial_params; | |
| 276 field_trial_params["disable_quic_on_timeout_with_open_streams"] = "true"; | |
| 277 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 278 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 279 | |
| 280 ParseFieldTrials(); | |
| 281 | |
| 282 EXPECT_TRUE(params_.disable_quic_on_timeout_with_open_streams); | |
| 283 } | |
| 284 | |
| 285 TEST_F(NetworkSessionConfiguratorTest, EnableQuicFromQuicProxyFieldTrialGroup) { | |
| 286 const struct { | |
| 287 std::string field_trial_group_name; | |
| 288 bool expect_enable_quic; | |
| 289 } tests[] = { | |
| 290 { | |
| 291 std::string(), false, | |
| 292 }, | |
| 293 { | |
| 294 "NotEnabled", false, | |
| 295 }, | |
| 296 { | |
| 297 "Control", false, | |
| 298 }, | |
| 299 { | |
| 300 "Disabled", false, | |
| 301 }, | |
| 302 { | |
| 303 "EnabledControl", true, | |
| 304 }, | |
| 305 { | |
| 306 "Enabled", true, | |
| 307 }, | |
| 308 }; | |
| 309 | |
| 310 field_trial_list_.reset(); | |
| 311 for (size_t i = 0; i < arraysize(tests); ++i) { | |
| 312 base::FieldTrialList field_trial_list(new base::MockEntropyProvider()); | |
| 313 base::FieldTrialList::CreateFieldTrial( | |
| 314 data_reduction_proxy::params::GetQuicFieldTrialName(), | |
| 315 tests[i].field_trial_group_name); | |
| 316 | |
| 317 ParseFieldTrials(); | |
| 318 | |
| 319 EXPECT_FALSE(params_.enable_quic) << i; | |
| 320 EXPECT_EQ(tests[i].expect_enable_quic, params_.enable_quic_for_proxies) | |
| 321 << i; | |
| 322 EXPECT_EQ(tests[i].expect_enable_quic, | |
| 323 IOThread::ShouldEnableQuicForDataReductionProxy()) | |
| 324 << i; | |
| 325 } | |
| 326 } | |
| 327 | |
| 328 TEST_F(NetworkSessionConfiguratorTest, EnableQuicFromCommandLine) { | |
| 329 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
| 330 | |
| 331 ParseFieldTrialsAndCommandLine(); | |
| 332 | |
| 333 EXPECT_TRUE(params_.enable_quic); | |
| 334 EXPECT_TRUE(params_.enable_quic_for_proxies); | |
| 335 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); | |
| 336 } | |
| 337 | |
| 338 TEST_F(NetworkSessionConfiguratorTest, | |
| 339 EnableAlternativeServicesFromCommandLineWithQuicDisabled) { | |
| 340 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 341 "enable-alternative-services"); | |
| 342 | |
| 343 ParseFieldTrialsAndCommandLine(); | |
| 344 | |
| 345 EXPECT_FALSE(params_.enable_quic); | |
| 346 EXPECT_TRUE(params_.parse_alternative_services); | |
| 347 EXPECT_TRUE(params_.enable_alternative_service_with_different_host); | |
| 348 } | |
| 349 | |
| 350 TEST_F(NetworkSessionConfiguratorTest, | |
| 351 EnableAlternativeServicesFromCommandLineWithQuicEnabled) { | |
| 352 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
| 353 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 354 "enable-alternative-services"); | |
| 355 | |
| 356 ParseFieldTrialsAndCommandLine(); | |
| 357 | |
| 358 EXPECT_TRUE(params_.enable_quic); | |
| 359 EXPECT_TRUE(params_.parse_alternative_services); | |
| 360 EXPECT_TRUE(params_.enable_alternative_service_with_different_host); | |
| 361 } | |
| 362 | |
| 363 TEST_F(NetworkSessionConfiguratorTest, PacketLengthFromCommandLine) { | |
| 364 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
| 365 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 366 "quic-max-packet-length", "1450"); | |
| 367 | |
| 368 ParseFieldTrialsAndCommandLine(); | |
| 369 | |
| 370 EXPECT_EQ(1450u, params_.quic_max_packet_length); | |
| 371 } | |
| 372 | |
| 373 TEST_F(NetworkSessionConfiguratorTest, | |
| 374 QuicCloseSessionsOnIpChangeFromFieldTrialParams) { | |
| 375 std::map<std::string, std::string> field_trial_params; | |
| 376 field_trial_params["close_sessions_on_ip_change"] = "true"; | |
| 377 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 378 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 379 | |
| 380 ParseFieldTrials(); | |
| 381 | |
| 382 EXPECT_TRUE(params_.quic_close_sessions_on_ip_change); | |
| 383 } | |
| 384 | |
| 385 TEST_F(NetworkSessionConfiguratorTest, | |
| 386 QuicIdleConnectionTimeoutSecondsFieldTrialParams) { | |
| 387 std::map<std::string, std::string> field_trial_params; | |
| 388 field_trial_params["idle_connection_timeout_seconds"] = "300"; | |
| 389 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 390 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 391 | |
| 392 ParseFieldTrials(); | |
| 393 | |
| 394 EXPECT_EQ(300, params_.quic_idle_connection_timeout_seconds); | |
| 395 } | |
| 396 | |
| 397 TEST_F(NetworkSessionConfiguratorTest, QuicDisablePreConnectIfZeroRtt) { | |
| 398 std::map<std::string, std::string> field_trial_params; | |
| 399 field_trial_params["disable_preconnect_if_0rtt"] = "true"; | |
| 400 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 401 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 402 | |
| 403 ParseFieldTrials(); | |
| 404 | |
| 405 EXPECT_TRUE(params_.quic_disable_preconnect_if_0rtt); | |
| 406 } | |
| 407 | |
| 408 TEST_F(NetworkSessionConfiguratorTest, | |
| 409 QuicMigrateSessionsOnNetworkChangeFromFieldTrialParams) { | |
| 410 std::map<std::string, std::string> field_trial_params; | |
| 411 field_trial_params["migrate_sessions_on_network_change"] = "true"; | |
| 412 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 413 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 414 | |
| 415 ParseFieldTrials(); | |
| 416 | |
| 417 EXPECT_TRUE(params_.quic_migrate_sessions_on_network_change); | |
| 418 } | |
| 419 | |
| 420 TEST_F(NetworkSessionConfiguratorTest, | |
| 421 QuicMigrateSessionsEarlyFromFieldTrialParams) { | |
| 422 std::map<std::string, std::string> field_trial_params; | |
| 423 field_trial_params["migrate_sessions_early"] = "true"; | |
| 424 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 425 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 426 | |
| 427 ParseFieldTrials(); | |
| 428 | |
| 429 EXPECT_TRUE(params_.quic_migrate_sessions_early); | |
| 430 } | |
| 431 | |
| 432 TEST_F(NetworkSessionConfiguratorTest, PacketLengthFromFieldTrialParams) { | |
| 433 std::map<std::string, std::string> field_trial_params; | |
| 434 field_trial_params["max_packet_length"] = "1450"; | |
| 435 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 436 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 437 | |
| 438 ParseFieldTrials(); | |
| 439 | |
| 440 EXPECT_EQ(1450u, params_.quic_max_packet_length); | |
| 441 } | |
| 442 | |
| 443 TEST_F(NetworkSessionConfiguratorTest, QuicVersionFromCommandLine) { | |
| 444 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
| 445 std::string version = | |
| 446 net::QuicVersionToString(net::QuicSupportedVersions().back()); | |
| 447 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII("quic-version", | |
| 448 version); | |
| 449 | |
| 450 ParseFieldTrialsAndCommandLine(); | |
| 451 | |
| 452 net::QuicVersionVector supported_versions; | |
| 453 supported_versions.push_back(net::QuicSupportedVersions().back()); | |
| 454 EXPECT_EQ(supported_versions, params_.quic_supported_versions); | |
| 455 } | |
| 456 | |
| 457 TEST_F(NetworkSessionConfiguratorTest, QuicVersionFromFieldTrialParams) { | |
| 458 std::map<std::string, std::string> field_trial_params; | |
| 459 field_trial_params["quic_version"] = | |
| 460 net::QuicVersionToString(net::QuicSupportedVersions().back()); | |
| 461 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 462 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 463 | |
| 464 ParseFieldTrials(); | |
| 465 | |
| 466 net::QuicVersionVector supported_versions; | |
| 467 supported_versions.push_back(net::QuicSupportedVersions().back()); | |
| 468 EXPECT_EQ(supported_versions, params_.quic_supported_versions); | |
| 469 } | |
| 470 | |
| 471 TEST_F(NetworkSessionConfiguratorTest, QuicConnectionOptionsFromCommandLine) { | |
| 472 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
| 473 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 474 "quic-connection-options", "TIME,TBBR,REJ"); | |
| 475 | |
| 476 ParseFieldTrialsAndCommandLine(); | |
| 477 | |
| 478 net::QuicTagVector options; | |
| 479 options.push_back(net::kTIME); | |
| 480 options.push_back(net::kTBBR); | |
| 481 options.push_back(net::kREJ); | |
| 482 EXPECT_EQ(options, params_.quic_connection_options); | |
| 483 } | |
| 484 | |
| 485 TEST_F(NetworkSessionConfiguratorTest, | |
| 486 QuicConnectionOptionsFromFieldTrialParams) { | |
| 487 std::map<std::string, std::string> field_trial_params; | |
| 488 field_trial_params["connection_options"] = "TIME,TBBR,REJ"; | |
| 489 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 490 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 491 | |
| 492 ParseFieldTrials(); | |
| 493 | |
| 494 net::QuicTagVector options; | |
| 495 options.push_back(net::kTIME); | |
| 496 options.push_back(net::kTBBR); | |
| 497 options.push_back(net::kREJ); | |
| 498 EXPECT_EQ(options, params_.quic_connection_options); | |
| 499 } | |
| 500 | |
| 501 TEST_F(NetworkSessionConfiguratorTest, | |
| 502 QuicAlwaysRequireHandshakeConfirmationFromFieldTrialParams) { | |
| 503 std::map<std::string, std::string> field_trial_params; | |
| 504 field_trial_params["always_require_handshake_confirmation"] = "true"; | |
| 505 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 506 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 507 | |
| 508 ParseFieldTrials(); | |
| 509 | |
| 510 EXPECT_TRUE(params_.quic_always_require_handshake_confirmation); | |
| 511 } | |
| 512 | |
| 513 TEST_F(NetworkSessionConfiguratorTest, | |
| 514 QuicDisableConnectionPoolingFromFieldTrialParams) { | |
| 515 std::map<std::string, std::string> field_trial_params; | |
| 516 field_trial_params["disable_connection_pooling"] = "true"; | |
| 517 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 518 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 519 | |
| 520 ParseFieldTrials(); | |
| 521 | |
| 522 EXPECT_TRUE(params_.quic_disable_connection_pooling); | |
| 523 } | |
| 524 | |
| 525 TEST_F(NetworkSessionConfiguratorTest, | |
| 526 QuicLoadServerInfoTimeToSmoothedRttFromFieldTrialParams) { | |
| 527 std::map<std::string, std::string> field_trial_params; | |
| 528 field_trial_params["load_server_info_time_to_srtt"] = "0.5"; | |
| 529 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 530 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 531 | |
| 532 ParseFieldTrials(); | |
| 533 | |
| 534 EXPECT_EQ(0.5f, params_.quic_load_server_info_timeout_srtt_multiplier); | |
| 535 } | |
| 536 | |
| 537 TEST_F(NetworkSessionConfiguratorTest, QuicEnableConnectionRacing) { | |
| 538 std::map<std::string, std::string> field_trial_params; | |
| 539 field_trial_params["enable_connection_racing"] = "true"; | |
| 540 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 541 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 542 | |
| 543 ParseFieldTrials(); | |
| 544 | |
| 545 EXPECT_TRUE(params_.quic_enable_connection_racing); | |
| 546 } | |
| 547 | |
| 548 TEST_F(NetworkSessionConfiguratorTest, QuicEnableNonBlockingIO) { | |
| 549 std::map<std::string, std::string> field_trial_params; | |
| 550 field_trial_params["enable_non_blocking_io"] = "true"; | |
| 551 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 552 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 553 | |
| 554 ParseFieldTrials(); | |
| 555 | |
| 556 EXPECT_TRUE(params_.quic_enable_non_blocking_io); | |
| 557 } | |
| 558 | |
| 559 TEST_F(NetworkSessionConfiguratorTest, QuicDisableDiskCache) { | |
| 560 std::map<std::string, std::string> field_trial_params; | |
| 561 field_trial_params["disable_disk_cache"] = "true"; | |
| 562 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 563 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 564 | |
| 565 ParseFieldTrials(); | |
| 566 | |
| 567 EXPECT_TRUE(params_.quic_disable_disk_cache); | |
| 568 } | |
| 569 | |
| 570 TEST_F(NetworkSessionConfiguratorTest, QuicPreferAes) { | |
| 571 std::map<std::string, std::string> field_trial_params; | |
| 572 field_trial_params["prefer_aes"] = "true"; | |
| 573 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 574 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 575 | |
| 576 ParseFieldTrials(); | |
| 577 | |
| 578 EXPECT_TRUE(params_.quic_prefer_aes); | |
| 579 } | |
| 580 | |
| 581 TEST_F(NetworkSessionConfiguratorTest, | |
| 582 QuicEnableAlternativeServicesFromFieldTrialParams) { | |
| 583 std::map<std::string, std::string> field_trial_params; | |
| 584 field_trial_params["enable_alternative_service_with_different_host"] = "true"; | |
| 585 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 586 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 587 | |
| 588 ParseFieldTrials(); | |
| 589 | |
| 590 EXPECT_TRUE(params_.enable_alternative_service_with_different_host); | |
| 591 // QUIC AltSvc pooling parameter should also enable AltSvc parsing. | |
| 592 EXPECT_TRUE(params_.parse_alternative_services); | |
| 593 } | |
| 594 | |
| 595 TEST_F(NetworkSessionConfiguratorTest, | |
| 596 QuicMaxNumberOfLossyConnectionsFieldTrialParams) { | |
| 597 std::map<std::string, std::string> field_trial_params; | |
| 598 field_trial_params["max_number_of_lossy_connections"] = "5"; | |
| 599 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 600 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 601 | |
| 602 ParseFieldTrials(); | |
| 603 | |
| 604 EXPECT_EQ(5, params_.quic_max_number_of_lossy_connections); | |
| 605 } | |
| 606 | |
| 607 TEST_F(NetworkSessionConfiguratorTest, | |
| 608 QuicPacketLossThresholdFieldTrialParams) { | |
| 609 std::map<std::string, std::string> field_trial_params; | |
| 610 field_trial_params["packet_loss_threshold"] = "0.5"; | |
| 611 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 612 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 613 | |
| 614 ParseFieldTrials(); | |
| 615 | |
| 616 EXPECT_EQ(0.5f, params_.quic_packet_loss_threshold); | |
| 617 } | |
| 618 | |
| 619 TEST_F(NetworkSessionConfiguratorTest, QuicReceiveBufferSize) { | |
| 620 std::map<std::string, std::string> field_trial_params; | |
| 621 field_trial_params["receive_buffer_size"] = "2097152"; | |
| 622 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 623 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 624 | |
| 625 ParseFieldTrials(); | |
| 626 | |
| 627 EXPECT_EQ(2097152, params_.quic_socket_receive_buffer_size); | |
| 628 } | |
| 629 | |
| 630 TEST_F(NetworkSessionConfiguratorTest, QuicDelayTcpConnection) { | |
| 631 std::map<std::string, std::string> field_trial_params; | |
| 632 field_trial_params["delay_tcp_race"] = "true"; | |
| 633 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 634 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 635 | |
| 636 ParseFieldTrials(); | |
| 637 | |
| 638 EXPECT_TRUE(params_.quic_delay_tcp_race); | |
| 639 } | |
| 640 | |
| 641 TEST_F(NetworkSessionConfiguratorTest, QuicOriginsToForceQuicOn) { | |
| 642 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
| 643 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 644 "origin-to-force-quic-on", "www.example.com:443, www.example.org:443"); | |
| 645 | |
| 646 ParseFieldTrialsAndCommandLine(); | |
| 647 | |
| 648 EXPECT_EQ(2u, params_.origins_to_force_quic_on.size()); | |
| 649 EXPECT_TRUE( | |
| 650 ContainsKey(params_.origins_to_force_quic_on, | |
| 651 net::HostPortPair::FromString("www.example.com:443"))); | |
| 652 EXPECT_TRUE( | |
| 653 ContainsKey(params_.origins_to_force_quic_on, | |
| 654 net::HostPortPair::FromString("www.example.org:443"))); | |
| 655 } | |
| 656 | |
| 657 TEST_F(NetworkSessionConfiguratorTest, QuicWhitelistFromCommandLinet) { | |
| 658 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); | |
| 659 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 660 "quic-host-whitelist", "www.example.org, www.example.com"); | |
| 661 | |
| 662 ParseFieldTrialsAndCommandLine(); | |
| 663 | |
| 664 EXPECT_EQ(2u, params_.quic_host_whitelist.size()); | |
| 665 EXPECT_TRUE(ContainsKey(params_.quic_host_whitelist, "www.example.org")); | |
| 666 EXPECT_TRUE(ContainsKey(params_.quic_host_whitelist, "www.example.com")); | |
| 667 } | |
| 668 | |
| 669 TEST_F(NetworkSessionConfiguratorTest, QuicWhitelistFromParams) { | |
| 670 std::map<std::string, std::string> field_trial_params; | |
| 671 field_trial_params["quic_host_whitelist"] = | |
| 672 "www.example.org, www.example.com"; | |
| 673 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); | |
| 674 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); | |
| 675 | |
| 676 ParseFieldTrials(); | |
| 677 | |
| 678 EXPECT_EQ(2u, params_.quic_host_whitelist.size()); | |
| 679 EXPECT_TRUE(ContainsKey(params_.quic_host_whitelist, "www.example.org")); | |
| 680 EXPECT_TRUE(ContainsKey(params_.quic_host_whitelist, "www.example.com")); | |
| 681 } | |
| 682 | |
| 683 TEST_F(NetworkSessionConfiguratorTest, QuicDisallowedByPolicy) { | |
| 684 base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableQuic); | |
| 685 is_quic_allowed_by_policy_ = false; | |
| 686 | |
| 687 ParseFieldTrialsAndCommandLine(); | |
| 688 | |
| 689 EXPECT_FALSE(params_.enable_quic); | |
| 690 } | |
| 691 | |
| 692 TEST_F(NetworkSessionConfiguratorTest, TCPFastOpenHttpsEnabled) { | |
| 693 base::FieldTrialList::CreateFieldTrial("TCPFastOpen", "HttpsEnabled"); | |
| 694 | |
| 695 ParseFieldTrials(); | |
| 696 | |
| 697 EXPECT_TRUE(params_.enable_tcp_fast_open_for_ssl); | |
| 698 } | |
| 699 | |
| 700 class IOThreadTestWithIOThreadObject : public testing::Test { | 57 class IOThreadTestWithIOThreadObject : public testing::Test { |
| 701 public: | 58 public: |
| 702 // 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 |
| 703 // 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 |
| 704 // the name of the actual test class). | 61 // the name of the actual test class). |
| 705 void CheckCnameLookup(bool expected) { | 62 void CheckCnameLookup(bool expected) { |
| 706 auto http_auth_preferences = | 63 auto http_auth_preferences = |
| 707 IOThreadPeer::GetAuthPreferences(io_thread_.get()); | 64 IOThreadPeer::GetAuthPreferences(io_thread_.get()); |
| 708 ASSERT_NE(nullptr, http_auth_preferences); | 65 ASSERT_NE(nullptr, http_auth_preferences); |
| 709 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... |
| 876 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType, | 233 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType, |
| 877 base::Unretained(this), "acc1")); | 234 base::Unretained(this), "acc1")); |
| 878 pref_service()->SetString(prefs::kAuthAndroidNegotiateAccountType, "acc2"); | 235 pref_service()->SetString(prefs::kAuthAndroidNegotiateAccountType, "acc2"); |
| 879 RunOnIOThreadBlocking(base::Bind( | 236 RunOnIOThreadBlocking(base::Bind( |
| 880 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType, | 237 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType, |
| 881 base::Unretained(this), "acc2")); | 238 base::Unretained(this), "acc2")); |
| 882 } | 239 } |
| 883 #endif | 240 #endif |
| 884 | 241 |
| 885 } // namespace test | 242 } // namespace test |
| OLD | NEW |