| Index: webrtc/p2p/base/p2ptransportchannel_unittest.cc
|
| diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
|
| index 86f4ec3852300fd1043e4ab049a72d7e8514bc95..37cda7c66136ef666b942ee3f1d9184be1d41b8d 100644
|
| --- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc
|
| +++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
|
| @@ -2159,3 +2159,34 @@ TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) {
|
| EXPECT_TRUE_WAIT(!conn2->active(), 1000);
|
| EXPECT_EQ(cricket::TransportChannelState::STATE_COMPLETED, ch.GetState());
|
| }
|
| +
|
| +// Test that if all connections in a channel has timed out on writing, they
|
| +// will all be deleted. We use Prune to simulate write_time_out.
|
| +TEST_F(P2PTransportChannelPingTest, TestDeleteConnectionsIfAllWriteTimedout) {
|
| + cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
|
| + cricket::P2PTransportChannel ch("test channel", 1, nullptr, &pa);
|
| + PrepareChannel(&ch);
|
| + ch.Connect();
|
| + ch.MaybeStartGathering();
|
| + // Have one connection only but later becomes write-time-out.
|
| + ch.AddRemoteCandidate(CreateCandidate("1.1.1.1", 1, 100));
|
| + cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
|
| + ASSERT_TRUE(conn1 != nullptr);
|
| + conn1->ReceivedPing(); // Becomes receiving
|
| + conn1->Prune();
|
| + EXPECT_TRUE_WAIT(ch.connections().empty(), 1000);
|
| +
|
| + // Have two connections but both become write-time-out later.
|
| + ch.AddRemoteCandidate(CreateCandidate("2.2.2.2", 2, 1));
|
| + cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
|
| + ASSERT_TRUE(conn2 != nullptr);
|
| + conn2->ReceivedPing(); // Becomes receiving
|
| + ch.AddRemoteCandidate(CreateCandidate("3.3.3.3", 3, 2));
|
| + cricket::Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3);
|
| + ASSERT_TRUE(conn3 != nullptr);
|
| + conn3->ReceivedPing(); // Becomes receiving
|
| + // Now prune both conn2 and conn3; they will be deleted soon.
|
| + conn2->Prune();
|
| + conn3->Prune();
|
| + EXPECT_TRUE_WAIT(ch.connections().empty(), 1000);
|
| +}
|
|
|