From: Sangchul Lee Date: Thu, 4 Oct 2018 03:10:52 +0000 (+0900) Subject: [AudioManager][TCSACR-182][Add new APIs for USB audio output device] X-Git-Tag: tct5.0_m2~9^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F04%2F190704%2F9;p=test%2Ftct%2Fcsharp%2Fapi.git [AudioManager][TCSACR-182][Add new APIs for USB audio output device] Change-Id: Ia8a9d1e5d6bd2d55670fd51ae72bf62ea6fc9942 Signed-off-by: Sangchul Lee --- diff --git a/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDevice.cs b/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDevice.cs index 408b25d..8e91899 100644 --- a/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDevice.cs +++ b/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDevice.cs @@ -1,4 +1,5 @@ using NUnit.Framework; +using System; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -10,11 +11,18 @@ namespace Tizen.Multimedia.Tests 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] @@ -127,5 +135,327 @@ namespace Tizen.Multimedia.Tests 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(() => _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(() => _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(() => _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(() => _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(() => _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(() => _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(() => _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(() => _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(() => _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(() => _device.GetAvoidResampling()); + } } }