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 |
| 15 |
13 namespace test { | 16 namespace test { |
14 | 17 |
15 using ::testing::ElementsAre; | 18 using ::testing::ElementsAre; |
16 | 19 |
| 20 class BadEntropyProvider : public base::FieldTrial::EntropyProvider { |
| 21 public: |
| 22 ~BadEntropyProvider() override {} |
| 23 |
| 24 double GetEntropyForTrial(const std::string& trial_name, |
| 25 uint32 randomization_seed) const override { |
| 26 return 0.5; |
| 27 } |
| 28 }; |
| 29 |
17 class IOThreadPeer { | 30 class IOThreadPeer { |
18 public: | 31 public: |
19 static void ConfigureQuicGlobals( | 32 static void ConfigureQuicGlobals( |
20 const base::CommandLine& command_line, | 33 const base::CommandLine& command_line, |
21 base::StringPiece quic_trial_group, | 34 base::StringPiece quic_trial_group, |
22 const std::map<std::string, std::string>& quic_trial_params, | 35 const std::map<std::string, std::string>& quic_trial_params, |
23 IOThread::Globals* globals) { | 36 IOThread::Globals* globals) { |
24 IOThread::ConfigureQuicGlobals(command_line, quic_trial_group, | 37 IOThread::ConfigureQuicGlobals(command_line, quic_trial_group, |
25 quic_trial_params, globals); | 38 quic_trial_params, globals); |
26 } | 39 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 net::kProtoSPDY31)); | 120 net::kProtoSPDY31)); |
108 globals_.use_alternate_protocols.CopyToIfSet(&use_alternate_protocols); | 121 globals_.use_alternate_protocols.CopyToIfSet(&use_alternate_protocols); |
109 EXPECT_TRUE(use_alternate_protocols); | 122 EXPECT_TRUE(use_alternate_protocols); |
110 } | 123 } |
111 | 124 |
112 TEST_F(IOThreadTest, DisableQuicByDefault) { | 125 TEST_F(IOThreadTest, DisableQuicByDefault) { |
113 ConfigureQuicGlobals(); | 126 ConfigureQuicGlobals(); |
114 net::HttpNetworkSession::Params params; | 127 net::HttpNetworkSession::Params params; |
115 InitializeNetworkSessionParams(¶ms); | 128 InitializeNetworkSessionParams(¶ms); |
116 EXPECT_FALSE(params.enable_quic); | 129 EXPECT_FALSE(params.enable_quic); |
| 130 EXPECT_FALSE(params.enable_quic_for_proxies); |
117 } | 131 } |
118 | 132 |
119 TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { | 133 TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) { |
120 field_trial_group_ = "Enabled"; | 134 field_trial_group_ = "Enabled"; |
121 | 135 |
122 ConfigureQuicGlobals(); | 136 ConfigureQuicGlobals(); |
123 net::HttpNetworkSession::Params default_params; | 137 net::HttpNetworkSession::Params default_params; |
124 net::HttpNetworkSession::Params params; | 138 net::HttpNetworkSession::Params params; |
125 InitializeNetworkSessionParams(¶ms); | 139 InitializeNetworkSessionParams(¶ms); |
126 EXPECT_TRUE(params.enable_quic); | 140 EXPECT_TRUE(params.enable_quic); |
| 141 EXPECT_TRUE(params.enable_quic_for_proxies); |
127 EXPECT_EQ(1350u, params.quic_max_packet_length); | 142 EXPECT_EQ(1350u, params.quic_max_packet_length); |
128 EXPECT_EQ(1.0, params.alternate_protocol_probability_threshold); | 143 EXPECT_EQ(1.0, params.alternate_protocol_probability_threshold); |
129 EXPECT_EQ(default_params.quic_supported_versions, | 144 EXPECT_EQ(default_params.quic_supported_versions, |
130 params.quic_supported_versions); | 145 params.quic_supported_versions); |
131 EXPECT_EQ(net::QuicTagVector(), params.quic_connection_options); | 146 EXPECT_EQ(net::QuicTagVector(), params.quic_connection_options); |
132 EXPECT_FALSE(params.quic_always_require_handshake_confirmation); | 147 EXPECT_FALSE(params.quic_always_require_handshake_confirmation); |
133 EXPECT_FALSE(params.quic_disable_connection_pooling); | 148 EXPECT_FALSE(params.quic_disable_connection_pooling); |
134 EXPECT_EQ(0, params.quic_load_server_info_timeout_ms); | 149 EXPECT_EQ(0, params.quic_load_server_info_timeout_ms); |
135 EXPECT_EQ(0.0f, params.quic_load_server_info_timeout_srtt_multiplier); | 150 EXPECT_EQ(0.0f, params.quic_load_server_info_timeout_srtt_multiplier); |
136 EXPECT_FALSE(params.quic_enable_truncated_connection_ids); | 151 EXPECT_FALSE(params.quic_enable_truncated_connection_ids); |
137 } | 152 } |
138 | 153 |
| 154 TEST_F(IOThreadTest, EnableQuicFromQuicProxyFieldTrialGroup) { |
| 155 base::FieldTrialList field_trial_list(new BadEntropyProvider()); |
| 156 base::FieldTrialList::CreateFieldTrial( |
| 157 data_reduction_proxy::DataReductionProxyParams::GetFieldTrialName(), |
| 158 "Enabled"); |
| 159 |
| 160 ConfigureQuicGlobals(); |
| 161 net::HttpNetworkSession::Params default_params; |
| 162 net::HttpNetworkSession::Params params; |
| 163 InitializeNetworkSessionParams(¶ms); |
| 164 EXPECT_FALSE(params.enable_quic); |
| 165 EXPECT_TRUE(params.enable_quic_for_proxies); |
| 166 } |
| 167 |
| 168 |
139 TEST_F(IOThreadTest, EnableQuicFromCommandLine) { | 169 TEST_F(IOThreadTest, EnableQuicFromCommandLine) { |
140 command_line_.AppendSwitch("enable-quic"); | 170 command_line_.AppendSwitch("enable-quic"); |
141 | 171 |
142 ConfigureQuicGlobals(); | 172 ConfigureQuicGlobals(); |
143 net::HttpNetworkSession::Params params; | 173 net::HttpNetworkSession::Params params; |
144 InitializeNetworkSessionParams(¶ms); | 174 InitializeNetworkSessionParams(¶ms); |
145 EXPECT_TRUE(params.enable_quic); | 175 EXPECT_TRUE(params.enable_quic); |
| 176 EXPECT_TRUE(params.enable_quic_for_proxies); |
146 } | 177 } |
147 | 178 |
148 TEST_F(IOThreadTest, EnablePacingFromCommandLine) { | 179 TEST_F(IOThreadTest, EnablePacingFromCommandLine) { |
149 command_line_.AppendSwitch("enable-quic"); | 180 command_line_.AppendSwitch("enable-quic"); |
150 command_line_.AppendSwitch("enable-quic-pacing"); | 181 command_line_.AppendSwitch("enable-quic-pacing"); |
151 | 182 |
152 ConfigureQuicGlobals(); | 183 ConfigureQuicGlobals(); |
153 net::HttpNetworkSession::Params params; | 184 net::HttpNetworkSession::Params params; |
154 InitializeNetworkSessionParams(¶ms); | 185 InitializeNetworkSessionParams(¶ms); |
155 net::QuicTagVector options; | 186 net::QuicTagVector options; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 field_trial_group_ = "Enabled"; | 353 field_trial_group_ = "Enabled"; |
323 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; | 354 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; |
324 | 355 |
325 ConfigureQuicGlobals(); | 356 ConfigureQuicGlobals(); |
326 net::HttpNetworkSession::Params params; | 357 net::HttpNetworkSession::Params params; |
327 InitializeNetworkSessionParams(¶ms); | 358 InitializeNetworkSessionParams(¶ms); |
328 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); | 359 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); |
329 } | 360 } |
330 | 361 |
331 } // namespace test | 362 } // namespace test |
OLD | NEW |