| 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 "chrome/browser/io_thread.h" | 7 #include "chrome/browser/io_thread.h" |
| 8 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
| 7 #include "net/http/http_network_session.h" | 9 #include "net/http/http_network_session.h" |
| 8 #include "net/http/http_server_properties_impl.h" | 10 #include "net/http/http_server_properties_impl.h" |
| 9 #include "net/quic/quic_protocol.h" | 11 #include "net/quic/quic_protocol.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 14 |
| 13 namespace test { | 15 namespace test { |
| 14 | 16 |
| 15 using ::testing::ElementsAre; | 17 using ::testing::ElementsAre; |
| 16 | 18 |
| 19 class BadEntropyProvider : public base::FieldTrial::EntropyProvider { |
| 20 public: |
| 21 ~BadEntropyProvider() override {} |
| 22 |
| 23 double GetEntropyForTrial(const std::string& trial_name, |
| 24 uint32 randomization_seed) const override { |
| 25 return 0.5; |
| 26 } |
| 27 }; |
| 28 |
| 17 class IOThreadPeer { | 29 class IOThreadPeer { |
| 18 public: | 30 public: |
| 19 static void ConfigureQuicGlobals( | 31 static void ConfigureQuicGlobals( |
| 20 const base::CommandLine& command_line, | 32 const base::CommandLine& command_line, |
| 21 base::StringPiece quic_trial_group, | 33 base::StringPiece quic_trial_group, |
| 22 const std::map<std::string, std::string>& quic_trial_params, | 34 const std::map<std::string, std::string>& quic_trial_params, |
| 23 IOThread::Globals* globals) { | 35 IOThread::Globals* globals) { |
| 24 IOThread::ConfigureQuicGlobals(command_line, quic_trial_group, | 36 IOThread::ConfigureQuicGlobals(command_line, quic_trial_group, |
| 25 quic_trial_params, globals); | 37 quic_trial_params, globals); |
| 26 } | 38 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 net::kProtoSPDY31)); | 119 net::kProtoSPDY31)); |
| 108 globals_.use_alternate_protocols.CopyToIfSet(&use_alternate_protocols); | 120 globals_.use_alternate_protocols.CopyToIfSet(&use_alternate_protocols); |
| 109 EXPECT_TRUE(use_alternate_protocols); | 121 EXPECT_TRUE(use_alternate_protocols); |
| 110 } | 122 } |
| 111 | 123 |
| 112 TEST_F(IOThreadTest, DisableQuicByDefault) { | 124 TEST_F(IOThreadTest, DisableQuicByDefault) { |
| 113 ConfigureQuicGlobals(); | 125 ConfigureQuicGlobals(); |
| 114 net::HttpNetworkSession::Params params; | 126 net::HttpNetworkSession::Params params; |
| 115 InitializeNetworkSessionParams(¶ms); | 127 InitializeNetworkSessionParams(¶ms); |
| 116 EXPECT_FALSE(params.enable_quic); | 128 EXPECT_FALSE(params.enable_quic); |
| 129 EXPECT_FALSE(params.enable_quic_for_proxies); |
| 130 bool enable_quic_for_data_reduction_proxy = true; |
| 131 globals_.enable_quic_for_data_reduction_proxy.CopyToIfSet( |
| 132 &enable_quic_for_data_reduction_proxy); |
| 133 EXPECT_FALSE(enable_quic_for_data_reduction_proxy); |
| 117 } | 134 } |
| 118 | 135 |
| 119 TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { | 136 TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { |
| 120 field_trial_group_ = "Enabled"; | 137 field_trial_group_ = "Enabled"; |
| 121 | 138 |
| 122 ConfigureQuicGlobals(); | 139 ConfigureQuicGlobals(); |
| 123 net::HttpNetworkSession::Params default_params; | 140 net::HttpNetworkSession::Params default_params; |
| 124 net::HttpNetworkSession::Params params; | 141 net::HttpNetworkSession::Params params; |
| 125 InitializeNetworkSessionParams(¶ms); | 142 InitializeNetworkSessionParams(¶ms); |
| 126 EXPECT_TRUE(params.enable_quic); | 143 EXPECT_TRUE(params.enable_quic); |
| 144 EXPECT_TRUE(params.enable_quic_for_proxies); |
| 145 bool enable_quic_for_data_reduction_proxy = true; |
| 146 globals_.enable_quic_for_data_reduction_proxy.CopyToIfSet( |
| 147 &enable_quic_for_data_reduction_proxy); |
| 148 EXPECT_FALSE(enable_quic_for_data_reduction_proxy); |
| 127 EXPECT_EQ(1350u, params.quic_max_packet_length); | 149 EXPECT_EQ(1350u, params.quic_max_packet_length); |
| 128 EXPECT_EQ(1.0, params.alternate_protocol_probability_threshold); | 150 EXPECT_EQ(1.0, params.alternate_protocol_probability_threshold); |
| 129 EXPECT_EQ(default_params.quic_supported_versions, | 151 EXPECT_EQ(default_params.quic_supported_versions, |
| 130 params.quic_supported_versions); | 152 params.quic_supported_versions); |
| 131 EXPECT_EQ(net::QuicTagVector(), params.quic_connection_options); | 153 EXPECT_EQ(net::QuicTagVector(), params.quic_connection_options); |
| 132 EXPECT_FALSE(params.quic_always_require_handshake_confirmation); | 154 EXPECT_FALSE(params.quic_always_require_handshake_confirmation); |
| 133 EXPECT_FALSE(params.quic_disable_connection_pooling); | 155 EXPECT_FALSE(params.quic_disable_connection_pooling); |
| 134 EXPECT_EQ(0, params.quic_load_server_info_timeout_ms); | 156 EXPECT_EQ(0, params.quic_load_server_info_timeout_ms); |
| 135 EXPECT_EQ(0.0f, params.quic_load_server_info_timeout_srtt_multiplier); | 157 EXPECT_EQ(0.0f, params.quic_load_server_info_timeout_srtt_multiplier); |
| 136 EXPECT_FALSE(params.quic_enable_truncated_connection_ids); | 158 EXPECT_FALSE(params.quic_enable_truncated_connection_ids); |
| 137 EXPECT_FALSE(params.quic_enable_connection_racing); | 159 EXPECT_FALSE(params.quic_enable_connection_racing); |
| 138 } | 160 } |
| 139 | 161 |
| 162 TEST_F(IOThreadTest, EnableQuicFromQuicProxyFieldTrialGroup) { |
| 163 base::FieldTrialList field_trial_list(new BadEntropyProvider()); |
| 164 base::FieldTrialList::CreateFieldTrial( |
| 165 data_reduction_proxy::DataReductionProxyParams::GetQuicFieldTrialName(), |
| 166 "Enabled"); |
| 167 |
| 168 ConfigureQuicGlobals(); |
| 169 net::HttpNetworkSession::Params params; |
| 170 InitializeNetworkSessionParams(¶ms); |
| 171 EXPECT_FALSE(params.enable_quic); |
| 172 EXPECT_TRUE(params.enable_quic_for_proxies); |
| 173 bool enable_quic_for_data_reduction_proxy = false; |
| 174 globals_.enable_quic_for_data_reduction_proxy.CopyToIfSet( |
| 175 &enable_quic_for_data_reduction_proxy); |
| 176 EXPECT_TRUE(enable_quic_for_data_reduction_proxy); |
| 177 } |
| 178 |
| 140 TEST_F(IOThreadTest, EnableQuicFromCommandLine) { | 179 TEST_F(IOThreadTest, EnableQuicFromCommandLine) { |
| 141 command_line_.AppendSwitch("enable-quic"); | 180 command_line_.AppendSwitch("enable-quic"); |
| 142 | 181 |
| 143 ConfigureQuicGlobals(); | 182 ConfigureQuicGlobals(); |
| 144 net::HttpNetworkSession::Params params; | 183 net::HttpNetworkSession::Params params; |
| 145 InitializeNetworkSessionParams(¶ms); | 184 InitializeNetworkSessionParams(¶ms); |
| 146 EXPECT_TRUE(params.enable_quic); | 185 EXPECT_TRUE(params.enable_quic); |
| 186 EXPECT_TRUE(params.enable_quic_for_proxies); |
| 187 bool enable_quic_for_data_reduction_proxy = true; |
| 188 globals_.enable_quic_for_data_reduction_proxy.CopyToIfSet( |
| 189 &enable_quic_for_data_reduction_proxy); |
| 190 EXPECT_FALSE(enable_quic_for_data_reduction_proxy); |
| 147 } | 191 } |
| 148 | 192 |
| 149 TEST_F(IOThreadTest, EnablePacingFromCommandLine) { | 193 TEST_F(IOThreadTest, EnablePacingFromCommandLine) { |
| 150 command_line_.AppendSwitch("enable-quic"); | 194 command_line_.AppendSwitch("enable-quic"); |
| 151 command_line_.AppendSwitch("enable-quic-pacing"); | 195 command_line_.AppendSwitch("enable-quic-pacing"); |
| 152 | 196 |
| 153 ConfigureQuicGlobals(); | 197 ConfigureQuicGlobals(); |
| 154 net::HttpNetworkSession::Params params; | 198 net::HttpNetworkSession::Params params; |
| 155 InitializeNetworkSessionParams(¶ms); | 199 InitializeNetworkSessionParams(¶ms); |
| 156 net::QuicTagVector options; | 200 net::QuicTagVector options; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 field_trial_group_ = "Enabled"; | 376 field_trial_group_ = "Enabled"; |
| 333 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; | 377 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; |
| 334 | 378 |
| 335 ConfigureQuicGlobals(); | 379 ConfigureQuicGlobals(); |
| 336 net::HttpNetworkSession::Params params; | 380 net::HttpNetworkSession::Params params; |
| 337 InitializeNetworkSessionParams(¶ms); | 381 InitializeNetworkSessionParams(¶ms); |
| 338 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); | 382 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); |
| 339 } | 383 } |
| 340 | 384 |
| 341 } // namespace test | 385 } // namespace test |
| OLD | NEW |