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 "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); | |
| 117 } | 130 } |
| 118 | 131 |
| 119 TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { | 132 TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { |
| 120 field_trial_group_ = "Enabled"; | 133 field_trial_group_ = "Enabled"; |
| 121 | 134 |
| 122 ConfigureQuicGlobals(); | 135 ConfigureQuicGlobals(); |
| 123 net::HttpNetworkSession::Params default_params; | 136 net::HttpNetworkSession::Params default_params; |
| 124 net::HttpNetworkSession::Params params; | 137 net::HttpNetworkSession::Params params; |
| 125 InitializeNetworkSessionParams(¶ms); | 138 InitializeNetworkSessionParams(¶ms); |
| 126 EXPECT_TRUE(params.enable_quic); | 139 EXPECT_TRUE(params.enable_quic); |
| 140 EXPECT_TRUE(params.enable_quic_for_proxies); | |
| 127 EXPECT_EQ(1350u, params.quic_max_packet_length); | 141 EXPECT_EQ(1350u, params.quic_max_packet_length); |
| 128 EXPECT_EQ(1.0, params.alternate_protocol_probability_threshold); | 142 EXPECT_EQ(1.0, params.alternate_protocol_probability_threshold); |
| 129 EXPECT_EQ(default_params.quic_supported_versions, | 143 EXPECT_EQ(default_params.quic_supported_versions, |
| 130 params.quic_supported_versions); | 144 params.quic_supported_versions); |
| 131 EXPECT_EQ(net::QuicTagVector(), params.quic_connection_options); | 145 EXPECT_EQ(net::QuicTagVector(), params.quic_connection_options); |
| 132 EXPECT_FALSE(params.quic_always_require_handshake_confirmation); | 146 EXPECT_FALSE(params.quic_always_require_handshake_confirmation); |
| 133 EXPECT_FALSE(params.quic_disable_connection_pooling); | 147 EXPECT_FALSE(params.quic_disable_connection_pooling); |
| 134 EXPECT_EQ(0, params.quic_load_server_info_timeout_ms); | 148 EXPECT_EQ(0, params.quic_load_server_info_timeout_ms); |
| 135 EXPECT_EQ(0.0f, params.quic_load_server_info_timeout_srtt_multiplier); | 149 EXPECT_EQ(0.0f, params.quic_load_server_info_timeout_srtt_multiplier); |
| 136 EXPECT_FALSE(params.quic_enable_truncated_connection_ids); | 150 EXPECT_FALSE(params.quic_enable_truncated_connection_ids); |
| 137 } | 151 } |
| 138 | 152 |
| 153 TEST_F(IOThreadTest, EnableQuicFromQuicProxyFieldTrialGroup) { | |
| 154 base::FieldTrialList field_trial_list(new BadEntropyProvider()); | |
| 155 base::FieldTrialList::CreateFieldTrial( | |
| 156 data_reduction_proxy::DataReductionProxyParams::GetQuicFieldTrialName(), | |
| 157 "Enabled"); | |
| 158 | |
| 159 ConfigureQuicGlobals(); | |
| 160 net::HttpNetworkSession::Params params; | |
| 161 InitializeNetworkSessionParams(¶ms); | |
| 162 EXPECT_FALSE(params.enable_quic); | |
| 163 EXPECT_TRUE(params.enable_quic_for_proxies); | |
|
mmenke
2015/02/12 18:10:45
I'm not following this test.
tbansal1
2015/02/13 17:10:40
When DRP field trial is enabled, we are making sur
| |
| 164 } | |
| 165 | |
| 166 | |
|
mmenke
2015/02/12 18:10:45
nit: Remove extra blank line
tbansal1
2015/02/13 17:10:40
Done.
| |
| 139 TEST_F(IOThreadTest, EnableQuicFromCommandLine) { | 167 TEST_F(IOThreadTest, EnableQuicFromCommandLine) { |
| 140 command_line_.AppendSwitch("enable-quic"); | 168 command_line_.AppendSwitch("enable-quic"); |
| 141 | 169 |
| 142 ConfigureQuicGlobals(); | 170 ConfigureQuicGlobals(); |
| 143 net::HttpNetworkSession::Params params; | 171 net::HttpNetworkSession::Params params; |
| 144 InitializeNetworkSessionParams(¶ms); | 172 InitializeNetworkSessionParams(¶ms); |
| 145 EXPECT_TRUE(params.enable_quic); | 173 EXPECT_TRUE(params.enable_quic); |
| 174 EXPECT_TRUE(params.enable_quic_for_proxies); | |
| 146 } | 175 } |
| 147 | 176 |
| 148 TEST_F(IOThreadTest, EnablePacingFromCommandLine) { | 177 TEST_F(IOThreadTest, EnablePacingFromCommandLine) { |
| 149 command_line_.AppendSwitch("enable-quic"); | 178 command_line_.AppendSwitch("enable-quic"); |
| 150 command_line_.AppendSwitch("enable-quic-pacing"); | 179 command_line_.AppendSwitch("enable-quic-pacing"); |
| 151 | 180 |
| 152 ConfigureQuicGlobals(); | 181 ConfigureQuicGlobals(); |
| 153 net::HttpNetworkSession::Params params; | 182 net::HttpNetworkSession::Params params; |
| 154 InitializeNetworkSessionParams(¶ms); | 183 InitializeNetworkSessionParams(¶ms); |
| 155 net::QuicTagVector options; | 184 net::QuicTagVector options; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 field_trial_group_ = "Enabled"; | 351 field_trial_group_ = "Enabled"; |
| 323 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; | 352 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; |
| 324 | 353 |
| 325 ConfigureQuicGlobals(); | 354 ConfigureQuicGlobals(); |
| 326 net::HttpNetworkSession::Params params; | 355 net::HttpNetworkSession::Params params; |
| 327 InitializeNetworkSessionParams(¶ms); | 356 InitializeNetworkSessionParams(¶ms); |
| 328 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); | 357 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); |
| 329 } | 358 } |
| 330 | 359 |
| 331 } // namespace test | 360 } // namespace test |
| OLD | NEW |