+using System.Linq;
/*
* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
*
[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<ObjectDisposedException>(),
+ "Should return ObjectDisposedException");
+
+ Assert.That(() => source.TransceiverCodec = codec, Throws.TypeOf<ObjectDisposedException>(),
+ "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<ObjectDisposedException>(),
+ "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", "-")]