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

Unified 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 side-by-side diff with in-line comments
Download patch
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);
}

Powered by Google App Engine
This is Rietveld 408576698