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

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

Issue 2163403002: Prepare for ICE-renomination (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: . 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..4ee49f08e7ca655586ac582c938396af54c0f698 100644
--- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc
+++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
@@ -2537,13 +2537,13 @@ class P2PTransportChannelPingTest : public testing::Test,
Connection* conn = GetConnectionTo(&channel, ip_addr, port);
if (conn && writable) {
- conn->ReceivedPingResponse(LOW_RTT); // make it writable
+ conn->ReceivedPingResponse(LOW_RTT, "id"); // make it writable
}
return conn;
}
void NominateConnection(Connection* conn) {
- conn->set_nominated(true);
+ conn->set_nominated_value(1);
conn->SignalNominated(conn);
}
@@ -2644,7 +2644,7 @@ TEST_F(P2PTransportChannelPingTest, TestAllConnectionsPingedSufficiently) {
// Low-priority connection becomes writable so that the other connection
// is not pruned.
- conn1->ReceivedPingResponse(LOW_RTT);
+ conn1->ReceivedPingResponse(LOW_RTT, "id");
EXPECT_TRUE_WAIT(
conn1->num_pings_sent() >= MIN_PINGS_AT_WEAK_PING_INTERVAL &&
conn2->num_pings_sent() >= MIN_PINGS_AT_WEAK_PING_INTERVAL,
@@ -2680,7 +2680,7 @@ TEST_F(P2PTransportChannelPingTest, TestStunPingIntervals) {
// Stabilizing.
- conn->ReceivedPingResponse(LOW_RTT);
+ conn->ReceivedPingResponse(LOW_RTT, "id");
int ping_sent_before = conn->num_pings_sent();
start = clock.TimeNanos();
// The connection becomes strong but not stable because we haven't been able
@@ -2696,7 +2696,7 @@ TEST_F(P2PTransportChannelPingTest, TestStunPingIntervals) {
// The connection becomes stable after receiving more than RTT_RATIO rtt
// samples.
for (int i = 0; i < RTT_RATIO; i++) {
- conn->ReceivedPingResponse(LOW_RTT);
+ conn->ReceivedPingResponse(LOW_RTT, "id");
}
ping_sent_before = conn->num_pings_sent();
start = clock.TimeNanos();
@@ -2708,7 +2708,7 @@ TEST_F(P2PTransportChannelPingTest, TestStunPingIntervals) {
// Destabilized.
- conn->ReceivedPingResponse(LOW_RTT);
+ conn->ReceivedPingResponse(LOW_RTT, "id");
// Create a in-flight ping.
conn->Ping(clock.TimeNanos() / rtc::kNumNanosecsPerMillisec);
start = clock.TimeNanos();
@@ -2790,7 +2790,7 @@ TEST_F(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) {
EXPECT_EQ(conn2, FindNextPingableConnectionAndPingIt(&ch));
EXPECT_EQ(conn1, FindNextPingableConnectionAndPingIt(&ch));
- conn1->ReceivedPingResponse(LOW_RTT);
+ conn1->ReceivedPingResponse(LOW_RTT, "id");
ASSERT_TRUE(conn1->writable());
conn1->ReceivedPing();
@@ -2907,7 +2907,7 @@ TEST_F(P2PTransportChannelPingTest, ConnectionResurrection) {
Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
ASSERT_TRUE(conn2 != nullptr);
conn2->ReceivedPing();
- conn2->ReceivedPingResponse(LOW_RTT);
+ conn2->ReceivedPingResponse(LOW_RTT, "id");
// Wait for conn1 to be pruned.
EXPECT_TRUE_WAIT(conn1->pruned(), 3000);
@@ -3008,10 +3008,10 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBeforeNomination) {
ASSERT_TRUE(conn3 != nullptr);
// Because it has a lower priority, the selected connection is still conn2.
EXPECT_EQ(conn2, ch.selected_connection());
- conn3->ReceivedPingResponse(LOW_RTT); // Become writable.
+ conn3->ReceivedPingResponse(LOW_RTT, "id"); // Become writable.
// But if it is nominated via use_candidate, it is chosen as the selected
// connection.
- conn3->set_nominated(true);
+ conn3->set_nominated_value(1);
conn3->SignalNominated(conn3);
EXPECT_EQ(conn3, ch.selected_connection());
EXPECT_EQ(conn3, last_selected_candidate_pair());
@@ -3028,13 +3028,13 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBeforeNomination) {
EXPECT_EQ(conn3, ch.selected_connection());
// But if it is nominated via use_candidate and writable, it will be set as
// the selected connection.
- conn4->set_nominated(true);
+ conn4->set_nominated_value(1);
conn4->SignalNominated(conn4);
// Not switched yet because conn4 is not writable.
EXPECT_EQ(conn3, ch.selected_connection());
reset_channel_ready_to_send();
// The selected connection switches after conn4 becomes writable.
- conn4->ReceivedPingResponse(LOW_RTT);
+ conn4->ReceivedPingResponse(LOW_RTT, "id");
EXPECT_EQ_WAIT(conn4, ch.selected_connection(), kDefaultTimeout);
EXPECT_EQ(conn4, last_selected_candidate_pair());
EXPECT_EQ(last_packet_id, last_sent_packet_id());
@@ -3069,7 +3069,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) {
ASSERT_TRUE(conn1 != nullptr);
EXPECT_TRUE(port->sent_binding_response());
EXPECT_EQ(conn1, ch.selected_connection());
- conn1->ReceivedPingResponse(LOW_RTT);
+ conn1->ReceivedPingResponse(LOW_RTT, "id");
EXPECT_EQ(conn1, ch.selected_connection());
port->set_sent_binding_response(false);
@@ -3081,8 +3081,8 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) {
EXPECT_EQ(conn1, ch.selected_connection());
// When it is nominated via use_candidate and writable, it is chosen as the
// selected connection.
- conn2->ReceivedPingResponse(LOW_RTT); // Become writable.
- conn2->set_nominated(true);
+ conn2->ReceivedPingResponse(LOW_RTT, "id"); // Become writable.
+ conn2->set_nominated_value(1);
conn2->SignalNominated(conn2);
EXPECT_EQ(conn2, ch.selected_connection());
@@ -3094,7 +3094,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) {
Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3);
ASSERT_TRUE(conn3 != nullptr);
EXPECT_TRUE(port->sent_binding_response());
- conn3->ReceivedPingResponse(LOW_RTT); // Become writable.
+ conn3->ReceivedPingResponse(LOW_RTT, "id"); // Become writable.
EXPECT_EQ(conn2, ch.selected_connection());
port->set_sent_binding_response(false);
@@ -3108,7 +3108,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) {
EXPECT_TRUE(port->sent_binding_response());
// conn4 is not the selected connection yet because it is not writable.
EXPECT_EQ(conn2, ch.selected_connection());
- conn4->ReceivedPingResponse(LOW_RTT); // Become writable.
+ conn4->ReceivedPingResponse(LOW_RTT, "id"); // Become writable.
EXPECT_EQ_WAIT(conn4, ch.selected_connection(), kDefaultTimeout);
// Test that the request from an unknown address contains a ufrag from an old
@@ -3148,7 +3148,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) {
conn2->ReceivedPing(); // Start receiving.
conn2->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0));
EXPECT_EQ(conn2, ch.selected_connection());
- conn2->ReceivedPingResponse(LOW_RTT); // Become writable.
+ conn2->ReceivedPingResponse(LOW_RTT, "id"); // Become writable.
// Now another STUN message with an unknown address and use_candidate will
// nominate the selected connection.
@@ -3166,13 +3166,13 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) {
Connection* conn3 = WaitForConnectionTo(&ch, "3.3.3.3", 3);
ASSERT_TRUE(conn3 != nullptr);
EXPECT_EQ(conn2, ch.selected_connection()); // Not writable yet.
- conn3->ReceivedPingResponse(LOW_RTT); // Become writable.
+ conn3->ReceivedPingResponse(LOW_RTT, "id"); // Become writable.
EXPECT_EQ_WAIT(conn3, ch.selected_connection(), kDefaultTimeout);
// Now another data packet will not switch the selected connection because the
// selected connection was nominated by the controlling side.
conn2->ReceivedPing();
- conn2->ReceivedPingResponse(LOW_RTT);
+ conn2->ReceivedPingResponse(LOW_RTT, "id");
conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0));
EXPECT_EQ_WAIT(conn3, ch.selected_connection(), kDefaultTimeout);
}
@@ -3282,7 +3282,7 @@ TEST_F(P2PTransportChannelPingTest,
EXPECT_EQ(1, reset_selected_candidate_pair_switches());
// conn2 becomes writable; it is selected even though it is not nominated.
- conn2->ReceivedPingResponse(LOW_RTT);
+ conn2->ReceivedPingResponse(LOW_RTT, "id");
EXPECT_EQ_SIMULATED_WAIT(1, reset_selected_candidate_pair_switches(),
kDefaultTimeout, clock);
@@ -3290,7 +3290,7 @@ TEST_F(P2PTransportChannelPingTest,
kDefaultTimeout, clock);
// If conn1 is also writable, it will become selected.
- conn1->ReceivedPingResponse(LOW_RTT);
+ conn1->ReceivedPingResponse(LOW_RTT, "id");
EXPECT_EQ_SIMULATED_WAIT(1, reset_selected_candidate_pair_switches(),
kDefaultTimeout, clock);
EXPECT_EQ_SIMULATED_WAIT(conn1, last_selected_candidate_pair(),
@@ -3351,15 +3351,15 @@ TEST_F(P2PTransportChannelPingTest, TestDontPruneWhenWeak) {
Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
ASSERT_TRUE(conn1 != nullptr);
EXPECT_EQ(conn1, ch.selected_connection());
- conn1->ReceivedPingResponse(LOW_RTT); // Becomes writable and receiving
+ conn1->ReceivedPingResponse(LOW_RTT, "id"); // Becomes writable and receiving
// When a higher-priority, nominated candidate comes in, the connections with
// lower-priority are pruned.
ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 10));
Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
ASSERT_TRUE(conn2 != nullptr);
- conn2->ReceivedPingResponse(LOW_RTT); // Becomes writable and receiving
- conn2->set_nominated(true);
+ conn2->ReceivedPingResponse(LOW_RTT, "id"); // Becomes writable and receiving
+ conn2->set_nominated_value(1);
conn2->SignalNominated(conn2);
EXPECT_TRUE_WAIT(conn1->pruned(), 3000);
@@ -3415,7 +3415,7 @@ TEST_F(P2PTransportChannelPingTest, TestGetState) {
// Now there are two connections, so the transport channel is connecting.
EXPECT_EQ(TransportChannelState::STATE_CONNECTING, ch.GetState());
// |conn1| becomes writable and receiving; it then should prune |conn2|.
- conn1->ReceivedPingResponse(LOW_RTT);
+ conn1->ReceivedPingResponse(LOW_RTT, "id");
EXPECT_TRUE_WAIT(conn2->pruned(), 1000);
EXPECT_EQ(TransportChannelState::STATE_COMPLETED, ch.GetState());
conn1->Prune(); // All connections are pruned.
@@ -3437,7 +3437,7 @@ TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) {
Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
ASSERT_TRUE(conn1 != nullptr);
EXPECT_EQ(conn1, ch.selected_connection());
- conn1->ReceivedPingResponse(LOW_RTT); // Becomes writable and receiving
+ conn1->ReceivedPingResponse(LOW_RTT, "id"); // Becomes writable and receiving
// Add a low-priority connection |conn2|, which will be pruned, but it will
// not be deleted right away. Once the current selected connection becomes not
@@ -3456,12 +3456,12 @@ TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) {
conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
ASSERT_TRUE(conn2 != nullptr);
EXPECT_EQ_WAIT(Connection::STATE_INPROGRESS, conn2->state(), 1000);
- conn2->ReceivedPingResponse(LOW_RTT);
+ conn2->ReceivedPingResponse(LOW_RTT, "id");
EXPECT_EQ_WAIT(conn2, ch.selected_connection(), 1000);
EXPECT_EQ(TransportChannelState::STATE_CONNECTING, ch.GetState());
// When |conn1| comes back again, |conn2| will be pruned again.
- conn1->ReceivedPingResponse(LOW_RTT);
+ conn1->ReceivedPingResponse(LOW_RTT, "id");
EXPECT_EQ_WAIT(conn1, ch.selected_connection(), 1000);
EXPECT_TRUE_WAIT(!conn2->active(), 1000);
EXPECT_EQ(TransportChannelState::STATE_COMPLETED, ch.GetState());
@@ -3510,7 +3510,7 @@ TEST_F(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) {
ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100));
Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
ASSERT_TRUE(conn1 != nullptr);
- conn1->ReceivedPingResponse(LOW_RTT); // Becomes writable and receiving
+ conn1->ReceivedPingResponse(LOW_RTT, "id"); // Becomes writable and receiving
EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts());
// Start a new session. Even though conn1, which belongs to an older
@@ -3519,7 +3519,7 @@ TEST_F(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) {
ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]);
ch.MaybeStartGathering();
conn1->Prune();
- conn1->ReceivedPingResponse(LOW_RTT);
+ conn1->ReceivedPingResponse(LOW_RTT, "id");
EXPECT_TRUE(ch.allocator_session()->IsGettingPorts());
// But if a new connection created from the new session becomes writable,
@@ -3527,7 +3527,7 @@ TEST_F(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) {
ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 100));
Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
ASSERT_TRUE(conn2 != nullptr);
- conn2->ReceivedPingResponse(LOW_RTT); // Becomes writable and receiving
+ conn2->ReceivedPingResponse(LOW_RTT, "id"); // Becomes writable and receiving
EXPECT_TRUE(!ch.allocator_session()->IsGettingPorts());
}
@@ -3693,7 +3693,7 @@ TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest,
Connection* conn3 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
EXPECT_EQ(conn3->local_candidate().type(), LOCAL_PORT_TYPE);
EXPECT_EQ(conn3->remote_candidate().type(), RELAY_PORT_TYPE);
- conn3->ReceivedPingResponse(LOW_RTT);
+ conn3->ReceivedPingResponse(LOW_RTT, "id");
ASSERT_TRUE(conn3->writable());
conn3->ReceivedPing();
@@ -3711,7 +3711,7 @@ TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest,
// pingable connection.
EXPECT_TRUE_WAIT(conn3 == ch.selected_connection(), 5000);
WAIT(false, max_strong_interval + 100);
- conn3->ReceivedPingResponse(LOW_RTT);
+ conn3->ReceivedPingResponse(LOW_RTT, "id");
ASSERT_TRUE(conn3->writable());
EXPECT_EQ(conn3, FindNextPingableConnectionAndPingIt(&ch));

Powered by Google App Engine
This is Rietveld 408576698