Chromium Code Reviews| Index: webrtc/p2p/base/p2ptransportchannel_unittest.cc |
| diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc |
| index 37cda7c66136ef666b942ee3f1d9184be1d41b8d..b6e2ed6e1710453c1732f3bb54c70f9eb55b8850 100644 |
| --- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc |
| +++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc |
| @@ -2190,3 +2190,30 @@ TEST_F(P2PTransportChannelPingTest, TestDeleteConnectionsIfAllWriteTimedout) { |
| conn3->Prune(); |
| EXPECT_TRUE_WAIT(ch.connections().empty(), 1000); |
| } |
| + |
| +// Test that after a port allocator session is started, it will be stopped |
| +// when a new connection becomes writable and receiving. Also test that this |
| +// holds even if the transport channel did not lose the writability. |
| +TEST_F(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) { |
| + cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| + cricket::P2PTransportChannel ch("test channel", 1, nullptr, &pa); |
| + PrepareChannel(&ch); |
| + ch.SetIceConfig(CreateIceConfig(2000, false)); |
| + ch.Connect(); |
| + ch.MaybeStartGathering(); |
| + ch.AddRemoteCandidate(CreateCandidate("1.1.1.1", 1, 100)); |
| + cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); |
| + ASSERT_TRUE(conn1 != nullptr); |
| + conn1->ReceivedPingResponse(); // Becomes writable and receiving |
| + EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); |
| + |
| + // Restart gathering even if the transport channel is still writable. |
| + // It should stop getting ports after a new connection becomes strong. |
|
pthatcher1
2015/11/04 15:06:14
strong => strongly connected
honghaiz3
2015/11/04 18:27:12
Done.
|
| + ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); |
| + ch.MaybeStartGathering(); |
| + ch.AddRemoteCandidate(CreateCandidate("2.2.2.2", 2, 100)); |
| + cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2); |
| + ASSERT_TRUE(conn2 != nullptr); |
| + conn2->ReceivedPingResponse(); // Becomes writable and receiving |
| + EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts()); |
| +} |