Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / net / tools / quic / quic_server_test.cc
blob7ed7774b6c71d08735a4b023daafd55586d11fb9
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
3 // found in the LICENSE file.
5 #include "net/tools/quic/quic_server.h"
7 #include "net/quic/crypto/quic_random.h"
8 #include "net/quic/quic_utils.h"
9 #include "net/quic/test_tools/mock_quic_dispatcher.h"
10 #include "net/tools/quic/quic_epoll_connection_helper.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 using ::testing::_;
14 using net::test::MockQuicDispatcher;
16 namespace net {
17 namespace tools {
18 namespace test {
20 namespace {
22 class QuicServerDispatchPacketTest : public ::testing::Test {
23 public:
24 QuicServerDispatchPacketTest()
25 : crypto_config_("blah", QuicRandom::GetInstance()),
26 dispatcher_(config_,
27 &crypto_config_,
28 new QuicDispatcher::DefaultPacketWriterFactory(),
29 new QuicEpollConnectionHelper(&eps_)) {
30 dispatcher_.InitializeWithWriter(new QuicDefaultPacketWriter(1234));
33 void DispatchPacket(const QuicEncryptedPacket& packet) {
34 IPEndPoint client_addr, server_addr;
35 dispatcher_.ProcessPacket(server_addr, client_addr, packet);
38 protected:
39 QuicConfig config_;
40 QuicCryptoServerConfig crypto_config_;
41 EpollServer eps_;
42 MockQuicDispatcher dispatcher_;
45 TEST_F(QuicServerDispatchPacketTest, DispatchPacket) {
46 // clang-format off
47 unsigned char valid_packet[] = {
48 // public flags (8 byte connection_id)
49 0x3C,
50 // connection_id
51 0x10, 0x32, 0x54, 0x76,
52 0x98, 0xBA, 0xDC, 0xFE,
53 // packet number
54 0xBC, 0x9A, 0x78, 0x56,
55 0x34, 0x12,
56 // private flags
57 0x00
59 // clang-format on
60 QuicEncryptedPacket encrypted_valid_packet(QuicUtils::AsChars(valid_packet),
61 arraysize(valid_packet), false);
63 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1);
64 DispatchPacket(encrypted_valid_packet);
67 } // namespace
68 } // namespace test
69 } // namespace tools
70 } // namespace net