Bug 1144432 - Part 1: Test-case r=mt
authorByron Campen [:bwc] <docfaraday@gmail.com>
Tue, 17 Mar 2015 17:23:20 -0700
changeset 234703 c9745d51c2f6a78a89e3856652068a4af9d019bc
parent 234702 1534390c5c6ebdeb12274ec13c447843f66874db
child 234704 d70bf74a36d08904e08e4e4798e7442bc70b66ba
push id57225
push userbcampen@mozilla.com
push dateFri, 20 Mar 2015 18:18:37 +0000
treeherdermozilla-inbound@dd253f2a520b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmt
bugs1144432
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1144432 - Part 1: Test-case r=mt
media/webrtc/signaling/test/jsep_session_unittest.cpp
--- a/media/webrtc/signaling/test/jsep_session_unittest.cpp
+++ b/media/webrtc/signaling/test/jsep_session_unittest.cpp
@@ -1349,16 +1349,76 @@ TEST_P(JsepSessionTest, RenegotiationBot
   for (size_t i = 0; i < newOffererPairs.size(); ++i) {
     ASSERT_TRUE(Equals(offererPairs[i + 1], newOffererPairs[i]));
   }
 
   ASSERT_EQ(answererPairs.size(), newAnswererPairs.size() + 1);
 
   for (size_t i = 0; i < newAnswererPairs.size(); ++i) {
     ASSERT_TRUE(Equals(answererPairs[i + 1], newAnswererPairs[i]));
+
+TEST_P(JsepSessionTest, RenegotiationBothRemoveThenAddTrack)
+{
+  AddTracks(mSessionOff);
+  AddTracks(mSessionAns);
+  if (types.front() == SdpMediaSection::kApplication) {
+    return;
+  }
+
+  SdpMediaSection::MediaType removedType = types.front();
+
+  OfferAnswer();
+
+  RefPtr<JsepTrack> removedTrackAnswer = GetTrackAns(0, removedType);
+  ASSERT_TRUE(removedTrackAnswer);
+  ASSERT_EQ(NS_OK, mSessionAns.RemoveTrack(removedTrackAnswer->GetStreamId(),
+                                           removedTrackAnswer->GetTrackId()));
+
+  RefPtr<JsepTrack> removedTrackOffer = GetTrackOff(0, removedType);
+  ASSERT_TRUE(removedTrackOffer);
+  ASSERT_EQ(NS_OK, mSessionOff.RemoveTrack(removedTrackOffer->GetStreamId(),
+                                           removedTrackOffer->GetTrackId()));
+
+  OfferAnswer(CHECK_SUCCESS);
+
+  auto offererPairs = GetTrackPairsByLevel(mSessionOff);
+  auto answererPairs = GetTrackPairsByLevel(mSessionAns);
+
+  std::vector<SdpMediaSection::MediaType> extraTypes;
+  extraTypes.push_back(removedType);
+  AddTracks(mSessionAns, extraTypes);
+  AddTracks(mSessionOff, extraTypes);
+  types.insert(types.end(), extraTypes.begin(), extraTypes.end());
+
+  OfferAnswer(CHECK_SUCCESS);
+
+  auto added = mSessionAns.GetRemoteTracksAdded();
+  auto removed = mSessionAns.GetRemoteTracksRemoved();
+  ASSERT_EQ(1U, added.size());
+  ASSERT_EQ(0U, removed.size());
+  ASSERT_EQ(removedType, added[0]->GetMediaType());
+
+  added = mSessionOff.GetRemoteTracksAdded();
+  removed = mSessionOff.GetRemoteTracksRemoved();
+  ASSERT_EQ(1U, added.size());
+  ASSERT_EQ(0U, removed.size());
+  ASSERT_EQ(removedType, added[0]->GetMediaType());
+
+  auto newOffererPairs = GetTrackPairsByLevel(mSessionOff);
+  auto newAnswererPairs = GetTrackPairsByLevel(mSessionAns);
+
+  ASSERT_EQ(offererPairs.size() + 1, newOffererPairs.size());
+  ASSERT_EQ(answererPairs.size() + 1, newAnswererPairs.size());
+
+  // Ensure that the m-section was re-used; no gaps
+  for (size_t i = 0; i < newOffererPairs.size(); ++i) {
+    ASSERT_EQ(i, newOffererPairs[i].mLevel);
+  }
+  for (size_t i = 0; i < newAnswererPairs.size(); ++i) {
+    ASSERT_EQ(i, newAnswererPairs[i].mLevel);
   }
 }
 
 TEST_P(JsepSessionTest, RenegotiationBothRemoveTrackDifferentMsection)
 {
   AddTracks(mSessionOff);
   AddTracks(mSessionAns);
   if (types.front() == SdpMediaSection::kApplication) {