From: Haesu Gwon Date: Thu, 20 Sep 2018 05:34:00 +0000 (+0900) Subject: [AudioManager][TCSACR-175][Add new APIs for device running changed event] X-Git-Tag: tct5.0_m2~43^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e2a70f67f1ecaca873576d661a85774e415400dd;p=test%2Ftct%2Fcsharp%2Fapi.git [AudioManager][TCSACR-175][Add new APIs for device running changed event] Change-Id: I00c67a1a841d747481317fe31d970e0ef6940d0c --- diff --git a/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDevice.cs b/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDevice.cs old mode 100755 new mode 100644 index 712e576..711a0d1 --- a/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDevice.cs +++ b/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDevice.cs @@ -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 index 0000000..a91f3e5 --- /dev/null +++ b/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioDeviceRunningChangedEventArgs.cs @@ -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( + 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( + nameof(AudioDeviceRunningChangedEventArgs.IsRunning)); + } + } +} diff --git a/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioManager.cs b/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioManager.cs old mode 100755 new mode 100644 index 4f5aee7..8da4ea4 --- a/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioManager.cs +++ b/tct-suite-vs/Tizen.Multimedia.Tests/testcase/AudioManager/TSAudioManager.cs @@ -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(); + var audioStreamPolicy = new AudioStreamPolicy(AudioStreamType.Media); + + EventHandler 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; + } + } } }