using NUnit.Framework;
+using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
public class AudioDeviceTests
{
private AudioDevice _device;
+ private AudioDevice _usb_output_device = null;
[SetUp]
public void SetUp()
{
_device = AudioManager.GetConnectedDevices().First();
+
+ foreach(AudioDevice d in AudioManager.GetConnectedDevices())
+ {
+ if (d.Type == AudioDeviceType.UsbAudio && d.IoDirection == AudioDeviceIoDirection.Output)
+ _usb_output_device = d;
+ }
}
[Test]
cts.Cancel();
}
}
+
+ [Test]
+ [Category("P1")]
+ [Description("Get supported sample rates if it is USB output device")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.GetSupportedSampleRates M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void GetSupportedSampleRates_RETURN_VALUE()
+ {
+ if (_usb_output_device != null)
+ {
+ Assert.That(_usb_output_device.GetSupportedSampleRates().Count(), Is.GreaterThan(0));
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("GetSupportedSampleRates throws InvalidOperationException when invalid device is given.")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.GetSupportedSampleRates M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void GetSupportedSampleRates_THROWS_IF_DEVICE_INVALID()
+ {
+ Assert.Throws<InvalidOperationException>(() => _device.GetSupportedSampleRates());
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Get supported sample formats if it is USB output device")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.GetSupportedSampleFormats M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void GetSupportedSampleFormats_RETURN_VALUE()
+ {
+ if (_usb_output_device != null)
+ {
+ Assert.That(_usb_output_device.GetSupportedSampleFormats().Count(), Is.GreaterThan(0));
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("GetSupportedSampleFormats throws InvalidOperationException when invalid device is given.")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.GetSupportedSampleFormats M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void GetSupportedSampleFormats_THROWS_IF_DEVICE_INVALID()
+ {
+ Assert.Throws<InvalidOperationException>(() => _device.GetSupportedSampleFormats());
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Set a sample rate if it is USB output device without any exception")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.SetSampleRate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void SetSampleRate_WITHOUT_EXCEPTION()
+ {
+ if (_usb_output_device != null)
+ {
+ foreach(uint rate in _usb_output_device.GetSupportedSampleRates())
+ {
+ Assert.DoesNotThrow(() => _usb_output_device.SetSampleRate(rate));
+ Assert.That(_usb_output_device.GetSampleRate(), Is.EqualTo(rate));
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("SetSampleRate throws InvalidOperationException when invalid device is given.")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.SetSampleRate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void SetSampleRate_THROWS_IF_DEVICE_INVALID()
+ {
+ Assert.Throws<InvalidOperationException>(() => _device.SetSampleRate(44100));
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Get a sample rate if it is USB output device without any exception")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.GetSampleRate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void GetSampleRate_WITHOUT_EXCEPTION()
+ {
+ if (_usb_output_device != null)
+ {
+ Assert.DoesNotThrow(() => {
+ bool found = false;
+ uint rate = _usb_output_device.GetSampleRate();
+ foreach (uint r in _usb_output_device.GetSupportedSampleRates())
+ {
+ if (r == rate)
+ {
+ found = true;
+ break;
+ }
+ }
+ Assert.True(found, "Returned rate value should be one of supported sample rates");
+ });
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("GetSampleRate throws InvalidOperationException when invalid device is given.")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.GetSampleRate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void GetSampleRate_THROWS_IF_DEVICE_INVALID()
+ {
+ Assert.Throws<InvalidOperationException>(() => _device.GetSampleRate());
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Set a sample format if it is USB output device without any exception")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.SetSampleFormat M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void SetSampleFormat_WITHOUT_EXCEPTION()
+ {
+ if (_usb_output_device != null)
+ {
+ foreach(AudioSampleFormat format in _usb_output_device.GetSupportedSampleFormats())
+ {
+ Assert.DoesNotThrow(() => _usb_output_device.SetSampleFormat(format));
+ Assert.That(_usb_output_device.GetSampleFormat(), Is.EqualTo(format));
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("SetSampleFormat throws InvalidOperationException when invalid device is given.")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.SetSampleFormat M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void SetSampleFormat_THROWS_IF_DEVICE_INVALID()
+ {
+ Assert.Throws<InvalidOperationException>(() => _device.SetSampleFormat(AudioSampleFormat.S16LE));
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Get a sample format if it is USB output device without any exception")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.GetSampleFormat M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void GetSampleFormat_WITHOUT_EXCEPTION()
+ {
+ if (_usb_output_device != null)
+ {
+ Assert.DoesNotThrow(() => {
+ bool found = false;
+ AudioSampleFormat format = _usb_output_device.GetSampleFormat();
+ foreach (AudioSampleFormat f in _usb_output_device.GetSupportedSampleFormats())
+ {
+ if (f == format)
+ {
+ found = true;
+ break;
+ }
+ }
+ Assert.True(found, "Returned format value should be one of supported sample formats");
+ });
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("GetSampleFormat throws InvalidOperationException when invalid device is given.")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.GetSampleFormat M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void GetSampleFormat_THROWS_IF_DEVICE_INVALID()
+ {
+ Assert.Throws<InvalidOperationException>(() => _device.GetSampleFormat());
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Set 'media stream only' value if it is USB output device without any exception")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.SetMediaStreamOnly M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void SetMediaStreamOnly_WITHOUT_EXCEPTION()
+ {
+ if (_usb_output_device != null)
+ {
+ Assert.DoesNotThrow(() => _usb_output_device.SetMediaStreamOnly(true));
+ Assert.That(_usb_output_device.GetMediaStreamOnly(), Is.EqualTo(true));
+
+ Assert.DoesNotThrow(() => _usb_output_device.SetMediaStreamOnly(false));
+ Assert.That(_usb_output_device.GetMediaStreamOnly(), Is.EqualTo(false));
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("SetMediaStreamOnly throws InvalidOperationException when invalid device is given.")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.SetMediaStreamOnly M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void SetMediaStreamOnly_THROWS_IF_DEVICE_INVALID()
+ {
+ Assert.Throws<InvalidOperationException>(() => _device.SetMediaStreamOnly(false));
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Get 'media stream only' value if it is USB output device without any exception")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.GetMediaStreamOnly M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void GetMediaStreamOnly_WITHOUT_EXCEPTION()
+ {
+ /* Note that it is same with SetMediaStreamOnly_WITHOUT_EXCEPTION().
+ * It could be removed if the csharp API coverage test tool is changed not to have dependency on testcase name */
+ if (_usb_output_device != null)
+ {
+ Assert.DoesNotThrow(() => _usb_output_device.SetMediaStreamOnly(true));
+ Assert.That(_usb_output_device.GetMediaStreamOnly(), Is.EqualTo(true));
+
+ Assert.DoesNotThrow(() => _usb_output_device.SetMediaStreamOnly(false));
+ Assert.That(_usb_output_device.GetMediaStreamOnly(), Is.EqualTo(false));
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("GetMediaStreamOnly throws InvalidOperationException when invalid device is given.")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.GetMediaStreamOnly M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void GetMediaStreamOnly_THROWS_IF_DEVICE_INVALID()
+ {
+ Assert.Throws<InvalidOperationException>(() => _device.GetMediaStreamOnly());
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Set 'avoid resampling' value if it is USB output device without any exception")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.SetAvoidResampling M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void SetAvoidResampling_WITHOUT_EXCEPTION()
+ {
+ if (_usb_output_device != null)
+ {
+ Assert.DoesNotThrow(() => _usb_output_device.SetAvoidResampling(true));
+ Assert.That(_usb_output_device.GetAvoidResampling(), Is.EqualTo(true));
+
+ Assert.DoesNotThrow(() => _usb_output_device.SetAvoidResampling(false));
+ Assert.That(_usb_output_device.GetAvoidResampling(), Is.EqualTo(false));
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("SetAvoidResampling throws InvalidOperationException when invalid device is given.")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.SetAvoidResampling M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void SetAvoidResampling_THROWS_IF_DEVICE_INVALID()
+ {
+ Assert.Throws<InvalidOperationException>(() => _device.SetAvoidResampling(false));
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Get 'avoid resampling' value if it is USB output device without any exception")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.GetAvoidResampling M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void GetAvoidResampling_WITHOUT_EXCEPTION()
+ {
+ /* Note that it is same with SetAvoidResampling_WITHOUT_EXCEPTION().
+ * It could be removed if the csharp API coverage test tool is changed not to have dependency on testcase name */
+ if (_usb_output_device != null)
+ {
+ Assert.DoesNotThrow(() => _usb_output_device.SetAvoidResampling(true));
+ Assert.That(_usb_output_device.GetAvoidResampling(), Is.EqualTo(true));
+
+ Assert.DoesNotThrow(() => _usb_output_device.SetAvoidResampling(false));
+ Assert.That(_usb_output_device.GetAvoidResampling(), Is.EqualTo(false));
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("GetAvoidResampling throws InvalidOperationException when invalid device is given.")]
+ [Property("SPEC", "Tizen.Multimedia.AudioDevice.GetAvoidResampling M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Sangchul Lee, sc11.lee@samsung.com")]
+ public void GetAvoidResampling_THROWS_IF_DEVICE_INVALID()
+ {
+ Assert.Throws<InvalidOperationException>(() => _device.GetAvoidResampling());
+ }
}
}