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" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 } | 211 } |
212 | 212 |
213 TEST_F(QuicTimeWaitListManagerTest, CheckStatelessConnectionIdInTimeWait) { | 213 TEST_F(QuicTimeWaitListManagerTest, CheckStatelessConnectionIdInTimeWait) { |
214 EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_)); | 214 EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_)); |
215 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); | 215 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); |
216 AddStatelessConnectionId(connection_id_); | 216 AddStatelessConnectionId(connection_id_); |
217 EXPECT_EQ(1u, time_wait_list_manager_.num_connections()); | 217 EXPECT_EQ(1u, time_wait_list_manager_.num_connections()); |
218 EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_)); | 218 EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_)); |
219 } | 219 } |
220 | 220 |
| 221 TEST_F(QuicTimeWaitListManagerTest, SendVersionNegotiationPacket) { |
| 222 scoped_ptr<QuicEncryptedPacket> packet( |
| 223 QuicFramer::BuildVersionNegotiationPacket(connection_id_, |
| 224 QuicSupportedVersions())); |
| 225 EXPECT_CALL(writer_, WritePacket(_, packet->length(), |
| 226 server_address_.address().bytes(), |
| 227 client_address_, _)) |
| 228 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1))); |
| 229 |
| 230 time_wait_list_manager_.SendVersionNegotiationPacket( |
| 231 connection_id_, QuicSupportedVersions(), server_address_, |
| 232 client_address_); |
| 233 EXPECT_EQ(0u, time_wait_list_manager_.num_connections()); |
| 234 } |
| 235 |
221 TEST_F(QuicTimeWaitListManagerTest, SendConnectionClose) { | 236 TEST_F(QuicTimeWaitListManagerTest, SendConnectionClose) { |
222 const size_t kConnectionCloseLength = 100; | 237 const size_t kConnectionCloseLength = 100; |
223 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); | 238 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); |
224 std::vector<QuicEncryptedPacket*> termination_packets; | 239 std::vector<QuicEncryptedPacket*> termination_packets; |
225 termination_packets.push_back(new QuicEncryptedPacket( | 240 termination_packets.push_back(new QuicEncryptedPacket( |
226 new char[kConnectionCloseLength], kConnectionCloseLength, true)); | 241 new char[kConnectionCloseLength], kConnectionCloseLength, true)); |
227 AddConnectionId(connection_id_, QuicVersionMax(), | 242 AddConnectionId(connection_id_, QuicVersionMax(), |
228 /*connection_rejected_statelessly=*/false, | 243 /*connection_rejected_statelessly=*/false, |
229 &termination_packets); | 244 &termination_packets); |
230 const int kRandomSequenceNumber = 1; | 245 const int kRandomSequenceNumber = 1; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections), | 553 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections), |
539 time_wait_list_manager_.num_connections()); | 554 time_wait_list_manager_.num_connections()); |
540 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict)); | 555 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict)); |
541 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id)); | 556 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id)); |
542 } | 557 } |
543 } | 558 } |
544 | 559 |
545 } // namespace | 560 } // namespace |
546 } // namespace test | 561 } // namespace test |
547 } // namespace net | 562 } // namespace net |
OLD | NEW |