--- /dev/null
+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;
+ }
+ }
+ }
+ }
+}
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()
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
}
}