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

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

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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_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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 virtual ~QuicTimeWaitListManagerTest() OVERRIDE {} 99 virtual ~QuicTimeWaitListManagerTest() OVERRIDE {}
100 100
101 virtual void SetUp() OVERRIDE { 101 virtual void SetUp() OVERRIDE {
102 EXPECT_CALL(writer_, IsWriteBlocked()) 102 EXPECT_CALL(writer_, IsWriteBlocked())
103 .WillRepeatedly(ReturnPointee(&writer_is_blocked_)); 103 .WillRepeatedly(ReturnPointee(&writer_is_blocked_));
104 EXPECT_CALL(writer_, IsWriteBlockedDataBuffered()) 104 EXPECT_CALL(writer_, IsWriteBlockedDataBuffered())
105 .WillRepeatedly(Return(false)); 105 .WillRepeatedly(Return(false));
106 } 106 }
107 107
108 void AddConnectionId(QuicConnectionId connection_id) { 108 void AddConnectionId(QuicConnectionId connection_id) {
109 AddConnectionId(connection_id, QuicVersionMax(), NULL); 109 AddConnectionId(connection_id, QuicVersionMax(), nullptr);
110 } 110 }
111 111
112 void AddConnectionId(QuicConnectionId connection_id, 112 void AddConnectionId(QuicConnectionId connection_id,
113 QuicVersion version, 113 QuicVersion version,
114 QuicEncryptedPacket* packet) { 114 QuicEncryptedPacket* packet) {
115 time_wait_list_manager_.AddConnectionIdToTimeWait( 115 time_wait_list_manager_.AddConnectionIdToTimeWait(
116 connection_id, version, packet); 116 connection_id, version, packet);
117 } 117 }
118 118
119 bool IsConnectionIdInTimeWait(QuicConnectionId connection_id) { 119 bool IsConnectionIdInTimeWait(QuicConnectionId connection_id) {
120 return time_wait_list_manager_.IsConnectionIdInTimeWait(connection_id); 120 return time_wait_list_manager_.IsConnectionIdInTimeWait(connection_id);
121 } 121 }
122 122
123 void ProcessPacket(QuicConnectionId connection_id, 123 void ProcessPacket(QuicConnectionId connection_id,
124 QuicPacketSequenceNumber sequence_number) { 124 QuicPacketSequenceNumber sequence_number) {
125 QuicEncryptedPacket packet(NULL, 0); 125 QuicEncryptedPacket packet(nullptr, 0);
126 time_wait_list_manager_.ProcessPacket(server_address_, 126 time_wait_list_manager_.ProcessPacket(server_address_,
127 client_address_, 127 client_address_,
128 connection_id, 128 connection_id,
129 sequence_number, 129 sequence_number,
130 packet); 130 packet);
131 } 131 }
132 132
133 QuicEncryptedPacket* ConstructEncryptedPacket( 133 QuicEncryptedPacket* ConstructEncryptedPacket(
134 EncryptionLevel level, 134 EncryptionLevel level,
135 QuicConnectionId connection_id, 135 QuicConnectionId connection_id,
136 QuicPacketSequenceNumber sequence_number) { 136 QuicPacketSequenceNumber sequence_number) {
137 QuicPacketHeader header; 137 QuicPacketHeader header;
138 header.public_header.connection_id = connection_id; 138 header.public_header.connection_id = connection_id;
139 header.public_header.connection_id_length = PACKET_8BYTE_CONNECTION_ID; 139 header.public_header.connection_id_length = PACKET_8BYTE_CONNECTION_ID;
140 header.public_header.version_flag = false; 140 header.public_header.version_flag = false;
141 header.public_header.reset_flag = false; 141 header.public_header.reset_flag = false;
142 header.public_header.sequence_number_length = PACKET_6BYTE_SEQUENCE_NUMBER; 142 header.public_header.sequence_number_length = PACKET_6BYTE_SEQUENCE_NUMBER;
143 header.packet_sequence_number = sequence_number; 143 header.packet_sequence_number = sequence_number;
144 header.entropy_flag = false; 144 header.entropy_flag = false;
145 header.entropy_hash = 0; 145 header.entropy_hash = 0;
146 header.fec_flag = false; 146 header.fec_flag = false;
147 header.is_in_fec_group = NOT_IN_FEC_GROUP; 147 header.is_in_fec_group = NOT_IN_FEC_GROUP;
148 header.fec_group = 0; 148 header.fec_group = 0;
149 QuicStreamFrame stream_frame(1, false, 0, MakeIOVector("data")); 149 QuicStreamFrame stream_frame(1, false, 0, MakeIOVector("data"));
150 QuicFrame frame(&stream_frame); 150 QuicFrame frame(&stream_frame);
151 QuicFrames frames; 151 QuicFrames frames;
152 frames.push_back(frame); 152 frames.push_back(frame);
153 scoped_ptr<QuicPacket> packet( 153 scoped_ptr<QuicPacket> packet(
154 BuildUnsizedDataPacket(&framer_, header, frames).packet); 154 BuildUnsizedDataPacket(&framer_, header, frames).packet);
155 EXPECT_TRUE(packet != NULL); 155 EXPECT_TRUE(packet != nullptr);
156 QuicEncryptedPacket* encrypted = framer_.EncryptPacket(ENCRYPTION_NONE, 156 QuicEncryptedPacket* encrypted = framer_.EncryptPacket(ENCRYPTION_NONE,
157 sequence_number, 157 sequence_number,
158 *packet); 158 *packet);
159 EXPECT_TRUE(encrypted != NULL); 159 EXPECT_TRUE(encrypted != nullptr);
160 return encrypted; 160 return encrypted;
161 } 161 }
162 162
163 NiceMock<MockFakeTimeEpollServer> epoll_server_; 163 NiceMock<MockFakeTimeEpollServer> epoll_server_;
164 StrictMock<MockPacketWriter> writer_; 164 StrictMock<MockPacketWriter> writer_;
165 StrictMock<MockQuicServerSessionVisitor> visitor_; 165 StrictMock<MockQuicServerSessionVisitor> visitor_;
166 QuicTimeWaitListManager time_wait_list_manager_; 166 QuicTimeWaitListManager time_wait_list_manager_;
167 QuicFramer framer_; 167 QuicFramer framer_;
168 QuicConnectionId connection_id_; 168 QuicConnectionId connection_id_;
169 IPEndPoint server_address_; 169 IPEndPoint server_address_;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 370 .WillOnce(Return(WriteResult(WRITE_STATUS_OK,
371 other_packet->length()))); 371 other_packet->length())));
372 time_wait_list_manager_.OnCanWrite(); 372 time_wait_list_manager_.OnCanWrite();
373 } 373 }
374 374
375 TEST_F(QuicTimeWaitListManagerTest, GetQuicVersionFromMap) { 375 TEST_F(QuicTimeWaitListManagerTest, GetQuicVersionFromMap) {
376 const int kConnectionId1 = 123; 376 const int kConnectionId1 = 123;
377 const int kConnectionId2 = 456; 377 const int kConnectionId2 = 456;
378 const int kConnectionId3 = 789; 378 const int kConnectionId3 = 789;
379 379
380 AddConnectionId(kConnectionId1, QuicVersionMin(), NULL); 380 AddConnectionId(kConnectionId1, QuicVersionMin(), nullptr);
381 AddConnectionId(kConnectionId2, QuicVersionMax(), NULL); 381 AddConnectionId(kConnectionId2, QuicVersionMax(), nullptr);
382 AddConnectionId(kConnectionId3, QuicVersionMax(), NULL); 382 AddConnectionId(kConnectionId3, QuicVersionMax(), nullptr);
383 383
384 EXPECT_EQ(QuicVersionMin(), 384 EXPECT_EQ(QuicVersionMin(),
385 QuicTimeWaitListManagerPeer::GetQuicVersionFromConnectionId( 385 QuicTimeWaitListManagerPeer::GetQuicVersionFromConnectionId(
386 &time_wait_list_manager_, kConnectionId1)); 386 &time_wait_list_manager_, kConnectionId1));
387 EXPECT_EQ(QuicVersionMax(), 387 EXPECT_EQ(QuicVersionMax(),
388 QuicTimeWaitListManagerPeer::GetQuicVersionFromConnectionId( 388 QuicTimeWaitListManagerPeer::GetQuicVersionFromConnectionId(
389 &time_wait_list_manager_, kConnectionId2)); 389 &time_wait_list_manager_, kConnectionId2));
390 EXPECT_EQ(QuicVersionMax(), 390 EXPECT_EQ(QuicVersionMax(),
391 QuicTimeWaitListManagerPeer::GetQuicVersionFromConnectionId( 391 QuicTimeWaitListManagerPeer::GetQuicVersionFromConnectionId(
392 &time_wait_list_manager_, kConnectionId3)); 392 &time_wait_list_manager_, kConnectionId3));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 EXPECT_CALL(epoll_server_, RegisterAlarm(_, _)); 452 EXPECT_CALL(epoll_server_, RegisterAlarm(_, _));
453 453
454 time_wait_list_manager_.CleanUpOldConnectionIds(); 454 time_wait_list_manager_.CleanUpOldConnectionIds();
455 EXPECT_FALSE(IsConnectionIdInTimeWait(kConnectionId1)); 455 EXPECT_FALSE(IsConnectionIdInTimeWait(kConnectionId1));
456 EXPECT_TRUE(IsConnectionIdInTimeWait(kConnectionId2)); 456 EXPECT_TRUE(IsConnectionIdInTimeWait(kConnectionId2));
457 } 457 }
458 } // namespace 458 } // namespace
459 } // namespace test 459 } // namespace test
460 } // namespace tools 460 } // namespace tools
461 } // namespace net 461 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_time_wait_list_manager.h ('k') | net/tools/quic/test_tools/packet_dropping_test_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698