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

Side by Side Diff: net/tools/quic/quic_server_test.cc

Issue 2848203002: Add a platform implementation of QuicTest and QuicTestWithParam (Closed)
Patch Set: net/quic/platform/impl/quic_test_impl.cc Created 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "net/tools/quic/quic_server.h" 5 #include "net/tools/quic/quic_server.h"
6 6
7 #include "net/quic/core/crypto/quic_random.h" 7 #include "net/quic/core/crypto/quic_random.h"
8 #include "net/quic/core/quic_utils.h" 8 #include "net/quic/core/quic_utils.h"
9 #include "net/quic/platform/api/quic_flags.h" 9 #include "net/quic/platform/api/quic_flags.h"
10 #include "net/quic/platform/api/quic_logging.h" 10 #include "net/quic/platform/api/quic_logging.h"
11 #include "net/quic/platform/api/quic_socket_address.h" 11 #include "net/quic/platform/api/quic_socket_address.h"
12 #include "net/quic/platform/api/quic_test.h"
12 #include "net/quic/test_tools/crypto_test_utils.h" 13 #include "net/quic/test_tools/crypto_test_utils.h"
13 #include "net/quic/test_tools/mock_quic_dispatcher.h" 14 #include "net/quic/test_tools/mock_quic_dispatcher.h"
14 #include "net/tools/quic/quic_epoll_alarm_factory.h" 15 #include "net/tools/quic/quic_epoll_alarm_factory.h"
15 #include "net/tools/quic/quic_epoll_connection_helper.h" 16 #include "net/tools/quic/quic_epoll_connection_helper.h"
16 #include "net/tools/quic/quic_simple_crypto_server_stream_helper.h" 17 #include "net/tools/quic/quic_simple_crypto_server_stream_helper.h"
17 #include "net/tools/quic/test_tools/quic_server_peer.h" 18 #include "net/tools/quic/test_tools/quic_server_peer.h"
18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 using ::testing::_; 20 using ::testing::_;
21 21
22 namespace net { 22 namespace net {
23 namespace test { 23 namespace test {
24 24
25 namespace { 25 namespace {
26 26
27 class MockQuicSimpleDispatcher : public QuicSimpleDispatcher { 27 class MockQuicSimpleDispatcher : public QuicSimpleDispatcher {
28 public: 28 public:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 std::unique_ptr<QuicEpollAlarmFactory>( 71 std::unique_ptr<QuicEpollAlarmFactory>(
72 new QuicEpollAlarmFactory(epoll_server())), 72 new QuicEpollAlarmFactory(epoll_server())),
73 &response_cache_); 73 &response_cache_);
74 return mock_dispatcher_; 74 return mock_dispatcher_;
75 } 75 }
76 76
77 MockQuicSimpleDispatcher* mock_dispatcher_; 77 MockQuicSimpleDispatcher* mock_dispatcher_;
78 QuicHttpResponseCache response_cache_; 78 QuicHttpResponseCache response_cache_;
79 }; 79 };
80 80
81 class QuicServerEpollInTest : public ::testing::Test { 81 class QuicServerEpollInTest : public QuicTest {
82 public: 82 public:
83 QuicServerEpollInTest() 83 QuicServerEpollInTest()
84 : port_(net::test::kTestPort), 84 : port_(net::test::kTestPort),
85 server_address_(QuicIpAddress::Loopback4(), port_) {} 85 server_address_(QuicIpAddress::Loopback4(), port_) {}
86 86
87 void StartListening() { 87 void StartListening() {
88 server_.CreateUDPSocketAndListen(server_address_); 88 server_.CreateUDPSocketAndListen(server_address_);
89 ASSERT_TRUE(QuicServerPeer::SetSmallSocket(&server_)); 89 ASSERT_TRUE(QuicServerPeer::SetSmallSocket(&server_));
90 90
91 if (!server_.overflow_supported()) { 91 if (!server_.overflow_supported()) {
92 QUIC_LOG(WARNING) << "Overflow not supported. Not testing."; 92 QUIC_LOG(WARNING) << "Overflow not supported. Not testing.";
93 return; 93 return;
94 } 94 }
95 } 95 }
96 96
97 protected: 97 protected:
98 QuicFlagSaver saver_;
99 int port_; 98 int port_;
100 QuicSocketAddress server_address_; 99 QuicSocketAddress server_address_;
101 TestQuicServer server_; 100 TestQuicServer server_;
102 }; 101 };
103 102
104 // Tests that if dispatcher has CHLOs waiting for connection creation, EPOLLIN 103 // Tests that if dispatcher has CHLOs waiting for connection creation, EPOLLIN
105 // event should try to create connections for them. And set epoll mask with 104 // event should try to create connections for them. And set epoll mask with
106 // EPOLLIN if there are still CHLOs remaining at the end of epoll event. 105 // EPOLLIN if there are still CHLOs remaining at the end of epoll event.
107 TEST_F(QuicServerEpollInTest, ProcessBufferedCHLOsOnEpollin) { 106 TEST_F(QuicServerEpollInTest, ProcessBufferedCHLOsOnEpollin) {
108 FLAGS_quic_reloadable_flag_quic_limit_num_new_sessions_per_epoll_loop = true; 107 FLAGS_quic_reloadable_flag_quic_limit_num_new_sessions_per_epoll_loop = true;
(...skipping 26 matching lines...) Expand all
135 reinterpret_cast<sockaddr*>(&storage), sizeof(storage)); 134 reinterpret_cast<sockaddr*>(&storage), sizeof(storage));
136 if (rc < 0) { 135 if (rc < 0) {
137 QUIC_DLOG(INFO) << errno << " " << strerror(errno); 136 QUIC_DLOG(INFO) << errno << " " << strerror(errno);
138 } 137 }
139 138
140 while (more_chlos) { 139 while (more_chlos) {
141 server_.WaitForEvents(); 140 server_.WaitForEvents();
142 } 141 }
143 } 142 }
144 143
145 class QuicServerDispatchPacketTest : public ::testing::Test { 144 class QuicServerDispatchPacketTest : public QuicTest {
146 public: 145 public:
147 QuicServerDispatchPacketTest() 146 QuicServerDispatchPacketTest()
148 : crypto_config_("blah", 147 : crypto_config_("blah",
149 QuicRandom::GetInstance(), 148 QuicRandom::GetInstance(),
150 crypto_test_utils::ProofSourceForTesting()), 149 crypto_test_utils::ProofSourceForTesting()),
151 version_manager_(AllSupportedVersions()), 150 version_manager_(AllSupportedVersions()),
152 dispatcher_( 151 dispatcher_(
153 config_, 152 config_,
154 &crypto_config_, 153 &crypto_config_,
155 &version_manager_, 154 &version_manager_,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 reinterpret_cast<char*>(valid_packet), arraysize(valid_packet), 197 reinterpret_cast<char*>(valid_packet), arraysize(valid_packet),
199 QuicTime::Zero(), false); 198 QuicTime::Zero(), false);
200 199
201 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1); 200 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1);
202 DispatchPacket(encrypted_valid_packet); 201 DispatchPacket(encrypted_valid_packet);
203 } 202 }
204 203
205 } // namespace 204 } // namespace
206 } // namespace test 205 } // namespace test
207 } // namespace net 206 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_http_response_cache_test.cc ('k') | net/tools/quic/quic_simple_server_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698