Chromium Code Reviews| Index: chrome/browser/io_thread_unittest.cc |
| diff --git a/chrome/browser/io_thread_unittest.cc b/chrome/browser/io_thread_unittest.cc |
| index 33bde3d841801dc4491ac268c3b7b064fa933008..20dcf1b431cccfd456b0ecad4789c85928be9916 100644 |
| --- a/chrome/browser/io_thread_unittest.cc |
| +++ b/chrome/browser/io_thread_unittest.cc |
| @@ -37,16 +37,20 @@ class IOThreadPeer { |
| quic_trial_params, globals); |
| } |
| + static void ConfigureSpdyGlobals( |
| + const base::CommandLine& command_line, |
| + base::StringPiece spdy_trial_group, |
| + const std::map<std::string, std::string>& spdy_trial_params, |
| + IOThread::Globals* globals) { |
| + IOThread::ConfigureSpdyGlobals(command_line, spdy_trial_group, |
| + spdy_trial_params, globals); |
| + } |
| + |
| static void InitializeNetworkSessionParamsFromGlobals( |
| const IOThread::Globals& globals, |
| net::HttpNetworkSession::Params* params) { |
| IOThread::InitializeNetworkSessionParamsFromGlobals(globals, params); |
| } |
| - |
| - static void ConfigureSpdyFromTrial(const std::string& trial_group, |
| - IOThread::Globals* globals) { |
| - IOThread::ConfigureSpdyFromTrial(trial_group, globals); |
| - } |
| }; |
| class IOThreadTest : public testing::Test { |
| @@ -60,6 +64,11 @@ class IOThreadTest : public testing::Test { |
| field_trial_params_, &globals_); |
| } |
| + void ConfigureSpdyGlobals() { |
| + IOThreadPeer::ConfigureSpdyGlobals(command_line_, field_trial_group_, |
| + field_trial_params_, &globals_); |
| + } |
| + |
| void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params) { |
| IOThreadPeer::InitializeNetworkSessionParamsFromGlobals(globals_, params); |
| } |
| @@ -83,13 +92,15 @@ TEST_F(IOThreadTest, InitializeNetworkSessionParamsFromGlobals) { |
| TEST_F(IOThreadTest, SpdyFieldTrialHoldbackEnabled) { |
| net::HttpStreamFactory::set_spdy_enabled(true); |
| - IOThreadPeer::ConfigureSpdyFromTrial("SpdyDisabled", &globals_); |
| + field_trial_group_ = "SpdyDisabled"; |
| + ConfigureSpdyGlobals(); |
| EXPECT_FALSE(net::HttpStreamFactory::spdy_enabled()); |
| } |
| TEST_F(IOThreadTest, SpdyFieldTrialSpdy31Enabled) { |
| bool use_alternate_protocols = false; |
| - IOThreadPeer::ConfigureSpdyFromTrial("Spdy31Enabled", &globals_); |
| + field_trial_group_ = "Spdy31Enabled"; |
| + ConfigureSpdyGlobals(); |
| EXPECT_THAT(globals_.next_protos, |
| ElementsAre(net::kProtoHTTP11, |
| net::kProtoQUIC1SPDY3, |
| @@ -100,11 +111,52 @@ TEST_F(IOThreadTest, SpdyFieldTrialSpdy31Enabled) { |
| TEST_F(IOThreadTest, SpdyFieldTrialSpdy4Enabled) { |
| bool use_alternate_protocols = false; |
| - IOThreadPeer::ConfigureSpdyFromTrial("Spdy4Enabled", &globals_); |
| + field_trial_group_ = "Spdy4Enabled"; |
| + ConfigureSpdyGlobals(); |
| + EXPECT_THAT( |
| + globals_.next_protos, |
| + ElementsAre(net::kProtoHTTP11, net::kProtoQUIC1SPDY3, net::kProtoSPDY31, |
| + net::kProtoSPDY4_14, net::kProtoSPDY4)); |
| + globals_.use_alternate_protocols.CopyToIfSet(&use_alternate_protocols); |
| + EXPECT_TRUE(use_alternate_protocols); |
| +} |
| + |
| +TEST_F(IOThreadTest, SpdyFieldTrialDefault) { |
| + field_trial_group_ = ""; |
| + ConfigureSpdyGlobals(); |
| EXPECT_THAT( |
| globals_.next_protos, |
| ElementsAre(net::kProtoHTTP11, net::kProtoQUIC1SPDY3, net::kProtoSPDY31, |
| net::kProtoSPDY4_14, net::kProtoSPDY4)); |
| + bool use_alternate_protocols = false; |
| + globals_.use_alternate_protocols.CopyToIfSet(&use_alternate_protocols); |
| + EXPECT_TRUE(use_alternate_protocols); |
| +} |
| + |
| +TEST_F(IOThreadTest, SpdyFieldTrialParametrized) { |
| + field_trial_params_["quic_enabled"] = "false"; |
| + field_trial_params_["spdy31_enabled"] = "false"; |
| + // Undefined parameter "h2_14_enabled" should default to false. |
| + field_trial_params_["h2_enabled"] = "true"; |
| + field_trial_group_ = "ParametrizedHTTP2Only"; |
| + ConfigureSpdyGlobals(); |
| + EXPECT_THAT(globals_.next_protos, |
| + ElementsAre(net::kProtoHTTP11, net::kProtoSPDY4)); |
| + bool use_alternate_protocols = false; |
| + globals_.use_alternate_protocols.CopyToIfSet(&use_alternate_protocols); |
| + EXPECT_TRUE(use_alternate_protocols); |
| +} |
| + |
| +TEST_F(IOThreadTest, SpdyFromCommandLine) { |
| + 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.
|
| + // Command line should overwrite field trial group. |
| + field_trial_group_ = "SpdyDisabled"; |
| + ConfigureSpdyGlobals(); |
| + EXPECT_THAT( |
| + globals_.next_protos, |
| + ElementsAre(net::kProtoHTTP11, net::kProtoQUIC1SPDY3, net::kProtoSPDY31, |
| + net::kProtoSPDY4_14, net::kProtoSPDY4)); |
| + bool use_alternate_protocols = false; |
| globals_.use_alternate_protocols.CopyToIfSet(&use_alternate_protocols); |
| EXPECT_TRUE(use_alternate_protocols); |
| } |