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/quic/quic_server.h" | 5 #include "net/tools/quic/quic_simple_server.h" |
6 | 6 |
7 #include "net/quic/crypto/quic_random.h" | 7 #include "net/quic/crypto/quic_random.h" |
8 #include "net/quic/quic_utils.h" | 8 #include "net/quic/quic_utils.h" |
9 #include "net/quic/test_tools/mock_quic_dispatcher.h" | 9 #include "net/quic/test_tools/mock_quic_dispatcher.h" |
10 #include "net/quic/test_tools/quic_test_utils.h" | 10 #include "net/quic/test_tools/quic_test_utils.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 using ::testing::_; | 13 using ::testing::_; |
14 | 14 |
15 namespace net { | 15 namespace net { |
| 16 namespace tools { |
16 namespace test { | 17 namespace test { |
17 | 18 |
18 namespace { | |
19 | |
20 // TODO(dmz) Remove "Chrome" part of name once net/tools/quic is deleted. | 19 // TODO(dmz) Remove "Chrome" part of name once net/tools/quic is deleted. |
21 class QuicChromeServerDispatchPacketTest : public ::testing::Test { | 20 class QuicChromeServerDispatchPacketTest : public ::testing::Test { |
22 public: | 21 public: |
23 QuicChromeServerDispatchPacketTest() | 22 QuicChromeServerDispatchPacketTest() |
24 : crypto_config_("blah", QuicRandom::GetInstance()), | 23 : crypto_config_("blah", QuicRandom::GetInstance()), |
25 dispatcher_(config_, | 24 dispatcher_(config_, |
26 crypto_config_, | 25 crypto_config_, |
27 new tools::QuicDispatcher::DefaultPacketWriterFactory(), | 26 new tools::QuicDispatcher::DefaultPacketWriterFactory(), |
28 new MockHelper) { | 27 new net::test::MockHelper) { |
29 dispatcher_.InitializeWithWriter(nullptr); | 28 dispatcher_.InitializeWithWriter(nullptr); |
30 } | 29 } |
31 | 30 |
32 void DispatchPacket(const QuicEncryptedPacket& packet) { | 31 void DispatchPacket(const QuicEncryptedPacket& packet) { |
33 IPEndPoint client_addr, server_addr; | 32 IPEndPoint client_addr, server_addr; |
34 dispatcher_.ProcessPacket(server_addr, client_addr, packet); | 33 dispatcher_.ProcessPacket(server_addr, client_addr, packet); |
35 } | 34 } |
36 | 35 |
37 protected: | 36 protected: |
38 QuicConfig config_; | 37 QuicConfig config_; |
39 QuicCryptoServerConfig crypto_config_; | 38 QuicCryptoServerConfig crypto_config_; |
40 MockQuicDispatcher dispatcher_; | 39 net::test::MockQuicDispatcher dispatcher_; |
41 }; | 40 }; |
42 | 41 |
43 TEST_F(QuicChromeServerDispatchPacketTest, DispatchPacket) { | 42 TEST_F(QuicChromeServerDispatchPacketTest, DispatchPacket) { |
44 unsigned char valid_packet[] = { | 43 unsigned char valid_packet[] = { |
45 // public flags (8 byte connection_id) | 44 // public flags (8 byte connection_id) |
46 0x3C, | 45 0x3C, |
47 // connection_id | 46 // connection_id |
48 0x10, 0x32, 0x54, 0x76, | 47 0x10, 0x32, 0x54, 0x76, |
49 0x98, 0xBA, 0xDC, 0xFE, | 48 0x98, 0xBA, 0xDC, 0xFE, |
50 // packet sequence number | 49 // packet sequence number |
51 0xBC, 0x9A, 0x78, 0x56, | 50 0xBC, 0x9A, 0x78, 0x56, |
52 0x34, 0x12, | 51 0x34, 0x12, |
53 // private flags | 52 // private flags |
54 0x00 }; | 53 0x00 }; |
55 QuicEncryptedPacket encrypted_valid_packet(QuicUtils::AsChars(valid_packet), | 54 QuicEncryptedPacket encrypted_valid_packet(QuicUtils::AsChars(valid_packet), |
56 arraysize(valid_packet), false); | 55 arraysize(valid_packet), false); |
57 | 56 |
58 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1); | 57 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1); |
59 DispatchPacket(encrypted_valid_packet); | 58 DispatchPacket(encrypted_valid_packet); |
60 } | 59 } |
61 | 60 |
62 } // namespace | 61 } // namespace tools |
63 } // namespace test | 62 } // namespace test |
64 } // namespace net | 63 } // namespace net |
OLD | NEW |