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 6673f8f54d3e9f96c501662664bd2106b9097ab5..240780272d27848fa01969f015b9b90ada34ac75 100644 |
| --- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc |
| +++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc |
| @@ -2497,6 +2497,13 @@ class P2PTransportChannelPingTest : public testing::Test, |
| return static_cast<Port*>(ch->ports()[0]); |
| } |
| + Port* GetRemovedPort(P2PTransportChannel* ch) { |
| + if (ch->removed_ports().empty()) { |
| + return nullptr; |
| + } |
| + return static_cast<Port*>(ch->removed_ports()[0]); |
| + } |
| + |
| Connection* GetConnectionTo(P2PTransportChannel* ch, |
| const std::string& ip, |
| int port_num) { |
| @@ -3579,8 +3586,9 @@ TEST_F(P2PTransportChannelPingTest, TestIceRoleUpdatedOnPortAfterIceRestart) { |
| } |
| // Test that after some amount of time without receiving data, the connection |
| -// and port are destroyed. |
| -TEST_F(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeout) { |
| +// will be destroyed. The port will only be destroyed after it is removed |
| +// from usage. |
| +TEST_F(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeoutAndRemoved) { |
| rtc::ScopedFakeClock fake_clock; |
| FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| @@ -3600,7 +3608,16 @@ TEST_F(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeout) { |
| fake_clock.AdvanceTime(rtc::TimeDelta::FromSeconds(1)); |
| } |
| EXPECT_EQ(nullptr, GetConnectionTo(&ch, "1.1.1.1", 1)); |
| - EXPECT_EQ(nullptr, GetPort(&ch)); |
| + // Port will not be removed because it is still used by the channel. |
| + PortInterface* port = GetPort(&ch); |
| + ASSERT_NE(nullptr, port); |
| + |
| + // If the session signals removing the port, the port will be destroyed. |
| + std::vector<PortInterface*> ports_to_remove(1, port); |
| + ch.allocator_session()->SignalPortsRemoved(ch.allocator_session(), |
| + ports_to_remove); |
| + EXPECT_EQ_SIMULATED_WAIT(nullptr, GetPort(&ch), 1, fake_clock); |
| + EXPECT_EQ_SIMULATED_WAIT(nullptr, GetRemovedPort(&ch), 1, fake_clock); |
|
pthatcher1
2016/07/27 18:33:15
If we move the logic to be between the session and
honghaiz3
2016/07/28 01:22:49
This is an extra test here. There are tests in Por
|
| } |
| class P2PTransportChannelMostLikelyToWorkFirstTest |