[AudioManager][Non-ACR][Add TearDown and revise TCs to release all resources properly] 64/214764/3
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 26 Sep 2019 06:59:05 +0000 (15:59 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 26 Sep 2019 10:13:22 +0000 (10:13 +0000)
Change-Id: Ia1b687dca7b9933ed8f0a78108e144c84ac4ed81
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDucking.cs
tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDuckingStateChangedEventArgs.cs

index bebe60c..a4dc1a6 100644 (file)
@@ -17,6 +17,18 @@ namespace Tizen.Multimedia.Tests
             _ducking = new AudioDucking(AudioStreamType.Media);
         }
 
+        [TearDown]
+        public void Destroy()
+        {
+            if (_ducking != null)
+            {
+                if (_ducking.IsDucked)
+                    _ducking.Deactivate();
+
+                _ducking.Dispose();
+            }
+        }
+
         [Test]
         [Category("P1")]
         [Description("AudioDucking Constructor")]
@@ -26,9 +38,11 @@ namespace Tizen.Multimedia.Tests
         [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
         public void AudioDucking_INIT()
         {
+            AudioDucking ducking = null;
             foreach (AudioStreamType type in Enum.GetValues(typeof(AudioStreamType)))
             {
-                Assert.That(() => new AudioDucking(type), Throws.Nothing);
+                Assert.That(() => { ducking = new AudioDucking(type); }, Throws.Nothing);
+                ducking.Dispose();
             }
         }
 
@@ -53,13 +67,10 @@ namespace Tizen.Multimedia.Tests
         [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.");
-            }
+            _ducking.Activate(0, 0.5);
+            Assert.IsTrue(_ducking.IsDucked, "Not ducked after activation.");
+            _ducking.Deactivate();
+            Assert.IsFalse(_ducking.IsDucked, "Ducked after deactivation.");
         }
 
         [Test]
@@ -71,11 +82,9 @@ namespace Tizen.Multimedia.Tests
         [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.");
-            }
+            Assert.That(() => _ducking.Activate(0, 0.5), Throws.Nothing);
+            Assert.IsTrue(_ducking.IsDucked, "Not ducked after activation.");
+            _ducking.Deactivate();
         }
 
         [Test]
@@ -87,12 +96,9 @@ namespace Tizen.Multimedia.Tests
         [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();
-            }
+            _ducking.Activate(0, 0.5);
+            Assert.That(() => _ducking.Activate(0, 0.5), Throws.TypeOf<InvalidOperationException>());
+            _ducking.Deactivate();
         }
 
         [Test]
@@ -104,10 +110,7 @@ namespace Tizen.Multimedia.Tests
         [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>());
-            }
+            Assert.That(() => _ducking.Activate(5000, 0.5), Throws.TypeOf<ArgumentOutOfRangeException>());
         }
 
         [Test]
@@ -119,10 +122,7 @@ namespace Tizen.Multimedia.Tests
         [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>());
-            }
+            Assert.That(() => _ducking.Activate(0, 2.0), Throws.TypeOf<ArgumentOutOfRangeException>());
         }
 
         [Test]
@@ -134,13 +134,10 @@ namespace Tizen.Multimedia.Tests
         [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.");
-            }
+            _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]
@@ -152,12 +149,9 @@ namespace Tizen.Multimedia.Tests
         [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>());
-            }
+            _ducking.Activate(0, 0.5);
+            _ducking.Deactivate();
+            Assert.That(() => _ducking.Deactivate(), Throws.TypeOf<InvalidOperationException>());
         }
 
         [Test]
@@ -170,14 +164,16 @@ namespace Tizen.Multimedia.Tests
         public async Task DuckingStateChanged_CHECK_EVENT()
         {
             using (var eventAwaiter = EventAwaiter<AudioDuckingStateChangedEventArgs>.Create())
-            using (_ducking)
             {
                 _ducking.DuckingStateChanged += eventAwaiter;
 
                 _ducking.Activate(0, 0.5);
+
+                Assert.That(await eventAwaiter.IsRaisedAsync(), Is.True, "DuckingStateChangedEvent is not raised");
+
                 _ducking.Deactivate();
 
-                Assert.That(await eventAwaiter.IsRaisedAsync(), Is.True, "DuckingStateChangedEvent is not rasied");
+                Assert.That(await eventAwaiter.IsRaisedAsync(), Is.True, "DuckingStateChangedEvent is not raised");
 
                 _ducking.DuckingStateChanged -= eventAwaiter;
             }
@@ -192,11 +188,13 @@ namespace Tizen.Multimedia.Tests
         [Property("AUTHOR", "Jeongmo Yang, jm80.yang@samsung.com")]
         public void Dispose_CHECK()
         {
-            _ducking.Dispose();
+            AudioDucking ducking = new AudioDucking(AudioStreamType.Media);
+
+            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>());
+            Assert.That(() => ducking.IsDucked, Throws.TypeOf<ObjectDisposedException>());
+            Assert.That(() => ducking.Activate(0, 0.5), Throws.TypeOf<ObjectDisposedException>());
+            Assert.That(() => ducking.Deactivate(), Throws.TypeOf<ObjectDisposedException>());
         }
     }
 }
index bf88dfd..b3d3ac3 100644 (file)
@@ -17,6 +17,12 @@ namespace Tizen.Multimedia.Tests
             _ducking = new AudioDucking(AudioStreamType.Media);
         }
 
+        [TearDown]
+        public void Destroy()
+        {
+            _ducking.Dispose();
+        }
+
         [Test]
         [Category("P1")]
         [Description("Check whether AudioDuckingStateChangedEventArgs.IsDucked returns valid value or not.")]
@@ -27,7 +33,6 @@ namespace Tizen.Multimedia.Tests
         public async Task IsDucked_PROPERTY_CHECK()
         {
             using (var eventAwaiter = EventAwaiter<AudioDuckingStateChangedEventArgs>.Create())
-            using (_ducking)
             {
                 _ducking.DuckingStateChanged += eventAwaiter;