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

Unified 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: Finished 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 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
new file mode 100644
index 0000000000000000000000000000000000000000..f4ee04bbc01b91d9786f81e0b9f448b97be0c395
--- /dev/null
+++ b/chrome/browser/io_thread_unittest.cc
@@ -0,0 +1,235 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "chrome/browser/io_thread.h"
+#include "net/http/http_network_session.h"
+#include "net/http/http_server_properties_impl.h"
+#include "net/quic/quic_protocol.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace test {
+
+class IOThreadPeer {
+ public:
+ static void ConfigureQuicGlobals(
+ const base::CommandLine& command_line,
+ base::StringPiece quic_trial_group,
+ const std::map<std::string, std::string>& quic_trial_params,
+ IOThread::Globals* globals) {
+ IOThread::ConfigureQuicGlobals(command_line, quic_trial_group,
+ quic_trial_params, globals);
+ }
+
+ static void InitializeNetworkSessionParamsFromGlobals(
+ const IOThread::Globals& globals,
+ net::HttpNetworkSession::Params* params) {
+ IOThread::InitializeNetworkSessionParamsFromGlobals(globals, params);
+ }
+};
+
+class IOThreadTest : public testing::Test {
+ public:
+ IOThreadTest() : command_line_(base::CommandLine::NO_PROGRAM) {
+ globals_.http_server_properties.reset(new net::HttpServerPropertiesImpl());
+ }
+
+ void ConfigureQuicGlobals() {
+ IOThreadPeer::ConfigureQuicGlobals(command_line_, field_trial_group_,
+ field_trial_params_, &globals_);
+ }
+
+ void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params) {
+ IOThreadPeer::InitializeNetworkSessionParamsFromGlobals(globals_, params);
+ }
+
+ base::CommandLine command_line_;
+ IOThread::Globals globals_;
+ std::string field_trial_group_;
+ std::map<std::string, std::string> field_trial_params_;
+};
+
+TEST_F(IOThreadTest, InitializeNetworkSessionParamsFromGlobals) {
+ globals_.quic_connection_options.push_back(net::kPACE);
+ globals_.quic_connection_options.push_back(net::kTBBR);
+ globals_.quic_connection_options.push_back(net::kTIME);
+
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ EXPECT_EQ(globals_.quic_connection_options,
+ params.quic_connection_options);
+}
+
+TEST_F(IOThreadTest, DisableQuicByDefault) {
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ EXPECT_FALSE(params.enable_quic);
+}
+
+TEST_F(IOThreadTest, EnableQuicFromFieldTrialGroup) {
+ field_trial_group_ = "Enabled";
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ EXPECT_TRUE(params.enable_quic);
+ EXPECT_FALSE(params.enable_quic_pacing);
+}
+
+TEST_F(IOThreadTest, EnableQuicFromCommandLine) {
+ base::CommandLine::StringVector args;
+ args.push_back("chrome");
+ args.push_back("--enable-quic");
+ command_line_.InitFromArgv(args);
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ EXPECT_TRUE(params.enable_quic);
+}
+
+TEST_F(IOThreadTest, EnablePacingFromCommandLine) {
+ base::CommandLine::StringVector args;
+ args.push_back("chrome");
+ args.push_back("--enable-quic");
+ args.push_back("--enable-quic-pacing");
+ command_line_.InitFromArgv(args);
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ EXPECT_TRUE(params.enable_quic_pacing);
+}
+
+TEST_F(IOThreadTest, EnablePacingFromFieldTrialGroup) {
+ field_trial_group_ = "EnabledWithPacing";
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ EXPECT_TRUE(params.enable_quic_pacing);
+}
+
+TEST_F(IOThreadTest, EnablePacingFromFieldTrialParams) {
+ field_trial_group_ = "Enabled";
+ field_trial_params_["enable_pacing"] = "true";
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ EXPECT_TRUE(params.enable_quic_pacing);
+}
+
+TEST_F(IOThreadTest, EnableTimeBasedLossDetectionFromCommandLine) {
+ base::CommandLine::StringVector args;
+ args.push_back("chrome");
+ args.push_back("--enable-quic");
+ args.push_back("--enable-quic-time-based-loss-detection");
+ command_line_.InitFromArgv(args);
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ EXPECT_TRUE(params.enable_quic_time_based_loss_detection);
+}
+
+TEST_F(IOThreadTest, EnableTimeBasedLossDetectionFromFieldTrialGroup) {
+ field_trial_group_ = "EnabledWithTimeBasedLossDetection";
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ EXPECT_TRUE(params.enable_quic_time_based_loss_detection);
+}
+
+TEST_F(IOThreadTest, EnableTimeBasedLossDetectionFromFieldTrialParams) {
+ field_trial_group_ = "Enabled";
+ field_trial_params_["enable_time_based_loss_detection"] = "true";
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ EXPECT_TRUE(params.enable_quic_time_based_loss_detection);
jar (doing other things) 2014/06/20 23:25:13 nit: FWIW: I don't think you ever test to see if t
Ryan Hamilton 2014/06/21 02:45:23 Done.
+}
+
+TEST_F(IOThreadTest, PacketLengthFromCommandLine) {
+ base::CommandLine::StringVector args;
+ args.push_back("chrome");
+ args.push_back("--enable-quic");
+ args.push_back("--quic-max-packet-length=1350");
+ command_line_.InitFromArgv(args);
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ EXPECT_EQ(1350u, params.quic_max_packet_length);
+}
+
+TEST_F(IOThreadTest, PacketLengthFromFieldTrialGroup) {
+ field_trial_group_ = "Enabled1350BytePackets";
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ EXPECT_EQ(1350u, params.quic_max_packet_length);
jar (doing other things) 2014/06/20 23:25:13 nit: nicer would be to use different values, so be
Ryan Hamilton 2014/06/21 02:45:23 I'm now checking that it's set to 1200 by default
jar (doing other things) 2014/06/22 18:48:34 Perfect. Thanks.
+}
+
+TEST_F(IOThreadTest, PacketLengthFromFieldTrialParams) {
+ field_trial_group_ = "Enabled";
+ field_trial_params_["max_packet_length"] = "1350";
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ EXPECT_EQ(1350u, params.quic_max_packet_length);
+}
+
+TEST_F(IOThreadTest, QuicVersionFromCommandLine) {
+ base::CommandLine::StringVector args;
+ args.push_back("chrome");
+ args.push_back("--enable-quic");
+ args.push_back("--quic-version=QUIC_VERSION_18");
+ command_line_.InitFromArgv(args);
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ net::QuicVersionVector supported_versions;
+ supported_versions.push_back(net::QUIC_VERSION_18);
+ EXPECT_EQ(supported_versions,
+ params.quic_supported_versions);
+}
+
+TEST_F(IOThreadTest, QuicVersionFromFieldTrialParams) {
+ field_trial_group_ = "Enabled";
+ field_trial_params_["quic_version"] = "QUIC_VERSION_18";
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+ net::QuicVersionVector supported_versions;
+ supported_versions.push_back(net::QUIC_VERSION_18);
jar (doing other things) 2014/06/20 23:25:12 Will this test fail as we stop supporting version
Ryan Hamilton 2014/06/21 02:45:23 Indeed. Refactored to programmatically use the old
jar (doing other things) 2014/06/22 18:48:34 Perfect. Thanks.
+ EXPECT_EQ(supported_versions,
+ params.quic_supported_versions);
+}
+
+TEST_F(IOThreadTest, QuicConnectionOptions) {
+ field_trial_group_ = "Enabled";
+ field_trial_params_["congestion_options"] = "PACE,TIME,TBBR,REJ";
+
+ ConfigureQuicGlobals();
+ net::HttpNetworkSession::Params params;
+ InitializeNetworkSessionParams(&params);
+
+ net::QuicTagVector options;
+ options.push_back(net::kPACE);
+ options.push_back(net::kTIME);
+ options.push_back(net::kTBBR);
+ options.push_back(net::kREJ);
+ EXPECT_EQ(options, params.quic_connection_options);
+
+}
+
+} // namespace test

Powered by Google App Engine
This is Rietveld 408576698