summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/pc/session_description_unittest.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/libwebrtc/pc/session_description_unittest.cc
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/pc/session_description_unittest.cc')
-rw-r--r--third_party/libwebrtc/pc/session_description_unittest.cc133
1 files changed, 133 insertions, 0 deletions
diff --git a/third_party/libwebrtc/pc/session_description_unittest.cc b/third_party/libwebrtc/pc/session_description_unittest.cc
new file mode 100644
index 0000000000..4d0913bad2
--- /dev/null
+++ b/third_party/libwebrtc/pc/session_description_unittest.cc
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2018 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+#include "pc/session_description.h"
+
+#include "test/gtest.h"
+
+namespace cricket {
+
+TEST(MediaContentDescriptionTest, ExtmapAllowMixedDefaultValue) {
+ VideoContentDescription video_desc;
+ EXPECT_EQ(MediaContentDescription::kMedia,
+ video_desc.extmap_allow_mixed_enum());
+}
+
+TEST(MediaContentDescriptionTest, SetExtmapAllowMixed) {
+ VideoContentDescription video_desc;
+ video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kNo);
+ EXPECT_EQ(MediaContentDescription::kNo, video_desc.extmap_allow_mixed_enum());
+ video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
+ EXPECT_EQ(MediaContentDescription::kMedia,
+ video_desc.extmap_allow_mixed_enum());
+ video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kSession);
+ EXPECT_EQ(MediaContentDescription::kSession,
+ video_desc.extmap_allow_mixed_enum());
+
+ // Not allowed to downgrade from kSession to kMedia.
+ video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
+ EXPECT_EQ(MediaContentDescription::kSession,
+ video_desc.extmap_allow_mixed_enum());
+
+ // Always okay to set not supported.
+ video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kNo);
+ EXPECT_EQ(MediaContentDescription::kNo, video_desc.extmap_allow_mixed_enum());
+ video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
+ EXPECT_EQ(MediaContentDescription::kMedia,
+ video_desc.extmap_allow_mixed_enum());
+ video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kNo);
+ EXPECT_EQ(MediaContentDescription::kNo, video_desc.extmap_allow_mixed_enum());
+}
+
+TEST(MediaContentDescriptionTest, MixedOneTwoByteHeaderSupported) {
+ VideoContentDescription video_desc;
+ video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kNo);
+ EXPECT_FALSE(video_desc.extmap_allow_mixed());
+ video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
+ EXPECT_TRUE(video_desc.extmap_allow_mixed());
+ video_desc.set_extmap_allow_mixed_enum(MediaContentDescription::kSession);
+ EXPECT_TRUE(video_desc.extmap_allow_mixed());
+}
+
+TEST(SessionDescriptionTest, SetExtmapAllowMixed) {
+ SessionDescription session_desc;
+ session_desc.set_extmap_allow_mixed(true);
+ EXPECT_TRUE(session_desc.extmap_allow_mixed());
+ session_desc.set_extmap_allow_mixed(false);
+ EXPECT_FALSE(session_desc.extmap_allow_mixed());
+}
+
+TEST(SessionDescriptionTest, SetExtmapAllowMixedPropagatesToMediaLevel) {
+ SessionDescription session_desc;
+ session_desc.AddContent("video", MediaProtocolType::kRtp,
+ std::make_unique<VideoContentDescription>());
+ MediaContentDescription* video_desc =
+ session_desc.GetContentDescriptionByName("video");
+
+ // Setting true on session level propagates to media level.
+ session_desc.set_extmap_allow_mixed(true);
+ EXPECT_EQ(MediaContentDescription::kSession,
+ video_desc->extmap_allow_mixed_enum());
+
+ // Don't downgrade from session level to media level
+ video_desc->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
+ EXPECT_EQ(MediaContentDescription::kSession,
+ video_desc->extmap_allow_mixed_enum());
+
+ // Setting false on session level propagates to media level if the current
+ // state is kSession.
+ session_desc.set_extmap_allow_mixed(false);
+ EXPECT_EQ(MediaContentDescription::kNo,
+ video_desc->extmap_allow_mixed_enum());
+
+ // Now possible to set at media level.
+ video_desc->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
+ EXPECT_EQ(MediaContentDescription::kMedia,
+ video_desc->extmap_allow_mixed_enum());
+
+ // Setting false on session level does not override on media level if current
+ // state is kMedia.
+ session_desc.set_extmap_allow_mixed(false);
+ EXPECT_EQ(MediaContentDescription::kMedia,
+ video_desc->extmap_allow_mixed_enum());
+
+ // Setting true on session level overrides setting on media level.
+ session_desc.set_extmap_allow_mixed(true);
+ EXPECT_EQ(MediaContentDescription::kSession,
+ video_desc->extmap_allow_mixed_enum());
+}
+
+TEST(SessionDescriptionTest, AddContentTransfersExtmapAllowMixedSetting) {
+ SessionDescription session_desc;
+ session_desc.set_extmap_allow_mixed(false);
+ std::unique_ptr<MediaContentDescription> audio_desc =
+ std::make_unique<AudioContentDescription>();
+ audio_desc->set_extmap_allow_mixed_enum(MediaContentDescription::kMedia);
+
+ // If session setting is false, media level setting is preserved when new
+ // content is added.
+ session_desc.AddContent("audio", MediaProtocolType::kRtp,
+ std::move(audio_desc));
+ EXPECT_EQ(MediaContentDescription::kMedia,
+ session_desc.GetContentDescriptionByName("audio")
+ ->extmap_allow_mixed_enum());
+
+ // If session setting is true, it's transferred to media level when new
+ // content is added.
+ session_desc.set_extmap_allow_mixed(true);
+ std::unique_ptr<MediaContentDescription> video_desc =
+ std::make_unique<VideoContentDescription>();
+ session_desc.AddContent("video", MediaProtocolType::kRtp,
+ std::move(video_desc));
+ EXPECT_EQ(MediaContentDescription::kSession,
+ session_desc.GetContentDescriptionByName("video")
+ ->extmap_allow_mixed_enum());
+}
+
+} // namespace cricket