| Index: talk/app/webrtc/webrtcsession_unittest.cc
|
| diff --git a/talk/app/webrtc/webrtcsession_unittest.cc b/talk/app/webrtc/webrtcsession_unittest.cc
|
| index 88a5d481ae33412bb070023be266b4213aac01c6..aa582eefe04db7c5f181acc0b79bc99e9b63b1fb 100644
|
| --- a/talk/app/webrtc/webrtcsession_unittest.cc
|
| +++ b/talk/app/webrtc/webrtcsession_unittest.cc
|
| @@ -821,6 +821,34 @@ class WebRtcSessionTest
|
| EXPECT_TRUE(expect_equal);
|
| }
|
|
|
| + // Compares ufrag/password only for specified media type.
|
| + void CompareIceUfragAndPassword(const cricket::SessionDescription* desc1,
|
| + const cricket::SessionDescription* desc2,
|
| + cricket::MediaType media_type,
|
| + bool expect_equal) {
|
| + if (desc1->contents().size() != desc2->contents().size()) {
|
| + EXPECT_FALSE(expect_equal);
|
| + return;
|
| + }
|
| +
|
| + const cricket::ContentInfo* cinfo =
|
| + cricket::GetFirstMediaContent(desc1->contents(), media_type);
|
| + const cricket::TransportDescription* transport_desc1 =
|
| + desc1->GetTransportDescriptionByName(cinfo->name);
|
| + const cricket::TransportDescription* transport_desc2 =
|
| + desc2->GetTransportDescriptionByName(cinfo->name);
|
| + if (!transport_desc1 || !transport_desc2) {
|
| + EXPECT_FALSE(expect_equal);
|
| + return;
|
| + }
|
| + if (transport_desc1->ice_pwd != transport_desc2->ice_pwd ||
|
| + transport_desc1->ice_ufrag != transport_desc2->ice_ufrag) {
|
| + EXPECT_FALSE(expect_equal);
|
| + return;
|
| + }
|
| + EXPECT_TRUE(expect_equal);
|
| + }
|
| +
|
| void RemoveIceUfragPwdLines(const SessionDescriptionInterface* current_desc,
|
| std::string *sdp) {
|
| const cricket::SessionDescription* desc = current_desc->description();
|
| @@ -874,6 +902,24 @@ class WebRtcSessionTest
|
| }
|
| }
|
|
|
| + // Modifies ufrag/pwd for specified |media_type|, by directly modifying the
|
| + // description.
|
| + void ModifyIceUfragPwd(SessionDescriptionInterface* current_desc,
|
| + cricket::MediaType media_type,
|
| + const std::string& modified_ice_ufrag,
|
| + const std::string& modified_ice_pwd) {
|
| + cricket::SessionDescription* desc = current_desc->description();
|
| + const cricket::ContentInfo* cinfo =
|
| + cricket::GetFirstMediaContent(desc->contents(), media_type);
|
| + // Replace ufrag and pwd with |modified_ice_ufrag| and
|
| + // |modified_ice_pwd| strings.
|
| + TransportInfo* transport_info = desc->GetTransportInfoByName(cinfo->name);
|
| + cricket::TransportDescription* transport_desc =
|
| + &transport_info->description;
|
| + transport_desc->ice_ufrag = modified_ice_ufrag;
|
| + transport_desc->ice_pwd = modified_ice_pwd;
|
| + }
|
| +
|
| // Creates a remote offer and and applies it as a remote description,
|
| // creates a local answer and applies is as a local description.
|
| // Call SendAudioVideoStreamX() before this function
|
| @@ -3575,24 +3621,34 @@ TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewUfragAndPassword) {
|
| SetRemoteDescriptionWithoutError(offer.release());
|
|
|
| SendAudioVideoStream1();
|
| - rtc::scoped_ptr<SessionDescriptionInterface> answer(
|
| - CreateAnswer(NULL));
|
| + rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(nullptr));
|
| SetLocalDescriptionWithoutError(answer.release());
|
|
|
| // Receive an offer with new ufrag and password.
|
| - options.transport_options.ice_restart = true;
|
| + options.audio_ice_restart = true;
|
| + options.video_ice_restart = true;
|
| + options.data_ice_restart = true;
|
| rtc::scoped_ptr<JsepSessionDescription> updated_offer1(
|
| CreateRemoteOffer(options, session_->remote_description()));
|
| SetRemoteDescriptionWithoutError(updated_offer1.release());
|
|
|
| rtc::scoped_ptr<SessionDescriptionInterface> updated_answer1(
|
| - CreateAnswer(NULL));
|
| + CreateAnswer(nullptr));
|
|
|
| CompareIceUfragAndPassword(updated_answer1->description(),
|
| session_->local_description()->description(),
|
| false);
|
|
|
| - SetLocalDescriptionWithoutError(updated_answer1.release());
|
| + // If we create another answer, it should still have a different
|
| + // ufrag/password than the current local description.
|
| + rtc::scoped_ptr<SessionDescriptionInterface> updated_answer2(
|
| + CreateAnswer(nullptr));
|
| +
|
| + CompareIceUfragAndPassword(updated_answer2->description(),
|
| + session_->local_description()->description(),
|
| + false);
|
| +
|
| + SetLocalDescriptionWithoutError(updated_answer2.release());
|
| }
|
|
|
| // This test verifies that an answer contains old ufrag and password if an offer
|
| @@ -3611,7 +3667,6 @@ TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) {
|
| SetLocalDescriptionWithoutError(answer.release());
|
|
|
| // Receive an offer without changed ufrag or password.
|
| - options.transport_options.ice_restart = false;
|
| rtc::scoped_ptr<JsepSessionDescription> updated_offer2(
|
| CreateRemoteOffer(options, session_->remote_description()));
|
| SetRemoteDescriptionWithoutError(updated_offer2.release());
|
| @@ -3626,6 +3681,47 @@ TEST_F(WebRtcSessionTest, TestCreateAnswerWithOldUfragAndPassword) {
|
| SetLocalDescriptionWithoutError(updated_answer2.release());
|
| }
|
|
|
| +// This test verifies that if an offer does an ICE restart on some, but not all
|
| +// m-lines, the answer will change the ufrag/password on the correct m-lines.
|
| +TEST_F(WebRtcSessionTest, TestCreateAnswerWithNewAndOldUfragAndPassword) {
|
| + Init();
|
| + cricket::MediaSessionOptions options;
|
| + options.recv_video = true;
|
| + options.recv_audio = true;
|
| + options.bundle_enabled = false;
|
| + rtc::scoped_ptr<JsepSessionDescription> offer(CreateRemoteOffer(options));
|
| +
|
| + ModifyIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_AUDIO, "aaaa",
|
| + "aaaaaaaaaaaaaaaaaaaaaa");
|
| + ModifyIceUfragPwd(offer.get(), cricket::MEDIA_TYPE_VIDEO, "bbbb",
|
| + "bbbbbbbbbbbbbbbbbbbbbb");
|
| + SetRemoteDescriptionWithoutError(offer.release());
|
| +
|
| + SendAudioVideoStream1();
|
| + rtc::scoped_ptr<SessionDescriptionInterface> answer(CreateAnswer(nullptr));
|
| + SetLocalDescriptionWithoutError(answer.release());
|
| +
|
| + // Receive an offer with new ufrag and password, but only on the video line.
|
| + rtc::scoped_ptr<JsepSessionDescription> updated_offer(
|
| + CreateRemoteOffer(options, session_->remote_description()));
|
| + ModifyIceUfragPwd(updated_offer.get(), cricket::MEDIA_TYPE_VIDEO, "cccc",
|
| + "cccccccccccccccccccccc");
|
| + SetRemoteDescriptionWithoutError(updated_offer.release());
|
| +
|
| + rtc::scoped_ptr<SessionDescriptionInterface> updated_answer(
|
| + CreateAnswer(nullptr));
|
| +
|
| + CompareIceUfragAndPassword(updated_answer->description(),
|
| + session_->local_description()->description(),
|
| + cricket::MEDIA_TYPE_AUDIO, true);
|
| +
|
| + CompareIceUfragAndPassword(updated_answer->description(),
|
| + session_->local_description()->description(),
|
| + cricket::MEDIA_TYPE_VIDEO, false);
|
| +
|
| + SetLocalDescriptionWithoutError(updated_answer.release());
|
| +}
|
| +
|
| TEST_F(WebRtcSessionTest, TestSessionContentError) {
|
| Init();
|
| SendAudioVideoStream1();
|
|
|