diff --git a/media/webrtc/signaling/gtest/jsep_session_unittest.cpp b/media/webrtc/signaling/gtest/jsep_session_unittest.cpp index 3a2e86c8f1f6..40adb99e45e0 100644 --- a/media/webrtc/signaling/gtest/jsep_session_unittest.cpp +++ b/media/webrtc/signaling/gtest/jsep_session_unittest.cpp @@ -2557,21 +2557,40 @@ TEST_P(JsepSessionTest, RenegotiationAnswererDisablesBundleTransport) { ASSERT_EQ(0U, ot0->mTransport.mComponents); ASSERT_EQ(0U, at0->mTransport.mComponents); + // With bundle-policy "balanced", this ends up being somewhat complicated. + // The first m-section of each type is _not_ marked bundle-only, + // but subsequent m-sections of that type are. This means that if there is + // more than one type, there is more than one transport, which means there's + // a fallback when the bundle-tag is disabled (the first such transport). We + // should be using that fallback when it exists. + Maybe fallbackTransport; + for (size_t level = 1; level != types.size(); ++level) { + if (types[level] != types[0]) { + fallbackTransport = Some(level); + break; + } + } + for (size_t i = 1; i < newOffererTransceivers.size(); ++i) { JsepTransceiver* ot = GetTransceiverByLevel(newOffererTransceivers, i); JsepTransceiver* at = GetTransceiverByLevel(newAnswererTransceivers, i); - JsepTransceiver* ot1 = GetTransceiverByLevel(newOffererTransceivers, 1); - JsepTransceiver* at1 = GetTransceiverByLevel(newAnswererTransceivers, 1); + // If there is no fallback, the bundle level will be left pointing at the + // dead transport at index 0. + size_t expectedBundleLevel = fallbackTransport.valueOr(0); + JsepTransceiver* otWithTransport = + GetTransceiverByLevel(newOffererTransceivers, expectedBundleLevel); + JsepTransceiver* atWithTransport = + GetTransceiverByLevel(newAnswererTransceivers, expectedBundleLevel); ASSERT_TRUE(ot->HasBundleLevel()); ASSERT_TRUE(at->HasBundleLevel()); - ASSERT_EQ(1U, ot->BundleLevel()); - ASSERT_EQ(1U, at->BundleLevel()); + ASSERT_EQ(expectedBundleLevel, ot->BundleLevel()); + ASSERT_EQ(expectedBundleLevel, at->BundleLevel()); // TODO: When creating an answer where we have rejected the bundle // transport, we do not do a good job of creating a sensible SDP. Mainly, // when we remove the rejected mid from the bundle group, we can leave a // bundle-only mid as the first one when others are available. - ASSERT_TRUE(Equals(ot1->mTransport, ot->mTransport)); - ASSERT_TRUE(Equals(at1->mTransport, at->mTransport)); + ASSERT_TRUE(Equals(otWithTransport->mTransport, ot->mTransport)); + ASSERT_TRUE(Equals(atWithTransport->mTransport, at->mTransport)); } }