[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")]
[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()
{
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]