[MediaPlayer][TCSACR-251] add TCs for exporting an audio data 01/210001/5
authorruble <just.nam@samsung.com>
Mon, 15 Jul 2019 04:58:22 +0000 (13:58 +0900)
committerruble <just.nam@samsung.com>
Wed, 17 Jul 2019 06:08:44 +0000 (15:08 +0900)
Change-Id: I46d7ce29843cbcd85383260aaa3e9207876b624e

tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSAudioDataDecodedEventArgs.cs [new file with mode: 0644]
tct-suite-vs/Tizen.MediaPlayer.Tests/testcase/TSPlayer.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 (file)
index 0000000..1e1377e
--- /dev/null
@@ -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<AudioDataDecodedEventArgs>(
+                nameof(AudioDataDecodedEventArgs.Packet));
+
+            using (var eventWaiter = EventAwaiter<AudioDataDecodedEventArgs>.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<MediaPacket>(eventArgs.Packet, "it is not a type of MediaPacket");
+                }
+                finally
+                {
+                    player.AudioDataDecoded -= eventWaiter;
+                }
+            }
+        }
+    }
+}
index cab6094..6327fe9 100755 (executable)
@@ -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<ObjectDisposedException>());
         }
         #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<AudioDataDecodedEventArgs>.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<AudioDataDecodedEventArgs>.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<ObjectDisposedException>());
+        }
+
+        [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<ObjectDisposedException>());
+        }
+        #endregion
     }
 }