--- /dev/null
+using NUnit.Framework;
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Tizen.Multimedia.Tests
+{
+ [TestFixture]
+ [Description("Testing Tizen.Multimedia.AudioDucking class")]
+ public class AudioDuckingTests
+ {
+ private AudioDucking _ducking;
+
+ [SetUp]
+ public void Init()
+ {
+ _ducking = new AudioDucking(AudioStreamType.Media);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("AudioDucking Constructor")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDucking.AudioDucking C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
+ public void AudioDucking_INIT()
+ {
+ foreach (AudioStreamType type in Enum.GetValues(typeof(AudioStreamType)))
+ {
+ Assert.That(() => new AudioDucking(type), Throws.Nothing);
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("AudioDucking Constructor with invalid AudioStreamType")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDucking.AudioDucking C")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTX")]
+ [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
+ public void AudioDucking_ARGUMENT_EXCEPTION()
+ {
+ Assert.That(() => new AudioDucking(AudioStreamType.MediaExternalOnly + 100), Throws.TypeOf<ArgumentException>());
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether IsDucked returns expected value or not")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDucking.IsDucked A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
+ public void IsDucked_GET_DUCKED_STATE()
+ {
+ using (_ducking)
+ {
+ _ducking.Activate(0, 0.5);
+ Assert.IsTrue(_ducking.IsDucked, "Not ducked after activation.");
+ _ducking.Deactivate();
+ Assert.IsFalse(_ducking.IsDucked, "Ducked after deactivation.");
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Activate ducking and check state")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDucking.Activate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
+ public void Activate_NO_EXCEPTION()
+ {
+ using (_ducking)
+ {
+ Assert.That(() => _ducking.Activate(0, 0.5), Throws.Nothing);
+ Assert.IsTrue(_ducking.IsDucked, "Not ducked after activation.");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Activate ducking after already activated")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDucking.Activate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
+ public void Activate_INVALID_OPERATION_EXCEPTION()
+ {
+ using (_ducking)
+ {
+ _ducking.Activate(0, 0.5);
+ Assert.That(() => _ducking.Activate(0, 0.5), Throws.TypeOf<InvalidOperationException>());
+ _ducking.Deactivate();
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Activate ducking with invalid argument 1")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDucking.Activate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
+ public void Activate_ARGUMENT_OUT_OF_RANGE_EXCEPTION1()
+ {
+ using (_ducking)
+ {
+ Assert.That(() => _ducking.Activate(5000, 0.5), Throws.TypeOf<ArgumentOutOfRangeException>());
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Activate ducking with invalid argument 2")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDucking.Activate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
+ public void Activate_ARGUMENT_OUT_OF_RANGE_EXCEPTION2()
+ {
+ using (_ducking)
+ {
+ Assert.That(() => _ducking.Activate(0, 2.0), Throws.TypeOf<ArgumentOutOfRangeException>());
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Deactivate ducking and check state")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDucking.Deactivate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
+ public void Deactivate_CHECK()
+ {
+ using (_ducking)
+ {
+ _ducking.Activate(0, 0.5);
+ Assert.IsTrue(_ducking.IsDucked, "Not ducked after activation.");
+ Assert.That(() => _ducking.Deactivate(), Throws.Nothing);
+ Assert.IsFalse(_ducking.IsDucked, "Ducked after deactivation.");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Deactivate ducking after already deactivated")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDucking.Deactivate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
+ public void Deactivate_INVALID_OPERATION_EXCEPTION()
+ {
+ using (_ducking)
+ {
+ _ducking.Activate(0, 0.5);
+ _ducking.Deactivate();
+ Assert.That(() => _ducking.Deactivate(), Throws.TypeOf<InvalidOperationException>());
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether event is raised when ducking state is changed")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDucking.DuckingStateChanged E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
+ public async Task DuckingStateChanged_CHECK_EVENT()
+ {
+ using (var eventAwaiter = EventAwaiter<AudioDuckingStateChangedEventArgs>.Create())
+ using (_ducking)
+ {
+ _ducking.DuckingStateChanged += eventAwaiter;
+
+ _ducking.Activate(0, 0.5);
+ _ducking.Deactivate();
+
+ Assert.That(await eventAwaiter.IsRaisedAsync(), Is.True, "DuckingStateChangedEvent is not rasied");
+
+ _ducking.DuckingStateChanged -= eventAwaiter;
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check ObjectDisposedException after disposed")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDucking.Dispose M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MCST")]
+ [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
+ public void Dispose_CHECK()
+ {
+ _ducking.Dispose();
+
+ Assert.That(() => _ducking.IsDucked, Throws.TypeOf<ObjectDisposedException>());
+ Assert.That(() => _ducking.Activate(0, 0.5), Throws.TypeOf<ObjectDisposedException>());
+ Assert.That(() => _ducking.Deactivate(), Throws.TypeOf<ObjectDisposedException>());
+ }
+ }
+}