--- a/media/webrtc/signaling/gtest/jsep_session_unittest.cpp
+++ b/media/webrtc/signaling/gtest/jsep_session_unittest.cpp
@@ -774,16 +774,17 @@ protected:
void Trickle(JsepSession& session)
{
for (const auto& levelMidAndCandidate : mCandidatesToTrickle) {
Level level;
Mid mid;
Candidate candidate;
Tie(level, mid, candidate) = levelMidAndCandidate;
+ std::cerr << "trickeling candidate: " << candidate << " level: " << level << " mid: " << mid << std::endl;
session.AddRemoteIceCandidate(candidate, mid, level);
}
mCandidatesToTrickle.clear();
}
void CheckRtpCandidates(bool expectRtpCandidates,
const SdpMediaSection& msection,
size_t transportLevel,
@@ -1219,16 +1220,88 @@ TEST_P(JsepSessionTest, FullCall)
SetLocalOffer(offer);
SetRemoteOffer(offer);
AddTracks(*mSessionAns);
std::string answer = CreateAnswer();
SetLocalAnswer(answer);
SetRemoteAnswer(answer);
}
+TEST_P(JsepSessionTest, GetDescriptions)
+{
+ AddTracks(*mSessionOff);
+ std::string offer = CreateOffer();
+ SetLocalOffer(offer);
+ std::string desc = mSessionOff->GetLocalDescription(kJsepDescriptionCurrent);
+ ASSERT_EQ(0U, desc.size());
+ desc = mSessionOff->GetLocalDescription(kJsepDescriptionPending);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionOff->GetLocalDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionOff->GetRemoteDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_EQ(0U, desc.size());
+ desc = mSessionAns->GetLocalDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_EQ(0U, desc.size());
+ desc = mSessionAns->GetRemoteDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_EQ(0U, desc.size());
+
+ SetRemoteOffer(offer);
+ desc = mSessionAns->GetRemoteDescription(kJsepDescriptionCurrent);
+ ASSERT_EQ(0U, desc.size());
+ desc = mSessionAns->GetRemoteDescription(kJsepDescriptionPending);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionAns->GetRemoteDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionAns->GetLocalDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_EQ(0U, desc.size());
+ desc = mSessionOff->GetLocalDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionOff->GetRemoteDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_EQ(0U, desc.size());
+
+ AddTracks(*mSessionAns);
+ std::string answer = CreateAnswer();
+ SetLocalAnswer(answer);
+ desc = mSessionAns->GetLocalDescription(kJsepDescriptionCurrent);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionAns->GetLocalDescription(kJsepDescriptionPending);
+ ASSERT_EQ(0U, desc.size());
+ desc = mSessionAns->GetLocalDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionAns->GetRemoteDescription(kJsepDescriptionCurrent);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionAns->GetRemoteDescription(kJsepDescriptionPending);
+ ASSERT_EQ(0U, desc.size());
+ desc = mSessionAns->GetRemoteDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionOff->GetLocalDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionOff->GetRemoteDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_EQ(0U, desc.size());
+
+ SetRemoteAnswer(answer);
+ desc = mSessionOff->GetLocalDescription(kJsepDescriptionCurrent);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionOff->GetLocalDescription(kJsepDescriptionPending);
+ ASSERT_EQ(0U, desc.size());
+ desc = mSessionOff->GetLocalDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionOff->GetRemoteDescription(kJsepDescriptionCurrent);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionOff->GetRemoteDescription(kJsepDescriptionPending);
+ ASSERT_EQ(0U, desc.size());
+ desc = mSessionOff->GetRemoteDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionAns->GetLocalDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_NE(0U, desc.size());
+ desc = mSessionAns->GetRemoteDescription(kJsepDescriptionPendingOrCurrent);
+ ASSERT_NE(0U, desc.size());
+}
+
+
TEST_P(JsepSessionTest, RenegotiationNoChange)
{
AddTracks(*mSessionOff);
std::string offer = CreateOffer();
SetLocalOffer(offer);
SetRemoteOffer(offer);
auto added = mSessionAns->GetRemoteTracksAdded();
@@ -2488,17 +2561,17 @@ TEST_P(JsepSessionTest, ParseRejectsBadM
TEST_P(JsepSessionTest, FullCallWithCandidates)
{
AddTracks(*mSessionOff);
std::string offer = CreateOffer();
SetLocalOffer(offer);
mOffCandidates->Gather(*mSessionOff, types);
UniquePtr<Sdp> localOffer(Parse(
- mSessionOff->GetLocalDescription(kJsepDescriptionCurrent)));
+ mSessionOff->GetLocalDescription(kJsepDescriptionPending)));
for (size_t i = 0; i < localOffer->GetMediaSectionCount(); ++i) {
mOffCandidates->CheckRtpCandidates(
true, localOffer->GetMediaSection(i), i,
"Local offer after gathering should have RTP candidates.");
mOffCandidates->CheckDefaultRtpCandidate(
true, localOffer->GetMediaSection(i), i,
"Local offer after gathering should have a default RTP candidate.");
mOffCandidates->CheckRtcpCandidates(
@@ -2514,17 +2587,17 @@ TEST_P(JsepSessionTest, FullCallWithCand
CheckEndOfCandidates(true, localOffer->GetMediaSection(i),
"Local offer after gathering should have an end-of-candidates.");
}
SetRemoteOffer(offer);
mOffCandidates->Trickle(*mSessionAns);
UniquePtr<Sdp> remoteOffer(Parse(
- mSessionAns->GetRemoteDescription(kJsepDescriptionCurrent)));
+ mSessionAns->GetRemoteDescription(kJsepDescriptionPending)));
for (size_t i = 0; i < remoteOffer->GetMediaSectionCount(); ++i) {
mOffCandidates->CheckRtpCandidates(
true, remoteOffer->GetMediaSection(i), i,
"Remote offer after trickle should have RTP candidates.");
mOffCandidates->CheckDefaultRtpCandidate(
false, remoteOffer->GetMediaSection(i), i,
"Initial remote offer should not have a default RTP candidate.");
mOffCandidates->CheckRtcpCandidates(
@@ -2678,17 +2751,17 @@ TEST_P(JsepSessionTest, RenegotiationWit
mOffCandidates->Gather(*mSessionOff, level, RTCP);
}
}
mOffCandidates->FinishGathering(*mSessionOff);
mOffCandidates->Trickle(*mSessionAns);
UniquePtr<Sdp> localOffer(Parse(
- mSessionOff->GetLocalDescription(kJsepDescriptionCurrent)));
+ mSessionOff->GetLocalDescription(kJsepDescriptionPending)));
for (size_t i = 0; i < localOffer->GetMediaSectionCount(); ++i) {
mOffCandidates->CheckRtpCandidates(
true, localOffer->GetMediaSection(i), i,
"Local reoffer after gathering should have RTP candidates.");
mOffCandidates->CheckDefaultRtpCandidate(
true, localOffer->GetMediaSection(i), i,
"Local reoffer after gathering should have a default RTP candidate.");
mOffCandidates->CheckRtcpCandidates(
@@ -2701,17 +2774,17 @@ TEST_P(JsepSessionTest, RenegotiationWit
localOffer->GetMediaSection(i), i,
"Local reoffer after gathering should have a default RTCP candidate "
"(unless m=application)");
CheckEndOfCandidates(true, localOffer->GetMediaSection(i),
"Local reoffer after gathering should have an end-of-candidates.");
}
UniquePtr<Sdp> remoteOffer(Parse(
- mSessionAns->GetRemoteDescription(kJsepDescriptionCurrent)));
+ mSessionAns->GetRemoteDescription(kJsepDescriptionPending)));
for (size_t i = 0; i < remoteOffer->GetMediaSectionCount(); ++i) {
mOffCandidates->CheckRtpCandidates(
true, remoteOffer->GetMediaSection(i), i,
"Remote reoffer after trickle should have RTP candidates.");
mOffCandidates->CheckDefaultRtpCandidate(
i == 0, remoteOffer->GetMediaSection(i), i,
"Remote reoffer should have a default RTP candidate on level 0 "
"(because it was gathered last offer/answer).");