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

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

Issue 1124583007: Added QuicAllowed policy. Added unit and browser tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2357
Patch Set: Created 5 years, 7 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
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | chrome/browser/policy/policy_network_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/common/chrome_switches.h"
8 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" 9 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h"
9 #include "net/http/http_network_session.h" 10 #include "net/http/http_network_session.h"
10 #include "net/http/http_server_properties_impl.h" 11 #include "net/http/http_server_properties_impl.h"
11 #include "net/quic/quic_protocol.h" 12 #include "net/quic/quic_protocol.h"
12 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace test { 16 namespace test {
16 17
17 using ::testing::ElementsAre; 18 using ::testing::ElementsAre;
18 19
19 class BadEntropyProvider : public base::FieldTrial::EntropyProvider { 20 class BadEntropyProvider : public base::FieldTrial::EntropyProvider {
20 public: 21 public:
21 ~BadEntropyProvider() override {} 22 ~BadEntropyProvider() override {}
22 23
23 double GetEntropyForTrial(const std::string& trial_name, 24 double GetEntropyForTrial(const std::string& trial_name,
24 uint32 randomization_seed) const override { 25 uint32 randomization_seed) const override {
25 return 0.5; 26 return 0.5;
26 } 27 }
27 }; 28 };
28 29
29 class IOThreadPeer { 30 class IOThreadPeer {
30 public: 31 public:
31 static void ConfigureQuicGlobals( 32 static void ConfigureQuicGlobals(
32 const base::CommandLine& command_line, 33 const base::CommandLine& command_line,
33 base::StringPiece quic_trial_group, 34 base::StringPiece quic_trial_group,
34 const std::map<std::string, std::string>& quic_trial_params, 35 const std::map<std::string, std::string>& quic_trial_params,
36 bool is_quic_allowed_by_policy,
35 IOThread::Globals* globals) { 37 IOThread::Globals* globals) {
36 IOThread::ConfigureQuicGlobals(command_line, quic_trial_group, 38 IOThread::ConfigureQuicGlobals(command_line, quic_trial_group,
37 quic_trial_params, globals); 39 quic_trial_params, is_quic_allowed_by_policy,
40 globals);
38 } 41 }
39 42
40 static void ConfigureSpdyGlobals( 43 static void ConfigureSpdyGlobals(
41 const base::CommandLine& command_line, 44 const base::CommandLine& command_line,
42 base::StringPiece spdy_trial_group, 45 base::StringPiece spdy_trial_group,
43 const std::map<std::string, std::string>& spdy_trial_params, 46 const std::map<std::string, std::string>& spdy_trial_params,
44 IOThread::Globals* globals) { 47 IOThread::Globals* globals) {
45 IOThread::ConfigureSpdyGlobals(command_line, spdy_trial_group, 48 IOThread::ConfigureSpdyGlobals(command_line, spdy_trial_group,
46 spdy_trial_params, globals); 49 spdy_trial_params, globals);
47 } 50 }
48 51
49 static void InitializeNetworkSessionParamsFromGlobals( 52 static void InitializeNetworkSessionParamsFromGlobals(
50 const IOThread::Globals& globals, 53 const IOThread::Globals& globals,
51 net::HttpNetworkSession::Params* params) { 54 net::HttpNetworkSession::Params* params) {
52 IOThread::InitializeNetworkSessionParamsFromGlobals(globals, params); 55 IOThread::InitializeNetworkSessionParamsFromGlobals(globals, params);
53 } 56 }
54 }; 57 };
55 58
56 class IOThreadTest : public testing::Test { 59 class IOThreadTest : public testing::Test {
57 public: 60 public:
58 IOThreadTest() : command_line_(base::CommandLine::NO_PROGRAM) { 61 IOThreadTest()
62 : command_line_(base::CommandLine::NO_PROGRAM),
63 is_quic_allowed_by_policy_(true) {
59 globals_.http_server_properties.reset(new net::HttpServerPropertiesImpl()); 64 globals_.http_server_properties.reset(new net::HttpServerPropertiesImpl());
60 } 65 }
61 66
62 void ConfigureQuicGlobals() { 67 void ConfigureQuicGlobals() {
63 IOThreadPeer::ConfigureQuicGlobals(command_line_, field_trial_group_, 68 IOThreadPeer::ConfigureQuicGlobals(command_line_,
64 field_trial_params_, &globals_); 69 field_trial_group_,
70 field_trial_params_,
71 is_quic_allowed_by_policy_,
72 &globals_);
65 } 73 }
66 74
67 void ConfigureSpdyGlobals() { 75 void ConfigureSpdyGlobals() {
68 IOThreadPeer::ConfigureSpdyGlobals(command_line_, field_trial_group_, 76 IOThreadPeer::ConfigureSpdyGlobals(command_line_, field_trial_group_,
69 field_trial_params_, &globals_); 77 field_trial_params_, &globals_);
70 } 78 }
71 79
72 void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params) { 80 void InitializeNetworkSessionParams(net::HttpNetworkSession::Params* params) {
73 IOThreadPeer::InitializeNetworkSessionParamsFromGlobals(globals_, params); 81 IOThreadPeer::InitializeNetworkSessionParamsFromGlobals(globals_, params);
74 } 82 }
75 83
76 base::CommandLine command_line_; 84 base::CommandLine command_line_;
77 IOThread::Globals globals_; 85 IOThread::Globals globals_;
78 std::string field_trial_group_; 86 std::string field_trial_group_;
87 bool is_quic_allowed_by_policy_;
79 std::map<std::string, std::string> field_trial_params_; 88 std::map<std::string, std::string> field_trial_params_;
80 }; 89 };
81 90
82 TEST_F(IOThreadTest, InitializeNetworkSessionParamsFromGlobals) { 91 TEST_F(IOThreadTest, InitializeNetworkSessionParamsFromGlobals) {
83 globals_.quic_connection_options.push_back(net::kPACE); 92 globals_.quic_connection_options.push_back(net::kPACE);
84 globals_.quic_connection_options.push_back(net::kTBBR); 93 globals_.quic_connection_options.push_back(net::kTBBR);
85 globals_.quic_connection_options.push_back(net::kTIME); 94 globals_.quic_connection_options.push_back(net::kTIME);
86 95
87 net::HttpNetworkSession::Params params; 96 net::HttpNetworkSession::Params params;
88 InitializeNetworkSessionParams(&params); 97 InitializeNetworkSessionParams(&params);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 AlternateProtocolProbabilityThresholdFromParams) { 477 AlternateProtocolProbabilityThresholdFromParams) {
469 field_trial_group_ = "Enabled"; 478 field_trial_group_ = "Enabled";
470 field_trial_params_["alternate_protocol_probability_threshold"] = ".5"; 479 field_trial_params_["alternate_protocol_probability_threshold"] = ".5";
471 480
472 ConfigureQuicGlobals(); 481 ConfigureQuicGlobals();
473 net::HttpNetworkSession::Params params; 482 net::HttpNetworkSession::Params params;
474 InitializeNetworkSessionParams(&params); 483 InitializeNetworkSessionParams(&params);
475 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold); 484 EXPECT_EQ(.5, params.alternate_protocol_probability_threshold);
476 } 485 }
477 486
487 TEST_F(IOThreadTest, QuicDisallowedByPolicy) {
488 command_line_.AppendSwitch(switches::kEnableQuic);
489 is_quic_allowed_by_policy_ = false;
490 ConfigureQuicGlobals();
491
492 net::HttpNetworkSession::Params params;
493 InitializeNetworkSessionParams(&params);
494 EXPECT_FALSE(params.enable_quic);
495 }
496
478 } // namespace test 497 } // namespace test
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | chrome/browser/policy/policy_network_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698