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

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

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

Powered by Google App Engine
This is Rietveld 408576698