Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Side by Side Diff: net/quic/quic_server_test.cc

Issue 340433002: Port QuicServer to Chrome network stack (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix invalid memory access + blocked writers Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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/tools/quic/quic_server.h" 5 #include "net/quic/quic_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/tools/quic/test_tools/mock_quic_dispatcher.h" 9 #include "net/quic/test_tools/mock_clock.h"
10 #include "net/quic/test_tools/mock_quic_dispatcher.h"
11 #include "net/quic/test_tools/mock_random.h"
12 #include "net/quic/test_tools/quic_test_utils.h"
13 #include "net/quic/test_tools/test_task_runner.h"
wtc 2014/06/18 02:04:47 We should be able to remove some of these headers.
dmziegler 2014/06/18 20:13:42 Done.
10 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
11 15
12 using ::testing::_; 16 using ::testing::_;
13 17
14 namespace net { 18 namespace net {
15 namespace tools {
16 namespace test { 19 namespace test {
17 20
18 namespace { 21 namespace {
19 22
20 class QuicServerDispatchPacketTest : public ::testing::Test { 23 class QuicChromeServerDispatchPacketTest : public ::testing::Test {
wtc 2014/06/18 02:04:47 Why do we need to rename this test class? Is there
dmziegler 2014/06/18 20:13:42 Yes, it conflicts with the other quic_server_test.
21 public: 24 public:
22 QuicServerDispatchPacketTest() 25 QuicChromeServerDispatchPacketTest()
23 : crypto_config_("blah", QuicRandom::GetInstance()), 26 : crypto_config_("blah", QuicRandom::GetInstance()),
24 dispatcher_(config_, crypto_config_, &eps_) { 27 dispatcher_(config_, crypto_config_, &helper_) {
25 dispatcher_.Initialize(1234); 28 dispatcher_.Initialize(NULL);
26 } 29 }
27 30
28 void DispatchPacket(const QuicEncryptedPacket& packet) { 31 void DispatchPacket(const QuicEncryptedPacket& packet) {
29 IPEndPoint client_addr, server_addr; 32 IPEndPoint client_addr, server_addr;
30 dispatcher_.ProcessPacket(server_addr, client_addr, packet); 33 dispatcher_.ProcessPacket(server_addr, client_addr, packet);
31 } 34 }
32 35
33 protected: 36 protected:
34 QuicConfig config_; 37 QuicConfig config_;
35 QuicCryptoServerConfig crypto_config_; 38 QuicCryptoServerConfig crypto_config_;
36 EpollServer eps_; 39 MockHelper helper_;
37 MockQuicDispatcher dispatcher_; 40 MockQuicDispatcher dispatcher_;
38 }; 41 };
39 42
40 TEST_F(QuicServerDispatchPacketTest, DispatchPacket) { 43 TEST_F(QuicChromeServerDispatchPacketTest, DispatchPacket) {
41 unsigned char valid_packet[] = { 44 unsigned char valid_packet[] = {
42 // public flags (8 byte connection_id) 45 // public flags (8 byte connection_id)
43 0x3C, 46 0x3C,
44 // connection_id 47 // connection_id
45 0x10, 0x32, 0x54, 0x76, 48 0x10, 0x32, 0x54, 0x76,
46 0x98, 0xBA, 0xDC, 0xFE, 49 0x98, 0xBA, 0xDC, 0xFE,
47 // packet sequence number 50 // packet sequence number
48 0xBC, 0x9A, 0x78, 0x56, 51 0xBC, 0x9A, 0x78, 0x56,
49 0x34, 0x12, 52 0x34, 0x12,
50 // private flags 53 // private flags
51 0x00 }; 54 0x00 };
52 QuicEncryptedPacket encrypted_valid_packet(QuicUtils::AsChars(valid_packet), 55 QuicEncryptedPacket encrypted_valid_packet(
53 arraysize(valid_packet), false); 56 QuicUtils::AsChars(valid_packet), arraysize(valid_packet), false);
54 57
55 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1); 58 EXPECT_CALL(dispatcher_, ProcessPacket(_, _, _)).Times(1);
56 DispatchPacket(encrypted_valid_packet); 59 DispatchPacket(encrypted_valid_packet);
57 } 60 }
58 61
59 } // namespace 62 } // namespace
60 } // namespace test 63 } // namespace test
61 } // namespace tools
62 } // namespace net 64 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698