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 | 8 |
9 #include "net/quic/crypto/crypto_protocol.h" | 9 #include "net/quic/crypto/crypto_protocol.h" |
10 #include "net/quic/crypto/null_encrypter.h" | 10 #include "net/quic/crypto/null_encrypter.h" |
11 #include "net/quic/crypto/quic_decrypter.h" | 11 #include "net/quic/crypto/quic_decrypter.h" |
12 #include "net/quic/crypto/quic_encrypter.h" | 12 #include "net/quic/crypto/quic_encrypter.h" |
13 #include "net/quic/quic_data_reader.h" | 13 #include "net/quic/quic_data_reader.h" |
14 #include "net/quic/quic_framer.h" | 14 #include "net/quic/quic_framer.h" |
15 #include "net/quic/quic_packet_writer.h" | 15 #include "net/quic/quic_packet_writer.h" |
16 #include "net/quic/quic_protocol.h" | 16 #include "net/quic/quic_protocol.h" |
| 17 #include "net/quic/quic_utils.h" |
17 #include "net/quic/test_tools/quic_test_utils.h" | 18 #include "net/quic/test_tools/quic_test_utils.h" |
18 #include "net/tools/quic/test_tools/mock_epoll_server.h" | 19 #include "net/tools/quic/test_tools/mock_epoll_server.h" |
19 #include "net/tools/quic/test_tools/quic_test_utils.h" | 20 #include "net/tools/quic/test_tools/quic_test_utils.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 | 23 |
23 using net::test::FramerVisitorCapturingPublicReset; | 24 using net::test::FramerVisitorCapturingPublicReset; |
24 using testing::_; | 25 using testing::_; |
25 using testing::Args; | 26 using testing::Args; |
26 using testing::Assign; | 27 using testing::Assign; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 EpollAlarmCallbackInterface* alarm)); | 64 EpollAlarmCallbackInterface* alarm)); |
64 }; | 65 }; |
65 | 66 |
66 class QuicTimeWaitListManagerTest : public testing::Test { | 67 class QuicTimeWaitListManagerTest : public testing::Test { |
67 protected: | 68 protected: |
68 QuicTimeWaitListManagerTest() | 69 QuicTimeWaitListManagerTest() |
69 : time_wait_list_manager_(&writer_, &visitor_, | 70 : time_wait_list_manager_(&writer_, &visitor_, |
70 &epoll_server_, QuicSupportedVersions()), | 71 &epoll_server_, QuicSupportedVersions()), |
71 framer_(QuicSupportedVersions(), QuicTime::Zero(), true), | 72 framer_(QuicSupportedVersions(), QuicTime::Zero(), true), |
72 guid_(45), | 73 guid_(45), |
| 74 client_address_(net::test::TestPeerIPAddress(), kTestPort), |
73 writer_is_blocked_(false) {} | 75 writer_is_blocked_(false) {} |
74 | 76 |
75 virtual ~QuicTimeWaitListManagerTest() {} | 77 virtual ~QuicTimeWaitListManagerTest() {} |
76 | 78 |
77 virtual void SetUp() { | 79 virtual void SetUp() { |
78 EXPECT_CALL(writer_, IsWriteBlocked()) | 80 EXPECT_CALL(writer_, IsWriteBlocked()) |
79 .WillRepeatedly(ReturnPointee(&writer_is_blocked_)); | 81 .WillRepeatedly(ReturnPointee(&writer_is_blocked_)); |
80 EXPECT_CALL(writer_, IsWriteBlockedDataBuffered()) | 82 EXPECT_CALL(writer_, IsWriteBlockedDataBuffered()) |
81 .WillRepeatedly(Return(false)); | 83 .WillRepeatedly(Return(false)); |
82 } | 84 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 QuicFramer framer(QuicSupportedVersions(), | 160 QuicFramer framer(QuicSupportedVersions(), |
159 QuicTime::Zero(), | 161 QuicTime::Zero(), |
160 false); | 162 false); |
161 framer.set_visitor(&visitor); | 163 framer.set_visitor(&visitor); |
162 QuicEncryptedPacket encrypted(std::tr1::get<0>(packet_buffer), | 164 QuicEncryptedPacket encrypted(std::tr1::get<0>(packet_buffer), |
163 std::tr1::get<1>(packet_buffer)); | 165 std::tr1::get<1>(packet_buffer)); |
164 framer.ProcessPacket(encrypted); | 166 framer.ProcessPacket(encrypted); |
165 QuicPublicResetPacket packet = visitor.public_reset_packet(); | 167 QuicPublicResetPacket packet = visitor.public_reset_packet(); |
166 return guid_ == packet.public_header.guid && | 168 return guid_ == packet.public_header.guid && |
167 packet.public_header.reset_flag && !packet.public_header.version_flag && | 169 packet.public_header.reset_flag && !packet.public_header.version_flag && |
168 sequence_number_ == packet.rejected_sequence_number; | 170 sequence_number_ == packet.rejected_sequence_number && |
| 171 net::test::TestPeerIPAddress() == packet.client_address.address() && |
| 172 kTestPort == packet.client_address.port(); |
169 } | 173 } |
170 | 174 |
171 virtual void DescribeTo(::std::ostream* os) const { } | 175 virtual void DescribeTo(::std::ostream* os) const { } |
172 | 176 |
173 virtual void DescribeNegationTo(::std::ostream* os) const { } | 177 virtual void DescribeNegationTo(::std::ostream* os) const { } |
174 | 178 |
175 private: | 179 private: |
176 QuicGuid guid_; | 180 QuicGuid guid_; |
177 QuicPacketSequenceNumber sequence_number_; | 181 QuicPacketSequenceNumber sequence_number_; |
178 }; | 182 }; |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 EXPECT_CALL(epoll_server_, RegisterAlarm(_, _)); | 415 EXPECT_CALL(epoll_server_, RegisterAlarm(_, _)); |
412 | 416 |
413 time_wait_list_manager_.CleanUpOldGuids(); | 417 time_wait_list_manager_.CleanUpOldGuids(); |
414 EXPECT_FALSE(IsGuidInTimeWait(kGuid1)); | 418 EXPECT_FALSE(IsGuidInTimeWait(kGuid1)); |
415 EXPECT_TRUE(IsGuidInTimeWait(kGuid2)); | 419 EXPECT_TRUE(IsGuidInTimeWait(kGuid2)); |
416 } | 420 } |
417 } // namespace | 421 } // namespace |
418 } // namespace test | 422 } // namespace test |
419 } // namespace tools | 423 } // namespace tools |
420 } // namespace net | 424 } // namespace net |
OLD | NEW |