| OLD | NEW |
| 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/test_tools/crypto_test_utils.h" | 9 #include "net/quic/test_tools/crypto_test_utils.h" |
| 10 #include "net/quic/test_tools/mock_quic_dispatcher.h" | 10 #include "net/quic/test_tools/mock_quic_dispatcher.h" |
| 11 #include "net/tools/quic/quic_epoll_alarm_factory.h" | 11 #include "net/tools/quic/quic_epoll_alarm_factory.h" |
| 12 #include "net/tools/quic/quic_epoll_connection_helper.h" | 12 #include "net/tools/quic/quic_epoll_connection_helper.h" |
| 13 #include "net/tools/quic/quic_simple_server_session_helper.h" | 13 #include "net/tools/quic/quic_simple_crypto_server_stream_helper.h" |
| 14 #include "net/tools/quic/test_tools/quic_server_peer.h" | 14 #include "net/tools/quic/test_tools/quic_server_peer.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 using ::testing::_; | 17 using ::testing::_; |
| 18 using net::test::CryptoTestUtils; | 18 using net::test::CryptoTestUtils; |
| 19 using net::test::MockQuicDispatcher; | 19 using net::test::MockQuicDispatcher; |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 namespace test { | 22 namespace test { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 class MockQuicSimpleDispatcher : public QuicSimpleDispatcher { | 26 class MockQuicSimpleDispatcher : public QuicSimpleDispatcher { |
| 27 public: | 27 public: |
| 28 MockQuicSimpleDispatcher( | 28 MockQuicSimpleDispatcher( |
| 29 const QuicConfig& config, | 29 const QuicConfig& config, |
| 30 const QuicCryptoServerConfig* crypto_config, | 30 const QuicCryptoServerConfig* crypto_config, |
| 31 QuicVersionManager* version_manager, | 31 QuicVersionManager* version_manager, |
| 32 std::unique_ptr<QuicConnectionHelperInterface> helper, | 32 std::unique_ptr<QuicConnectionHelperInterface> helper, |
| 33 std::unique_ptr<QuicServerSessionBase::Helper> session_helper, | 33 std::unique_ptr<QuicCryptoServerStream::Helper> session_helper, |
| 34 std::unique_ptr<QuicAlarmFactory> alarm_factory) | 34 std::unique_ptr<QuicAlarmFactory> alarm_factory) |
| 35 : QuicSimpleDispatcher(config, | 35 : QuicSimpleDispatcher(config, |
| 36 crypto_config, | 36 crypto_config, |
| 37 version_manager, | 37 version_manager, |
| 38 std::move(helper), | 38 std::move(helper), |
| 39 std::move(session_helper), | 39 std::move(session_helper), |
| 40 std::move(alarm_factory)) {} | 40 std::move(alarm_factory)) {} |
| 41 ~MockQuicSimpleDispatcher() override {} | 41 ~MockQuicSimpleDispatcher() override {} |
| 42 | 42 |
| 43 MOCK_METHOD0(OnCanWrite, void()); | 43 MOCK_METHOD0(OnCanWrite, void()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 54 | 54 |
| 55 MockQuicSimpleDispatcher* mock_dispatcher() { return mock_dispatcher_; } | 55 MockQuicSimpleDispatcher* mock_dispatcher() { return mock_dispatcher_; } |
| 56 | 56 |
| 57 protected: | 57 protected: |
| 58 QuicDispatcher* CreateQuicDispatcher() override { | 58 QuicDispatcher* CreateQuicDispatcher() override { |
| 59 mock_dispatcher_ = new MockQuicSimpleDispatcher( | 59 mock_dispatcher_ = new MockQuicSimpleDispatcher( |
| 60 config(), &crypto_config(), version_manager(), | 60 config(), &crypto_config(), version_manager(), |
| 61 std::unique_ptr<QuicEpollConnectionHelper>( | 61 std::unique_ptr<QuicEpollConnectionHelper>( |
| 62 new QuicEpollConnectionHelper(epoll_server(), | 62 new QuicEpollConnectionHelper(epoll_server(), |
| 63 QuicAllocator::BUFFER_POOL)), | 63 QuicAllocator::BUFFER_POOL)), |
| 64 std::unique_ptr<QuicServerSessionBase::Helper>( | 64 std::unique_ptr<QuicCryptoServerStream::Helper>( |
| 65 new QuicSimpleServerSessionHelper(QuicRandom::GetInstance())), | 65 new QuicSimpleCryptoServerStreamHelper(QuicRandom::GetInstance())), |
| 66 std::unique_ptr<QuicEpollAlarmFactory>( | 66 std::unique_ptr<QuicEpollAlarmFactory>( |
| 67 new QuicEpollAlarmFactory(epoll_server()))); | 67 new QuicEpollAlarmFactory(epoll_server()))); |
| 68 return mock_dispatcher_; | 68 return mock_dispatcher_; |
| 69 } | 69 } |
| 70 | 70 |
| 71 MockQuicSimpleDispatcher* mock_dispatcher_; | 71 MockQuicSimpleDispatcher* mock_dispatcher_; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 class QuicServerEpollInTest : public ::testing::Test { | 74 class QuicServerEpollInTest : public ::testing::Test { |
| 75 public: | 75 public: |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 QuicRandom::GetInstance(), | 144 QuicRandom::GetInstance(), |
| 145 CryptoTestUtils::ProofSourceForTesting()), | 145 CryptoTestUtils::ProofSourceForTesting()), |
| 146 version_manager_(AllSupportedVersions()), | 146 version_manager_(AllSupportedVersions()), |
| 147 dispatcher_( | 147 dispatcher_( |
| 148 config_, | 148 config_, |
| 149 &crypto_config_, | 149 &crypto_config_, |
| 150 &version_manager_, | 150 &version_manager_, |
| 151 std::unique_ptr<QuicEpollConnectionHelper>( | 151 std::unique_ptr<QuicEpollConnectionHelper>( |
| 152 new QuicEpollConnectionHelper(&eps_, | 152 new QuicEpollConnectionHelper(&eps_, |
| 153 QuicAllocator::BUFFER_POOL)), | 153 QuicAllocator::BUFFER_POOL)), |
| 154 std::unique_ptr<QuicServerSessionBase::Helper>( | 154 std::unique_ptr<QuicCryptoServerStream::Helper>( |
| 155 new QuicSimpleServerSessionHelper(QuicRandom::GetInstance())), | 155 new QuicSimpleCryptoServerStreamHelper( |
| 156 QuicRandom::GetInstance())), |
| 156 std::unique_ptr<QuicEpollAlarmFactory>( | 157 std::unique_ptr<QuicEpollAlarmFactory>( |
| 157 new QuicEpollAlarmFactory(&eps_))) { | 158 new QuicEpollAlarmFactory(&eps_))) { |
| 158 dispatcher_.InitializeWithWriter(new QuicDefaultPacketWriter(1234)); | 159 dispatcher_.InitializeWithWriter(new QuicDefaultPacketWriter(1234)); |
| 159 } | 160 } |
| 160 | 161 |
| 161 void DispatchPacket(const QuicReceivedPacket& packet) { | 162 void DispatchPacket(const QuicReceivedPacket& packet) { |
| 162 IPEndPoint client_addr, server_addr; | 163 IPEndPoint client_addr, server_addr; |
| 163 dispatcher_.ProcessPacket(server_addr, client_addr, packet); | 164 dispatcher_.ProcessPacket(server_addr, client_addr, packet); |
| 164 } | 165 } |
| 165 | 166 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 190 arraysize(valid_packet), | 191 arraysize(valid_packet), |
| 191 QuicTime::Zero(), false); | 192 QuicTime::Zero(), false); |
| 192 | 193 |
| 193 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1); | 194 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1); |
| 194 DispatchPacket(encrypted_valid_packet); | 195 DispatchPacket(encrypted_valid_packet); |
| 195 } | 196 } |
| 196 | 197 |
| 197 } // namespace | 198 } // namespace |
| 198 } // namespace test | 199 } // namespace test |
| 199 } // namespace net | 200 } // namespace net |
| OLD | NEW |