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

Side by Side Diff: net/tools/quic/quic_time_wait_list_manager_test.cc

Issue 2236463004: Rename QuicSupportedVersions to QuicAllSupportedVersions. Add QuicCurrentSupportedVersions which re… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@129437595
Patch Set: update more files outside net/ Created 4 years, 4 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
« no previous file with comments | « net/tools/quic/quic_simple_server_test.cc ('k') | net/tools/quic/stateless_rejector_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 9
10 #include "net/quic/core/crypto/crypto_protocol.h" 10 #include "net/quic/core/crypto/crypto_protocol.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 : public MatcherInterface<const std::tr1::tuple<const char*, int>> { 169 : public MatcherInterface<const std::tr1::tuple<const char*, int>> {
170 public: 170 public:
171 explicit ValidatePublicResetPacketPredicate(QuicConnectionId connection_id, 171 explicit ValidatePublicResetPacketPredicate(QuicConnectionId connection_id,
172 QuicPacketNumber number) 172 QuicPacketNumber number)
173 : connection_id_(connection_id), packet_number_(number) {} 173 : connection_id_(connection_id), packet_number_(number) {}
174 174
175 bool MatchAndExplain( 175 bool MatchAndExplain(
176 const std::tr1::tuple<const char*, int> packet_buffer, 176 const std::tr1::tuple<const char*, int> packet_buffer,
177 testing::MatchResultListener* /* listener */) const override { 177 testing::MatchResultListener* /* listener */) const override {
178 FramerVisitorCapturingPublicReset visitor; 178 FramerVisitorCapturingPublicReset visitor;
179 QuicFramer framer(QuicSupportedVersions(), QuicTime::Zero(), 179 QuicFramer framer(AllSupportedVersions(), QuicTime::Zero(),
180 Perspective::IS_CLIENT); 180 Perspective::IS_CLIENT);
181 framer.set_visitor(&visitor); 181 framer.set_visitor(&visitor);
182 QuicEncryptedPacket encrypted(std::tr1::get<0>(packet_buffer), 182 QuicEncryptedPacket encrypted(std::tr1::get<0>(packet_buffer),
183 std::tr1::get<1>(packet_buffer)); 183 std::tr1::get<1>(packet_buffer));
184 framer.ProcessPacket(encrypted); 184 framer.ProcessPacket(encrypted);
185 QuicPublicResetPacket packet = visitor.public_reset_packet(); 185 QuicPublicResetPacket packet = visitor.public_reset_packet();
186 return connection_id_ == packet.public_header.connection_id && 186 return connection_id_ == packet.public_header.connection_id &&
187 packet.public_header.reset_flag && 187 packet.public_header.reset_flag &&
188 !packet.public_header.version_flag && 188 !packet.public_header.version_flag &&
189 packet_number_ == packet.rejected_packet_number && 189 packet_number_ == packet.rejected_packet_number &&
(...skipping 29 matching lines...) Expand all
219 EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_)); 219 EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_));
220 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); 220 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_));
221 AddStatelessConnectionId(connection_id_); 221 AddStatelessConnectionId(connection_id_);
222 EXPECT_EQ(1u, time_wait_list_manager_.num_connections()); 222 EXPECT_EQ(1u, time_wait_list_manager_.num_connections());
223 EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_)); 223 EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_));
224 } 224 }
225 225
226 TEST_F(QuicTimeWaitListManagerTest, SendVersionNegotiationPacket) { 226 TEST_F(QuicTimeWaitListManagerTest, SendVersionNegotiationPacket) {
227 std::unique_ptr<QuicEncryptedPacket> packet( 227 std::unique_ptr<QuicEncryptedPacket> packet(
228 QuicFramer::BuildVersionNegotiationPacket(connection_id_, 228 QuicFramer::BuildVersionNegotiationPacket(connection_id_,
229 QuicSupportedVersions())); 229 AllSupportedVersions()));
230 EXPECT_CALL(writer_, 230 EXPECT_CALL(writer_,
231 WritePacket(_, packet->length(), server_address_.address(), 231 WritePacket(_, packet->length(), server_address_.address(),
232 client_address_, _)) 232 client_address_, _))
233 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1))); 233 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1)));
234 234
235 time_wait_list_manager_.SendVersionNegotiationPacket( 235 time_wait_list_manager_.SendVersionNegotiationPacket(
236 connection_id_, QuicSupportedVersions(), server_address_, 236 connection_id_, AllSupportedVersions(), server_address_, client_address_);
237 client_address_);
238 EXPECT_EQ(0u, time_wait_list_manager_.num_connections()); 237 EXPECT_EQ(0u, time_wait_list_manager_.num_connections());
239 } 238 }
240 239
241 TEST_F(QuicTimeWaitListManagerTest, SendConnectionClose) { 240 TEST_F(QuicTimeWaitListManagerTest, SendConnectionClose) {
242 const size_t kConnectionCloseLength = 100; 241 const size_t kConnectionCloseLength = 100;
243 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); 242 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_));
244 std::vector<std::unique_ptr<QuicEncryptedPacket>> termination_packets; 243 std::vector<std::unique_ptr<QuicEncryptedPacket>> termination_packets;
245 termination_packets.push_back( 244 termination_packets.push_back(
246 std::unique_ptr<QuicEncryptedPacket>(new QuicEncryptedPacket( 245 std::unique_ptr<QuicEncryptedPacket>(new QuicEncryptedPacket(
247 new char[kConnectionCloseLength], kConnectionCloseLength, true))); 246 new char[kConnectionCloseLength], kConnectionCloseLength, true)));
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections), 550 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections),
552 time_wait_list_manager_.num_connections()); 551 time_wait_list_manager_.num_connections());
553 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict)); 552 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict));
554 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id)); 553 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id));
555 } 554 }
556 } 555 }
557 556
558 } // namespace 557 } // namespace
559 } // namespace test 558 } // namespace test
560 } // namespace net 559 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_server_test.cc ('k') | net/tools/quic/stateless_rejector_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698