[AudioManager][TCSACR-271][Add new TCs for AudioDucking class] 84/212984/11
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 29 Aug 2019 05:35:49 +0000 (14:35 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Tue, 24 Sep 2019 02:58:39 +0000 (02:58 +0000)
Change-Id: Ic7988bdd7694704a8880c2a532e985506af8e81f
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDucking.cs [new file with mode: 0644]
tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDuckingStateChangedEventArgs.cs [new file with mode: 0644]

diff --git a/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDucking.cs b/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDucking.cs
new file mode 100644 (file)
index 0000000..bebe60c
--- /dev/null
@@ -0,0 +1,202 @@
+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>());
+        }
+    }
+}
diff --git a/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDuckingStateChangedEventArgs.cs b/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDuckingStateChangedEventArgs.cs
new file mode 100644 (file)
index 0000000..bf88dfd
--- /dev/null
@@ -0,0 +1,49 @@
+using NUnit.Framework;
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Tizen.Multimedia.Tests
+{
+    [TestFixture]
+    [Description("Testing Tizen.Multimedia.AudioDuckingStateChangedEventArgs class")]
+    public class AudioDuckingStateChangedEventArgsTests
+    {
+        private AudioDucking _ducking;
+
+        [SetUp]
+        public void Init()
+        {
+            _ducking = new AudioDucking(AudioStreamType.Media);
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether AudioDuckingStateChangedEventArgs.IsDucked returns valid value or not.")]
+        [Property("SPEC", "Tizen.Multimedia.AudioDuckingStateChangedEventArgs.IsDucked A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
+        public async Task IsDucked_PROPERTY_CHECK()
+        {
+            using (var eventAwaiter = EventAwaiter<AudioDuckingStateChangedEventArgs>.Create())
+            using (_ducking)
+            {
+                _ducking.DuckingStateChanged += eventAwaiter;
+
+                _ducking.Activate(0, 0.5);
+
+                var eventArgs = await eventAwaiter.GetResultAsync();
+                Assert.That(eventArgs.IsDucked, Is.EqualTo(true), "IsDucked should be true, but it's not.");
+                eventAwaiter.Reset();
+
+                _ducking.Deactivate();
+
+                eventArgs = await eventAwaiter.GetResultAsync();
+                Assert.That(eventArgs.IsDucked, Is.EqualTo(false), "IsDucked should be false, but it's not.");
+
+                _ducking.DuckingStateChanged -= eventAwaiter;
+            }
+        }
+    }
+}