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/tools/quic/test_tools/mock_quic_dispatcher.h"
10 #include "testing/gtest/include/gtest/gtest.h"
20 class QuicServerDispatchPacketTest
: public ::testing::Test
{
22 QuicServerDispatchPacketTest()
23 : crypto_config_("blah", QuicRandom::GetInstance()),
24 dispatcher_(config_
, crypto_config_
, 1234, &eps_
) {}
26 void DispatchPacket(const QuicEncryptedPacket
& packet
) {
27 IPEndPoint client_addr
, server_addr
;
28 dispatcher_
.ProcessPacket(server_addr
, client_addr
, packet
);
33 QuicCryptoServerConfig crypto_config_
;
35 MockQuicDispatcher dispatcher_
;
38 TEST_F(QuicServerDispatchPacketTest
, DispatchPacket
) {
39 unsigned char valid_packet
[] = {
40 // public flags (8 byte guid)
43 0x10, 0x32, 0x54, 0x76,
44 0x98, 0xBA, 0xDC, 0xFE,
45 // packet sequence number
46 0xBC, 0x9A, 0x78, 0x56,
50 QuicEncryptedPacket
encrypted_valid_packet(QuicUtils::AsChars(valid_packet
),
51 arraysize(valid_packet
), false);
53 EXPECT_CALL(dispatcher_
, ProcessPacket(_
, _
, _
)).Times(1);
54 DispatchPacket(encrypted_valid_packet
);