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

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

Issue 2591143003: Add QuicStrCat. (Closed)
Patch Set: correct quic_client_bin.cc Created 3 years, 12 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_dispatcher.h" 5 #include "net/tools/quic/quic_dispatcher.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <ostream> 8 #include <ostream>
9 #include <string> 9 #include <string>
10 10
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 InSequence s; 1198 InSequence s;
1199 QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); 1199 QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1);
1200 server_address_ = QuicSocketAddress(QuicIpAddress::Any4(), 5); 1200 server_address_ = QuicSocketAddress(QuicIpAddress::Any4(), 5);
1201 QuicConnectionId conn_id = 1; 1201 QuicConnectionId conn_id = 1;
1202 // A bunch of non-CHLO should be buffered upon arrival, and the first one 1202 // A bunch of non-CHLO should be buffered upon arrival, and the first one
1203 // should trigger ShouldCreateOrBufferPacketForConnection(). 1203 // should trigger ShouldCreateOrBufferPacketForConnection().
1204 EXPECT_CALL(*dispatcher_, ShouldCreateOrBufferPacketForConnection(conn_id)) 1204 EXPECT_CALL(*dispatcher_, ShouldCreateOrBufferPacketForConnection(conn_id))
1205 .Times(1); 1205 .Times(1);
1206 for (size_t i = 1; i <= kDefaultMaxUndecryptablePackets + 1; ++i) { 1206 for (size_t i = 1; i <= kDefaultMaxUndecryptablePackets + 1; ++i) {
1207 ProcessPacket(client_address, conn_id, true, false, 1207 ProcessPacket(client_address, conn_id, true, false,
1208 "data packet " + IntToString(i + 1), 1208 QuicStrCat("data packet ", i + 1), PACKET_8BYTE_CONNECTION_ID,
1209 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, 1209 PACKET_6BYTE_PACKET_NUMBER, kDefaultPathId,
1210 kDefaultPathId,
1211 /*packet_number=*/i + 1); 1210 /*packet_number=*/i + 1);
1212 } 1211 }
1213 EXPECT_EQ(0u, dispatcher_->session_map().size()) 1212 EXPECT_EQ(0u, dispatcher_->session_map().size())
1214 << "No session should be created before CHLO arrives."; 1213 << "No session should be created before CHLO arrives.";
1215 1214
1216 // Pop out the last packet as it is also be dropped by the store. 1215 // Pop out the last packet as it is also be dropped by the store.
1217 data_connection_map_[conn_id].pop_back(); 1216 data_connection_map_[conn_id].pop_back();
1218 // When CHLO arrives, a new session should be created, and all packets 1217 // When CHLO arrives, a new session should be created, and all packets
1219 // buffered should be delivered to the session. 1218 // buffered should be delivered to the session.
1220 EXPECT_CALL(*dispatcher_, CreateQuicSession(conn_id, client_address)) 1219 EXPECT_CALL(*dispatcher_, CreateQuicSession(conn_id, client_address))
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 } else { 1251 } else {
1253 if (i <= kNumConnections - 1) { 1252 if (i <= kNumConnections - 1) {
1254 // As they are on different connection, they should trigger 1253 // As they are on different connection, they should trigger
1255 // ShouldCreateOrBufferPacketForConnection(). The last packet should be 1254 // ShouldCreateOrBufferPacketForConnection(). The last packet should be
1256 // dropped. 1255 // dropped.
1257 EXPECT_CALL(*dispatcher_, 1256 EXPECT_CALL(*dispatcher_,
1258 ShouldCreateOrBufferPacketForConnection(conn_id)); 1257 ShouldCreateOrBufferPacketForConnection(conn_id));
1259 } 1258 }
1260 } 1259 }
1261 ProcessPacket(client_address, conn_id, true, false, 1260 ProcessPacket(client_address, conn_id, true, false,
1262 "data packet on connection " + IntToString(i), 1261 QuicStrCat("data packet on connection ", i),
1263 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, 1262 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER,
1264 kDefaultPathId, 1263 kDefaultPathId,
1265 /*packet_number=*/2); 1264 /*packet_number=*/2);
1266 } 1265 }
1267 1266
1268 // Pop out the packet on last connection as it shouldn't be enqueued in store 1267 // Pop out the packet on last connection as it shouldn't be enqueued in store
1269 // as well. 1268 // as well.
1270 data_connection_map_[kNumConnections].pop_front(); 1269 data_connection_map_[kNumConnections].pop_front();
1271 1270
1272 // Reset session creation counter to ensure processing CHLO can always 1271 // Reset session creation counter to ensure processing CHLO can always
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 } 1326 }
1328 1327
1329 // Tests that a retransmitted CHLO arrives after a connection for the 1328 // Tests that a retransmitted CHLO arrives after a connection for the
1330 // CHLO has been created. 1329 // CHLO has been created.
1331 TEST_P(BufferedPacketStoreTest, ReceiveRetransmittedCHLO) { 1330 TEST_P(BufferedPacketStoreTest, ReceiveRetransmittedCHLO) {
1332 InSequence s; 1331 InSequence s;
1333 QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); 1332 QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1);
1334 server_address_ = QuicSocketAddress(QuicIpAddress::Any4(), 5); 1333 server_address_ = QuicSocketAddress(QuicIpAddress::Any4(), 5);
1335 QuicConnectionId conn_id = 1; 1334 QuicConnectionId conn_id = 1;
1336 ProcessPacket(client_address, conn_id, true, false, 1335 ProcessPacket(client_address, conn_id, true, false,
1337 "data packet " + IntToString(2), PACKET_8BYTE_CONNECTION_ID, 1336 QuicStrCat("data packet ", 2), PACKET_8BYTE_CONNECTION_ID,
1338 PACKET_6BYTE_PACKET_NUMBER, kDefaultPathId, 1337 PACKET_6BYTE_PACKET_NUMBER, kDefaultPathId,
1339 /*packet_number=*/2); 1338 /*packet_number=*/2);
1340 1339
1341 // When CHLO arrives, a new session should be created, and all packets 1340 // When CHLO arrives, a new session should be created, and all packets
1342 // buffered should be delivered to the session. 1341 // buffered should be delivered to the session.
1343 EXPECT_CALL(*dispatcher_, CreateQuicSession(conn_id, client_address)) 1342 EXPECT_CALL(*dispatcher_, CreateQuicSession(conn_id, client_address))
1344 .Times(1) // Only triggered by 1st CHLO. 1343 .Times(1) // Only triggered by 1st CHLO.
1345 .WillOnce(testing::Return(CreateSession( 1344 .WillOnce(testing::Return(CreateSession(
1346 dispatcher_.get(), config_, conn_id, client_address, &mock_helper_, 1345 dispatcher_.get(), config_, conn_id, client_address, &mock_helper_,
1347 &mock_alarm_factory_, &crypto_config_, 1346 &mock_alarm_factory_, &crypto_config_,
(...skipping 14 matching lines...) Expand all
1362 InSequence s; 1361 InSequence s;
1363 CreateTimeWaitListManager(); 1362 CreateTimeWaitListManager();
1364 QuicBufferedPacketStore* store = 1363 QuicBufferedPacketStore* store =
1365 QuicDispatcherPeer::GetBufferedPackets(dispatcher_.get()); 1364 QuicDispatcherPeer::GetBufferedPackets(dispatcher_.get());
1366 QuicBufferedPacketStorePeer::set_clock(store, mock_helper_.GetClock()); 1365 QuicBufferedPacketStorePeer::set_clock(store, mock_helper_.GetClock());
1367 1366
1368 QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1); 1367 QuicSocketAddress client_address(QuicIpAddress::Loopback4(), 1);
1369 server_address_ = QuicSocketAddress(QuicIpAddress::Any4(), 5); 1368 server_address_ = QuicSocketAddress(QuicIpAddress::Any4(), 5);
1370 QuicConnectionId conn_id = 1; 1369 QuicConnectionId conn_id = 1;
1371 ProcessPacket(client_address, conn_id, true, false, 1370 ProcessPacket(client_address, conn_id, true, false,
1372 "data packet " + IntToString(2), PACKET_8BYTE_CONNECTION_ID, 1371 QuicStrCat("data packet ", 2), PACKET_8BYTE_CONNECTION_ID,
1373 PACKET_6BYTE_PACKET_NUMBER, kDefaultPathId, 1372 PACKET_6BYTE_PACKET_NUMBER, kDefaultPathId,
1374 /*packet_number=*/2); 1373 /*packet_number=*/2);
1375 1374
1376 mock_helper_.AdvanceTime( 1375 mock_helper_.AdvanceTime(
1377 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs)); 1376 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs));
1378 QuicAlarm* alarm = QuicBufferedPacketStorePeer::expiration_alarm(store); 1377 QuicAlarm* alarm = QuicBufferedPacketStorePeer::expiration_alarm(store);
1379 // Cancel alarm as if it had been fired. 1378 // Cancel alarm as if it had been fired.
1380 alarm->Cancel(); 1379 alarm->Cancel();
1381 store->OnExpirationTimeout(); 1380 store->OnExpirationTimeout();
1382 // New arrived CHLO will be dropped because this connection is in time wait 1381 // New arrived CHLO will be dropped because this connection is in time wait
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 check.Call(2); 2076 check.Call(2);
2078 GetFakeProofSource()->InvokePendingCallback(0); 2077 GetFakeProofSource()->InvokePendingCallback(0);
2079 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); 2078 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0);
2080 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); 2079 EXPECT_FALSE(store->HasBufferedPackets(conn_id));
2081 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); 2080 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id));
2082 } 2081 }
2083 2082
2084 } // namespace 2083 } // namespace
2085 } // namespace test 2084 } // namespace test
2086 } // namespace net 2085 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698