OLD | NEW |
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 "net/tools/quic/quic_simple_server.h" | 5 #include "net/tools/quic/quic_simple_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_crypto_stream.h" |
8 #include "net/quic/core/quic_utils.h" | 9 #include "net/quic/core/quic_utils.h" |
9 #include "net/quic/test_tools/crypto_test_utils.h" | 10 #include "net/quic/test_tools/crypto_test_utils.h" |
10 #include "net/quic/test_tools/mock_quic_dispatcher.h" | 11 #include "net/quic/test_tools/mock_quic_dispatcher.h" |
11 #include "net/quic/test_tools/quic_test_utils.h" | 12 #include "net/quic/test_tools/quic_test_utils.h" |
12 #include "net/tools/quic/quic_simple_server_session_helper.h" | 13 #include "net/tools/quic/quic_simple_server_session_helper.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 using ::testing::_; | 16 using ::testing::_; |
16 using net::test::CryptoTestUtils; | 17 using net::test::CryptoTestUtils; |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 namespace test { | 20 namespace test { |
20 | 21 |
21 // TODO(dmz) Remove "Chrome" part of name once net/tools/quic is deleted. | 22 // TODO(dmz) Remove "Chrome" part of name once net/tools/quic is deleted. |
22 class QuicChromeServerDispatchPacketTest : public ::testing::Test { | 23 class QuicChromeServerDispatchPacketTest : public ::testing::Test { |
23 public: | 24 public: |
24 QuicChromeServerDispatchPacketTest() | 25 QuicChromeServerDispatchPacketTest() |
25 : crypto_config_("blah", | 26 : crypto_config_("blah", |
26 QuicRandom::GetInstance(), | 27 QuicRandom::GetInstance(), |
27 CryptoTestUtils::ProofSourceForTesting()), | 28 CryptoTestUtils::ProofSourceForTesting()), |
28 version_manager_(AllSupportedVersions()), | 29 version_manager_(AllSupportedVersions()), |
29 dispatcher_( | 30 dispatcher_( |
30 config_, | 31 config_, |
31 &crypto_config_, | 32 &crypto_config_, |
32 &version_manager_, | 33 &version_manager_, |
33 std::unique_ptr<MockQuicConnectionHelper>( | 34 std::unique_ptr<MockQuicConnectionHelper>( |
34 new net::test::MockQuicConnectionHelper), | 35 new net::test::MockQuicConnectionHelper), |
35 std::unique_ptr<QuicServerSessionBase::Helper>( | 36 std::unique_ptr<QuicCryptoServerStream::Helper>( |
36 new QuicSimpleServerSessionHelper(QuicRandom::GetInstance())), | 37 new QuicSimpleServerSessionHelper(QuicRandom::GetInstance())), |
37 std::unique_ptr<MockAlarmFactory>( | 38 std::unique_ptr<MockAlarmFactory>( |
38 new net::test::MockAlarmFactory)) { | 39 new net::test::MockAlarmFactory)) { |
39 dispatcher_.InitializeWithWriter(nullptr); | 40 dispatcher_.InitializeWithWriter(nullptr); |
40 } | 41 } |
41 | 42 |
42 void DispatchPacket(const QuicReceivedPacket& packet) { | 43 void DispatchPacket(const QuicReceivedPacket& packet) { |
43 IPEndPoint client_addr, server_addr; | 44 IPEndPoint client_addr, server_addr; |
44 dispatcher_.ProcessPacket(server_addr, client_addr, packet); | 45 dispatcher_.ProcessPacket(server_addr, client_addr, packet); |
45 } | 46 } |
(...skipping 18 matching lines...) Expand all Loading... |
64 QuicReceivedPacket encrypted_valid_packet(QuicUtils::AsChars(valid_packet), | 65 QuicReceivedPacket encrypted_valid_packet(QuicUtils::AsChars(valid_packet), |
65 arraysize(valid_packet), | 66 arraysize(valid_packet), |
66 QuicTime::Zero(), false); | 67 QuicTime::Zero(), false); |
67 | 68 |
68 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1); | 69 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1); |
69 DispatchPacket(encrypted_valid_packet); | 70 DispatchPacket(encrypted_valid_packet); |
70 } | 71 } |
71 | 72 |
72 } // namespace test | 73 } // namespace test |
73 } // namespace net | 74 } // namespace net |
OLD | NEW |