using NUnit.Framework;
using System.Linq;
+using System.Threading.Tasks;
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);
+ }
}
}
--- /dev/null
+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<AudioDeviceRunningChangedEventArgs>(
+ 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<AudioDeviceRunningChangedEventArgs>(
+ nameof(AudioDeviceRunningChangedEventArgs.IsRunning));
+ }
+ }
+}
using NUnit.Framework;
+using System;
+using System.Threading.Tasks;
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<bool>();
+ var audioStreamPolicy = new AudioStreamPolicy(AudioStreamType.Media);
+
+ EventHandler<AudioDeviceRunningChangedEventArgs> 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;
+ }
+ }
}
}