Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: chrome/browser/io_thread_unittest.cc

Issue 346043002: Add support for setting QUIC connection options via field trial config. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better Windows fix Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/command_line.h"
6 #include "chrome/browser/io_thread.h"
7 #include "net/http/http_network_session.h"
8 #include "net/http/http_server_properties_impl.h"
9 #include "net/quic/quic_protocol.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace test {
13
14 class IOThreadPeer {
15 public:
16 static void ConfigureQuicGlobals(
17 const base::CommandLine& command_line,
18 base::StringPiece quic_trial_group,
19 const std::map<std::string, std::string>& quic_trial_params,
20 IOThread::Globals* globals) {
21 IOThread::ConfigureQuicGlobals(command_line, quic_trial_group,
22 quic_trial_params, globals);
23 }
24
25 static void InitializeNetworkSessionParamsFromGlobals(
26 const IOThread::Globals& globals,
27 net::HttpNetworkSession::Params* params) {
28 IOThread::InitializeNetworkSessionParamsFromGlobals(globals, params);
29 }
30 };
31
32 class IOThreadTest : public testing::Test {
33 public:
34 IOThreadTest() : command_line_(base::CommandLine::NO_PROGRAM) {
35 globals_.http_server_properties.reset(new net::HttpServerPropertiesImpl());
36 }
37
38 void ConfigureQuicGlobals() {
39 IOThreadPeer::ConfigureQuicGlobals(command_line_, field_trial_group_,
40 field_trial_params_, &globals_);
41 }
42
43 void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params) {
44 IOThreadPeer::InitializeNetworkSessionParamsFromGlobals(globals_, params);
45 }
46
47 base::CommandLine command_line_;
48 IOThread::Globals globals_;
49 std::string field_trial_group_;
50 std::map<std::string, std::string> field_trial_params_;
51 };
52
53 TEST_F(IOThreadTest, InitializeNetworkSessionParamsFromGlobals) {
54 globals_.quic_connection_options.push_back(net::kPACE);
55 globals_.quic_connection_options.push_back(net::kTBBR);
56 globals_.quic_connection_options.push_back(net::kTIME);
57
58 net::HttpNetworkSession::Params params;
59 InitializeNetworkSessionParams(&params);
60 EXPECT_EQ(globals_.quic_connection_options,
61 params.quic_connection_options);
62 }
63
64 TEST_F(IOThreadTest, DisableQuicByDefault) {
65 ConfigureQuicGlobals();
66 net::HttpNetworkSession::Params params;
67 InitializeNetworkSessionParams(&params);
68 EXPECT_FALSE(params.enable_quic);
69 }
70
71 TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) {
72 field_trial_group_ = "Enabled";
73
74 ConfigureQuicGlobals();
75 net::HttpNetworkSession::Params default_params;
76 net::HttpNetworkSession::Params params;
77 InitializeNetworkSessionParams(&params);
78 EXPECT_TRUE(params.enable_quic);
79 EXPECT_FALSE(params.enable_quic_pacing);
80 EXPECT_FALSE(params.enable_quic_time_based_loss_detection);
81 EXPECT_EQ(1200u, params.quic_max_packet_length);
82 EXPECT_EQ(default_params.quic_supported_versions,
83 params.quic_supported_versions);
84 EXPECT_EQ(net::QuicTagVector(), params.quic_connection_options);
85 }
86
87 TEST_F(IOThreadTest, EnableQuicFromCommandLine) {
88 base::CommandLine::StringVector args;
89 command_line_.AppendSwitch("enable-quic");
90
91 ConfigureQuicGlobals();
92 net::HttpNetworkSession::Params params;
93 InitializeNetworkSessionParams(&params);
94 EXPECT_TRUE(params.enable_quic);
95 }
96
97 TEST_F(IOThreadTest, EnablePacingFromCommandLine) {
98 base::CommandLine::StringVector args;
99 command_line_.AppendSwitch("enable-quic");
100 command_line_.AppendSwitch("enable-quic-pacing");
101
102 ConfigureQuicGlobals();
103 net::HttpNetworkSession::Params params;
104 InitializeNetworkSessionParams(&params);
105 EXPECT_TRUE(params.enable_quic_pacing);
106 }
107
108 TEST_F(IOThreadTest, EnablePacingFromFieldTrialGroup) {
109 field_trial_group_ = "EnabledWithPacing";
110
111 ConfigureQuicGlobals();
112 net::HttpNetworkSession::Params params;
113 InitializeNetworkSessionParams(&params);
114 EXPECT_TRUE(params.enable_quic_pacing);
115 }
116
117 TEST_F(IOThreadTest, EnablePacingFromFieldTrialParams) {
118 field_trial_group_ = "Enabled";
119 field_trial_params_["enable_pacing"] = "true";
120
121 ConfigureQuicGlobals();
122 net::HttpNetworkSession::Params params;
123 InitializeNetworkSessionParams(&params);
124 EXPECT_TRUE(params.enable_quic_pacing);
125 }
126
127 TEST_F(IOThreadTest, EnableTimeBasedLossDetectionFromCommandLine) {
128 base::CommandLine::StringVector args;
129 command_line_.AppendSwitch("enable-quic");
130 command_line_.AppendSwitch("enable-quic-time-based-loss-detection");
131
132 ConfigureQuicGlobals();
133 net::HttpNetworkSession::Params params;
134 InitializeNetworkSessionParams(&params);
135 EXPECT_TRUE(params.enable_quic_time_based_loss_detection);
136 }
137
138 TEST_F(IOThreadTest, EnableTimeBasedLossDetectionFromFieldTrialGroup) {
139 field_trial_group_ = "EnabledWithTimeBasedLossDetection";
140
141 ConfigureQuicGlobals();
142 net::HttpNetworkSession::Params params;
143 InitializeNetworkSessionParams(&params);
144 EXPECT_TRUE(params.enable_quic_time_based_loss_detection);
145 }
146
147 TEST_F(IOThreadTest, EnableTimeBasedLossDetectionFromFieldTrialParams) {
148 field_trial_group_ = "Enabled";
149 field_trial_params_["enable_time_based_loss_detection"] = "true";
150
151 ConfigureQuicGlobals();
152 net::HttpNetworkSession::Params params;
153 InitializeNetworkSessionParams(&params);
154 EXPECT_TRUE(params.enable_quic_time_based_loss_detection);
155 }
156
157 TEST_F(IOThreadTest, PacketLengthFromCommandLine) {
158 base::CommandLine::StringVector args;
159 command_line_.AppendSwitch("enable-quic");
160 command_line_.AppendSwitchASCII("quic-max-packet-length", "1350");
161
162 ConfigureQuicGlobals();
163 net::HttpNetworkSession::Params params;
164 InitializeNetworkSessionParams(&params);
165 EXPECT_EQ(1350u, params.quic_max_packet_length);
166 }
167
168 TEST_F(IOThreadTest, PacketLengthFromFieldTrialGroup) {
169 field_trial_group_ = "Enabled1350BytePackets";
170
171 ConfigureQuicGlobals();
172 net::HttpNetworkSession::Params params;
173 InitializeNetworkSessionParams(&params);
174 EXPECT_EQ(1350u, params.quic_max_packet_length);
175 }
176
177 TEST_F(IOThreadTest, PacketLengthFromFieldTrialParams) {
178 field_trial_group_ = "Enabled";
179 field_trial_params_["max_packet_length"] = "1350";
180
181 ConfigureQuicGlobals();
182 net::HttpNetworkSession::Params params;
183 InitializeNetworkSessionParams(&params);
184 EXPECT_EQ(1350u, params.quic_max_packet_length);
185 }
186
187 TEST_F(IOThreadTest, QuicVersionFromCommandLine) {
188 base::CommandLine::StringVector args;
189 command_line_.AppendSwitch("enable-quic");
190 std::string version =
191 net::QuicVersionToString(net::QuicSupportedVersions().back());
192 command_line_.AppendSwitchASCII("quic-version", version);
193
194 ConfigureQuicGlobals();
195 net::HttpNetworkSession::Params params;
196 InitializeNetworkSessionParams(&params);
197 net::QuicVersionVector supported_versions;
198 supported_versions.push_back(net::QuicSupportedVersions().back());
199 EXPECT_EQ(supported_versions,
200 params.quic_supported_versions);
201 }
202
203 TEST_F(IOThreadTest, QuicVersionFromFieldTrialParams) {
204 field_trial_group_ = "Enabled";
205 field_trial_params_["quic_version"] =
206 net::QuicVersionToString(net::QuicSupportedVersions().back());
207
208 ConfigureQuicGlobals();
209 net::HttpNetworkSession::Params params;
210 InitializeNetworkSessionParams(&params);
211 net::QuicVersionVector supported_versions;
212 supported_versions.push_back(net::QuicSupportedVersions().back());
213 EXPECT_EQ(supported_versions,
214 params.quic_supported_versions);
215 }
216
217 TEST_F(IOThreadTest, QuicConnectionOptionsFromCommandLine) {
218 base::CommandLine::StringVector args;
219 command_line_.AppendSwitch("enable-quic");
220 command_line_.AppendSwitchASCII("quic-connection-options",
221 "PACE,TIME,TBBR,REJ");
222
223 ConfigureQuicGlobals();
224 net::HttpNetworkSession::Params params;
225 InitializeNetworkSessionParams(&params);
226
227 net::QuicTagVector options;
228 options.push_back(net::kPACE);
229 options.push_back(net::kTIME);
230 options.push_back(net::kTBBR);
231 options.push_back(net::kREJ);
232 EXPECT_EQ(options, params.quic_connection_options);
233 }
234
235 TEST_F(IOThreadTest, QuicConnectionOptionsFromFieldTrialParams) {
236 field_trial_group_ = "Enabled";
237 field_trial_params_["congestion_options"] = "PACE,TIME,TBBR,REJ";
238
239 ConfigureQuicGlobals();
240 net::HttpNetworkSession::Params params;
241 InitializeNetworkSessionParams(&params);
242
243 net::QuicTagVector options;
244 options.push_back(net::kPACE);
245 options.push_back(net::kTIME);
246 options.push_back(net::kTBBR);
247 options.push_back(net::kREJ);
248 EXPECT_EQ(options, params.quic_connection_options);
249 }
250
251 } // namespace test
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698