[AudioManager][TCSACR-269][Add new TCs for preferred device] 61/213661/4
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 10 Sep 2019 03:34:27 +0000 (12:34 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 26 Sep 2019 01:18:27 +0000 (10:18 +0900)
Change-Id: Iac4ffe499c750bd80e60e6a2c3f35b4600ffeef1
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioStreamPolicy.cs

index 269f15b..9d83ef0 100644 (file)
@@ -9,6 +9,27 @@ namespace Tizen.Multimedia.Tests
     [Description("Testing Tizen.Multimedia.AudioStreamPolicy class")]
     public class AudioStreamPolicyTests
     {
+        private AudioDevice _inputDevice = null;
+        private AudioDevice _outputDevice = null;
+        private AudioDevice _receiverSpeaker = null;
+        private AudioDevice _audioJackWithoutMic = null;
+
+        [SetUp]
+        public void SetUp()
+        {
+            foreach (AudioDevice d in AudioManager.GetConnectedDevices())
+            {
+                if (d.Type == AudioDeviceType.BuiltinSpeaker && d.IoDirection == AudioDeviceIoDirection.Output)
+                    _outputDevice = d;
+                if (d.Type == AudioDeviceType.BuiltinMic && d.IoDirection == AudioDeviceIoDirection.Input)
+                    _inputDevice = d;
+                if (d.Type == AudioDeviceType.BuiltinReceiver && d.IoDirection == AudioDeviceIoDirection.Output)
+                    _receiverSpeaker = d;
+                if (d.Type == AudioDeviceType.AudioJack && d.IoDirection == AudioDeviceIoDirection.Output)
+                    _audioJackWithoutMic = d;
+            }
+        }
+
         [Test]
         [Category("P1")]
         [Description("AudioStreamPolicy Constructor")]
@@ -482,10 +503,122 @@ namespace Tizen.Multimedia.Tests
 
         [Test]
         [Category("P1")]
-        [Description("Throws after disposed")]
+        [Description("Sets and gets the preferred output device.")]
+        [Property("SPEC", "Tizen.Multimedia.AudioStreamPolicy.PreferredOutputDevice A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRW")]
+        [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+        public void PreferredOutputDevice_READ_WRITE()
+        {
+            using (AudioStreamPolicy asp = new AudioStreamPolicy(AudioStreamType.Media))
+            {
+                if (_outputDevice != null)
+                {
+                    Assert.That((asp.PreferredOutputDevice == null), Is.True, "PreferredOutputDevice should be null by default.");
+
+                    asp.PreferredOutputDevice = _outputDevice;
+
+                    Assert.That((asp.PreferredOutputDevice == _outputDevice), Is.True, "PreferredOutputDevice should be set properly.");
+                }
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws if the device is not for output direction")]
+        [Property("SPEC", "Tizen.Multimedia.AudioStreamPolicy.PreferredOutputDevice A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PEX")]
+        [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+        public void PreferredOutputDevice_IF_DEVICE_IS_NOT_FOR_OUTPUT()
+        {
+            using (AudioStreamPolicy asp = new AudioStreamPolicy(AudioStreamType.Media))
+            {
+                if (_inputDevice != null)
+                    Assert.That(() => asp.PreferredOutputDevice = _inputDevice,
+                        Throws.TypeOf<ArgumentException>());
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws if the device is not supported by the instance of AudioStreamPolicy")]
+        [Property("SPEC", "Tizen.Multimedia.AudioStreamPolicy.PreferredOutputDevice A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PEX")]
+        [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+        public void PreferredOutputDevice_IF_DEVICE_IS_NOT_SUPPORTED()
+        {
+            using (AudioStreamPolicy asp = new AudioStreamPolicy(AudioStreamType.Media))
+            {
+                if (_receiverSpeaker != null)
+                    Assert.That(() => asp.PreferredOutputDevice = _receiverSpeaker,
+                        Throws.TypeOf<AudioPolicyException>());
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Sets and gets the preferred input device.")]
+        [Property("SPEC", "Tizen.Multimedia.AudioStreamPolicy.PreferredInputDevice A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRW")]
+        [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+        public void PreferredInputDevice_READ_WRITE()
+        {
+            using (AudioStreamPolicy asp = new AudioStreamPolicy(AudioStreamType.Media))
+            {
+                if (_inputDevice != null)
+                {
+                    Assert.That((asp.PreferredInputDevice == null), Is.True, "PreferredInputDevice should be null by default.");
+
+                    asp.PreferredInputDevice = _inputDevice;
+
+                    Assert.That((asp.PreferredInputDevice == _inputDevice), Is.True, "PreferredInputDevice should be set properly.");
+                }
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws if the device is not for input direction")]
+        [Property("SPEC", "Tizen.Multimedia.AudioStreamPolicy.PreferredInputDevice A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PEX")]
+        [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+        public void PreferredInputDevice_IF_DEVICE_IS_NOT_FOR_INPUT()
+        {
+            using (AudioStreamPolicy asp = new AudioStreamPolicy(AudioStreamType.Media))
+            {
+                if (_outputDevice != null)
+                    Assert.That(() => asp.PreferredInputDevice = _outputDevice,
+                        Throws.TypeOf<ArgumentException>());
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws if the device is not supported by the instance of AudioStreamPolicy")]
+        [Property("SPEC", "Tizen.Multimedia.AudioStreamPolicy.PreferredInputDevice A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PEX")]
+        [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+        public void PreferredInputDevice_IF_DEVICE_IS_NOT_SUPPORTED()
+        {
+            using (AudioStreamPolicy asp = new AudioStreamPolicy(AudioStreamType.Media))
+            {
+                if (_audioJackWithoutMic != null)
+                    Assert.That(() => asp.PreferredInputDevice = _audioJackWithoutMic,
+                        Throws.TypeOf<AudioPolicyException>());
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Throws when access to methods and properties after disposed")]
         [Property("SPEC", "Tizen.Multimedia.AudioStreamPolicy.Dispose M")]
         [Property("SPEC_URL", "-")]
-        [Property("CRITERIA", "MCST")]
+        [Property("CRITERIA", "MEX")]
         [Property("AUTHOR", "JungHo Kim, jhyo.kim@samsung.com")]
         public void Dispose_CHECK()
         {
@@ -498,6 +631,8 @@ namespace Tizen.Multimedia.Tests
             Assert.That(() => asp.ApplyStreamRouting(), Throws.TypeOf<ObjectDisposedException>());
             Assert.That(() => asp.AcquireFocus(AudioStreamFocusOptions.Playback, 0, ""), Throws.TypeOf<ObjectDisposedException>());
             Assert.That(() => asp.ReleaseFocus(AudioStreamFocusOptions.Playback, 0, ""), Throws.TypeOf<ObjectDisposedException>());
+            Assert.That(() => asp.PreferredInputDevice, Throws.TypeOf<ObjectDisposedException>());
+            Assert.That(() => asp.PreferredOutputDevice, Throws.TypeOf<ObjectDisposedException>());
         }
 
         [Test]