Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Unified Diff: webrtc/p2p/base/p2ptransportchannel_unittest.cc

Issue 2171183002: Remove ports that are not used by any channel after timeout (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: fix a comment Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698