Chromium Code Reviews| Index: webrtc/p2p/base/port_unittest.cc |
| diff --git a/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc |
| index c4fa5f8331c877b2dc52e82ee318870b26b46708..5bc6857190e6ecc6e8c46d307c8ae3a9621ab13f 100644 |
| --- a/webrtc/p2p/base/port_unittest.cc |
| +++ b/webrtc/p2p/base/port_unittest.cc |
| @@ -2410,3 +2410,38 @@ TEST_F(PortTest, TestControlledTimeout) { |
| // The controlled port should be destroyed after 10 milliseconds. |
| EXPECT_TRUE_WAIT(destroyed(), kTimeout); |
| } |
| + |
| +// This test case verifies that if the role of a port changes from controlled |
| +// to controlling after all connections fail, the port will not time out. |
|
pthatcher1
2015/09/30 17:08:03
will not timeout => will not be destroyed
honghaiz3
2015/09/30 17:17:53
Done.
|
| +TEST_F(PortTest, TestControlledToControllingNoTimeout) { |
|
pthatcher1
2015/09/30 17:08:03
NoTimeout => NotDestroyed
honghaiz3
2015/09/30 17:17:53
Done.
|
| + UDPPort* port1 = CreateUdpPort(kLocalAddr1); |
| + port1->SetIceRole(cricket::ICEROLE_CONTROLLING); |
| + port1->SetIceTiebreaker(kTiebreaker1); |
| + |
| + UDPPort* port2 = CreateUdpPort(kLocalAddr2); |
| + ConnectToSignalDestroyed(port2); |
| + port2->set_timeout_delay(10); // milliseconds |
| + port2->SetIceRole(cricket::ICEROLE_CONTROLLED); |
| + port2->SetIceTiebreaker(kTiebreaker2); |
| + |
| + // The connection must not be destroyed before a connection is attempted. |
| + EXPECT_FALSE(destroyed()); |
| + |
| + port1->set_component(cricket::ICE_CANDIDATE_COMPONENT_DEFAULT); |
| + port2->set_component(cricket::ICE_CANDIDATE_COMPONENT_DEFAULT); |
| + |
| + // Set up channels and ensure both ports will be deleted. |
| + TestChannel ch1(port1); |
| + TestChannel ch2(port2); |
| + |
| + // Simulate a connection that succeeds, and then is destroyed. |
| + StartConnectAndStopChannels(&ch1, &ch2); |
| + // Switch the role after all connections are destroyed. |
| + EXPECT_TRUE_WAIT(ch2.conn() == nullptr, kTimeout); |
| + port1->SetIceRole(cricket::ICEROLE_CONTROLLED); |
| + port2->SetIceRole(cricket::ICEROLE_CONTROLLING); |
| + |
| + // After the connection is destroyed, the port should not be destroyed. |
| + rtc::Thread::Current()->ProcessMessages(kTimeout); |
| + EXPECT_FALSE(destroyed()); |
| +} |