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 d41e3304f4ee3a47b9276b37f422b6daff3b2e27..0e309aa03e222dab8e7d77cad88815093dee4fde 100644 |
| --- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc |
| +++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc |
| @@ -92,16 +92,19 @@ static const SocketAddress kTurnUdpExtAddr("99.99.99.5", 0); |
| static const cricket::RelayCredentials kRelayCredentials("test", "test"); |
| // Based on ICE_UFRAG_LENGTH |
| -static const char* kIceUfrag[4] = {"UF00", "UF01", |
| - "UF02", "UF03"}; |
| +const char* kIceUfrag[4] = {"UF00", "UF01", "UF02", "UF03"}; |
| // Based on ICE_PWD_LENGTH |
| -static const char* kIcePwd[4] = {"TESTICEPWD00000000000000", |
| - "TESTICEPWD00000000000001", |
| - "TESTICEPWD00000000000002", |
| - "TESTICEPWD00000000000003"}; |
| - |
| -static const uint64_t kLowTiebreaker = 11111; |
| -static const uint64_t kHighTiebreaker = 22222; |
| +const char* kIcePwd[4] = { |
| + "TESTICEPWD00000000000000", "TESTICEPWD00000000000001", |
| + "TESTICEPWD00000000000002", "TESTICEPWD00000000000003"}; |
| +const cricket::IceParameters kIceParams[4] = { |
| + {kIceUfrag[0], kIcePwd[0], false}, |
| + {kIceUfrag[1], kIcePwd[1], false}, |
| + {kIceUfrag[2], kIcePwd[2], false}, |
| + {kIceUfrag[3], kIcePwd[3], false}}; |
| + |
| +const uint64_t kLowTiebreaker = 11111; |
| +const uint64_t kHighTiebreaker = 22222; |
| enum { MSG_ADD_CANDIDATES, MSG_REMOVE_CANDIDATES }; |
| @@ -131,7 +134,7 @@ cricket::Candidate CreateUdpCandidate(const std::string& type, |
| return c; |
| } |
| -} // namespace { |
| +} // namespace |
| namespace cricket { |
| @@ -305,40 +308,36 @@ class P2PTransportChannelTestBase : public testing::Test, |
| return ep2_.GetChannelData(channel); |
| } |
| - void CreateChannels(int num) { |
| - std::string ice_ufrag_ep1_cd1_ch = kIceUfrag[0]; |
| - std::string ice_pwd_ep1_cd1_ch = kIcePwd[0]; |
| - std::string ice_ufrag_ep2_cd1_ch = kIceUfrag[1]; |
| - std::string ice_pwd_ep2_cd1_ch = kIcePwd[1]; |
| - ep1_.cd1_.ch_.reset(CreateChannel( |
| - 0, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep1_cd1_ch, |
| - ice_pwd_ep1_cd1_ch, ice_ufrag_ep2_cd1_ch, ice_pwd_ep2_cd1_ch)); |
| - ep2_.cd1_.ch_.reset(CreateChannel( |
| - 1, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep2_cd1_ch, |
| - ice_pwd_ep2_cd1_ch, ice_ufrag_ep1_cd1_ch, ice_pwd_ep1_cd1_ch)); |
| + IceParameters GetIceParams(const IceParameters& ice, bool renomination) { |
|
Taylor Brandstetter
2016/08/17 01:08:17
nit: "CreateIceParamsWithRenomination" or somethin
pthatcher1
2016/08/17 17:25:46
+1
honghaiz3
2016/08/17 20:21:48
Done.
|
| + IceParameters new_ice = ice; |
| + new_ice.renomination = renomination; |
| + return new_ice; |
| + } |
| + |
| + void CreateChannels(int num, bool renomination = false) { |
| + IceParameters ice_ep1_cd1_ch = GetIceParams(kIceParams[0], renomination); |
| + IceParameters ice_ep2_cd1_ch = GetIceParams(kIceParams[1], renomination); |
| + ep1_.cd1_.ch_.reset(CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, |
| + ice_ep1_cd1_ch, ice_ep2_cd1_ch)); |
| + ep2_.cd1_.ch_.reset(CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, |
| + ice_ep2_cd1_ch, ice_ep1_cd1_ch)); |
| ep1_.cd1_.ch_->MaybeStartGathering(); |
| ep2_.cd1_.ch_->MaybeStartGathering(); |
| if (num == 2) { |
| - std::string ice_ufrag_ep1_cd2_ch = kIceUfrag[2]; |
| - std::string ice_pwd_ep1_cd2_ch = kIcePwd[2]; |
| - std::string ice_ufrag_ep2_cd2_ch = kIceUfrag[3]; |
| - std::string ice_pwd_ep2_cd2_ch = kIcePwd[3]; |
| - ep1_.cd2_.ch_.reset(CreateChannel( |
| - 0, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep1_cd2_ch, |
| - ice_pwd_ep1_cd2_ch, ice_ufrag_ep2_cd2_ch, ice_pwd_ep2_cd2_ch)); |
| - ep2_.cd2_.ch_.reset(CreateChannel( |
| - 1, ICE_CANDIDATE_COMPONENT_DEFAULT, ice_ufrag_ep2_cd2_ch, |
| - ice_pwd_ep2_cd2_ch, ice_ufrag_ep1_cd2_ch, ice_pwd_ep1_cd2_ch)); |
| + IceParameters ice_ep1_cd2_ch = GetIceParams(kIceParams[2], renomination); |
| + IceParameters ice_ep2_cd2_ch = GetIceParams(kIceParams[3], renomination); |
| + ep1_.cd2_.ch_.reset(CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, |
| + ice_ep1_cd2_ch, ice_ep2_cd2_ch)); |
| + ep2_.cd2_.ch_.reset(CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, |
| + ice_ep2_cd2_ch, ice_ep1_cd2_ch)); |
| ep1_.cd2_.ch_->MaybeStartGathering(); |
| ep2_.cd2_.ch_->MaybeStartGathering(); |
| } |
| } |
| P2PTransportChannel* CreateChannel(int endpoint, |
| int component, |
| - const std::string& local_ice_ufrag, |
| - const std::string& local_ice_pwd, |
| - const std::string& remote_ice_ufrag, |
| - const std::string& remote_ice_pwd) { |
| + const IceParameters& local_ice, |
| + const IceParameters& remote_ice) { |
| P2PTransportChannel* channel = new P2PTransportChannel( |
| "test content name", component, GetAllocator(endpoint)); |
| channel->SignalReadyToSend.connect( |
| @@ -353,9 +352,9 @@ class P2PTransportChannelTestBase : public testing::Test, |
| this, &P2PTransportChannelTestBase::OnRoleConflict); |
| channel->SignalSelectedCandidatePairChanged.connect( |
| this, &P2PTransportChannelTestBase::OnSelectedCandidatePairChanged); |
| - channel->SetIceCredentials(local_ice_ufrag, local_ice_pwd); |
| - if (remote_ice_credential_source_ == FROM_SETICECREDENTIALS) { |
| - channel->SetRemoteIceCredentials(remote_ice_ufrag, remote_ice_pwd); |
| + channel->SetIceParameters(local_ice); |
| + if (remote_ice_parameter_source_ == FROM_SETICEPARAMETERS) { |
| + channel->SetRemoteIceParameters(remote_ice); |
| } |
| channel->SetIceRole(GetEndpoint(endpoint)->ice_role()); |
| channel->SetIceTiebreaker(GetEndpoint(endpoint)->GetIceTiebreaker()); |
| @@ -586,13 +585,13 @@ class P2PTransportChannelTestBase : public testing::Test, |
| } |
| // This test waits for the transport to become receiving and writable on both |
| - // end points. Once they are, the end points set new local ice credentials and |
| + // end points. Once they are, the end points set new local ice parameters and |
| // restart the ice gathering. Finally it waits for the transport to select a |
| // new connection using the newly generated ice candidates. |
| // Before calling this function the end points must be configured. |
| void TestHandleIceUfragPasswordChanged() { |
| - ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); |
| - ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); |
| + ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
| + ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
| EXPECT_TRUE_WAIT_MARGIN(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| 1000, 1000); |
| @@ -602,11 +601,12 @@ class P2PTransportChannelTestBase : public testing::Test, |
| const Candidate* old_remote_candidate1 = RemoteCandidate(ep1_ch1()); |
| const Candidate* old_remote_candidate2 = RemoteCandidate(ep2_ch1()); |
| - ep1_ch1()->SetIceCredentials(kIceUfrag[2], kIcePwd[2]); |
| - ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); |
| + ep1_ch1()->SetIceParameters(kIceParams[2]); |
| + ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); |
| ep1_ch1()->MaybeStartGathering(); |
| - ep2_ch1()->SetIceCredentials(kIceUfrag[3], kIcePwd[3]); |
| - ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); |
| + ep2_ch1()->SetIceParameters(kIceParams[3]); |
| + |
| + ep2_ch1()->SetRemoteIceParameters(kIceParams[2]); |
| ep2_ch1()->MaybeStartGathering(); |
| EXPECT_TRUE_WAIT_MARGIN(LocalCandidate(ep1_ch1())->generation() != |
| @@ -729,7 +729,7 @@ class P2PTransportChannelTestBase : public testing::Test, |
| return; |
| } |
| for (auto& c : data->candidates) { |
| - if (remote_ice_credential_source_ != FROM_CANDIDATE) { |
| + if (remote_ice_parameter_source_ != FROM_CANDIDATE) { |
| c.set_username(""); |
| c.set_password(""); |
| } |
| @@ -814,13 +814,13 @@ class P2PTransportChannelTestBase : public testing::Test, |
| return GetChannelData(ch)->ch_packets_; |
| } |
| - enum RemoteIceCredentialSource { FROM_CANDIDATE, FROM_SETICECREDENTIALS }; |
| + enum RemoteIceParameterSource { FROM_CANDIDATE, FROM_SETICEPARAMETERS }; |
| - // How does the test pass ICE credentials to the P2PTransportChannel? |
| - // On the candidate itself, or through SetIceCredentials? |
| + // How does the test pass ICE parameters to the P2PTransportChannel? |
| + // On the candidate itself, or through SetRemoteIceParameters? |
| // Goes through the candidate itself by default. |
| - void set_remote_ice_credential_source(RemoteIceCredentialSource source) { |
| - remote_ice_credential_source_ = source; |
| + void set_remote_ice_parameter_source(RemoteIceParameterSource source) { |
| + remote_ice_parameter_source_ = source; |
| } |
| void set_force_relay(bool relay) { |
| @@ -849,7 +849,7 @@ class P2PTransportChannelTestBase : public testing::Test, |
| rtc::SocksProxyServer socks_server2_; |
| Endpoint ep1_; |
| Endpoint ep2_; |
| - RemoteIceCredentialSource remote_ice_credential_source_ = FROM_CANDIDATE; |
| + RemoteIceParameterSource remote_ice_parameter_source_ = FROM_CANDIDATE; |
| bool force_relay_; |
| int selected_candidate_pair_switches_ = 0; |
| @@ -975,7 +975,7 @@ class P2PTransportChannelTest : public P2PTransportChannelTestBase { |
| SetAllocatorFlags(1, allocator_flags2); |
| SetAllocationStepDelay(1, delay); |
| - set_remote_ice_credential_source(FROM_SETICECREDENTIALS); |
| + set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
| } |
| void ConfigureEndpoint(int endpoint, Config config) { |
| switch (config) { |
| @@ -1186,11 +1186,11 @@ TEST_F(P2PTransportChannelTest, GetStats) { |
| TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { |
| ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
| kDefaultPortAllocatorFlags); |
| - // Emulate no remote credentials coming in. |
| - set_remote_ice_credential_source(FROM_CANDIDATE); |
| + // Emulate no remote parameters coming in. |
| + set_remote_ice_parameter_source(FROM_CANDIDATE); |
| CreateChannels(1); |
| - // Only have remote credentials come in for ep2, not ep1. |
| - ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); |
| + // Only have remote parameters come in for ep2, not ep1. |
| + ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
| // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
| // candidate. |
| @@ -1208,16 +1208,17 @@ TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { |
| ep1_ch1()->selected_connection()->remote_candidate().username()); |
| EXPECT_EQ("", |
| ep1_ch1()->selected_connection()->remote_candidate().password()); |
| - // Because we don't have ICE credentials yet, we don't know the generation. |
| + // Because we don't have ICE parameters yet, we don't know the generation. |
| EXPECT_EQ(0u, |
| ep1_ch1()->selected_connection()->remote_candidate().generation()); |
| EXPECT_TRUE(nullptr == ep1_ch1()->FindNextPingableConnection()); |
| - // Add two sets of remote ICE credentials, so that the ones used by the |
| + // Add two sets of remote ICE parameters, so that the ones used by the |
| // candidate will be generation 1 instead of 0. |
| - ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); |
| - ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); |
| - // After setting the remote ICE credentials, the password and generation |
| + ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); |
| + ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
| + |
| + // After setting the remote ICE parameters, the password and generation |
| // of the peer reflexive candidate should be updated. |
| EXPECT_EQ(kIcePwd[1], |
| ep1_ch1()->selected_connection()->remote_candidate().password()); |
| @@ -1241,11 +1242,11 @@ TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignaling) { |
| TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { |
| ConfigureEndpoints(OPEN, NAT_SYMMETRIC, kDefaultPortAllocatorFlags, |
| kDefaultPortAllocatorFlags); |
| - // Emulate no remote credentials coming in. |
| - set_remote_ice_credential_source(FROM_CANDIDATE); |
| + // Emulate no remote parameters coming in. |
| + set_remote_ice_parameter_source(FROM_CANDIDATE); |
| CreateChannels(1); |
| - // Only have remote credentials come in for ep2, not ep1. |
| - ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); |
| + // Only have remote parameters come in for ep2, not ep1. |
| + ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
| // Pause sending ep2's candidates to ep1 until ep1 receives the peer reflexive |
| // candidate. |
| PauseCandidates(1); |
| @@ -1261,16 +1262,16 @@ TEST_F(P2PTransportChannelTest, PeerReflexiveCandidateBeforeSignalingWithNAT) { |
| ep1_ch1()->selected_connection()->remote_candidate().username()); |
| EXPECT_EQ("", |
| ep1_ch1()->selected_connection()->remote_candidate().password()); |
| - // Because we don't have ICE credentials yet, we don't know the generation. |
| + // Because we don't have ICE parameters yet, we don't know the generation. |
| EXPECT_EQ(0u, |
| ep1_ch1()->selected_connection()->remote_candidate().generation()); |
| EXPECT_TRUE(nullptr == ep1_ch1()->FindNextPingableConnection()); |
| - // Add two sets of remote ICE credentials, so that the ones used by the |
| + // Add two sets of remote ICE parameters, so that the ones used by the |
| // candidate will be generation 1 instead of 0. |
| - ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); |
| - ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); |
| - // After setting the remote ICE credentials, the password and generation |
| + ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); |
| + ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
| + // After setting the remote ICE parameters, the password and generation |
| // of the peer reflexive candidate should be updated. |
| EXPECT_EQ(kIcePwd[1], |
| ep1_ch1()->selected_connection()->remote_candidate().password()); |
| @@ -1307,21 +1308,22 @@ TEST_F(P2PTransportChannelTest, |
| // it's prioritized above the current candidate pair. |
| GetEndpoint(0)->allocator_->set_candidate_filter(CF_RELAY); |
| GetEndpoint(1)->allocator_->set_candidate_filter(CF_RELAY); |
| - // Setting this allows us to control when SetRemoteIceCredentials is called. |
| - set_remote_ice_credential_source(FROM_CANDIDATE); |
| + // Setting this allows us to control when SetRemoteIceParameters is called. |
| + set_remote_ice_parameter_source(FROM_CANDIDATE); |
| CreateChannels(1); |
| // Wait for the initial connection to be made. |
| - ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); |
| - ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[0], kIcePwd[0]); |
| + ep1_ch1()->SetRemoteIceParameters(kIceParams[1]); |
| + ep2_ch1()->SetRemoteIceParameters(kIceParams[0]); |
| EXPECT_TRUE_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| ep2_ch1()->receiving() && ep2_ch1()->writable(), |
| kDefaultTimeout); |
| // Simulate an ICE restart on ep2, but don't signal the candidate or new |
| - // ICE credentials until after a prflx connection has been made. |
| + // ICE parameters until after a prflx connection has been made. |
| PauseCandidates(1); |
| - ep2_ch1()->SetIceCredentials(kIceUfrag[3], kIcePwd[3]); |
| - ep1_ch1()->SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); |
| + ep2_ch1()->SetIceParameters(kIceParams[3]); |
| + |
| + ep1_ch1()->SetRemoteIceParameters(kIceParams[3]); |
| ep2_ch1()->MaybeStartGathering(); |
| // The caller should have the selected connection connected to the peer |
| @@ -1333,8 +1335,9 @@ TEST_F(P2PTransportChannelTest, |
| ep1_ch1()->selected_connection(); |
| // Now simulate the ICE restart on ep1. |
| - ep1_ch1()->SetIceCredentials(kIceUfrag[2], kIcePwd[2]); |
| - ep2_ch1()->SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); |
| + ep1_ch1()->SetIceParameters(kIceParams[2]); |
| + |
| + ep2_ch1()->SetRemoteIceParameters(kIceParams[2]); |
| ep1_ch1()->MaybeStartGathering(); |
| // Finally send the candidates from ep2's ICE restart and verify that ep1 uses |
| @@ -1350,7 +1353,7 @@ TEST_F(P2PTransportChannelTest, |
| // Test that if remote candidates don't have ufrag and pwd, we still work. |
| TEST_F(P2PTransportChannelTest, RemoteCandidatesWithoutUfragPwd) { |
| - set_remote_ice_credential_source(FROM_SETICECREDENTIALS); |
| + set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
| ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, |
| kDefaultPortAllocatorFlags); |
| CreateChannels(1); |
| @@ -1419,10 +1422,10 @@ TEST_F(P2PTransportChannelTest, TestTcpConnectionsFromActiveToPassive) { |
| SetAllowTcpListen(0, true); // actpass. |
| SetAllowTcpListen(1, false); // active. |
| - // We want SetRemoteIceCredentials to be called as it normally would. |
| - // Otherwise we won't know what credentials to use for the expected |
| + // We want SetRemoteIceParameters to be called as it normally would. |
| + // Otherwise we won't know what parameters to use for the expected |
| // prflx TCP candidates. |
| - set_remote_ice_credential_source(FROM_SETICECREDENTIALS); |
| + set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
| // Pause candidate so we could verify the candidate properties. |
| PauseCandidates(0); |
| @@ -1708,9 +1711,8 @@ TEST_F(P2PTransportChannelTest, TurnToTurnPresumedWritable) { |
| kDefaultPortAllocatorFlags); |
| // Only configure one channel so we can control when the remote candidate |
| // is added. |
| - GetEndpoint(0)->cd1_.ch_.reset( |
| - CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[0], |
| - kIcePwd[0], kIceUfrag[1], kIcePwd[1])); |
| + GetEndpoint(0)->cd1_.ch_.reset(CreateChannel( |
| + 0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[0], kIceParams[1])); |
| IceConfig config; |
| config.presume_writable_when_fully_relayed = true; |
| ep1_ch1()->SetIceConfig(config); |
| @@ -1756,12 +1758,10 @@ TEST_F(P2PTransportChannelTest, TurnToPrflxPresumedWritable) { |
| test_turn_server()->set_enable_permission_checks(false); |
| IceConfig config; |
| config.presume_writable_when_fully_relayed = true; |
| - GetEndpoint(0)->cd1_.ch_.reset( |
| - CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[0], |
| - kIcePwd[0], kIceUfrag[1], kIcePwd[1])); |
| - GetEndpoint(1)->cd1_.ch_.reset( |
| - CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[1], |
| - kIcePwd[1], kIceUfrag[0], kIcePwd[0])); |
| + GetEndpoint(0)->cd1_.ch_.reset(CreateChannel( |
| + 0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[0], kIceParams[1])); |
| + GetEndpoint(1)->cd1_.ch_.reset(CreateChannel( |
| + 1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[1], kIceParams[0])); |
| ep1_ch1()->SetIceConfig(config); |
| ep2_ch1()->SetIceConfig(config); |
| // Don't signal candidates from channel 2, so that channel 1 sees the TURN |
| @@ -1797,12 +1797,10 @@ TEST_F(P2PTransportChannelTest, PresumedWritablePreferredOverUnreliable) { |
| kDefaultPortAllocatorFlags); |
| IceConfig config; |
| config.presume_writable_when_fully_relayed = true; |
| - GetEndpoint(0)->cd1_.ch_.reset( |
| - CreateChannel(0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[0], |
| - kIcePwd[0], kIceUfrag[1], kIcePwd[1])); |
| - GetEndpoint(1)->cd1_.ch_.reset( |
| - CreateChannel(1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceUfrag[1], |
| - kIcePwd[1], kIceUfrag[0], kIcePwd[0])); |
| + GetEndpoint(0)->cd1_.ch_.reset(CreateChannel( |
| + 0, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[0], kIceParams[1])); |
| + GetEndpoint(1)->cd1_.ch_.reset(CreateChannel( |
| + 1, ICE_CANDIDATE_COMPONENT_DEFAULT, kIceParams[1], kIceParams[0])); |
| ep1_ch1()->SetIceConfig(config); |
| ep2_ch1()->SetIceConfig(config); |
| ep1_ch1()->MaybeStartGathering(); |
| @@ -1845,7 +1843,7 @@ class P2PTransportChannelSameNatTest : public P2PTransportChannelTestBase { |
| static_cast<rtc::NATType>(nat_type - NAT_FULL_CONE)); |
| ConfigureEndpoint(outer_nat, 0, config1); |
| ConfigureEndpoint(outer_nat, 1, config2); |
| - set_remote_ice_credential_source(FROM_SETICECREDENTIALS); |
| + set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
| } |
| void ConfigureEndpoint(rtc::NATSocketServer::Translator* nat, |
| int endpoint, Config config) { |
| @@ -2041,9 +2039,10 @@ TEST_F(P2PTransportChannelMultihomedTest, TestIceRenomination) { |
| SetAllocatorFlags(0, kOnlyLocalPorts); |
| SetAllocatorFlags(1, kOnlyLocalPorts); |
| - // Create channels and let them go writable, as usual. |
| - CreateChannels(1); |
| - ep1_ch1()->set_remote_supports_renomination(true); |
| + // We want it to set the remote ICE parameters when creating channels. |
| + set_remote_ice_parameter_source(FROM_SETICEPARAMETERS); |
| + // Create channels with renomination enabled. |
| + CreateChannels(1, true); |
| EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && |
| ep2_ch1()->receiving() && |
| ep2_ch1()->writable(), |
| @@ -2569,8 +2568,8 @@ class P2PTransportChannelPingTest : public testing::Test, |
| protected: |
| void PrepareChannel(P2PTransportChannel* ch) { |
| ch->SetIceRole(ICEROLE_CONTROLLING); |
| - ch->SetIceCredentials(kIceUfrag[0], kIcePwd[0]); |
| - ch->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); |
| + ch->SetIceParameters(kIceParams[0]); |
| + ch->SetRemoteIceParameters(kIceParams[1]); |
| ch->SignalSelectedCandidatePairChanged.connect( |
| this, &P2PTransportChannelPingTest::OnSelectedCandidatePairChanged); |
| ch->SignalReadyToSend.connect(this, |
| @@ -2843,20 +2842,20 @@ TEST_F(P2PTransportChannelPingTest, TestStunPingIntervals) { |
| } |
| // Test that we start pinging as soon as we have a connection and remote ICE |
| -// credentials. |
| +// parameters. |
| TEST_F(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) { |
| rtc::ScopedFakeClock clock; |
| FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| P2PTransportChannel ch("TestChannel", 1, &pa); |
| ch.SetIceRole(ICEROLE_CONTROLLING); |
| - ch.SetIceCredentials(kIceUfrag[0], kIcePwd[0]); |
| + ch.SetIceParameters(kIceParams[0]); |
| ch.MaybeStartGathering(); |
| EXPECT_EQ_WAIT(IceGatheringState::kIceGatheringComplete, ch.gathering_state(), |
| kDefaultTimeout); |
| // Simulate a binding request being received, creating a peer reflexive |
| - // candidate pair while we still don't have remote ICE credentials. |
| + // candidate pair while we still don't have remote ICE parameters. |
| IceMessage request; |
| request.SetType(STUN_BINDING_REQUEST); |
| request.AddAttribute( |
| @@ -2872,14 +2871,14 @@ TEST_F(P2PTransportChannelPingTest, PingingStartedAsSoonAsPossible) { |
| ASSERT_NE(nullptr, conn); |
| // Simulate waiting for a second (and change) and verify that no pings were |
| - // sent, since we don't yet have remote ICE credentials. |
| + // sent, since we don't yet have remote ICE parameters. |
| SIMULATED_WAIT(conn->num_pings_sent() > 0, 1025, clock); |
| EXPECT_EQ(0, conn->num_pings_sent()); |
| - // Set remote ICE credentials. Now we should be able to ping. Ensure that |
| + // Set remote ICE parameters. Now we should be able to ping. Ensure that |
| // the first ping is sent as soon as possible, within one simulated clock |
| // tick. |
| - ch.SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); |
| + ch.SetRemoteIceParameters(kIceParams[1]); |
| EXPECT_TRUE_SIMULATED_WAIT(conn->num_pings_sent() > 0, 1, clock); |
| } |
| @@ -2943,7 +2942,7 @@ TEST_F(P2PTransportChannelPingTest, TestSignalStateChanged) { |
| // is added with an old ufrag, it will be discarded. If it is added with a |
| // ufrag that was not seen before, it will be used to create connections |
| // although the ICE pwd in the remote candidate will be set when the ICE |
| -// credentials arrive. If a remote candidate is added with the current ICE |
| +// parameters arrive. If a remote candidate is added with the current ICE |
| // ufrag, its pwd and generation will be set properly. |
| TEST_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithVariousUfrags) { |
| FakePortAllocator pa(rtc::Thread::Current(), nullptr); |
| @@ -2960,10 +2959,10 @@ TEST_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithVariousUfrags) { |
| EXPECT_TRUE(candidate.password().empty()); |
| EXPECT_TRUE(FindNextPingableConnectionAndPingIt(&ch) == nullptr); |
| - // Set the remote credentials with the "future" ufrag. |
| + // Set the remote ICE parameters with the "future" ufrag. |
| // This should set the ICE pwd in the remote candidate of |conn1|, making |
| // it pingable. |
| - ch.SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); |
| + ch.SetRemoteIceParameters(kIceParams[2]); |
| EXPECT_EQ(kIceUfrag[2], candidate.username()); |
| EXPECT_EQ(kIcePwd[2], candidate.password()); |
| EXPECT_EQ(conn1, FindNextPingableConnectionAndPingIt(&ch)); |
| @@ -3219,8 +3218,8 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) { |
| // Test that the request from an unknown address contains a ufrag from an old |
| // generation. |
| port->set_sent_binding_response(false); |
| - ch.SetRemoteIceCredentials(kIceUfrag[2], kIcePwd[2]); |
| - ch.SetRemoteIceCredentials(kIceUfrag[3], kIcePwd[3]); |
| + ch.SetRemoteIceParameters(kIceParams[2]); |
| + ch.SetRemoteIceParameters(kIceParams[3]); |
| port->SignalUnknownAddress(port, rtc::SocketAddress("5.5.5.5", 5), PROTO_UDP, |
| &request, kIceUfrag[2], false); |
| Connection* conn5 = WaitForConnectionTo(&ch, "5.5.5.5", 5); |
| @@ -3679,7 +3678,7 @@ TEST_F(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) { |
| // Start a new session. Even though conn1, which belongs to an older |
| // session, becomes unwritable and writable again, it should not stop the |
| // current session. |
| - ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); |
| + ch.SetIceParameters(kIceParams[1]); |
| ch.MaybeStartGathering(); |
| conn1->Prune(); |
| conn1->ReceivedPingResponse(LOW_RTT, "id"); |
| @@ -3735,7 +3734,7 @@ TEST_F(P2PTransportChannelPingTest, TestIceRoleUpdatedOnPortAfterIceRestart) { |
| // Do an ICE restart, change the role, and expect the old port to have its |
| // role updated. |
| - ch.SetIceCredentials(kIceUfrag[1], kIcePwd[1]); |
| + ch.SetIceParameters(kIceParams[1]); |
| ch.MaybeStartGathering(); |
| ch.SetIceRole(ICEROLE_CONTROLLED); |
| EXPECT_EQ(ICEROLE_CONTROLLED, conn->port()->GetIceRole()); |