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 was pruned (a.k.a, write-timeout) and has never received anything | |
1240 // for MIN_CONNECTION_LIFETIME milliseconds since it was created, or | |
1241 // ii) it was pruned and has not received anything for | |
1242 // DEAD_CONNECTION_RECEIVE_TIMEOUT milliseconds since last receiving. | |
pthatcher1
2015/11/11 21:04:54
Both of these say it has to be pruned first, but I
honghaiz3
2015/11/12 00:27:10
That condition was related to my original code.
| |
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 conn->Prune(); // Simulate write-time-out. | |
1260 // If the connection has never received anything, it will be dead after | |
1261 // MIN_CONNECTION_LIFETIME | |
1262 conn->UpdateState(before_created + MIN_CONNECTION_LIFETIME - 1); | |
1263 rtc::Thread::Current()->ProcessMessages(100); | |
1264 EXPECT_TRUE(ch1.conn() != nullptr); | |
1265 conn->UpdateState(after_created + MIN_CONNECTION_LIFETIME + 1); | |
1266 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kTimeout); | |
1267 | |
1268 // Create a connection again and receive a ping. | |
1269 ch1.CreateConnection(GetCandidate(port2)); | |
1270 conn = ch1.conn(); | |
1271 ASSERT(conn != nullptr); | |
1272 conn->Prune(); // Simulate write-time-out. | |
1273 uint32_t before_last_receiving = rtc::Time(); | |
1274 conn->ReceivedPing(); | |
1275 uint32_t after_last_receiving = rtc::Time(); | |
1276 // The connection will be dead after DEAD_CONNECTION_RECEIVE_TIMEOUT | |
1277 conn->UpdateState( | |
1278 before_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT - 1); | |
1279 rtc::Thread::Current()->ProcessMessages(100); | |
1280 EXPECT_TRUE(ch1.conn() != nullptr); | |
1281 conn->UpdateState(after_last_receiving + DEAD_CONNECTION_RECEIVE_TIMEOUT + 1); | |
1282 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kTimeout); | |
1283 } | |
1284 | |
1238 // This test case verifies standard ICE features in STUN messages. Currently it | 1285 // This test case verifies standard ICE features in STUN messages. Currently it |
1239 // verifies Message Integrity attribute in STUN messages and username in STUN | 1286 // verifies Message Integrity attribute in STUN messages and username in STUN |
1240 // binding request will have colon (":") between remote and local username. | 1287 // binding request will have colon (":") between remote and local username. |
1241 TEST_F(PortTest, TestLocalToLocalStandard) { | 1288 TEST_F(PortTest, TestLocalToLocalStandard) { |
1242 UDPPort* port1 = CreateUdpPort(kLocalAddr1); | 1289 UDPPort* port1 = CreateUdpPort(kLocalAddr1); |
1243 port1->SetIceRole(cricket::ICEROLE_CONTROLLING); | 1290 port1->SetIceRole(cricket::ICEROLE_CONTROLLING); |
1244 port1->SetIceTiebreaker(kTiebreaker1); | 1291 port1->SetIceTiebreaker(kTiebreaker1); |
1245 UDPPort* port2 = CreateUdpPort(kLocalAddr2); | 1292 UDPPort* port2 = CreateUdpPort(kLocalAddr2); |
1246 port2->SetIceRole(cricket::ICEROLE_CONTROLLED); | 1293 port2->SetIceRole(cricket::ICEROLE_CONTROLLED); |
1247 port2->SetIceTiebreaker(kTiebreaker2); | 1294 port2->SetIceTiebreaker(kTiebreaker2); |
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2443 StartConnectAndStopChannels(&ch1, &ch2); | 2490 StartConnectAndStopChannels(&ch1, &ch2); |
2444 // Switch the role after all connections are destroyed. | 2491 // Switch the role after all connections are destroyed. |
2445 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); | 2492 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); |
2446 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); | 2493 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); |
2447 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); | 2494 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); |
2448 | 2495 |
2449 // After the connection is destroyed, the port should not be destroyed. | 2496 // After the connection is destroyed, the port should not be destroyed. |
2450 rtc::Thread::Current()->ProcessMessages(kTimeout); | 2497 rtc::Thread::Current()->ProcessMessages(kTimeout); |
2451 EXPECT_FALSE(destroyed()); | 2498 EXPECT_FALSE(destroyed()); |
2452 } | 2499 } |
OLD | NEW |