Add diagnostics_writer.cc to the list of files allowed to printf.
[chromium-blink-merge.git] / net / quic / quic_server_test.cc
blob74db34de240aed7a2607579c30212bc774c39406
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
3 // found in the LICENSE file.
5 #include "net/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/quic/test_tools/quic_test_utils.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 using ::testing::_;
15 namespace net {
16 namespace test {
18 namespace {
20 // TODO(dmz) Remove "Chrome" part of name once net/tools/quic is deleted.
21 class QuicChromeServerDispatchPacketTest : public ::testing::Test {
22 public:
23 QuicChromeServerDispatchPacketTest()
24 : crypto_config_("blah", QuicRandom::GetInstance()),
25 dispatcher_(config_, crypto_config_, &helper_) {
26 dispatcher_.Initialize(NULL);
29 void DispatchPacket(const QuicEncryptedPacket& packet) {
30 IPEndPoint client_addr, server_addr;
31 dispatcher_.ProcessPacket(server_addr, client_addr, packet);
34 protected:
35 QuicConfig config_;
36 QuicCryptoServerConfig crypto_config_;
37 MockHelper helper_;
38 MockQuicDispatcher dispatcher_;
41 TEST_F(QuicChromeServerDispatchPacketTest, DispatchPacket) {
42 unsigned char valid_packet[] = {
43 // public flags (8 byte connection_id)
44 0x3C,
45 // connection_id
46 0x10, 0x32, 0x54, 0x76,
47 0x98, 0xBA, 0xDC, 0xFE,
48 // packet sequence number
49 0xBC, 0x9A, 0x78, 0x56,
50 0x34, 0x12,
51 // private flags
52 0x00 };
53 QuicEncryptedPacket encrypted_valid_packet(QuicUtils::AsChars(valid_packet),
54 arraysize(valid_packet), false);
56 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1);
57 DispatchPacket(encrypted_valid_packet);
60 } // namespace
61 } // namespace test
62 } // namespace net