From: Haesu Gwon Date: Mon, 26 Sep 2022 07:44:04 +0000 (+0900) Subject: [WebRTC][TCSACR-502] Add functions for transceiver codec X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ce291df75eec0ec18cc84b12f89d4f41d4d3584a;p=test%2Ftct%2Fcsharp%2Fapi.git [WebRTC][TCSACR-502] Add functions for transceiver codec Change-Id: I597ae7faeef810b240c85549ffe1ae1c125c6388 --- diff --git a/tct-suite-vs/Tizen.WebRTC.Tests/testcase/TSMediaSource.cs b/tct-suite-vs/Tizen.WebRTC.Tests/testcase/TSMediaSource.cs index 7591449..677358a 100755 --- a/tct-suite-vs/Tizen.WebRTC.Tests/testcase/TSMediaSource.cs +++ b/tct-suite-vs/Tizen.WebRTC.Tests/testcase/TSMediaSource.cs @@ -1,3 +1,4 @@ +using System.Linq; /* * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved * @@ -106,6 +107,230 @@ namespace Tizen.Multimedia.Remoting.Tests [Test] [Category("P1")] + [Description("Check whether TransceiverCodec returns expected value or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaSource.TransceiverCodec A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void TransceiverCodec_READ_WRITE() + { + var source = new MediaTestSource(MediaType.Video); + _offerClient.AddSource(source); + + var supportedCodecs = source.SupportedTransceiverCodecs; + if (supportedCodecs.Any() == false) + { + Assert.Pass("There's no supported codec"); + } + + foreach (var supportedCodec in supportedCodecs) + { + source.TransceiverCodec = supportedCodec; + Assert.That(source.TransceiverCodec == supportedCodec, "Should return same value"); + } + } + + [Test] + [Category("P2")] + [Description("Check whether TransceiverCodec throws exception when it's not attached.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaSource.TransceiverCodec A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void TransceiverCodec_THROWS_IF_NOT_ATTACHED() + { + var source = new MediaTestSource(MediaType.Video); + + var supportedCodecs = source.SupportedTransceiverCodecs; + if (supportedCodecs.Any() == false) + { + Assert.Pass("There's no supported codec"); + } + + var codec = supportedCodecs.First(); + + Assert.That(() => source.TransceiverCodec = codec, Throws.InvalidOperationException, + "Should return InvalidOperationException"); + + Assert.That(() => source.TransceiverCodec, Throws.InvalidOperationException, + "Should return InvalidOperationException"); + } + + [Test] + [Category("P2")] + [Description("Check whether TransceiverCodec throws exception when it's already disposed.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaSource.TransceiverCodec A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void TransceiverCodec_THROWS_IF_ALREADY_DISPOSED() + { + var source = new MediaTestSource(MediaType.Video); + _offerClient.AddSource(source); + + var supportedCodecs = source.SupportedTransceiverCodecs; + if (supportedCodecs.Any() == false) + { + Assert.Pass("There's no supported codec"); + } + + var codec = supportedCodecs.First(); + + _offerClient.Dispose(); + + Assert.That(() => source.TransceiverCodec, Throws.TypeOf(), + "Should return ObjectDisposedException"); + + Assert.That(() => source.TransceiverCodec = codec, Throws.TypeOf(), + "Should return ObjectDisposedException"); + } + + [Test] + [Category("P2")] + [Description("Check whether TransceiverCodec throws exception when used invalid MediaSource class.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaSource.TransceiverCodec A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void TransceiverCodec_INVALID_SOURCE_TYPE_MEDIAFILESOURCE() + { + var mediaFileSource = new MediaFileSource(VideoFilePath); + _offerClient.AddSource(mediaFileSource); + + Assert.That(() => mediaFileSource.TransceiverCodec, Throws.InvalidOperationException, + "Should throw InvalidOperationException"); + } + + [Test] + [Category("P2")] + [Description("Check whether TransceiverCodec throws exception when used invalid MediaSource class.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaSource.TransceiverCodec A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void TransceiverCodec_INVALID_SOURCE_TYPE_MEDIAPACKETSOURCE() + { + var mediaPacketSource = new MediaPacketSource(VideoDecoderParser.Format); + _offerClient.AddSource(mediaPacketSource); + + Assert.That(() => mediaPacketSource.TransceiverCodec, Throws.InvalidOperationException, + "Should throw InvalidOperationException"); + } + + [Test] + [Category("P2")] + [Description("Check whether TransceiverCodec throws exception when used invalid MediaSource class.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaSource.TransceiverCodec A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void TransceiverCodec_INVALID_SOURCE_TYPE_MEDIANULLSOURCE() + { + var mediaNullSource = new MediaNullSource(); + _offerClient.AddSource(mediaNullSource); + + Assert.That(() => mediaNullSource.TransceiverCodec, Throws.InvalidOperationException, + "Should throw InvalidOperationException"); + } + + [Test] + [Category("P2")] + [Description("Check whether TransceiverCodec throws exception when it's not attached.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaSource.TransceiverCodec A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task TransceiverCodec_INVALID_STATE() + { + using (var offerClient = new WebRTC()) + using (var answerClient = new WebRTC()) + { + var source = new MediaTestSource(MediaType.Video); + offerClient.AddSource(source); + + var supportedCodecs = source.SupportedTransceiverCodecs; + if (supportedCodecs.Any() == false) + { + Assert.Pass("There's no supported codec"); + } + + await offerClient.StartAsync(); + await answerClient.StartAsync(); + + await ConnectPeerAsync(offerClient, answerClient); + + Assert.That(() => source.TransceiverCodec = supportedCodecs.First(), Throws.InvalidOperationException, + "Should throw InvalidOperationException"); + } + } + + [Test] + [Category("P1")] + [Description("Check whether SupportedTransceiverCodecs returns expected value or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaSource.SupportedTransceiverCodecs A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SupportedTransceiverCodecs_READ_ONLY() + { + var source = new MediaTestSource(MediaType.Video); + _offerClient.AddSource(source); + + Assert.That(() => source.SupportedTransceiverCodecs, Throws.Nothing, "Should not throw"); + } + + [Test] + [Category("P2")] + [Description("Check whether SupportedTransceiverCodecs throws exception when it's already disposed.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaSource.SupportedTransceiverCodecs A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SupportedTransceiverCodecs_THROWS_IF_ALREADY_DISPOSED() + { + var source = new MediaTestSource(MediaType.Video); + _offerClient.AddSource(source); + + _offerClient.Dispose(); + + Assert.That(() => source.SupportedTransceiverCodecs, Throws.TypeOf(), + "Should return ObjectDisposedException"); + } + + [Test] + [Category("P2")] + [Description("Check whether SupportedTransceiverCodecs throws exception when used invalid MediaSource class.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaSource.SupportedTransceiverCodecs A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SupportedTransceiverCodecs_INVALID_SOURCE_TYPE_MEDIAFILESOURCE() + { + var mediaFileSource = new MediaFileSource(VideoFilePath); + _offerClient.AddSource(mediaFileSource); + + Assert.That(() => mediaFileSource.SupportedTransceiverCodecs, Throws.InvalidOperationException, + "Should throw InvalidOperationException"); + } + + [Test] + [Category("P2")] + [Description("Check whether SupportedTransceiverCodecs throws exception when used invalid MediaSource class.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaSource.SupportedTransceiverCodecs A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SupportedTransceiverCodecs_INVALID_SOURCE_TYPE_MEDIAPACKETSOURCE() + { + var mediaPacketSource = new MediaPacketSource(VideoDecoderParser.Format); + _offerClient.AddSource(mediaPacketSource); + + Assert.That(() => mediaPacketSource.SupportedTransceiverCodecs, Throws.InvalidOperationException, + "Should throw InvalidOperationException"); + } + + [Test] + [Category("P1")] [Description("Check whether Pause returns expected value or not.")] [Property("SPEC", "Tizen.Multimedia.Remoting.MediaSource.Pause A")] [Property("SPEC_URL", "-")]