OLD | NEW |
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_time_wait_list_manager.h" | 5 #include "net/tools/quic/quic_time_wait_list_manager.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <memory> | 8 #include <memory> |
9 #include <ostream> | 9 #include <ostream> |
10 | 10 |
11 #include "net/quic/core/crypto/crypto_protocol.h" | 11 #include "net/quic/core/crypto/crypto_protocol.h" |
12 #include "net/quic/core/crypto/null_encrypter.h" | 12 #include "net/quic/core/crypto/null_encrypter.h" |
13 #include "net/quic/core/crypto/quic_decrypter.h" | 13 #include "net/quic/core/crypto/quic_decrypter.h" |
14 #include "net/quic/core/crypto/quic_encrypter.h" | 14 #include "net/quic/core/crypto/quic_encrypter.h" |
15 #include "net/quic/core/quic_data_reader.h" | 15 #include "net/quic/core/quic_data_reader.h" |
16 #include "net/quic/core/quic_framer.h" | 16 #include "net/quic/core/quic_framer.h" |
17 #include "net/quic/core/quic_packet_writer.h" | 17 #include "net/quic/core/quic_packet_writer.h" |
18 #include "net/quic/core/quic_packets.h" | 18 #include "net/quic/core/quic_packets.h" |
19 #include "net/quic/core/quic_utils.h" | 19 #include "net/quic/core/quic_utils.h" |
20 #include "net/quic/platform/api/quic_flags.h" | 20 #include "net/quic/platform/api/quic_flags.h" |
| 21 #include "net/quic/platform/api/quic_test.h" |
21 #include "net/quic/test_tools/quic_test_utils.h" | 22 #include "net/quic/test_tools/quic_test_utils.h" |
22 #include "net/quic/test_tools/quic_time_wait_list_manager_peer.h" | 23 #include "net/quic/test_tools/quic_time_wait_list_manager_peer.h" |
23 #include "net/tools/quic/quic_epoll_alarm_factory.h" | 24 #include "net/tools/quic/quic_epoll_alarm_factory.h" |
24 #include "net/tools/quic/quic_epoll_connection_helper.h" | 25 #include "net/tools/quic/quic_epoll_connection_helper.h" |
25 #include "net/tools/quic/test_tools/mock_epoll_server.h" | 26 #include "net/tools/quic/test_tools/mock_epoll_server.h" |
26 #include "net/tools/quic/test_tools/mock_quic_session_visitor.h" | 27 #include "net/tools/quic/test_tools/mock_quic_session_visitor.h" |
27 #include "testing/gmock/include/gmock/gmock.h" | |
28 #include "testing/gtest/include/gtest/gtest.h" | |
29 | 28 |
30 using testing::Args; | 29 using testing::Args; |
31 using testing::Assign; | 30 using testing::Assign; |
32 using testing::DoAll; | 31 using testing::DoAll; |
33 using testing::Matcher; | 32 using testing::Matcher; |
34 using testing::MatcherInterface; | 33 using testing::MatcherInterface; |
35 using testing::NiceMock; | 34 using testing::NiceMock; |
36 using testing::Return; | 35 using testing::Return; |
37 using testing::ReturnPointee; | 36 using testing::ReturnPointee; |
38 using testing::SetArgPointee; | 37 using testing::SetArgPointee; |
(...skipping 22 matching lines...) Expand all Loading... |
61 }; | 60 }; |
62 | 61 |
63 namespace { | 62 namespace { |
64 | 63 |
65 class MockFakeTimeEpollServer : public FakeTimeEpollServer { | 64 class MockFakeTimeEpollServer : public FakeTimeEpollServer { |
66 public: | 65 public: |
67 MOCK_METHOD2(RegisterAlarm, | 66 MOCK_METHOD2(RegisterAlarm, |
68 void(int64_t timeout_in_us, EpollAlarmCallbackInterface* alarm)); | 67 void(int64_t timeout_in_us, EpollAlarmCallbackInterface* alarm)); |
69 }; | 68 }; |
70 | 69 |
71 class QuicTimeWaitListManagerTest : public ::testing::Test { | 70 class QuicTimeWaitListManagerTest : public QuicTest { |
72 protected: | 71 protected: |
73 QuicTimeWaitListManagerTest() | 72 QuicTimeWaitListManagerTest() |
74 : helper_(&epoll_server_, QuicAllocator::BUFFER_POOL), | 73 : helper_(&epoll_server_, QuicAllocator::BUFFER_POOL), |
75 alarm_factory_(&epoll_server_), | 74 alarm_factory_(&epoll_server_), |
76 time_wait_list_manager_(&writer_, &visitor_, &helper_, &alarm_factory_), | 75 time_wait_list_manager_(&writer_, &visitor_, &helper_, &alarm_factory_), |
77 connection_id_(45), | 76 connection_id_(45), |
78 client_address_(net::test::TestPeerIPAddress(), kTestPort), | 77 client_address_(net::test::TestPeerIPAddress(), kTestPort), |
79 writer_is_blocked_(false) {} | 78 writer_is_blocked_(false) {} |
80 | 79 |
81 ~QuicTimeWaitListManagerTest() override {} | 80 ~QuicTimeWaitListManagerTest() override {} |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 connection_id); | 118 connection_id); |
120 } | 119 } |
121 | 120 |
122 QuicEncryptedPacket* ConstructEncryptedPacket( | 121 QuicEncryptedPacket* ConstructEncryptedPacket( |
123 QuicConnectionId connection_id, | 122 QuicConnectionId connection_id, |
124 QuicPacketNumber packet_number) { | 123 QuicPacketNumber packet_number) { |
125 return net::test::ConstructEncryptedPacket(connection_id, false, false, | 124 return net::test::ConstructEncryptedPacket(connection_id, false, false, |
126 packet_number, "data"); | 125 packet_number, "data"); |
127 } | 126 } |
128 | 127 |
129 QuicFlagSaver flags_; // Save/restore all QUIC flag values. | |
130 NiceMock<MockFakeTimeEpollServer> epoll_server_; | 128 NiceMock<MockFakeTimeEpollServer> epoll_server_; |
131 QuicEpollConnectionHelper helper_; | 129 QuicEpollConnectionHelper helper_; |
132 QuicEpollAlarmFactory alarm_factory_; | 130 QuicEpollAlarmFactory alarm_factory_; |
133 StrictMock<MockPacketWriter> writer_; | 131 StrictMock<MockPacketWriter> writer_; |
134 StrictMock<MockQuicSessionVisitor> visitor_; | 132 StrictMock<MockQuicSessionVisitor> visitor_; |
135 QuicTimeWaitListManager time_wait_list_manager_; | 133 QuicTimeWaitListManager time_wait_list_manager_; |
136 QuicConnectionId connection_id_; | 134 QuicConnectionId connection_id_; |
137 QuicSocketAddress server_address_; | 135 QuicSocketAddress server_address_; |
138 QuicSocketAddress client_address_; | 136 QuicSocketAddress client_address_; |
139 bool writer_is_blocked_; | 137 bool writer_is_blocked_; |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections), | 509 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections), |
512 time_wait_list_manager_.num_connections()); | 510 time_wait_list_manager_.num_connections()); |
513 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict)); | 511 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict)); |
514 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id)); | 512 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id)); |
515 } | 513 } |
516 } | 514 } |
517 | 515 |
518 } // namespace | 516 } // namespace |
519 } // namespace test | 517 } // namespace test |
520 } // namespace net | 518 } // namespace net |
OLD | NEW |