Index: webrtc/api/peerconnection_unittest.cc |
diff --git a/webrtc/api/peerconnection_unittest.cc b/webrtc/api/peerconnection_unittest.cc |
index 406fab0d89eb6cc13d397a1ac668a87fca043b6e..157545ffa24b8cd19ac0be8eecadb74afe797680 100644 |
--- a/webrtc/api/peerconnection_unittest.cc |
+++ b/webrtc/api/peerconnection_unittest.cc |
@@ -392,6 +392,17 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, |
bool ExpectIceRestart() const { return expect_ice_restart_; } |
+ void IceRenomination() { |
+ offer_answer_constraints_.SetOptionalIceRenomination(true); |
+ offer_answer_options_.ice_renomination = true; |
+ expect_ice_renomination_ = true; |
+ } |
+ void SetExpectRemoteIceRenomination(bool expect_renomination) { |
+ expect_remote_ice_renomination_ = expect_renomination; |
+ } |
+ bool ExpectIceRenomination() { return expect_ice_renomination_; } |
+ bool ExpectRemoteIceRenomination() { return expect_remote_ice_renomination_; } |
+ |
void SetReceiveAudioVideo(bool audio, bool video) { |
SetReceiveAudio(audio); |
SetReceiveVideo(video); |
@@ -669,6 +680,42 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, |
} |
} |
+ void VerifyLocalIceRenomination() { |
+ ASSERT_TRUE(peer_connection_->local_description() != nullptr); |
+ const cricket::SessionDescription* desc = |
+ peer_connection_->local_description()->description(); |
+ const cricket::ContentInfos& contents = desc->contents(); |
+ |
+ for (auto content : contents) { |
+ if (content.rejected) |
+ continue; |
+ const cricket::TransportDescription* transport_desc = |
+ desc->GetTransportDescriptionByName(content.name); |
+ const auto& options = transport_desc->transport_options; |
+ auto iter = std::find(options.begin(), options.end(), |
+ cricket::ICE_RENOMINATION_STR); |
+ EXPECT_EQ(ExpectIceRenomination(), iter != options.end()); |
+ } |
+ } |
+ |
+ void VerifyRemoteIceReomination() { |
+ ASSERT_TRUE(peer_connection_->remote_description() != nullptr); |
+ const cricket::SessionDescription* desc = |
+ peer_connection_->remote_description()->description(); |
+ const cricket::ContentInfos& contents = desc->contents(); |
+ |
+ for (auto content : contents) { |
+ if (content.rejected) |
+ continue; |
+ const cricket::TransportDescription* transport_desc = |
+ desc->GetTransportDescriptionByName(content.name); |
+ const auto& options = transport_desc->transport_options; |
+ auto iter = std::find(options.begin(), options.end(), |
+ cricket::ICE_RENOMINATION_STR); |
+ EXPECT_EQ(ExpectRemoteIceRenomination(), iter != options.end()); |
+ } |
+ } |
+ |
int GetAudioOutputLevelStats(webrtc::MediaStreamTrackInterface* track) { |
rtc::scoped_refptr<MockStatsObserver> |
observer(new rtc::RefCountedObject<MockStatsObserver>()); |
@@ -1029,6 +1076,8 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver, |
typedef std::pair<std::string, std::string> IceUfragPwdPair; |
std::map<int, IceUfragPwdPair> ice_ufrag_pwd_; |
bool expect_ice_restart_ = false; |
+ bool expect_ice_renomination_ = false; |
+ bool expect_remote_ice_renomination_ = false; |
// Needed to keep track of number of frames sent. |
rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; |
@@ -1171,6 +1220,11 @@ class P2PTestConductor : public testing::Test { |
receiving_client_->VerifyRejectedMediaInSessionDescription(); |
initiating_client_->VerifyLocalIceUfragAndPassword(); |
receiving_client_->VerifyLocalIceUfragAndPassword(); |
+ |
+ initiating_client_->VerifyLocalIceRenomination(); |
+ receiving_client_->VerifyLocalIceRenomination(); |
+ initiating_client_->VerifyRemoteIceReomination(); |
+ receiving_client_->VerifyRemoteIceReomination(); |
} |
~P2PTestConductor() { |
@@ -2065,6 +2119,25 @@ TEST_F(P2PTestConductor, IceRestart) { |
EXPECT_NE(receiver_candidate, receiver_candidate_restart); |
} |
+TEST_F(P2PTestConductor, IceRenomination) { |
+ ASSERT_TRUE(CreateTestClients()); |
+ // Only one side supports ICE renomination. |
+ initializing_client()->SetExpectRemoteIceRenomination(true); |
+ receiving_client()->IceRenomination(); |
+ LocalP2PTest(); |
+ |
+ // Both sides support ICE renomination. |
+ initializing_client()->SetExpectRemoteIceRenomination(true); |
+ receiving_client()->SetExpectRemoteIceRenomination(true); |
+ initializing_client()->IceRenomination(); |
+ receiving_client()->IceRenomination(); |
+ // Restart ice on the initializing client. |
+ receiving_client()->SetExpectIceRestart(true); |
+ initializing_client()->IceRestart(); |
+ // Negotiate and wait for ice completion again and verify ICE renominations. |
+ LocalP2PTest(); |
+} |
+ |
// This test sets up a call between two parties with audio, and video. |
// It then renegotiates setting the video m-line to "port 0", then later |
// renegotiates again, enabling video. |