Chromium Code Reviews| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/metrics/field_trial.h" | 6 #include "base/metrics/field_trial.h" |
| 7 #include "base/test/mock_entropy_provider.h" | 7 #include "base/test/mock_entropy_provider.h" |
| 8 #include "chrome/browser/io_thread.h" | 8 #include "chrome/browser/io_thread.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" | 10 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 } | 90 } |
| 91 | 91 |
| 92 TEST_F(IOThreadTest, SpdyFieldTrialHoldbackEnabled) { | 92 TEST_F(IOThreadTest, SpdyFieldTrialHoldbackEnabled) { |
| 93 net::HttpStreamFactory::set_spdy_enabled(true); | 93 net::HttpStreamFactory::set_spdy_enabled(true); |
| 94 field_trial_group_ = "SpdyDisabled"; | 94 field_trial_group_ = "SpdyDisabled"; |
| 95 ConfigureSpdyGlobals(); | 95 ConfigureSpdyGlobals(); |
| 96 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled()); | 96 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 TEST_F(IOThreadTest, SpdyFieldTrialSpdy31Enabled) { | 99 TEST_F(IOThreadTest, SpdyFieldTrialSpdy31Enabled) { |
| 100 bool use_alternative_services = false; | |
| 101 field_trial_group_ = "Spdy31Enabled"; | 100 field_trial_group_ = "Spdy31Enabled"; |
| 102 ConfigureSpdyGlobals(); | 101 ConfigureSpdyGlobals(); |
| 103 EXPECT_THAT(globals_.next_protos, | 102 EXPECT_THAT(globals_.next_protos, |
| 104 ElementsAre(net::kProtoHTTP11, | 103 ElementsAre(net::kProtoHTTP11, |
| 105 net::kProtoSPDY31)); | 104 net::kProtoSPDY31)); |
| 106 globals_.use_alternative_services.CopyToIfSet(&use_alternative_services); | |
| 107 EXPECT_TRUE(use_alternative_services); | |
| 108 } | 105 } |
| 109 | 106 |
| 110 TEST_F(IOThreadTest, SpdyFieldTrialSpdy4Enabled) { | 107 TEST_F(IOThreadTest, SpdyFieldTrialSpdy4Enabled) { |
| 111 bool use_alternative_services = false; | |
| 112 field_trial_group_ = "Spdy4Enabled"; | 108 field_trial_group_ = "Spdy4Enabled"; |
| 113 ConfigureSpdyGlobals(); | 109 ConfigureSpdyGlobals(); |
| 114 EXPECT_THAT( | 110 EXPECT_THAT( |
| 115 globals_.next_protos, | 111 globals_.next_protos, |
| 116 ElementsAre(net::kProtoHTTP11, net::kProtoSPDY31, net::kProtoHTTP2)); | 112 ElementsAre(net::kProtoHTTP11, net::kProtoSPDY31, net::kProtoHTTP2)); |
| 117 globals_.use_alternative_services.CopyToIfSet(&use_alternative_services); | |
| 118 EXPECT_TRUE(use_alternative_services); | |
| 119 } | 113 } |
| 120 | 114 |
| 121 TEST_F(IOThreadTest, SpdyFieldTrialDefault) { | 115 TEST_F(IOThreadTest, SpdyFieldTrialDefault) { |
| 122 field_trial_group_ = ""; | 116 field_trial_group_ = ""; |
| 123 ConfigureSpdyGlobals(); | 117 ConfigureSpdyGlobals(); |
| 124 EXPECT_THAT( | 118 EXPECT_THAT( |
| 125 globals_.next_protos, | 119 globals_.next_protos, |
| 126 ElementsAre(net::kProtoHTTP11, net::kProtoSPDY31, net::kProtoHTTP2)); | 120 ElementsAre(net::kProtoHTTP11, net::kProtoSPDY31, net::kProtoHTTP2)); |
| 127 bool use_alternative_services = false; | |
| 128 globals_.use_alternative_services.CopyToIfSet(&use_alternative_services); | |
| 129 EXPECT_TRUE(use_alternative_services); | |
| 130 } | 121 } |
| 131 | 122 |
| 132 TEST_F(IOThreadTest, SpdyFieldTrialParametrized) { | 123 TEST_F(IOThreadTest, SpdyFieldTrialParametrized) { |
| 133 field_trial_params_["enable_spdy31"] = "false"; | 124 field_trial_params_["enable_spdy31"] = "false"; |
| 134 // Undefined parameter "enable_http2_14" should default to false. | 125 // Undefined parameter "enable_http2_14" should default to false. |
| 135 field_trial_params_["enable_http2"] = "true"; | 126 field_trial_params_["enable_http2"] = "true"; |
| 136 field_trial_group_ = "ParametrizedHTTP2Only"; | 127 field_trial_group_ = "ParametrizedHTTP2Only"; |
| 137 ConfigureSpdyGlobals(); | 128 ConfigureSpdyGlobals(); |
| 138 EXPECT_THAT(globals_.next_protos, | 129 EXPECT_THAT(globals_.next_protos, |
| 139 ElementsAre(net::kProtoHTTP11, net::kProtoHTTP2)); | 130 ElementsAre(net::kProtoHTTP11, net::kProtoHTTP2)); |
| 140 bool use_alternative_services = false; | |
| 141 globals_.use_alternative_services.CopyToIfSet(&use_alternative_services); | |
| 142 EXPECT_TRUE(use_alternative_services); | |
| 143 } | 131 } |
| 144 | 132 |
| 145 TEST_F(IOThreadTest, SpdyCommandLineUseSpdyOff) { | 133 TEST_F(IOThreadTest, SpdyCommandLineUseSpdyOff) { |
| 146 command_line_.AppendSwitchASCII("use-spdy", "off"); | 134 command_line_.AppendSwitchASCII("use-spdy", "off"); |
| 147 // Command line should overwrite field trial group. | 135 // Command line should overwrite field trial group. |
| 148 field_trial_group_ = "Spdy4Enabled"; | 136 field_trial_group_ = "Spdy4Enabled"; |
| 149 ConfigureSpdyGlobals(); | 137 ConfigureSpdyGlobals(); |
| 150 EXPECT_EQ(0u, globals_.next_protos.size()); | 138 EXPECT_EQ(0u, globals_.next_protos.size()); |
| 151 } | 139 } |
| 152 | 140 |
| 141 TEST_F(IOThreadTest, EnableAlternativeServicesFromFieldTrialParams) { | |
|
Ryan Hamilton
2015/08/27 17:24:18
Can you move this down into the QUIC section, just
Bence
2015/08/27 17:29:54
Done.
| |
| 142 field_trial_group_ = "Enabled"; | |
| 143 field_trial_params_["use_alternative_services"] = "true"; | |
| 144 | |
| 145 ConfigureQuicGlobals(); | |
| 146 net::HttpNetworkSession::Params params; | |
| 147 InitializeNetworkSessionParams(¶ms); | |
| 148 EXPECT_TRUE(params.use_alternative_services); | |
| 149 } | |
| 150 | |
| 153 TEST_F(IOThreadTest, DisableQuicByDefault) { | 151 TEST_F(IOThreadTest, DisableQuicByDefault) { |
| 154 ConfigureQuicGlobals(); | 152 ConfigureQuicGlobals(); |
| 155 net::HttpNetworkSession::Params params; | 153 net::HttpNetworkSession::Params params; |
| 156 InitializeNetworkSessionParams(¶ms); | 154 InitializeNetworkSessionParams(¶ms); |
| 157 EXPECT_FALSE(params.enable_quic); | 155 EXPECT_FALSE(params.enable_quic); |
| 158 EXPECT_FALSE(params.enable_quic_for_proxies); | 156 EXPECT_FALSE(params.enable_quic_for_proxies); |
| 159 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); | 157 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); |
| 160 } | 158 } |
| 161 | 159 |
| 162 TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { | 160 TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 174 EXPECT_EQ(default_params.quic_supported_versions, | 172 EXPECT_EQ(default_params.quic_supported_versions, |
| 175 params.quic_supported_versions); | 173 params.quic_supported_versions); |
| 176 EXPECT_EQ(net::QuicTagVector(), params.quic_connection_options); | 174 EXPECT_EQ(net::QuicTagVector(), params.quic_connection_options); |
| 177 EXPECT_FALSE(params.quic_always_require_handshake_confirmation); | 175 EXPECT_FALSE(params.quic_always_require_handshake_confirmation); |
| 178 EXPECT_FALSE(params.quic_disable_connection_pooling); | 176 EXPECT_FALSE(params.quic_disable_connection_pooling); |
| 179 EXPECT_EQ(0.25f, params.quic_load_server_info_timeout_srtt_multiplier); | 177 EXPECT_EQ(0.25f, params.quic_load_server_info_timeout_srtt_multiplier); |
| 180 EXPECT_FALSE(params.quic_enable_connection_racing); | 178 EXPECT_FALSE(params.quic_enable_connection_racing); |
| 181 EXPECT_FALSE(params.quic_enable_non_blocking_io); | 179 EXPECT_FALSE(params.quic_enable_non_blocking_io); |
| 182 EXPECT_FALSE(params.quic_disable_disk_cache); | 180 EXPECT_FALSE(params.quic_disable_disk_cache); |
| 183 EXPECT_FALSE(params.quic_prefer_aes); | 181 EXPECT_FALSE(params.quic_prefer_aes); |
| 182 EXPECT_FALSE(params.use_alternative_services); | |
| 184 EXPECT_EQ(0, params.quic_max_number_of_lossy_connections); | 183 EXPECT_EQ(0, params.quic_max_number_of_lossy_connections); |
| 185 EXPECT_EQ(1.0f, params.quic_packet_loss_threshold); | 184 EXPECT_EQ(1.0f, params.quic_packet_loss_threshold); |
| 186 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); | 185 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); |
| 187 } | 186 } |
| 188 | 187 |
| 189 TEST_F(IOThreadTest, EnableQuicFromQuicProxyFieldTrialGroup) { | 188 TEST_F(IOThreadTest, EnableQuicFromQuicProxyFieldTrialGroup) { |
| 190 base::FieldTrialList field_trial_list(new base::MockEntropyProvider()); | 189 base::FieldTrialList field_trial_list(new base::MockEntropyProvider()); |
| 191 base::FieldTrialList::CreateFieldTrial( | 190 base::FieldTrialList::CreateFieldTrial( |
| 192 data_reduction_proxy::params::GetQuicFieldTrialName(), "Enabled"); | 191 data_reduction_proxy::params::GetQuicFieldTrialName(), "Enabled"); |
| 193 | 192 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 command_line_.AppendSwitch(switches::kEnableQuic); | 445 command_line_.AppendSwitch(switches::kEnableQuic); |
| 447 is_quic_allowed_by_policy_ = false; | 446 is_quic_allowed_by_policy_ = false; |
| 448 ConfigureQuicGlobals(); | 447 ConfigureQuicGlobals(); |
| 449 | 448 |
| 450 net::HttpNetworkSession::Params params; | 449 net::HttpNetworkSession::Params params; |
| 451 InitializeNetworkSessionParams(¶ms); | 450 InitializeNetworkSessionParams(¶ms); |
| 452 EXPECT_FALSE(params.enable_quic); | 451 EXPECT_FALSE(params.enable_quic); |
| 453 } | 452 } |
| 454 | 453 |
| 455 } // namespace test | 454 } // namespace test |
| OLD | NEW |