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

Side by Side Diff: webrtc/p2p/base/port_unittest.cc

Issue 1544003002: Delete a connection after it is pruned or becomes write_timeout (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix comments Created 4 years, 11 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 | « webrtc/p2p/base/port.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 UDPPort* port1 = CreateUdpPort(kLocalAddr1); 1248 UDPPort* port1 = CreateUdpPort(kLocalAddr1);
1249 UDPPort* port2 = CreateUdpPort(kLocalAddr2); 1249 UDPPort* port2 = CreateUdpPort(kLocalAddr2);
1250 TestChannel ch1(port1); 1250 TestChannel ch1(port1);
1251 TestChannel ch2(port2); 1251 TestChannel ch2(port2);
1252 // Acquire address. 1252 // Acquire address.
1253 ch1.Start(); 1253 ch1.Start();
1254 ch2.Start(); 1254 ch2.Start();
1255 ASSERT_EQ_WAIT(1, ch1.complete_count(), kTimeout); 1255 ASSERT_EQ_WAIT(1, ch1.complete_count(), kTimeout);
1256 ASSERT_EQ_WAIT(1, ch2.complete_count(), kTimeout); 1256 ASSERT_EQ_WAIT(1, ch2.complete_count(), kTimeout);
1257 1257
1258 // Test case that the connection has never received anything.
1258 uint32_t before_created = rtc::Time(); 1259 uint32_t before_created = rtc::Time();
1259 ch1.CreateConnection(GetCandidate(port2)); 1260 ch1.CreateConnection(GetCandidate(port2));
1260 uint32_t after_created = rtc::Time(); 1261 uint32_t after_created = rtc::Time();
1261 Connection* conn = ch1.conn(); 1262 Connection* conn = ch1.conn();
1262 ASSERT(conn != nullptr); 1263 ASSERT(conn != nullptr);
1263 // If the connection has never received anything, it will be dead after 1264 // It is not dead if it is after MIN_CONNECTION_LIFETIME but not pruned.
1264 // MIN_CONNECTION_LIFETIME 1265 conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1);
1266 rtc::Thread::Current()->ProcessMessages(0);
1267 EXPECT_TRUE(ch1.conn() != nullptr);
1268 // It is not dead if it is before MIN_CONNECTION_LIFETIME and pruned.
1265 conn->UpdateState(before_created + MIN_CONNECTION_LIFETIME - 1); 1269 conn->UpdateState(before_created + MIN_CONNECTION_LIFETIME - 1);
1266 rtc::Thread::Current()->ProcessMessages(100); 1270 conn->Prune();
1271 rtc::Thread::Current()->ProcessMessages(0);
1267 EXPECT_TRUE(ch1.conn() != nullptr); 1272 EXPECT_TRUE(ch1.conn() != nullptr);
1273 // It will be dead after MIN_CONNECTION_LIFETIME and pruned.
1268 conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1); 1274 conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1);
1269 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kTimeout); 1275 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kTimeout);
1270 1276
1277 // Test case that the connection has received something.
1271 // Create a connection again and receive a ping. 1278 // Create a connection again and receive a ping.
1272 ch1.CreateConnection(GetCandidate(port2)); 1279 ch1.CreateConnection(GetCandidate(port2));
1273 conn = ch1.conn(); 1280 conn = ch1.conn();
1274 ASSERT(conn != nullptr); 1281 ASSERT(conn != nullptr);
1275 uint32_t before_last_receiving = rtc::Time(); 1282 uint32_t before_last_receiving = rtc::Time();
1276 conn->ReceivedPing(); 1283 conn->ReceivedPing();
1277 uint32_t after_last_receiving = rtc::Time(); 1284 uint32_t after_last_receiving = rtc::Time();
1278 // The connection will be dead after DEAD_CONNECTION_RECEIVE_TIMEOUT 1285 // The connection will be dead after DEAD_CONNECTION_RECEIVE_TIMEOUT
1279 conn->UpdateState( 1286 conn->UpdateState(
1280 before_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT - 1); 1287 before_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT - 1);
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 rtc::scoped_ptr<Port> tcp_port(CreateTcpPort(kLocalAddr1)); 2520 rtc::scoped_ptr<Port> tcp_port(CreateTcpPort(kLocalAddr1));
2514 EXPECT_TRUE(tcp_port->SupportsProtocol(TCP_PROTOCOL_NAME)); 2521 EXPECT_TRUE(tcp_port->SupportsProtocol(TCP_PROTOCOL_NAME));
2515 EXPECT_TRUE(tcp_port->SupportsProtocol(SSLTCP_PROTOCOL_NAME)); 2522 EXPECT_TRUE(tcp_port->SupportsProtocol(SSLTCP_PROTOCOL_NAME));
2516 EXPECT_FALSE(tcp_port->SupportsProtocol(UDP_PROTOCOL_NAME)); 2523 EXPECT_FALSE(tcp_port->SupportsProtocol(UDP_PROTOCOL_NAME));
2517 2524
2518 rtc::scoped_ptr<Port> turn_port( 2525 rtc::scoped_ptr<Port> turn_port(
2519 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); 2526 CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP));
2520 EXPECT_TRUE(turn_port->SupportsProtocol(UDP_PROTOCOL_NAME)); 2527 EXPECT_TRUE(turn_port->SupportsProtocol(UDP_PROTOCOL_NAME));
2521 EXPECT_FALSE(turn_port->SupportsProtocol(TCP_PROTOCOL_NAME)); 2528 EXPECT_FALSE(turn_port->SupportsProtocol(TCP_PROTOCOL_NAME));
2522 } 2529 }
OLDNEW
« no previous file with comments | « webrtc/p2p/base/port.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698