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

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

Issue 1020363003: Independently enable SPDY versions from field trial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keep NextProtosSpdy31() for compatibility; reorder params. Created 5 years, 9 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
OLDNEW
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 "base/metrics/field_trial.h"
7 #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" 8 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h"
9 #include "net/http/http_network_session.h" 9 #include "net/http/http_network_session.h"
10 #include "net/http/http_server_properties_impl.h" 10 #include "net/http/http_server_properties_impl.h"
(...skipping 19 matching lines...) Expand all
30 public: 30 public:
31 static void ConfigureQuicGlobals( 31 static void ConfigureQuicGlobals(
32 const base::CommandLine& command_line, 32 const base::CommandLine& command_line,
33 base::StringPiece quic_trial_group, 33 base::StringPiece quic_trial_group,
34 const std::map<std::string, std::string>& quic_trial_params, 34 const std::map<std::string, std::string>& quic_trial_params,
35 IOThread::Globals* globals) { 35 IOThread::Globals* globals) {
36 IOThread::ConfigureQuicGlobals(command_line, quic_trial_group, 36 IOThread::ConfigureQuicGlobals(command_line, quic_trial_group,
37 quic_trial_params, globals); 37 quic_trial_params, globals);
38 } 38 }
39 39
40 static void ConfigureSpdyGlobals(
41 const base::CommandLine& command_line,
42 base::StringPiece spdy_trial_group,
43 const std::map<std::string, std::string>& spdy_trial_params,
44 IOThread::Globals* globals) {
45 IOThread::ConfigureSpdyGlobals(command_line, spdy_trial_group,
46 spdy_trial_params, globals);
47 }
48
40 static void InitializeNetworkSessionParamsFromGlobals( 49 static void InitializeNetworkSessionParamsFromGlobals(
41 const IOThread::Globals& globals, 50 const IOThread::Globals& globals,
42 net::HttpNetworkSession::Params* params) { 51 net::HttpNetworkSession::Params* params) {
43 IOThread::InitializeNetworkSessionParamsFromGlobals(globals, params); 52 IOThread::InitializeNetworkSessionParamsFromGlobals(globals, params);
44 } 53 }
45
46 static void ConfigureSpdyFromTrial(const std::string& trial_group,
47 IOThread::Globals* globals) {
48 IOThread::ConfigureSpdyFromTrial(trial_group, globals);
49 }
50 }; 54 };
51 55
52 class IOThreadTest : public testing::Test { 56 class IOThreadTest : public testing::Test {
53 public: 57 public:
54 IOThreadTest() : command_line_(base::CommandLine::NO_PROGRAM) { 58 IOThreadTest() : command_line_(base::CommandLine::NO_PROGRAM) {
55 globals_.http_server_properties.reset(new net::HttpServerPropertiesImpl()); 59 globals_.http_server_properties.reset(new net::HttpServerPropertiesImpl());
56 } 60 }
57 61
58 void ConfigureQuicGlobals() { 62 void ConfigureQuicGlobals() {
59 IOThreadPeer::ConfigureQuicGlobals(command_line_, field_trial_group_, 63 IOThreadPeer::ConfigureQuicGlobals(command_line_, field_trial_group_,
60 field_trial_params_, &globals_); 64 field_trial_params_, &globals_);
61 } 65 }
62 66
67 void ConfigureSpdyGlobals() {
68 IOThreadPeer::ConfigureSpdyGlobals(command_line_, field_trial_group_,
69 field_trial_params_, &globals_);
70 }
71
63 void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params) { 72 void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params) {
64 IOThreadPeer::InitializeNetworkSessionParamsFromGlobals(globals_, params); 73 IOThreadPeer::InitializeNetworkSessionParamsFromGlobals(globals_, params);
65 } 74 }
66 75
67 base::CommandLine command_line_; 76 base::CommandLine command_line_;
68 IOThread::Globals globals_; 77 IOThread::Globals globals_;
69 std::string field_trial_group_; 78 std::string field_trial_group_;
70 std::map<std::string, std::string> field_trial_params_; 79 std::map<std::string, std::string> field_trial_params_;
71 }; 80 };
72 81
73 TEST_F(IOThreadTest, InitializeNetworkSessionParamsFromGlobals) { 82 TEST_F(IOThreadTest, InitializeNetworkSessionParamsFromGlobals) {
74 globals_.quic_connection_options.push_back(net::kPACE); 83 globals_.quic_connection_options.push_back(net::kPACE);
75 globals_.quic_connection_options.push_back(net::kTBBR); 84 globals_.quic_connection_options.push_back(net::kTBBR);
76 globals_.quic_connection_options.push_back(net::kTIME); 85 globals_.quic_connection_options.push_back(net::kTIME);
77 86
78 net::HttpNetworkSession::Params params; 87 net::HttpNetworkSession::Params params;
79 InitializeNetworkSessionParams(&params); 88 InitializeNetworkSessionParams(&params);
80 EXPECT_EQ(globals_.quic_connection_options, 89 EXPECT_EQ(globals_.quic_connection_options,
81 params.quic_connection_options); 90 params.quic_connection_options);
82 } 91 }
83 92
84 TEST_F(IOThreadTest, SpdyFieldTrialHoldbackEnabled) { 93 TEST_F(IOThreadTest, SpdyFieldTrialHoldbackEnabled) {
85 net::HttpStreamFactory::set_spdy_enabled(true); 94 net::HttpStreamFactory::set_spdy_enabled(true);
86 IOThreadPeer::ConfigureSpdyFromTrial("SpdyDisabled", &globals_); 95 field_trial_group_ = "SpdyDisabled";
96 ConfigureSpdyGlobals();
87 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled()); 97 EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled());
88 } 98 }
89 99
90 TEST_F(IOThreadTest, SpdyFieldTrialSpdy31Enabled) { 100 TEST_F(IOThreadTest, SpdyFieldTrialSpdy31Enabled) {
91 bool use_alternate_protocols = false; 101 bool use_alternate_protocols = false;
92 IOThreadPeer::ConfigureSpdyFromTrial("Spdy31Enabled", &globals_); 102 field_trial_group_ = "Spdy31Enabled";
103 ConfigureSpdyGlobals();
93 EXPECT_THAT(globals_.next_protos, 104 EXPECT_THAT(globals_.next_protos,
94 ElementsAre(net::kProtoHTTP11, 105 ElementsAre(net::kProtoHTTP11,
95 net::kProtoQUIC1SPDY3, 106 net::kProtoQUIC1SPDY3,
96 net::kProtoSPDY31)); 107 net::kProtoSPDY31));
97 globals_.use_alternate_protocols.CopyToIfSet(&use_alternate_protocols); 108 globals_.use_alternate_protocols.CopyToIfSet(&use_alternate_protocols);
98 EXPECT_TRUE(use_alternate_protocols); 109 EXPECT_TRUE(use_alternate_protocols);
99 } 110 }
100 111
101 TEST_F(IOThreadTest, SpdyFieldTrialSpdy4Enabled) { 112 TEST_F(IOThreadTest, SpdyFieldTrialSpdy4Enabled) {
102 bool use_alternate_protocols = false; 113 bool use_alternate_protocols = false;
103 IOThreadPeer::ConfigureSpdyFromTrial("Spdy4Enabled", &globals_); 114 field_trial_group_ = "Spdy4Enabled";
115 ConfigureSpdyGlobals();
104 EXPECT_THAT( 116 EXPECT_THAT(
105 globals_.next_protos, 117 globals_.next_protos,
106 ElementsAre(net::kProtoHTTP11, net::kProtoQUIC1SPDY3, net::kProtoSPDY31, 118 ElementsAre(net::kProtoHTTP11, net::kProtoQUIC1SPDY3, net::kProtoSPDY31,
107 net::kProtoSPDY4_14, net::kProtoSPDY4)); 119 net::kProtoSPDY4_14, net::kProtoSPDY4));
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 }
123
124 TEST_F(IOThreadTest, SpdyFieldTrialDefault) {
125 field_trial_group_ = "";
126 ConfigureSpdyGlobals();
127 EXPECT_THAT(
128 globals_.next_protos,
129 ElementsAre(net::kProtoHTTP11, net::kProtoQUIC1SPDY3, net::kProtoSPDY31,
130 net::kProtoSPDY4_14, net::kProtoSPDY4));
131 bool use_alternate_protocols = false;
132 globals_.use_alternate_protocols.CopyToIfSet(&use_alternate_protocols);
133 EXPECT_TRUE(use_alternate_protocols);
134 }
135
136 TEST_F(IOThreadTest, SpdyFieldTrialParametrized) {
137 field_trial_params_["quic_enabled"] = "false";
138 field_trial_params_["spdy31_enabled"] = "false";
139 // Undefined parameter "h2_14_enabled" should default to false.
140 field_trial_params_["h2_enabled"] = "true";
141 field_trial_group_ = "ParametrizedHTTP2Only";
142 ConfigureSpdyGlobals();
143 EXPECT_THAT(globals_.next_protos,
144 ElementsAre(net::kProtoHTTP11, net::kProtoSPDY4));
145 bool use_alternate_protocols = false;
146 globals_.use_alternate_protocols.CopyToIfSet(&use_alternate_protocols);
147 EXPECT_TRUE(use_alternate_protocols);
148 }
149
150 TEST_F(IOThreadTest, SpdyFromCommandLine) {
151 command_line_.AppendSwitch("enable-spdy4");
Ryan Hamilton 2015/03/20 23:38:07 As long as you're testing the command line handlin
Bence 2015/03/23 14:19:13 Done.
152 // Command line should overwrite field trial group.
153 field_trial_group_ = "SpdyDisabled";
154 ConfigureSpdyGlobals();
155 EXPECT_THAT(
156 globals_.next_protos,
157 ElementsAre(net::kProtoHTTP11, net::kProtoQUIC1SPDY3, net::kProtoSPDY31,
158 net::kProtoSPDY4_14, net::kProtoSPDY4));
159 bool use_alternate_protocols = false;
160 globals_.use_alternate_protocols.CopyToIfSet(&use_alternate_protocols);
161 EXPECT_TRUE(use_alternate_protocols);
162 }
111 163
112 TEST_F(IOThreadTest, DisableQuicByDefault) { 164 TEST_F(IOThreadTest, DisableQuicByDefault) {
113 ConfigureQuicGlobals(); 165 ConfigureQuicGlobals();
114 net::HttpNetworkSession::Params params; 166 net::HttpNetworkSession::Params params;
115 InitializeNetworkSessionParams(&params); 167 InitializeNetworkSessionParams(&params);
116 EXPECT_FALSE(params.enable_quic); 168 EXPECT_FALSE(params.enable_quic);
117 EXPECT_FALSE(params.enable_quic_for_proxies); 169 EXPECT_FALSE(params.enable_quic_for_proxies);
118 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy()); 170 EXPECT_FALSE(IOThread::ShouldEnableQuicForDataReductionProxy());
119 } 171 }
120 172
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 field_trial_group_ = "Enabled"; 414 field_trial_group_ = "Enabled";
363 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; 415 field_trial_params_["alternate_protocol_probability_threshold"] = ".5";
364 416
365 ConfigureQuicGlobals(); 417 ConfigureQuicGlobals();
366 net::HttpNetworkSession::Params params; 418 net::HttpNetworkSession::Params params;
367 InitializeNetworkSessionParams(&params); 419 InitializeNetworkSessionParams(&params);
368 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); 420 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold);
369 } 421 }
370 422
371 } // namespace test 423 } // namespace test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698