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 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); |
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 EXPECT_FALSE(params.quic_enable_connection_racing); | 152 EXPECT_FALSE(params.quic_enable_connection_racing); |
| 153 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); |
| 154 } |
| 155 |
| 156 TEST_F(IOThreadTest, EnableQuicFromQuicProxyFieldTrialGroup) { |
| 157 base::FieldTrialList field_trial_list(new BadEntropyProvider()); |
| 158 base::FieldTrialList::CreateFieldTrial( |
| 159 data_reduction_proxy::DataReductionProxyParams::GetQuicFieldTrialName(), |
| 160 "Enabled"); |
| 161 |
| 162 ConfigureQuicGlobals(); |
| 163 net::HttpNetworkSession::Params params; |
| 164 InitializeNetworkSessionParams(¶ms); |
| 165 EXPECT_FALSE(params.enable_quic); |
| 166 EXPECT_TRUE(params.enable_quic_for_proxies); |
| 167 EXPECT_TRUE(IOThread::ShouldEnableQuicForDataReductionProxy()); |
138 } | 168 } |
139 | 169 |
140 TEST_F(IOThreadTest, EnableQuicFromCommandLine) { | 170 TEST_F(IOThreadTest, EnableQuicFromCommandLine) { |
141 command_line_.AppendSwitch("enable-quic"); | 171 command_line_.AppendSwitch("enable-quic"); |
142 | 172 |
143 ConfigureQuicGlobals(); | 173 ConfigureQuicGlobals(); |
144 net::HttpNetworkSession::Params params; | 174 net::HttpNetworkSession::Params params; |
145 InitializeNetworkSessionParams(¶ms); | 175 InitializeNetworkSessionParams(¶ms); |
146 EXPECT_TRUE(params.enable_quic); | 176 EXPECT_TRUE(params.enable_quic); |
| 177 EXPECT_TRUE(params.enable_quic_for_proxies); |
| 178 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); |
147 } | 179 } |
148 | 180 |
149 TEST_F(IOThreadTest, EnablePacingFromCommandLine) { | 181 TEST_F(IOThreadTest, EnablePacingFromCommandLine) { |
150 command_line_.AppendSwitch("enable-quic"); | 182 command_line_.AppendSwitch("enable-quic"); |
151 command_line_.AppendSwitch("enable-quic-pacing"); | 183 command_line_.AppendSwitch("enable-quic-pacing"); |
152 | 184 |
153 ConfigureQuicGlobals(); | 185 ConfigureQuicGlobals(); |
154 net::HttpNetworkSession::Params params; | 186 net::HttpNetworkSession::Params params; |
155 InitializeNetworkSessionParams(¶ms); | 187 InitializeNetworkSessionParams(¶ms); |
156 net::QuicTagVector options; | 188 net::QuicTagVector options; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 field_trial_group_ = "Enabled"; | 364 field_trial_group_ = "Enabled"; |
333 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; | 365 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; |
334 | 366 |
335 ConfigureQuicGlobals(); | 367 ConfigureQuicGlobals(); |
336 net::HttpNetworkSession::Params params; | 368 net::HttpNetworkSession::Params params; |
337 InitializeNetworkSessionParams(¶ms); | 369 InitializeNetworkSessionParams(¶ms); |
338 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); | 370 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); |
339 } | 371 } |
340 | 372 |
341 } // namespace test | 373 } // namespace test |
OLD | NEW |