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

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

Issue 1364683002: Do not prune if the current best connection is weak. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Add tests and merge Created 5 years, 3 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
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.cc ('k') | webrtc/p2p/base/port.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/p2ptransportchannel_unittest.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
index 485449fa88d6aa7b821f129de11290c66cdf5bd4..2f9af2c6d5b5e02c2f507fb2d066e9ff1b8c85a4 100644
--- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc
+++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
@@ -1771,7 +1771,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBeforeNomination) {
// as the best connection.
ch.AddRemoteCandidate(CreateCandidate("2.2.2.2", 2, 10));
cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
- ASSERT_TRUE(conn1 != nullptr);
+ ASSERT_TRUE(conn2 != nullptr);
EXPECT_EQ(conn2, ch.best_connection());
// If a stun request with use-candidate attribute arrives, the receiving
@@ -1931,3 +1931,42 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) {
conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0));
EXPECT_EQ(conn3, ch.best_connection());
}
+
+// When the current best connection is strong, lower-priority connections will
+// be pruned. Otherwise, lower-priority connections are kept.
+TEST_F(P2PTransportChannelPingTest, TestPruneConnections) {
pthatcher1 2015/09/24 06:35:21 Would a better name be TestDontPruneWhenWeak?
honghaiz3 2015/09/24 16:48:49 Done.
+ cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr);
+ cricket::P2PTransportChannel ch("test channel", 1, nullptr, &pa);
+ PrepareChannel(&ch);
+ ch.SetIceRole(cricket::ICEROLE_CONTROLLED);
+ ch.Connect();
+ ch.MaybeStartGathering();
+ ch.AddRemoteCandidate(CreateCandidate("1.1.1.1", 1, 1));
+ cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
+ ASSERT_TRUE(conn1 != nullptr);
+ EXPECT_EQ(conn1, ch.best_connection());
+ conn1->ReceivedPingResponse(); // Becomes writable and receiving
+
+ // When a higher-priority, nominated candidate comes in, the connections with
+ // lower-priority are pruned.
+ ch.AddRemoteCandidate(CreateCandidate("2.2.2.2", 2, 10));
+ cricket::Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
+ ASSERT_TRUE(conn2 != nullptr);
+ conn2->ReceivedPingResponse(); // Becomes writable and receiving
+ conn2->set_nominated(true);
+ conn2->SignalNominated(conn2);
+ EXPECT_TRUE_WAIT(conn1->pruned(), 3000);
+
+ ch.SetReceivingTimeout(500);
+ // Wait until conn2 becomes not receiving.
+ EXPECT_TRUE_WAIT(!conn2->receiving(), 3000);
+
+ ch.AddRemoteCandidate(CreateCandidate("3.3.3.3", 3, 1));
+ cricket::Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3);
+ ASSERT_TRUE(conn3 != nullptr);
+ // The best connection should still be conn2. Even through conn3 has lower
+ // priority and is not receiving/writable, it is not pruned because the best
+ // connection is not receiving.
+ WAIT(conn3->pruned(), 1000);
+ EXPECT_FALSE(conn3->pruned());
+}
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.cc ('k') | webrtc/p2p/base/port.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698