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); |
127 EXPECT_EQ(1350u, params.quic_max_packet_length); | 140 EXPECT_EQ(1350u, params.quic_max_packet_length); |
128 EXPECT_EQ(1.0, params.alternate_protocol_probability_threshold); | 141 EXPECT_EQ(1.0, params.alternate_protocol_probability_threshold); |
129 EXPECT_EQ(default_params.quic_supported_versions, | 142 EXPECT_EQ(default_params.quic_supported_versions, |
130 params.quic_supported_versions); | 143 params.quic_supported_versions); |
131 EXPECT_EQ(net::QuicTagVector(), params.quic_connection_options); | 144 EXPECT_EQ(net::QuicTagVector(), params.quic_connection_options); |
132 EXPECT_FALSE(params.quic_always_require_handshake_confirmation); | 145 EXPECT_FALSE(params.quic_always_require_handshake_confirmation); |
133 EXPECT_FALSE(params.quic_disable_connection_pooling); | 146 EXPECT_FALSE(params.quic_disable_connection_pooling); |
134 EXPECT_EQ(0, params.quic_load_server_info_timeout_ms); | 147 EXPECT_EQ(0, params.quic_load_server_info_timeout_ms); |
135 EXPECT_EQ(0.0f, params.quic_load_server_info_timeout_srtt_multiplier); | 148 EXPECT_EQ(0.0f, params.quic_load_server_info_timeout_srtt_multiplier); |
136 EXPECT_FALSE(params.quic_enable_truncated_connection_ids); | 149 EXPECT_FALSE(params.quic_enable_truncated_connection_ids); |
137 EXPECT_FALSE(params.quic_enable_connection_racing); | 150 EXPECT_FALSE(params.quic_enable_connection_racing); |
mmenke
2015/02/13 18:27:15
Should check params.enable_quic_for_proxies here (
| |
138 } | 151 } |
139 | 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/13 17:45:21
Could you explain how this works? I really don't
tbansal1
2015/02/13 18:03:47
Constructor of FieldTrialList requires an entropy
mmenke
2015/02/13 18:09:44
Thanks for the explanation!
Worth having a test w
tbansal1
2015/02/13 19:54:29
Done.
| |
164 } | |
165 | |
140 TEST_F(IOThreadTest, EnableQuicFromCommandLine) { | 166 TEST_F(IOThreadTest, EnableQuicFromCommandLine) { |
141 command_line_.AppendSwitch("enable-quic"); | 167 command_line_.AppendSwitch("enable-quic"); |
142 | 168 |
143 ConfigureQuicGlobals(); | 169 ConfigureQuicGlobals(); |
144 net::HttpNetworkSession::Params params; | 170 net::HttpNetworkSession::Params params; |
145 InitializeNetworkSessionParams(¶ms); | 171 InitializeNetworkSessionParams(¶ms); |
146 EXPECT_TRUE(params.enable_quic); | 172 EXPECT_TRUE(params.enable_quic); |
147 } | 173 } |
148 | 174 |
149 TEST_F(IOThreadTest, EnablePacingFromCommandLine) { | 175 TEST_F(IOThreadTest, EnablePacingFromCommandLine) { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 field_trial_group_ = "Enabled"; | 358 field_trial_group_ = "Enabled"; |
333 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; | 359 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; |
334 | 360 |
335 ConfigureQuicGlobals(); | 361 ConfigureQuicGlobals(); |
336 net::HttpNetworkSession::Params params; | 362 net::HttpNetworkSession::Params params; |
337 InitializeNetworkSessionParams(¶ms); | 363 InitializeNetworkSessionParams(¶ms); |
338 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); | 364 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); |
339 } | 365 } |
340 | 366 |
341 } // namespace test | 367 } // namespace test |
OLD | NEW |