OLD | NEW |
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 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 /* TODO: Enable these once testrelayserver can accept external SSL. | 1228 /* TODO: Enable these once testrelayserver can accept external SSL. |
1229 TEST_F(PortTest, TestSslTcpToTcpRelay) { | 1229 TEST_F(PortTest, TestSslTcpToTcpRelay) { |
1230 TestSslTcpToRelay(PROTO_TCP); | 1230 TestSslTcpToRelay(PROTO_TCP); |
1231 } | 1231 } |
1232 | 1232 |
1233 TEST_F(PortTest, TestSslTcpToSslTcpRelay) { | 1233 TEST_F(PortTest, TestSslTcpToSslTcpRelay) { |
1234 TestSslTcpToRelay(PROTO_SSLTCP); | 1234 TestSslTcpToRelay(PROTO_SSLTCP); |
1235 } | 1235 } |
1236 */ | 1236 */ |
1237 | 1237 |
| 1238 // Test that a connection will be dead and deleted if |
| 1239 // i) it has never received anything for MIN_CONNECTION_LIFETIME milliseconds |
| 1240 // since it was created, or |
| 1241 // ii) it has not received anything for DEAD_CONNECTION_RECEIVE_TIMEOUT |
| 1242 // milliseconds since last receiving. |
| 1243 TEST_F(PortTest, TestConnectionDead) { |
| 1244 UDPPort* port1 = CreateUdpPort(kLocalAddr1); |
| 1245 UDPPort* port2 = CreateUdpPort(kLocalAddr2); |
| 1246 TestChannel ch1(port1); |
| 1247 TestChannel ch2(port2); |
| 1248 // Acquire address. |
| 1249 ch1.Start(); |
| 1250 ch2.Start(); |
| 1251 ASSERT_EQ_WAIT(1, ch1.complete_count(), kTimeout); |
| 1252 ASSERT_EQ_WAIT(1, ch2.complete_count(), kTimeout); |
| 1253 |
| 1254 uint32_t before_created = rtc::Time(); |
| 1255 ch1.CreateConnection(GetCandidate(port2)); |
| 1256 uint32_t after_created = rtc::Time(); |
| 1257 Connection* conn = ch1.conn(); |
| 1258 ASSERT(conn != nullptr); |
| 1259 // If the connection has never received anything, it will be dead after |
| 1260 // MIN_CONNECTION_LIFETIME |
| 1261 conn->UpdateState(before_created + MIN_CONNECTION_LIFETIME - 1); |
| 1262 rtc::Thread::Current()->ProcessMessages(100); |
| 1263 EXPECT_TRUE(ch1.conn() != nullptr); |
| 1264 conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1); |
| 1265 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kTimeout); |
| 1266 |
| 1267 // Create a connection again and receive a ping. |
| 1268 ch1.CreateConnection(GetCandidate(port2)); |
| 1269 conn = ch1.conn(); |
| 1270 ASSERT(conn != nullptr); |
| 1271 uint32_t before_last_receiving = rtc::Time(); |
| 1272 conn->ReceivedPing(); |
| 1273 uint32_t after_last_receiving = rtc::Time(); |
| 1274 // The connection will be dead after DEAD_CONNECTION_RECEIVE_TIMEOUT |
| 1275 conn->UpdateState( |
| 1276 before_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT - 1); |
| 1277 rtc::Thread::Current()->ProcessMessages(100); |
| 1278 EXPECT_TRUE(ch1.conn() != nullptr); |
| 1279 conn->UpdateState(after_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT + 1); |
| 1280 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kTimeout); |
| 1281 } |
| 1282 |
1238 // This test case verifies standard ICE features in STUN messages. Currently it | 1283 // This test case verifies standard ICE features in STUN messages. Currently it |
1239 // verifies Message Integrity attribute in STUN messages and username in STUN | 1284 // verifies Message Integrity attribute in STUN messages and username in STUN |
1240 // binding request will have colon (":") between remote and local username. | 1285 // binding request will have colon (":") between remote and local username. |
1241 TEST_F(PortTest, TestLocalToLocalStandard) { | 1286 TEST_F(PortTest, TestLocalToLocalStandard) { |
1242 UDPPort* port1 = CreateUdpPort(kLocalAddr1); | 1287 UDPPort* port1 = CreateUdpPort(kLocalAddr1); |
1243 port1->SetIceRole(cricket::ICEROLE_CONTROLLING); | 1288 port1->SetIceRole(cricket::ICEROLE_CONTROLLING); |
1244 port1->SetIceTiebreaker(kTiebreaker1); | 1289 port1->SetIceTiebreaker(kTiebreaker1); |
1245 UDPPort* port2 = CreateUdpPort(kLocalAddr2); | 1290 UDPPort* port2 = CreateUdpPort(kLocalAddr2); |
1246 port2->SetIceRole(cricket::ICEROLE_CONTROLLED); | 1291 port2->SetIceRole(cricket::ICEROLE_CONTROLLED); |
1247 port2->SetIceTiebreaker(kTiebreaker2); | 1292 port2->SetIceTiebreaker(kTiebreaker2); |
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2443 StartConnectAndStopChannels(&ch1, &ch2); | 2488 StartConnectAndStopChannels(&ch1, &ch2); |
2444 // Switch the role after all connections are destroyed. | 2489 // Switch the role after all connections are destroyed. |
2445 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); | 2490 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); |
2446 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); | 2491 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); |
2447 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); | 2492 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); |
2448 | 2493 |
2449 // After the connection is destroyed, the port should not be destroyed. | 2494 // After the connection is destroyed, the port should not be destroyed. |
2450 rtc::Thread::Current()->ProcessMessages(kTimeout); | 2495 rtc::Thread::Current()->ProcessMessages(kTimeout); |
2451 EXPECT_FALSE(destroyed()); | 2496 EXPECT_FALSE(destroyed()); |
2452 } | 2497 } |
OLD | NEW |