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 2392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2403 // Set up channels and ensure both ports will be deleted. | 2403 // Set up channels and ensure both ports will be deleted. |
2404 TestChannel ch1(port1); | 2404 TestChannel ch1(port1); |
2405 TestChannel ch2(port2); | 2405 TestChannel ch2(port2); |
2406 | 2406 |
2407 // Simulate a connection that succeeds, and then is destroyed. | 2407 // Simulate a connection that succeeds, and then is destroyed. |
2408 StartConnectAndStopChannels(&ch1, &ch2); | 2408 StartConnectAndStopChannels(&ch1, &ch2); |
2409 | 2409 |
2410 // The controlled port should be destroyed after 10 milliseconds. | 2410 // The controlled port should be destroyed after 10 milliseconds. |
2411 EXPECT_TRUE_WAIT(destroyed(), kTimeout); | 2411 EXPECT_TRUE_WAIT(destroyed(), kTimeout); |
2412 } | 2412 } |
| 2413 |
| 2414 // This test case verifies that if the role of a port changes from controlling |
| 2415 // to controlled after all connections fail, the port will time out. |
| 2416 TEST_F(PortTest, TestControllingToControlledTimeout) { |
| 2417 UDPPort* port1 = CreateUdpPort(kLocalAddr1); |
| 2418 ConnectToSignalDestroyed(port1); |
| 2419 port1->set_timeout_delay(10); // milliseconds |
| 2420 port1->SetIceRole(cricket::ICEROLE_CONTROLLING); |
| 2421 port1->SetIceTiebreaker(kTiebreaker1); |
| 2422 |
| 2423 UDPPort* port2 = CreateUdpPort(kLocalAddr2); |
| 2424 port2->SetIceRole(cricket::ICEROLE_CONTROLLED); |
| 2425 port2->SetIceTiebreaker(kTiebreaker2); |
| 2426 |
| 2427 // Set up channels and ensure both ports will be deleted. |
| 2428 TestChannel ch1(port1); |
| 2429 TestChannel ch2(port2); |
| 2430 |
| 2431 // Simulate a connection that succeeds, and then is destroyed. |
| 2432 StartConnectAndStopChannels(&ch1, &ch2); |
| 2433 // Switch the role after connections are destroyed. |
| 2434 EXPECT_TRUE_WAIT(ch1.conn() == nullptr, kTimeout); |
| 2435 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); |
| 2436 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); |
| 2437 |
| 2438 // The controlled port should be destroyed after 10 milliseconds. |
| 2439 EXPECT_TRUE_WAIT(destroyed(), kTimeout); |
| 2440 } |
| 2441 |
| 2442 // This test case verifies that if the role of a port changes from controlled |
| 2443 // to controlling after all connections fail, the port will not time out. |
| 2444 TEST_F(PortTest, TestControlledToControllingNoTimeout) { |
| 2445 UDPPort* port1 = CreateUdpPort(kLocalAddr1); |
| 2446 port1->SetIceRole(cricket::ICEROLE_CONTROLLING); |
| 2447 port1->SetIceTiebreaker(kTiebreaker1); |
| 2448 |
| 2449 UDPPort* port2 = CreateUdpPort(kLocalAddr2); |
| 2450 ConnectToSignalDestroyed(port2); |
| 2451 port2->set_timeout_delay(10); // milliseconds |
| 2452 port2->SetIceRole(cricket::ICEROLE_CONTROLLED); |
| 2453 port2->SetIceTiebreaker(kTiebreaker2); |
| 2454 |
| 2455 // The connection must not be destroyed before a connection is attempted. |
| 2456 EXPECT_FALSE(destroyed()); |
| 2457 |
| 2458 port1->set_component(cricket::ICE_CANDIDATE_COMPONENT_DEFAULT); |
| 2459 port2->set_component(cricket::ICE_CANDIDATE_COMPONENT_DEFAULT); |
| 2460 |
| 2461 // Set up channels and ensure both ports will be deleted. |
| 2462 TestChannel ch1(port1); |
| 2463 TestChannel ch2(port2); |
| 2464 |
| 2465 // Simulate a connection that succeeds, and then is destroyed. |
| 2466 StartConnectAndStopChannels(&ch1, &ch2); |
| 2467 // Switch the role after all connections are destroyed. |
| 2468 EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); |
| 2469 port1->SetIceRole(cricket::ICEROLE_CONTROLLED); |
| 2470 port2->SetIceRole(cricket::ICEROLE_CONTROLLING); |
| 2471 |
| 2472 // After the connection is destroyed, the port should not be destroyed. |
| 2473 rtc::Thread::Current()->ProcessMessages(kTimeout); |
| 2474 EXPECT_FALSE(destroyed()); |
| 2475 } |
OLD | NEW |