We started redesigning GpuMemoryBuffer interface to handle multiple buffers [0].
[chromium-blink-merge.git] / net / tools / quic / quic_server_test.cc
blob091f28061d2be315875506ceb8ef92e44657cd81
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/quic_epoll_connection_helper.h"
10 #include "net/tools/quic/test_tools/mock_quic_dispatcher.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 using ::testing::_;
15 namespace net {
16 namespace tools {
17 namespace test {
19 namespace {
21 class QuicServerDispatchPacketTest : public ::testing::Test {
22 public:
23 QuicServerDispatchPacketTest()
24 : crypto_config_("blah", QuicRandom::GetInstance()),
25 dispatcher_(config_,
26 &crypto_config_,
27 new QuicDispatcher::DefaultPacketWriterFactory(),
28 new QuicEpollConnectionHelper(&eps_)) {
29 dispatcher_.InitializeWithWriter(new QuicDefaultPacketWriter(1234));
32 void DispatchPacket(const QuicEncryptedPacket& packet) {
33 IPEndPoint client_addr, server_addr;
34 dispatcher_.ProcessPacket(server_addr, client_addr, packet);
37 protected:
38 QuicConfig config_;
39 QuicCryptoServerConfig crypto_config_;
40 EpollServer eps_;
41 MockQuicDispatcher dispatcher_;
44 TEST_F(QuicServerDispatchPacketTest, DispatchPacket) {
45 unsigned char valid_packet[] = {
46 // public flags (8 byte connection_id)
47 0x3C,
48 // connection_id
49 0x10, 0x32, 0x54, 0x76,
50 0x98, 0xBA, 0xDC, 0xFE,
51 // packet sequence number
52 0xBC, 0x9A, 0x78, 0x56,
53 0x34, 0x12,
54 // private flags
55 0x00 };
56 QuicEncryptedPacket encrypted_valid_packet(QuicUtils::AsChars(valid_packet),
57 arraysize(valid_packet), false);
59 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1);
60 DispatchPacket(encrypted_valid_packet);
63 } // namespace
64 } // namespace test
65 } // namespace tools
66 } // namespace net