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_crypto_stream.h" |
9 #include "net/quic/core/quic_utils.h" | 9 #include "net/quic/core/quic_utils.h" |
10 #include "net/quic/test_tools/crypto_test_utils.h" | 10 #include "net/quic/test_tools/crypto_test_utils.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 version_manager_(AllSupportedVersions()), | 29 version_manager_(AllSupportedVersions()), |
30 dispatcher_( | 30 dispatcher_( |
31 config_, | 31 config_, |
32 &crypto_config_, | 32 &crypto_config_, |
33 &version_manager_, | 33 &version_manager_, |
34 std::unique_ptr<MockQuicConnectionHelper>( | 34 std::unique_ptr<MockQuicConnectionHelper>( |
35 new net::test::MockQuicConnectionHelper), | 35 new net::test::MockQuicConnectionHelper), |
36 std::unique_ptr<QuicCryptoServerStream::Helper>( | 36 std::unique_ptr<QuicCryptoServerStream::Helper>( |
37 new QuicSimpleServerSessionHelper(QuicRandom::GetInstance())), | 37 new QuicSimpleServerSessionHelper(QuicRandom::GetInstance())), |
38 std::unique_ptr<MockAlarmFactory>(new net::test::MockAlarmFactory), | 38 std::unique_ptr<MockAlarmFactory>(new net::test::MockAlarmFactory), |
39 &in_memory_cache_) { | 39 &response_cache_) { |
40 dispatcher_.InitializeWithWriter(nullptr); | 40 dispatcher_.InitializeWithWriter(nullptr); |
41 } | 41 } |
42 | 42 |
43 void DispatchPacket(const QuicReceivedPacket& packet) { | 43 void DispatchPacket(const QuicReceivedPacket& packet) { |
44 IPEndPoint client_addr, server_addr; | 44 IPEndPoint client_addr, server_addr; |
45 dispatcher_.ProcessPacket( | 45 dispatcher_.ProcessPacket( |
46 QuicSocketAddress(QuicSocketAddressImpl(server_addr)), | 46 QuicSocketAddress(QuicSocketAddressImpl(server_addr)), |
47 QuicSocketAddress(QuicSocketAddressImpl(client_addr)), packet); | 47 QuicSocketAddress(QuicSocketAddressImpl(client_addr)), packet); |
48 } | 48 } |
49 | 49 |
50 protected: | 50 protected: |
51 QuicConfig config_; | 51 QuicConfig config_; |
52 QuicCryptoServerConfig crypto_config_; | 52 QuicCryptoServerConfig crypto_config_; |
53 QuicVersionManager version_manager_; | 53 QuicVersionManager version_manager_; |
54 net::test::MockQuicDispatcher dispatcher_; | 54 net::test::MockQuicDispatcher dispatcher_; |
55 QuicInMemoryCache in_memory_cache_; | 55 QuicHttpResponseCache response_cache_; |
56 }; | 56 }; |
57 | 57 |
58 TEST_F(QuicChromeServerDispatchPacketTest, DispatchPacket) { | 58 TEST_F(QuicChromeServerDispatchPacketTest, DispatchPacket) { |
59 unsigned char valid_packet[] = {// public flags (8 byte connection_id) | 59 unsigned char valid_packet[] = {// public flags (8 byte connection_id) |
60 0x3C, | 60 0x3C, |
61 // connection_id | 61 // connection_id |
62 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, | 62 0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, |
63 0xFE, | 63 0xFE, |
64 // packet sequence number | 64 // packet sequence number |
65 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, | 65 0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12, |
66 // private flags | 66 // private flags |
67 0x00}; | 67 0x00}; |
68 QuicReceivedPacket encrypted_valid_packet( | 68 QuicReceivedPacket encrypted_valid_packet( |
69 reinterpret_cast<char*>(valid_packet), arraysize(valid_packet), | 69 reinterpret_cast<char*>(valid_packet), arraysize(valid_packet), |
70 QuicTime::Zero(), false); | 70 QuicTime::Zero(), false); |
71 | 71 |
72 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1); | 72 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1); |
73 DispatchPacket(encrypted_valid_packet); | 73 DispatchPacket(encrypted_valid_packet); |
74 } | 74 } |
75 | 75 |
76 } // namespace test | 76 } // namespace test |
77 } // namespace net | 77 } // namespace net |
OLD | NEW |