From 31de4a474d0dcee28d3360b86f4407d3c97e829e Mon Sep 17 00:00:00 2001 From: ruble Date: Mon, 15 Jul 2019 13:58:22 +0900 Subject: [PATCH] [MediaPlayer][TCSACR-251] add TCs for exporting an audio data Change-Id: I46d7ce29843cbcd85383260aaa3e9207876b624e --- .../testcase/TSAudioDataDecodedEventArgs.cs | 52 +++++ .../testcase/TSPlayer.cs | 187 ++++++++++++++++++ 2 files changed, 239 insertions(+) create mode 100644 tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSAudioDataDecodedEventArgs.cs diff --git a/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSAudioDataDecodedEventArgs.cs b/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSAudioDataDecodedEventArgs.cs new file mode 100644 index 000000000..1e1377eb3 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSAudioDataDecodedEventArgs.cs @@ -0,0 +1,52 @@ +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Tizen.Multimedia.Tests +{ + + [TestFixture] + [Description("Tizen.Multimedia.AudioDataDecodedEventArgs Tests")] + public class TSAudioDataDecodedEventArgs : TestBase + { + public const string LogTag = "TizenTest.Multimedia.Player"; + + [Test] + [Category("P1")] + [Description("Check if packet is READONLY")] + [Property("SPEC", "Tizen.Multimedia.AudioDataDecodedEventArgs.Packet A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public async Task Packet_READONLY() + { + Log.Info(LogTag, "[Enter] TSAudioDataDecodedEventArgs"); + AssertHelper.PropertyReadOnly( + nameof(AudioDataDecodedEventArgs.Packet)); + + using (var eventWaiter = EventAwaiter.Create()) + { + var player = GetIdlePlayer(); + + player.SetSource(Constants.AudioFileSource); + player.EnableExportingAudioData(null, PlayerAudioExtractOption.Default); + + try + { + player.AudioDataDecoded += eventWaiter; + player.AudioDataDecoded += (s, e) => e.Packet.Dispose(); + + await player.PrepareAsync(); + player.Start(); + + var eventArgs = await eventWaiter.GetResultAsync(); + + Assert.IsInstanceOf(eventArgs.Packet, "it is not a type of MediaPacket"); + } + finally + { + player.AudioDataDecoded -= eventWaiter; + } + } + } + } +} diff --git a/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSPlayer.cs b/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSPlayer.cs index cab6094c1..6327fe9cc 100755 --- a/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSPlayer.cs +++ b/tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSPlayer.cs @@ -16,6 +16,7 @@ namespace Tizen.Multimedia.Tests private long ConvertMillisecondsToNanoseconds(int milliseconds) => milliseconds * Unit; private MediaUriSource _streamingSource = null; private bool _isInternetSupported; + private readonly AudioMediaFormat _audioFormat = new AudioMediaFormat(MediaFormatAudioMimeType.Pcm, 2, 48000, 16, 128); [OneTimeSetUp] public void Init() @@ -2026,5 +2027,191 @@ namespace Tizen.Multimedia.Tests Assert.That(() => TestPlayer.AudioPitch = 1.0F, Throws.TypeOf()); } #endregion + + #region AudioFrameDecoded + [Test] + [Category("P1")] + [Description("Check if AudioDataDecoded event is raised")] + [Property("SPEC", "Tizen.Multimedia.Player.AudioDataDecoded E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public async Task AudioDataDecoded_CHECK() + { + var player = GetIdlePlayer(); + + player.SetSource(Constants.AudioFileSource); + player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.NoSyncAndDeinterleave); + + using (var eventWaiter = EventAwaiter.Create()) + { + try + { + player.AudioDataDecoded += eventWaiter; + player.AudioDataDecoded += (s, e) => e.Packet.Dispose(); + + await player.PrepareAsync(); + player.Start(); + + Assert.True(await eventWaiter.IsRaisedAsync()); + } + catch (Exception ex) + { + Assert.Fail("fail message : " + ex.ToString()); + } + finally + { + player.AudioDataDecoded -= eventWaiter; + } + } + } + + [Test] + [Category("P1")] + [Description("Check if AudioDataDecoded event is raised, when audioformat is not set")] + [Property("SPEC", "Tizen.Multimedia.Player.AudioDataDecoded E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public async Task AudioDataDecoded_CHECK_WITHOUT_FORMAT() + { + var player = GetIdlePlayer(); + + player.SetSource(Constants.AudioFileSource); + player.EnableExportingAudioData(null, PlayerAudioExtractOption.Default); + + using (var eventWaiter = EventAwaiter.Create()) + { + try + { + player.AudioDataDecoded += eventWaiter; + player.AudioDataDecoded += (s, e) => e.Packet.Dispose(); + + await player.PrepareAsync(); + player.Start(); + + Assert.True(await eventWaiter.IsRaisedAsync()); + } + catch (Exception ex) + { + Assert.Fail("fail message : " + ex.ToString()); + } + finally + { + player.AudioDataDecoded -= eventWaiter; + } + } + } + + [Test] + [Category("P1")] + [Description("Check EnableExportingAudioData does not throw exceptions")] + [Property("SPEC", "Tizen.Multimedia.Player.EnableExportingAudioData M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public void EnableExportingAudioData_CHECK() + { + var player = GetIdlePlayer(); + player.SetSource(Constants.AudioFileSource); + + Assert.That(() => player.EnableExportingAudioData(_audioFormat,PlayerAudioExtractOption.Default), Throws.Nothing); + Assert.That(() => player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.NoSyncWithClock), Throws.Nothing); + Assert.That(() => player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.Deinterleave), Throws.Nothing); + Assert.That(() => player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.NoSyncAndDeinterleave), Throws.Nothing); + } + + [Test] + [Category("P2")] + [Description("EnableExportingAudioData throw exception if the player is not in a valid state")] + [Property("SPEC", "Tizen.Multimedia.Player.EnableExportingAudioData M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public async Task EnableExportingAudioData_THROWS_IF_NOT_VALID_STATE() + { + var player = await GetPreparedPlayer(Constants.AudioFileSource); + + Assert.That(() => player.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.NoSyncAndDeinterleave), + Throws.InvalidOperationException); + } + + [Test] + [Category("P2")] + [Description("AudioFrameDecoded throw exception if the param is not valid")] + [Property("SPEC", "Tizen.Multimedia.Player.EnableExportingAudioData M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public void EnableExportingAudioData_THROWS_IF_PARAM_NOT_VALID() + { + var player = GetIdlePlayer(); + player.SetSource(Constants.AudioFileSource); + + Assert.That(() => player.EnableExportingAudioData(_audioFormat, (PlayerAudioExtractOption)6), + Throws.ArgumentException); + } + + [Test] + [Category("P2")] + [Description("Any attempt to access the EnableExportingAudioData if the player has been disposed of")] + [Property("SPEC", "Tizen.Multimedia.Player.EnableExportingAudioData M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public void EnableExportingAudioData_DISPOSED() + { + GetIdlePlayer().Dispose(); + + Assert.That(() => TestPlayer.EnableExportingAudioData(_audioFormat, PlayerAudioExtractOption.NoSyncAndDeinterleave), + Throws.TypeOf()); + } + + [Test] + [Category("P1")] + [Description("Check DisableExportingAudioData does not throw exceptions")] + [Property("SPEC", "Tizen.Multimedia.Player.DisableExportingAudioData M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public async Task DisableExportingAudioData_CHECK() + { + var player = GetIdlePlayer(); + Assert.That(() => player.DisableExportingAudioData(), Throws.Nothing); + + player.SetSource(Constants.AudioFileSource); + await player.PrepareAsync(); + Assert.That(() => player.DisableExportingAudioData(), Throws.Nothing); + } + + [Test] + [Category("P2")] + [Description("DisableExportingAudioData throw exception if the player is not in a valid state")] + [Property("SPEC", "Tizen.Multimedia.Player.DisableExportingAudioData M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public async Task DisableExportingAudioData_THROWS_IF_NOT_VALID_STATE() + { + var player = await GetPlayingPlayer(Constants.AudioFileSource); + + Assert.That(() => player.DisableExportingAudioData(), + Throws.InvalidOperationException); + } + + [Test] + [Category("P2")] + [Description("Any attempt to access the DisableExportingAudioData if the player has been disposed of")] + [Property("SPEC", "Tizen.Multimedia.Player.DisableExportingAudioData M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Jeongyoon Nam, just.nam@samsung.com")] + public void DisableExportingAudioData_DISPOSED() + { + GetIdlePlayer().Dispose(); + + Assert.That(() => TestPlayer.DisableExportingAudioData(), Throws.TypeOf()); + } + #endregion } } -- 2.34.1