[AudioManager][TCSACR-175][Add new APIs for device running changed event] 23/189723/3
authorHaesu Gwon <haesu.gwon@samsung.com>
Thu, 20 Sep 2018 05:34:00 +0000 (14:34 +0900)
committerHaesu Gwon <haesu.gwon@samsung.com>
Fri, 28 Sep 2018 02:47:28 +0000 (11:47 +0900)
Change-Id: I00c67a1a841d747481317fe31d970e0ef6940d0c

tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDevice.cs [changed mode: 0755->0644]
tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDeviceRunningChangedEventArgs.cs [new file with mode: 0644]
tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioManager.cs [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 712e576..711a0d1
@@ -1,5 +1,6 @@
 using NUnit.Framework;
 using System.Linq;
+using System.Threading.Tasks;
 
 namespace Tizen.Multimedia.Tests
 {
@@ -95,5 +96,27 @@ namespace Tizen.Multimedia.Tests
             Assert.That(AudioManager.GetConnectedDevices().Count(d => d.State == AudioDeviceState.Activated),
                 Is.GreaterThan(0));
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether IsRunning returns expected value or not.")]
+        [Property("SPEC", "Tizen.Multimedia.AudioDevice.IsRunning A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public async Task IsRunning_GET_RUNNING_STATE()
+        {
+            var audioStreamPolicy = new AudioStreamPolicy(AudioStreamType.Media);
+
+            // We need to play anything in BACKGROUND for checking whether IsRunning returns true or not.
+            Task.Run(() => TonePlayer.StartAsync(ToneType.Default, audioStreamPolicy, 500));
+
+            // Wait until tone is played.
+            await Task.Delay(300);
+
+            // We need to check IsRunning property while audioDevice is running.
+            Assert.IsTrue(AudioManager.GetConnectedDevices().FirstOrDefault(
+                device => device.Type == AudioDeviceType.BuiltinSpeaker).IsRunning);
+        }
     }
 }
diff --git a/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDeviceRunningChangedEventArgs.cs b/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDeviceRunningChangedEventArgs.cs
new file mode 100644 (file)
index 0000000..a91f3e5
--- /dev/null
@@ -0,0 +1,35 @@
+using NUnit.Framework;
+
+namespace Tizen.Multimedia.Tests
+{
+    [TestFixture]
+    [Description("Testing Tizen.Multimedia.AudioDeviceRunningChangedEventArgs class")]
+    public class AudioDeviceRunningChangedEventArgsTests
+    {
+        [Test]
+        [Category("P1")]
+        [Description("Check whether Device property is readonly or not.")]
+        [Property("SPEC", "Tizen.Multimedia.AudioDeviceRunningChangedEventArgs.Device A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void Device_READ_ONLY()
+        {
+            AssertHelper.PropertyReadOnly<AudioDeviceRunningChangedEventArgs>(
+                nameof(AudioDeviceRunningChangedEventArgs.Device));
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether IsRunning property is readonly or not.")]
+        [Property("SPEC", "Tizen.Multimedia.AudioDeviceRunningChangedEventArgs.IsRunning A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void IsRunning_READ_ONLY()
+        {
+            AssertHelper.PropertyReadOnly<AudioDeviceRunningChangedEventArgs>(
+                nameof(AudioDeviceRunningChangedEventArgs.IsRunning));
+        }
+    }
+}
old mode 100755 (executable)
new mode 100644 (file)
index 4f5aee7..8da4ea4
@@ -1,4 +1,6 @@
 using NUnit.Framework;
+using System;
+using System.Threading.Tasks;
 
 namespace Tizen.Multimedia.Tests
 {
@@ -29,5 +31,40 @@ namespace Tizen.Multimedia.Tests
         {
             Assert.That(AudioManager.VolumeController, Is.Not.Null);
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether DeviceRunningChanged is raised correctly or not.")]
+        [Property("SPEC", "Tizen.Multimedia.AudioManager.DeviceRunningChanged E")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public async Task DeviceRunningChanged_CHECK_EVENT()
+        {
+            var tcs = new TaskCompletionSource<bool>();
+            var audioStreamPolicy = new AudioStreamPolicy(AudioStreamType.Media);
+
+            EventHandler<AudioDeviceRunningChangedEventArgs> eventHandler = (s, e) =>
+            {
+                if (e.IsRunning)
+                {
+                    tcs.TrySetResult(true);
+                }
+            };
+
+            try
+            {
+                AudioManager.DeviceRunningChanged += eventHandler;
+
+                // We need to play anything in BACKGROUND for checking whether IsRunning returns true or not.
+                Task.Run(() => TonePlayer.StartAsync(ToneType.Default, audioStreamPolicy, 500));
+
+                Assert.That(await tcs.Task);
+            }
+            finally
+            {
+                AudioManager.DeviceRunningChanged -= eventHandler;
+            }
+        }
     }
 }