Bug 1264479: added unit tests for [current|pending][Local|Remote]Description. r?bwc draft
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Sun, 02 Jul 2017 10:55:22 -0700
changeset 607695 d9af1e0681611c9c2d26b71f3e4597d8b22b7985
parent 605496 13886b1b8470a5e2e18ecb0b0f756f5ab8fc6629
child 637129 4fa3f806e7c1c123dd2dcf8c867ef069d63e8a1c
push id68090
push userdrno@ohlmeier.org
push dateWed, 12 Jul 2017 19:19:49 +0000
reviewersbwc
bugs1264479
milestone56.0a1
Bug 1264479: added unit tests for [current|pending][Local|Remote]Description. r?bwc MozReview-Commit-ID: 9KFsvkUtN4D
media/webrtc/signaling/gtest/jsep_session_unittest.cpp
--- 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).");