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 605497 0a64d24cf0e7ccfe255cff1f69a285dfabc2622d
parent 605496 13886b1b8470a5e2e18ecb0b0f756f5ab8fc6629
child 636505 52424665e0de395bdabf04bd5a615c083be9b519
push id67422
push userdrno@ohlmeier.org
push dateFri, 07 Jul 2017 20:28:13 +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
@@ -1219,16 +1219,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();