From d794f6ec6de943aa8ba958dd5ae0162b334f3cba Mon Sep 17 00:00:00 2001 From: Haesu Gwon Date: Fri, 28 Sep 2018 14:49:50 +0900 Subject: [PATCH] [MediaController][TCSACR-176 and TCSACR-188][Add new APIs for sending command and its callback] Change-Id: Idfd2d79c253b5298385f72bfc2473d8fa269039c --- .../testcase/TSCommand.cs | 103 +++ .../testcase/TSCustomCommand.cs | 124 ++++ .../testcase/TSCustomCommandReceivedEventArgs.cs | 49 ++ .../testcase/TSMediaControlPlaylist.cs | 226 ++++++ .../testcase/TSMediaControlSearchCondition.cs | 73 +- .../testcase/TSMediaControlServer.cs | 784 +++++++++++++++++++++ .../testcase/TSMediaController.cs | 482 ++++++++++++- .../TSPlaybackActionCommandReceivedEventArgs.cs | 50 ++ .../TSPlaybackCapabilityUpdatedEventArgs.cs | 27 +- .../testcase/TSPlaybackCommand.cs | 77 ++ .../testcase/TSPlaybackPositionCommand.cs | 64 ++ .../TSPlaybackPositionCommandReceivedEventArgs.cs | 50 ++ .../testcase/TSPlaylistCommand.cs | 156 ++++ .../testcase/TSPlaylistCommandReceivedEventArgs.cs | 54 ++ .../testcase/TSPlaylistUpdatedEventArgs.cs | 105 +++ .../TSRepeatModeCapabilityUpdatedEventArgs.cs | 23 +- .../testcase/TSRepeatModeCommand.cs | 77 ++ .../TSRepeatModeCommandReceivedEventArgs.cs | 51 ++ .../testcase/TSSearchCommand.cs | 158 +++++ .../testcase/TSSearchCommandReceivedEventArgs.cs | 65 +- .../TSShuffleModeCapabilityUpdatedEventArgs.cs | 24 +- .../testcase/TSShuffleModeCommand.cs | 72 ++ .../TSShuffleModeCommandReceivedEventArgs.cs | 52 ++ 23 files changed, 2917 insertions(+), 29 deletions(-) create mode 100644 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSCommand.cs create mode 100644 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSCustomCommand.cs create mode 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSCustomCommandReceivedEventArgs.cs create mode 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlPlaylist.cs mode change 100755 => 100644 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlServer.cs mode change 100755 => 100644 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaController.cs create mode 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackActionCommandReceivedEventArgs.cs mode change 100644 => 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackCapabilityUpdatedEventArgs.cs create mode 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackCommand.cs create mode 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackPositionCommand.cs create mode 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackPositionCommandReceivedEventArgs.cs create mode 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaylistCommand.cs create mode 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaylistCommandReceivedEventArgs.cs create mode 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaylistUpdatedEventArgs.cs mode change 100644 => 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSRepeatModeCapabilityUpdatedEventArgs.cs create mode 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSRepeatModeCommand.cs create mode 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSRepeatModeCommandReceivedEventArgs.cs create mode 100644 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSSearchCommand.cs mode change 100644 => 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSSearchCommandReceivedEventArgs.cs create mode 100644 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSShuffleModeCommand.cs create mode 100755 tct-suite-vs/Tizen.MediaController.Tests/testcase/TSShuffleModeCommandReceivedEventArgs.cs diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSCommand.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSCommand.cs new file mode 100644 index 0000000..28a04e8 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSCommand.cs @@ -0,0 +1,103 @@ +using NUnit.Framework; +using System.Linq; +using System.Collections.Generic; +using System.Threading.Tasks; +using Tizen.Applications; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.Command class")] + public class CommandTests + { + private MediaController _controller; + private MediaControllerManager _manager; + + // Command class is abstract so we need to test with derived class. + private SearchCommand _command; + + [SetUp] + public void SetUp() + { + MediaControlServer.Start(); + + _manager = new MediaControllerManager(); + _controller = _manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + _command = new SearchCommand(new MediaControlSearchCondition(MediaControlContentType.Image, "test", null)); + } + + [TearDown] + public void TearDown() + { + if (MediaControlServer.IsRunning) + { + MediaControlServer.Stop(); + } + + _manager.Dispose(); + } + + [Test] + [Category("P1")] + [Description("Create SearchCommand instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.Command.Command C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Command_CHECK_CREATE_CONSTRUCTOR() + { + Assert.IsNotNull(_command, "Object should not be null after initializing"); + Assert.IsInstanceOf(_command, "Should return SearchCommand instance"); + } + + [Test] + [Category("P1")] + [Description("Check whether client and server communicate correctly using OnResponseCompleted internally.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.Command.OnResponseCompleted M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task OnResponseCompleted_AFTER_RESPONSE() + { + SearchCommand searchCommand = null; + + MediaControlServer.SearchCommandReceived += (s, e) => + { + searchCommand = e.Command; + + Assert.That(() => MediaControlServer.Response(searchCommand, 0, new Bundle()), Throws.Nothing); + }; + + await Task.Run(() => + { + _controller.RequestAsync(_command); + }); + } + + [Test] + [Category("P1")] + [Description("Check whether client and server communicate correctly using ReceiverId internally.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.Command.ReceiverId A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task ReceiverId_WITH_RESPONSE() + { + SearchCommand searchCommand = null; + + MediaControlServer.SearchCommandReceived += (s, e) => + { + searchCommand = e.Command; + + // protected ReceiverId is called in MediaControlServer.Response(). + Assert.That(() => MediaControlServer.Response(searchCommand, 0, new Bundle()), Throws.Nothing); + }; + + await Task.Run(() => + { + _controller.RequestAsync(_command); + }); + } + } +} diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSCustomCommand.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSCustomCommand.cs new file mode 100644 index 0000000..28073a6 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSCustomCommand.cs @@ -0,0 +1,124 @@ +using NUnit.Framework; +using System; +using System.Linq; +using Tizen.Applications; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.CustomCommand class")] + public class CustomCommandTests + { + private MediaController _controller; + private MediaControllerManager _manager; + private CustomCommand _command; + private string _action = "test"; + + [SetUp] + public void SetUp() + { + MediaControlServer.Start(); + + _manager = new MediaControllerManager(); + _controller = _manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + _command = new CustomCommand(_action); + } + + [TearDown] + public void TearDown() + { + if (MediaControlServer.IsRunning) + { + MediaControlServer.Stop(); + } + + _manager.Dispose(); + } + + [Test] + [Category("P1")] + [Description("Create CustomCommand instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.CustomCommand.CustomCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("COVPARAM", "string")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void CustomCommand_CHECK_CREATE_CONSTRUCTOR() + { + Assert.IsNotNull(_command, "Object should not be null after initializing"); + Assert.IsInstanceOf(_command, "Should return CustomCommand instance"); + } + + [Test] + [Category("P1")] + [Description("Create CustomCommand instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.CustomCommand.CustomCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("COVPARAM", "string, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void CustomCommand_CHECK_CREATE_CONSTRUCTOR_WITH_BUNDLE() + { + var command = new CustomCommand("test", new Bundle()); + Assert.IsNotNull(command, "Object should not be null after initializing"); + Assert.IsInstanceOf(command, "Should return CustomCommand instance"); + } + + [Test] + [Category("P2")] + [Description("Check whether PlaylistCommand throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.CustomCommand.CustomCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("COVPARAM", "string")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void CustomCommand_THROWS_EXCEPTION() + { + Assert.Throws(() => new CustomCommand(null)); + } + + [Test] + [Category("P2")] + [Description("Check whether PlaylistCommand throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.CustomCommand.CustomCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("COVPARAM", "string, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void CustomCommand_WITH_BUNDLE_THROWS_EXCEPTION() + { + Assert.Throws(() => new CustomCommand(null, null)); + } + + [Test] + [Category("P1")] + [Description("Check whether Action property is null or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.CustomCommand.Action A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Action_READ_ONLY() + { + Assert.That(_command.Action, Is.TypeOf()); + Assert.That(() => _command.Action, Is.EqualTo(_action)); + } + + [Test] + [Category("P1")] + [Description("Check whether Bundle property is null or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.CustomCommand.Bundle A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Bundle_READ_ONLY() + { + var bundle = new Bundle(); + bundle.AddItem("test_key", "test_value"); + + var command = new CustomCommand("test", bundle); + Assert.That(command.Bundle, Is.TypeOf()); + Assert.That(() => command.Bundle.GetItem("test_key"), Is.EqualTo("test_value")); + } + } +} \ No newline at end of file diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSCustomCommandReceivedEventArgs.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSCustomCommandReceivedEventArgs.cs new file mode 100755 index 0000000..c811610 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSCustomCommandReceivedEventArgs.cs @@ -0,0 +1,49 @@ +using NUnit.Framework; +using System; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.CustomCommandReceivedEventArgs class")] + public class CustomCommandReceivedEventArgsTests + { + [Test] + [Category("P1")] + [Description("Create CustomCommandReceivedEventArgs instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.CustomCommandReceivedEventArgs.CustomCommandReceivedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void CustomCommandReceivedEventArgs_CONSTRUCTOR() + { + Assert.That(() => new CustomCommandReceivedEventArgs(new CustomCommand("test")), Throws.Nothing); + } + + [Test] + [Category("P2")] + [Description("Check whether constructor throw exeption or not, when creating instance with null parameter.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.CustomCommandReceivedEventArgs.CustomCommandReceivedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void CustomCommandReceivedEventArgs_CONSTRUCTOR_CHECK_EXCEPTION() + { + Assert.Throws(() => new CustomCommandReceivedEventArgs(null)); + } + + [Test] + [Category("P1")] + [Description("Check whether Command property is null or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.CustomCommandReceivedEventArgs.Command A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Command_READ_ONLY() + { + var args = new CustomCommandReceivedEventArgs(new CustomCommand("test")); + + Assert.IsInstanceOf(args.Command); + Assert.That(() => args.Command.Action, Is.EqualTo("test")); + } + } +} diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlPlaylist.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlPlaylist.cs new file mode 100755 index 0000000..dd412e6 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlPlaylist.cs @@ -0,0 +1,226 @@ +using NUnit.Framework; +using System.Linq; +using System.Collections.Generic; +using System.Threading.Tasks; +using Tizen.Applications; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.MediaControlPlaylist class")] + public class MediaControlPlaylistTests + { + private MediaController _controller; + private MediaControllerManager _manager; + + [SetUp] + public void SetUp() + { + MediaControlServer.Start(); + + _manager = new MediaControllerManager(); + _controller = _manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + } + + [TearDown] + public void TearDown() + { + if (MediaControlServer.IsRunning) + { + MediaControlServer.Stop(); + } + + _manager.Dispose(); + } + + [Test] + [Category("P1")] + [Description("Create MediaControlPlaylist instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlPlaylist.MediaControlPlaylist C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("COVPARAM", "string")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void MediaControlPlaylist_CHECK_CREATE_CONSTRUCTOR() + { + using (var playlist = new MediaControlPlaylist("MyFavorite")) + { + Assert.IsNotNull(playlist, "Object should not be null after initializing"); + Assert.IsInstanceOf(playlist, "Should return MediaControlPlaylist instance"); + } + } + + [Test] + [Category("P1")] + [Description("Create MediaControlPlaylist instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlPlaylist.MediaControlPlaylist C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("COVPARAM", "string, Dictionary")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void MediaControlPlaylist_CHECK_CREATE_CONSTRUCTOR_WITH_METADATA() + { + using (var playlist = new MediaControlPlaylist("MyFavorite2", + new Dictionary() + { + {"Song1", new MediaControlMetadata()}, + {"Song2", new MediaControlMetadata()} + })) + { + Assert.IsNotNull(playlist, "Object should not be null after initializing"); + Assert.IsInstanceOf(playlist, "Should return MediaControlPlaylist instance"); + } + } + + [Test] + [Category("P1")] + [Description("Check whether Name returns expected value or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlPlaylist.Name A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Name_READ_ONLY() + { + using (var playlist = new MediaControlPlaylist("MyFavorite")) + { + Assert.That(playlist.Name, Is.EqualTo("MyFavorite")); + } + } + + [Test] + [Category("P1")] + [Description("Check whether TotalCount returns expected value or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlPlaylist.TotalCount A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void TotalCount_READ_ONLY() + { + using (var playlist = new MediaControlPlaylist("MyFavorite")) + { + playlist.AddMetadata("Song1", new MediaControlMetadata()); + + Assert.That(playlist.TotalCount, Is.GreaterThan(0)); + } + } + + [Test] + [Category("P1")] + [Description("Gets the metadata and compare with metadata added. ")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlPlaylist.GetMetadata M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetMetadata_RETURN_VALUE() + { + using (var playlist = new MediaControlPlaylist("MyFavorite")) + { + var metadatasPair = new Dictionary() + { + {"ID1", new MediaControlMetadata() { Artist = "GD" } }, + {"ID2", new MediaControlMetadata() { Artist = "BeWHY"} } + }; + + playlist.AddMetadata(metadatasPair); + + Assert.That(playlist.GetMetadata(), Is.EqualTo(metadatasPair)); + } + } + + [Test] + [Category("P1")] + [Description("Gets the metadata with index and compare with metadata added. ")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlPlaylist.GetMetadata M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("COVPARAM", "string")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetMetadata_RETURN_VALUE_WITH_STRING() + { + using (var playlist = new MediaControlPlaylist("MyFavorite")) + { + var metadata = new MediaControlMetadata() + { + Artist = "GD", + Album = "GoodBoy" + }; + + playlist.AddMetadata("ID1", metadata); + + Assert.That(playlist.GetMetadata("ID1"), Is.EqualTo(metadata)); + } + } + + [Test] + [Category("P1")] + [Description("Adds the metadata and then, get and compare with metadata added. ")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlPlaylist.AddMetadata M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("COVPARAM", "Dictionary")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void AddMetadata_RETURN_VALUE() + { + using (var playlist = new MediaControlPlaylist("MyFavorite")) + { + var metadatasPair = new Dictionary() + { + {"ID1", new MediaControlMetadata() { Artist = "GD" } }, + {"ID2", new MediaControlMetadata() { Artist = "BeWHY"} } + }; + + playlist.AddMetadata(metadatasPair); + + Assert.That(playlist.GetMetadata(), Is.EqualTo(metadatasPair)); + } + } + + [Test] + [Category("P1")] + [Description("Adds the metadata with index and then, get and compare with metadata added. ")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlPlaylist.AddMetadata M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("COVPARAM", "string, MediaControlMetadata")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void AddMetadata_RETURN_VALUE_WITH_STRING() + { + using (var playlist = new MediaControlPlaylist("MyFavorite")) + { + var metadata = new MediaControlMetadata() + { + Artist = "GD", + Album = "GoodBoy" + }; + + playlist.AddMetadata("ID1", metadata); + + Assert.That(playlist.GetMetadata("ID1"), Is.EqualTo(metadata)); + } + } + + [Test] + [Category("P1")] + [Description("Returns value set by the server")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlPlaylist.Update M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Update_RETURN_VALUE() + { + using (var playlist = new MediaControlPlaylist("MyFavorite")) + { + var metadata = new MediaControlMetadata() + { + Artist = "GD", + Album = "GoodBoy" + }; + + playlist.AddMetadata("ID1", metadata); + + Assert.That(playlist.GetMetadata("ID1"), Is.EqualTo(metadata)); + } + } + } +} \ No newline at end of file diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlSearchCondition.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlSearchCondition.cs index 291c050..88179e6 100644 --- a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlSearchCondition.cs +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlSearchCondition.cs @@ -1,7 +1,6 @@ using NUnit.Framework; +using System; using System.Linq; -using System.Collections.Generic; -using System.Threading.Tasks; using Tizen.Applications; namespace Tizen.Multimedia.Remoting.Tests @@ -13,6 +12,7 @@ namespace Tizen.Multimedia.Remoting.Tests private MediaController _controller; private MediaControllerManager _manager; private MediaControlSearchCondition _condition; + private Bundle _bundle = new Bundle(); [SetUp] public void SetUp() @@ -23,7 +23,7 @@ namespace Tizen.Multimedia.Remoting.Tests _controller = _manager.GetActiveControllers().Single( c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); _condition = new MediaControlSearchCondition(MediaControlContentType.Image, - MediaControlSearchCategory.Artist, "GD", new Bundle()); + MediaControlSearchCategory.Artist, "GD", _bundle); } [TearDown] @@ -39,7 +39,7 @@ namespace Tizen.Multimedia.Remoting.Tests [Test] [Category("P1")] - [Description("Create MediaControlSearchCondition instance")] + [Description("Create MediaControlSearchCondition instance with content type, category, keyword and buldle")] [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlSearchCondition.MediaControlSearchCondition C")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "CONSTR")] @@ -52,8 +52,32 @@ namespace Tizen.Multimedia.Remoting.Tests } [Test] + [Category("P2")] + [Description("Check whether MediaControlSearchCondition throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlSearchCondition.MediaControlSearchCondition C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("COVPARAM", "MediaControlContentType, MediaControlSearchCategory, string, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void MediaControlSearchCondition_THROWS_EXCEPTION() + { + Assert.Throws(() => new MediaControlSearchCondition(MediaControlContentType.Image - 1, + MediaControlSearchCategory.Artist, "GD", new Bundle())); + Assert.Throws(() => new MediaControlSearchCondition(MediaControlContentType.NotDecided + 1, + MediaControlSearchCategory.Artist, "GD", new Bundle())); + + Assert.Throws(() => new MediaControlSearchCondition(MediaControlContentType.Image, + MediaControlSearchCategory.All - 1, "GD", new Bundle())); + Assert.Throws(() => new MediaControlSearchCondition(MediaControlContentType.Image, + MediaControlSearchCategory.Tpo + 1, "GD", new Bundle())); + + Assert.Throws(() => new MediaControlSearchCondition(MediaControlContentType.Image, + MediaControlSearchCategory.Artist, null, new Bundle())); + } + + [Test] [Category("P1")] - [Description("Create MediaControlSearchCondition instance")] + [Description("Create MediaControlSearchCondition instance with content type, keyword, buldle and all category")] [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlSearchCondition.MediaControlSearchCondition C")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "CONSTR")] @@ -68,51 +92,74 @@ namespace Tizen.Multimedia.Remoting.Tests } [Test] + [Category("P2")] + [Description("Check whether MediaControlSearchCondition throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlSearchCondition.MediaControlSearchCondition C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("COVPARAM", "MediaControlContentType, string, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void MediaControlSearchCondition_WITH_ALL_CATEGORY_THROWS_EXCEPTION() + { + Assert.Throws(() => new MediaControlSearchCondition(MediaControlContentType.Image - 1, + "GD", new Bundle())); + Assert.Throws(() => new MediaControlSearchCondition(MediaControlContentType.NotDecided + 1, + "GD", new Bundle())); + + Assert.Throws(() => new MediaControlSearchCondition(MediaControlContentType.Image, + null, new Bundle())); + } + + [Test] [Category("P1")] - [Description("Is always not null")] + [Description("Check whether ContentType property is type of MediaControlContentType or not.")] [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlSearchCondition.ContentType A")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] public void ContentType_READ_ONLY() { - Assert.That(() => _condition.ContentType, Is.Not.Null); + Assert.IsInstanceOf(_condition.ContentType); + Assert.That(_condition.ContentType, Is.EqualTo(MediaControlContentType.Image)); } [Test] [Category("P1")] - [Description("Is always not null")] + [Description("Check whether Category property is type of MediaControlSearchCategory or not.")] [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlSearchCondition.Category A")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] public void Category_READ_ONLY() { - Assert.That(() => _condition.Category, Is.Not.Null); + Assert.IsInstanceOf(_condition.Category); + Assert.That(_condition.Category, Is.EqualTo(MediaControlSearchCategory.Artist)); } [Test] [Category("P1")] - [Description("Is always not null")] + [Description("Check whether Keyword property is type of string or not.")] [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlSearchCondition.Keyword A")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] public void Keyword_READ_ONLY() { - Assert.That(() => _condition.Keyword, Is.Not.Null); + Assert.IsInstanceOf(_condition.Keyword); + Assert.That(_condition.Keyword, Is.EqualTo("GD")); } [Test] [Category("P1")] - [Description("Is always not null")] + [Description("Check whether Bundle property is type of Bundle or not.")] [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlSearchCondition.Bundle A")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] public void Bundle_READ_ONLY() { - Assert.That(() => _condition.Bundle, Is.Not.Null); + Assert.IsInstanceOf(_condition.Bundle); + Assert.That(_condition.Bundle, Is.EqualTo(_bundle)); } } } diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlServer.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlServer.cs old mode 100755 new mode 100644 index 94ca6e3..13cfc7a --- a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlServer.cs +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlServer.cs @@ -1,8 +1,10 @@ using NUnit.Framework; using System; using System.Linq; +using System.Collections.Generic; using System.Threading.Tasks; using Tizen.Applications; +using Tizen.Internals.Errors; namespace Tizen.Multimedia.Remoting.Tests { @@ -234,5 +236,787 @@ namespace Tizen.Multimedia.Remoting.Tests { Assert.That(MediaControlServer.IsRunning, Is.True); } + + [Test] + [Category("P1")] + [Description("Test for getting activated client list")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.GetActivatedClients M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetActivatedClients_RETURN_VALUE() + { + using (var manager = new MediaControllerManager()) + { + var mediaController = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + foreach (var controller in MediaControlServer.GetActivatedClients()) + { + //Assert.That(controller, Is.Not.Null); + Assert.That(controller, Is.EqualTo(Application.Current.ApplicationInfo.ApplicationId)); + } + } + } + + [Test] + [Category("P1")] + [Description("Test for removing playlist")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.RemovePlaylist M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void RemovePlaylist_RETURN_VALUE() + { + var playlist = new MediaControlPlaylist("MyFavor"); + + Assert.That(() => MediaControlServer.RemovePlaylist(playlist), Throws.Nothing); + } + + [Test] + [Category("P2")] + [Description("Check whether RemovePlaylist throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.RemovePlaylist M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void RemovePlaylist_THROWS_EXCEPTION() + { + Assert.Throws(() => MediaControlServer.RemovePlaylist(null)); + } + + [Test] + [Category("P1")] + [Description("Thows nothing when RequestAsync to client")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.RequestAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task RequestAsync_RETURN_VALUE() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + CustomCommand customCommand = null; + + controller.CustomCommandReceived += (s, e) => + { + customCommand = e.Command; + + controller.Response(customCommand, 0); + }; + + await Task.Run(() => + { + Assert.That(() => MediaControlServer.RequestAsync(new CustomCommand("CustomCommand"), + Application.Current.ApplicationInfo.ApplicationId), Throws.Nothing); + }); + } + } + + [Test] + [Category("P2")] + [Description("Check whether RequestAsync throws exception if client response with error")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.RequestAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task RequestAsync_THROWS_EXCEPTION() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + CustomCommand customCommand = null; + + controller.CustomCommandReceived += (s, e) => + { + customCommand = e.Command; + + controller.Response(customCommand, (int)ErrorCode.InvalidOperation); + }; + + await Task.Run(() => + { + Assert.That(() => MediaControlServer.RequestAsync(new CustomCommand("CustomCommand"), + Application.Current.ApplicationInfo.ApplicationId), Throws.InvalidOperationException); + }); + } + } + + [Test] + [Category("P2")] + [Description("Check whether RequestAsync throws exception if parameter is null")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.RequestAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void RequestAsync_WITH_NULL_THROWS_EXCEPTION() + { + Assert.ThrowsAsync(() => MediaControlServer.RequestAsync(null, + Application.Current.ApplicationInfo.ApplicationId)); + + Assert.ThrowsAsync(() => MediaControlServer.RequestAsync( + new CustomCommand("CustomCommand"), null)); + } + + [Test] + [Category("P1")] + [Description("Thows nothing when response to client")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("COVPARAM", "Command, int, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task Response_WITH_BUNDLE_THROWS_NOTHING() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + EventHandler eventHandler = (s, e) => + { + var customCommand = e.Command; + + Assert.That(() => MediaControlServer.Response(customCommand, 0, new Bundle()), Throws.Nothing); + }; + + try + { + MediaControlServer.CustomCommandReceived += eventHandler; + + await Task.Run(() => + { + Assert.That(() => controller.RequestAsync(new CustomCommand("Custom")), Throws.Nothing); + }); + } + finally + { + MediaControlServer.CustomCommandReceived -= eventHandler; + } + } + } + + [Test] + [Category("P2")] + [Description("Check whether Response throws exception if server is not working")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "Command, int, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Response_WITH_BUNDLE_THROWS_EXCEPTION() + { + MediaControlServer.Stop(); + + Assert.That(() => MediaControlServer.Response(new CustomCommand("custom"), 0, new Bundle()), + Throws.InvalidOperationException); + + Assert.Throws(() => MediaControlServer.Response(null, 0, new Bundle())); + } + + [Test] + [Category("P1")] + [Description("Thows nothing when response to client")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("COVPARAM", "Command, int")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task Response_THROWS_NOTHING() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + EventHandler eventHandler = (s, e) => + { + var customCommand = e.Command; + + Assert.That(() => MediaControlServer.Response(customCommand, 0), Throws.Nothing); + }; + + try + { + MediaControlServer.CustomCommandReceived += eventHandler; + + await Task.Run(() => + { + Assert.That(() => controller.RequestAsync(new CustomCommand("Custom")), Throws.Nothing); + }); + } + finally + { + MediaControlServer.CustomCommandReceived -= eventHandler; + } + } + } + + [Test] + [Category("P2")] + [Description("Check whether Response throws exception if server is not working")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "Command, int")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Response_THROWS_EXCEPTION() + { + MediaControlServer.Stop(); + + Assert.That(() => MediaControlServer.Response(new CustomCommand("custom"), 0), + Throws.InvalidOperationException); + + Assert.Throws(() => MediaControlServer.Response(null, 0)); + } + + [Test] + [Category("P1")] + [Description("Returns index of current playing media")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetIndexOfCurrentPlayingMedia M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetIndexOfCurrentPlayingMedia_RETURN_VALUE() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + var index = "ID1"; + Assert.That(() => MediaControlServer.SetIndexOfCurrentPlayingMedia(index), Throws.Nothing); + + Assert.That(controller.GetIndexOfCurrentPlayingMedia(), Is.EqualTo(index)); + } + } + + [Test] + [Category("P2")] + [Description("Check whether SetIndexOfCurrentPlayingMedia throws exception if index is null")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetIndexOfCurrentPlayingMedia M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetIndexOfCurrentPlayingMedia_THROWS_EXCEPTION() + { + Assert.Throws(() => MediaControlServer.SetIndexOfCurrentPlayingMedia(null)); + } + + [Test] + [Category("P1")] + [Description("Sets age rating and get and compare with value")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetAgeRating M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetAgeRating_RETURN_VALUE() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + var ageRating = 12; + Assert.That(() => MediaControlServer.SetAgeRating(ageRating), Throws.Nothing); + + Assert.That(controller.GetAgeRatingOfCurrentPlayingMedia(), Is.EqualTo(ageRating)); + } + } + + [Test] + [Category("P2")] + [Description("Check whether SetAgeRating throws exception if ageRating is in invalid range")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetAgeRating M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetAgeRating_THROWS_EXCEPTION() + { + Assert.Throws(() => MediaControlServer.SetAgeRating(-1)); + + Assert.Throws(() => MediaControlServer.SetAgeRating(20)); + } + + [Test] + [Category("P1")] + [Description("Sets icon path and get it and compare with value previosly set")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetIconPath M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetIconPath_RETURN_VALUE() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + var iconPath = "test.jpg"; + Assert.That(() => MediaControlServer.SetIconPath(iconPath), Throws.Nothing); + + Assert.That(controller.GetIconPath(), Is.EqualTo(iconPath)); + } + } + + [Test] + [Category("P2")] + [Description("Check whether SetIconPath throws exception if path is null")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetIconPath M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetIconPath_THROWS_EXCEPTION() + { + Assert.Throws(() => MediaControlServer.SetIconPath(null)); + } + + [Test] + [Category("P1")] + [Description("Sets playlist name and index of currnet playing media")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetInfoOfCurrentPlayingMedia M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetInfoOfCurrentPlayingMedia_RETURN_VALUE() + { + using (var manager = new MediaControllerManager()) + using (var playlist1 = new MediaControlPlaylist("MyFavor", + new Dictionary() { { "Song1", new MediaControlMetadata() } })) + using (var playlist2 = new MediaControlPlaylist("Classic", + new Dictionary() { { "Song2", new MediaControlMetadata() } })) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + var playlistName = "Classic"; + var index = "Song2"; + MediaControlServer.SetInfoOfCurrentPlayingMedia(playlistName, index); + + Assert.That(controller.GetPlaylistOfCurrentPlayingMedia().Name, Is.EqualTo(playlistName)); + } + } + + [Test] + [Category("P2")] + [Description("Check whether SetInfoOfCurrentPlayingMedia throws exception if parameter is null")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetInfoOfCurrentPlayingMedia M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetInfoOfCurrentPlayingMedia_THROW_EXCEPTION() + { + Assert.Throws(() => MediaControlServer.SetInfoOfCurrentPlayingMedia("MyFavor", null)); + + Assert.Throws(() => MediaControlServer.SetInfoOfCurrentPlayingMedia(null, "ID1")); + } + + [Test] + [Category("P1")] + [Description("Sets playback capability and get it and compare with the value")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetPlaybackCapability M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetPlaybackCapability_RETURN_VALUE() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + MediaControlServer.SetPlaybackCapability(MediaControlPlaybackCommand.FastForward, + MediaControlCapabilitySupport.NotSupported); + + Assert.That(controller.GetPlaybackCapability(MediaControlPlaybackCommand.FastForward), + Is.EqualTo(MediaControlCapabilitySupport.NotSupported)); + } + } + + [Test] + [Category("P2")] + [Description("Check whether SetPlaybackCapability throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetPlaybackCapability M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetPlaybackCapability_THROWS_NOTHING() + { + Assert.Throws(() => MediaControlServer.SetPlaybackCapability( + MediaControlPlaybackCommand.Play - 1, MediaControlCapabilitySupport.NotSupported)); + + Assert.Throws(() => MediaControlServer.SetPlaybackCapability( + MediaControlPlaybackCommand.Toggle + 1, MediaControlCapabilitySupport.NotSupported)); + + Assert.Throws(() => MediaControlServer.SetPlaybackCapability( + MediaControlPlaybackCommand.Play, MediaControlCapabilitySupport.NotDecided)); + + Assert.Throws(() => MediaControlServer.SetPlaybackCapability( + MediaControlPlaybackCommand.Play, MediaControlCapabilitySupport.Supported - 1)); + } + + [Test] + [Category("P1")] + [Description("Sets playback capabilities without exception")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetPlaybackCapabilities M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetPlaybackCapabilities_RETURN_VALUE() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + var capabilities = new Dictionary() + { + {MediaControlPlaybackCommand.FastForward, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Next, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Pause, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Play, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Previous, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Rewind, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Stop, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Toggle, MediaControlCapabilitySupport.Supported } + }; + + Assert.That(() => MediaControlServer.SetPlaybackCapabilities(capabilities), Throws.Nothing); + + Assert.That(controller.GetPlaybackCapabilities(), Is.EqualTo(capabilities)); + } + } + + [Test] + [Category("P2")] + [Description("Check whether SetPlaybackCapabilities throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetPlaybackCapabilities M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetPlaybackCapabilities_THROWS_EXCEPTION() + { + var capabilities = new Dictionary() + { {MediaControlPlaybackCommand.Play - 1, MediaControlCapabilitySupport.Supported } }; + Assert.Throws(() => MediaControlServer.SetPlaybackCapabilities(capabilities)); + + capabilities = new Dictionary() + { {MediaControlPlaybackCommand.Toggle + 1, MediaControlCapabilitySupport.Supported } }; + Assert.Throws(() => MediaControlServer.SetPlaybackCapabilities(capabilities)); + + capabilities = new Dictionary() + { {MediaControlPlaybackCommand.Play, MediaControlCapabilitySupport.NotDecided } }; + Assert.Throws(() => MediaControlServer.SetPlaybackCapabilities(capabilities)); + + capabilities = new Dictionary() + { {MediaControlPlaybackCommand.Play, MediaControlCapabilitySupport.Supported - 1 } }; + Assert.Throws(() => MediaControlServer.SetPlaybackCapabilities(capabilities)); + } + + [Test] + [Category("P1")] + [Description("Sets content type of current playing media")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetPlaybackContentType M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetPlaybackContentType_THROWS_NOTHING() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + var contentType = MediaControlContentType.Music; + MediaControlServer.SetPlaybackContentType(contentType); + + Assert.That(controller.GetContentTypeOfCurrentPlayingMedia(), Is.EqualTo(contentType)); + } + } + + [Test] + [Category("P2")] + [Description("Check whether SetPlaybackContentType throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetPlaybackContentType M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetPlaybackContentType_THROWS_EXCEPTION() + { + Assert.Throws(() => MediaControlServer.SetPlaybackContentType(MediaControlContentType.Image - 1)); + + Assert.Throws(() => MediaControlServer.SetPlaybackContentType(MediaControlContentType.NotDecided)); + } + + [Test] + [Category("P1")] + [Description("Sets repeat mode capability")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetRepeatModeCapability M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetRepeatModeCapability_RETURN_VALUE() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + MediaControlServer.SetRepeatModeCapability(MediaControlCapabilitySupport.NotSupported); + Assert.That(controller.GetRepeatModeCapability(), Is.EqualTo(MediaControlCapabilitySupport.NotSupported)); + + MediaControlServer.SetRepeatModeCapability(MediaControlCapabilitySupport.Supported); + Assert.That(controller.GetRepeatModeCapability(), Is.EqualTo(MediaControlCapabilitySupport.Supported)); + } + } + + [Test] + [Category("P2")] + [Description("Check whether SetRepeatModeCapability throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetRepeatModeCapability M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetRepeatModeCapability_THROWS_EXCEPTION() + { + Assert.Throws(() => + MediaControlServer.SetRepeatModeCapability(MediaControlCapabilitySupport.Supported - 1)); + + Assert.Throws(() => + MediaControlServer.SetRepeatModeCapability(MediaControlCapabilitySupport.NotDecided)); + } + + [Test] + [Category("P1")] + [Description("Sets shuffle mode capability")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetShuffleModeCapability M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetShuffleModeCapability_RETURN_VALUE() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + MediaControlServer.SetShuffleModeCapability(MediaControlCapabilitySupport.NotSupported); + Assert.That(controller.GetShuffleModeCapability(), Is.EqualTo(MediaControlCapabilitySupport.NotSupported)); + + MediaControlServer.SetShuffleModeCapability(MediaControlCapabilitySupport.Supported); + Assert.That(controller.GetShuffleModeCapability(), Is.EqualTo(MediaControlCapabilitySupport.Supported)); + } + } + + [Test] + [Category("P2")] + [Description("Check whether SetShuffleModeCapability throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SetShuffleModeCapability M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SetShuffleModeCapability_THROW_EXCEPTION() + { + Assert.Throws(() => + MediaControlServer.SetShuffleModeCapability(MediaControlCapabilitySupport.Supported - 1)); + + Assert.Throws(() => + MediaControlServer.SetShuffleModeCapability(MediaControlCapabilitySupport.NotDecided)); + } + + [Test] + [Category("P1")] + [Description("Invoked when server sends custom command")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.CustomCommandReceived E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task CustomCommandReceived_CHECK_EVENT() + { + using (var eventWaiter = EventAwaiter.Create()) + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + try + { + MediaControlServer.CustomCommandReceived += eventWaiter; + + await Task.Run(() => + { + controller.RequestAsync(new CustomCommand("CustomCommand")); + }); + + Assert.That(await eventWaiter.IsRaisedAsync()); + } + finally + { + MediaControlServer.CustomCommandReceived -= eventWaiter; + } + } + } + + [Test] + [Category("P1")] + [Description("Invoked when server sends playback command")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.PlaybackActionCommandReceived E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task PlaybackActionCommandReceived_CHECK_EVENT() + { + using (var eventWaiter = EventAwaiter.Create()) + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + MediaControlServer.PlaybackActionCommandReceived += eventWaiter; + + await Task.Run(() => + { + controller.RequestAsync(new PlaybackCommand(MediaControlPlaybackCommand.Play)); + }); + + Assert.That(await eventWaiter.IsRaisedAsync()); + } + } + + [Test] + [Category("P1")] + [Description("Invoked when server sends playback position command")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.PlaybackPositionCommandReceived E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task PlaybackPositionCommandReceived_CHECK_EVENT() + { + using (var eventWaiter = EventAwaiter.Create()) + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + MediaControlServer.PlaybackPositionCommandReceived += eventWaiter; + + await Task.Run(() => + { + controller.RequestAsync(new PlaybackPositionCommand(100)); + }); + + Assert.That(await eventWaiter.IsRaisedAsync()); + } + } + + [Test] + [Category("P1")] + [Description("Invoked when server sends playlist command")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.PlaylistCommandReceived E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task PlaylistCommandReceived_CHECK_EVENT() + { + using (var eventWaiter = EventAwaiter.Create()) + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + MediaControlServer.PlaylistCommandReceived += eventWaiter; + + await Task.Run(() => + { + controller.RequestAsync(new PlaylistCommand(MediaControlPlaybackCommand.Play, + "MyFavor", "Song1", 100)); + }); + + Assert.That(await eventWaiter.IsRaisedAsync()); + } + } + + [Test] + [Category("P1")] + [Description("Invoked when server sends repeat mode command")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.RepeatModeCommandReceived E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task RepeatModeCommandReceived_CHECK_EVENT() + { + using (var eventWaiter = EventAwaiter.Create()) + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + MediaControlServer.RepeatModeCommandReceived += eventWaiter; + + await Task.Run(() => + { + controller.RequestAsync(new RepeatModeCommand(MediaControlRepeatMode.On)); + }); + + Assert.That(await eventWaiter.IsRaisedAsync()); + } + } + + [Test] + [Category("P1")] + [Description("Invoked when server sends shuffle mode command")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.ShuffleModeCommandReceived E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task ShuffleModeCommandReceived_CHECK_EVENT() + { + using (var eventWaiter = EventAwaiter.Create()) + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + MediaControlServer.ShuffleModeCommandReceived += eventWaiter; + + await Task.Run(() => + { + controller.RequestAsync(new ShuffleModeCommand(true)); + }); + + Assert.That(await eventWaiter.IsRaisedAsync()); + } + } + + [Test] + [Category("P1")] + [Description("Invoked when server sends search command")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.SearchCommandReceived E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task SearchCommandReceived_CHECK_EVENT() + { + using (var eventWaiter = EventAwaiter.Create()) + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + MediaControlServer.SearchCommandReceived += eventWaiter; + + await Task.Run(() => + { + controller.RequestAsync(new SearchCommand( + new MediaControlSearchCondition(MediaControlContentType.Music, "Song1", null)) + ); + }); + + Assert.That(await eventWaiter.IsRaisedAsync()); + } + } } } diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaController.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaController.cs old mode 100755 new mode 100644 index b23a094..f670ed2 --- a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaController.cs +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaController.cs @@ -1,7 +1,10 @@ using NUnit.Framework; +using System; using System.Linq; using System.Threading.Tasks; +using System.Collections.Generic; using Tizen.Applications; +using Tizen.Internals.Errors; namespace Tizen.Multimedia.Remoting.Tests { @@ -11,6 +14,7 @@ namespace Tizen.Multimedia.Remoting.Tests { private MediaController _controller; private MediaControllerManager _manager; + private CustomCommand _command; [SetUp] public void SetUp() @@ -20,6 +24,7 @@ namespace Tizen.Multimedia.Remoting.Tests _manager = new MediaControllerManager(); _controller = _manager.GetActiveControllers().Single( c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + _command = new CustomCommand("Custom"); } [TearDown] @@ -276,5 +281,480 @@ namespace Tizen.Multimedia.Remoting.Tests Assert.That(() => _controller.SendPlaybackCommand((MediaControlPlaybackCommand)(-1)), Throws.ArgumentException); } + + [Test] + [Category("P1")] + [Description("Returns age rating value of current playing media")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.GetAgeRatingOfCurrentPlayingMedia M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetAgeRatingOfCurrentPlayingMedia_RETURN_VALUE() + { + var ageRating = 12; + MediaControlServer.SetAgeRating(ageRating); + + Assert.That(_controller.GetAgeRatingOfCurrentPlayingMedia(), Is.EqualTo(ageRating)); + } + + [Test] + [Category("P1")] + [Description("Returns content type of current playing media")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.GetContentTypeOfCurrentPlayingMedia M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetContentTypeOfCurrentPlayingMedia_RETURN_VALUE() + { + var contentType = MediaControlContentType.Music; + MediaControlServer.SetPlaybackContentType(contentType); + + Assert.That(_controller.GetContentTypeOfCurrentPlayingMedia(), Is.EqualTo(contentType)); + } + + [Test] + [Category("P1")] + [Description("Sets icon path. And get and compare it with the value previously set")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.GetIconPath M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetIconPath_RETURN_VALUE() + { + var iconPath = "test.jpg"; + MediaControlServer.SetIconPath(iconPath); + + Assert.That(_controller.GetIconPath(), Is.EqualTo(iconPath)); + } + + [Test] + [Category("P1")] + [Description("Returns index of current playing media")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.GetIndexOfCurrentPlayingMedia M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetIndexOfCurrentPlayingMedia_RETURN_VALUE() + { + var index = "ID1"; + MediaControlServer.SetIndexOfCurrentPlayingMedia(index); + + Assert.That(_controller.GetIndexOfCurrentPlayingMedia(), Is.EqualTo(index)); + } + + [Test] + [Category("P1")] + [Description("Sets playback capability and compare it with the value previosly set")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.GetPlaybackCapability M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetPlaybackCapability_RETURN_VALUE() + { + foreach (MediaControlPlaybackCommand capability in Enum.GetValues(typeof(MediaControlPlaybackCommand))) + { + // NotDecided can not be set directly. + + var isSupported = MediaControlCapabilitySupport.NotSupported; + MediaControlServer.SetPlaybackCapability(capability, isSupported); + Assert.That(_controller.GetPlaybackCapability(capability), Is.EqualTo(isSupported)); + + isSupported = MediaControlCapabilitySupport.Supported; + MediaControlServer.SetPlaybackCapability(capability, isSupported); + Assert.That(_controller.GetPlaybackCapability(capability), Is.EqualTo(isSupported)); + } + } + + [Test] + [Category("P2")] + [Description("Sets playback capability and compare it with the value previosly set")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.GetPlaybackCapability M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetPlaybackCapability_THROWS_EXCEPTION() + { + foreach (MediaControlPlaybackCommand capability in Enum.GetValues(typeof(MediaControlPlaybackCommand))) + { + // NotDecided can not be set directly. + + var isSupported = MediaControlCapabilitySupport.NotSupported; + MediaControlServer.SetPlaybackCapability(capability, isSupported); + Assert.That(_controller.GetPlaybackCapability(capability), Is.EqualTo(isSupported)); + + isSupported = MediaControlCapabilitySupport.Supported; + MediaControlServer.SetPlaybackCapability(capability, isSupported); + Assert.That(_controller.GetPlaybackCapability(capability), Is.EqualTo(isSupported)); + + Assert.Throws(() => _controller.GetPlaybackCapability(MediaControlPlaybackCommand.Play - 1)); + Assert.Throws(() => _controller.GetPlaybackCapability(MediaControlPlaybackCommand.Toggle + 1)); + } + } + + [Test] + [Category("P1")] + [Description("Sets playback capabilities and compare it with the value previosly set")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.GetPlaybackCapabilities M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetPlaybackCapabilities_RETURN_VALUE() + { + var capabilities = new Dictionary() + { + {MediaControlPlaybackCommand.FastForward, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Next, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Pause, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Play, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Previous, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Rewind, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Stop, MediaControlCapabilitySupport.Supported }, + {MediaControlPlaybackCommand.Toggle, MediaControlCapabilitySupport.Supported } + }; + + MediaControlServer.SetPlaybackCapabilities(capabilities); + + Assert.That(_controller.GetPlaybackCapabilities(), Is.EqualTo(capabilities)); + } + + [Test] + [Category("P1")] + [Description("Returns playlist of currnet playing media")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.GetPlaylistOfCurrentPlayingMedia M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetPlaylistOfCurrentPlayingMedia_RETURN_VALUE() + { + using (var playlist1 = new MediaControlPlaylist("MyFavor", + new Dictionary() { { "Song1", new MediaControlMetadata() } })) + using (var playlist2 = new MediaControlPlaylist("Classic", + new Dictionary() { { "Song2", new MediaControlMetadata() } })) + { + var playlistName = "Classic"; + var index = "Song2"; + MediaControlServer.SetInfoOfCurrentPlayingMedia(playlistName, index); + + Assert.That(_controller.GetPlaylistOfCurrentPlayingMedia().Name, Is.EqualTo(playlistName)); + }; + } + + [Test] + [Category("P1")] + [Description("Returns all playlists created before")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.GetPlaylists M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetPlaylists_RETURN_VALUE() + { + using (var playlist1 = new MediaControlPlaylist("MyFavor", + new Dictionary() { { "Song1", new MediaControlMetadata() } })) + using (var playlist2 = new MediaControlPlaylist("Classic", + new Dictionary() { { "Song2", new MediaControlMetadata() } })) + { + foreach (var playlist in _controller.GetPlaylists()) + { + Assert.IsTrue(playlist.Name.Equals(playlist1.Name) || playlist.Name.Equals(playlist2.Name)); + } + }; + } + + [Test] + [Category("P1")] + [Description("Sets repeat mode capability and compare it with the value previosly set")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.GetRepeatModeCapability M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetRepeatModeCapability_RETURN_VALUE() + { + MediaControlServer.SetRepeatModeCapability(MediaControlCapabilitySupport.NotSupported); + Assert.That(_controller.GetRepeatModeCapability(), Is.EqualTo(MediaControlCapabilitySupport.NotSupported)); + + MediaControlServer.SetRepeatModeCapability(MediaControlCapabilitySupport.Supported); + Assert.That(_controller.GetRepeatModeCapability(), Is.EqualTo(MediaControlCapabilitySupport.Supported)); + } + + [Test] + [Category("P1")] + [Description("Sets shuffle mode capability and compare it with the value previosly set")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.GetShuffleModeCapability M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void GetShuffleModeCapability_RETURN_VALUE() + { + MediaControlServer.SetShuffleModeCapability(MediaControlCapabilitySupport.NotSupported); + Assert.That(_controller.GetShuffleModeCapability(), Is.EqualTo(MediaControlCapabilitySupport.NotSupported)); + + MediaControlServer.SetShuffleModeCapability(MediaControlCapabilitySupport.Supported); + Assert.That(_controller.GetShuffleModeCapability(), Is.EqualTo(MediaControlCapabilitySupport.Supported)); + } + + [Test] + [Category("P1")] + [Description("Throws nothing when request to server")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.RequestAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task RequestAsync_THROWS_NOTHING() + { + CustomCommand customCommand = null; + EventHandler eventHandler = (s, e) => + { + customCommand = e.Command; + Log.Info("Remoting.Tests", $"e.Command.Action : {e.Command.Action}"); + + MediaControlServer.Response(customCommand, (int)ErrorCode.None, new Bundle()); + }; + + try + { + MediaControlServer.CustomCommandReceived += eventHandler; + + await Task.Run(() => + { + Assert.That(() => _controller.RequestAsync(_command), Throws.Nothing); + }); + } + finally + { + MediaControlServer.CustomCommandReceived -= eventHandler; + } + } + + [Test] + [Category("P2")] + [Description("Check whether RequestAsync throws exception if server response with error")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.RequestAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task RequestAsync_THROWS_EXCEPTION() + { + CustomCommand customCommand = null; + + EventHandler eventHandler = (s, e) => + { + customCommand = e.Command; + Log.Info("Remoting.Tests", $"22 e.Command.Action : {e.Command.Action}"); + + MediaControlServer.Response(customCommand, (int)ErrorCode.InvalidOperation, new Bundle()); + }; + + try + { + MediaControlServer.CustomCommandReceived += eventHandler; + + await Task.Run(() => + { + Assert.That(() => _controller.RequestAsync(_command), Throws.InvalidOperationException); + }); + } + finally + { + MediaControlServer.CustomCommandReceived -= eventHandler; + } + } + + [Test] + [Category("P2")] + [Description("Check whether RequestAsync throws exception if parameter is null")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.RequestAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void RequestAsync_THROWS_EXCEPTION_NULL() + { + Assert.That(() => _controller.RequestAsync(null), Throws.ArgumentNullException); + } + + [Test] + [Category("P1")] + [Description("Throws nothing when response to server")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("COVPARAM", "Command, int")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task Response_THROWS_NOTHING() + { + CustomCommand customCommand = null; + + _controller.CustomCommandReceived += (s, e) => + { + customCommand = e.Command; + + Assert.That(() => _controller.Response(customCommand, 0), Throws.Nothing); + }; + + await Task.Run(() => + { + MediaControlServer.RequestAsync(new CustomCommand("CustomCommand"), + Application.Current.ApplicationInfo.ApplicationId); + }); + } + + [Test] + [Category("P2")] + [Description("Check whether Response throws exception if server is not working")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "Command, int")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Response_THROWS_EXCEPTION() + { + MediaControlServer.Stop(); + + Assert.That(() => _controller.Response(new CustomCommand("Custom"), 0), Throws.InvalidOperationException); + Assert.That(() => _controller.Response(null, 0), Throws.ArgumentNullException); + } + + [Test] + [Category("P1")] + [Description("Throws nothing when response to server")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("COVPARAM", "Command, int, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task Response_WITH_BUNDLE_THROWS_NOTHING() + { + CustomCommand customCommand = null; + + _controller.CustomCommandReceived += (s, e) => + { + customCommand = e.Command; + + Assert.That(() => _controller.Response(customCommand, 0, new Bundle()), Throws.Nothing); + }; + + await Task.Run(() => + { + MediaControlServer.RequestAsync(new CustomCommand("CustomCommand"), + Application.Current.ApplicationInfo.ApplicationId); + }); + } + + [Test] + [Category("P2")] + [Description("Check whether Response throws exception if server is not working")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "Command, int, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Response_WITH_BUNDLE_THROWS_EXCEPTION() + { + MediaControlServer.Stop(); + + Assert.That(() => _controller.Response(new CustomCommand("Custom"), 0, new Bundle()), Throws.InvalidOperationException); + Assert.That(() => _controller.Response(null, 0, new Bundle()), Throws.ArgumentNullException); + } + + [Test] + [Category("P1")] + [Description("Invoked when server sends custom command")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.CustomCommandReceived E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task CustomCommandReceived_CHECK_EVENT() + { + using (var eventWaiter = EventAwaiter.Create()) + { + _controller.CustomCommandReceived += eventWaiter; + + await Task.Run(() => + { + MediaControlServer.RequestAsync(new CustomCommand("CustomCommand"), + Application.Current.ApplicationInfo.ApplicationId); + }); + + Assert.That(await eventWaiter.IsRaisedAsync()); + } + } + + [Test] + [Category("P1")] + [Description("Invoked when the server set playback capability")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.PlaybackCapabilityUpdated E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task PlaybackCapabilityUpdated_CHECK_EVENT() + { + using (var eventWaiter = EventAwaiter.Create()) + { + _controller.PlaybackCapabilityUpdated += eventWaiter; + + MediaControlServer.SetPlaybackCapability(MediaControlPlaybackCommand.Play, + MediaControlCapabilitySupport.NotSupported); + + Assert.That(await eventWaiter.IsRaisedAsync()); + } + } + + [Test] + [Category("P1")] + [Description("Invoked when the playlist is created")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.PlaylistUpdated E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task PlaylistUpdated_CHECK_EVENT() + { + using (var eventWaiter = EventAwaiter.Create()) + { + _controller.PlaylistUpdated += eventWaiter; + + new MediaControlPlaylist("MyFavor"); + + Assert.That(await eventWaiter.IsRaisedAsync()); + } + } + + [Test] + [Category("P1")] + [Description("Invoked when the server set repeat mode capability")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.RepeatModeCapabilityUpdated E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task RepeatModeCapabilityUpdated_CHECK_EVENT() + { + using (var eventWaiter = EventAwaiter.Create()) + { + _controller.RepeatModeCapabilityUpdated += eventWaiter; + + MediaControlServer.SetRepeatModeCapability(MediaControlCapabilitySupport.NotSupported); + + var args = await eventWaiter.GetResultAsync(); + Assert.IsTrue(args.Support.Equals(MediaControlCapabilitySupport.NotSupported)); + } + } + + [Test] + [Category("P1")] + [Description("Invoked when the server set shuffle mode capability")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.ShuffleModeCapabilityUpdated E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task ShuffleModeCapabilityUpdated_CHECK_EVENT() + { + using (var eventWaiter = EventAwaiter.Create()) + { + _controller.ShuffleModeCapabilityUpdated += eventWaiter; + + MediaControlServer.SetShuffleModeCapability(MediaControlCapabilitySupport.NotSupported); + + var args = await eventWaiter.GetResultAsync(); + Assert.IsTrue(args.Support.Equals(MediaControlCapabilitySupport.NotSupported)); + } + } } -} \ No newline at end of file +} diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackActionCommandReceivedEventArgs.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackActionCommandReceivedEventArgs.cs new file mode 100755 index 0000000..feb00f8 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackActionCommandReceivedEventArgs.cs @@ -0,0 +1,50 @@ +using NUnit.Framework; +using System; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.PlaybackActionCommandReceivedEventArgs class")] + public class PlaybackActionCommandReceivedEventArgsTests + { + [Test] + [Category("P1")] + [Description("Create PlaybackActionCommandReceivedEventArgs instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackActionCommandReceivedEventArgs.PlaybackActionCommandReceivedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaybackActionCommandReceivedEventArgs_CONSTRUCTOR() + { + Assert.That(() => new PlaybackActionCommandReceivedEventArgs( + new PlaybackCommand(MediaControlPlaybackCommand.Play)), Throws.Nothing); + } + + [Test] + [Category("P2")] + [Description("Check whether PlaybackActionCommandReceivedEventArgs throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackActionCommandReceivedEventArgs.PlaybackActionCommandReceivedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaybackActionCommandReceivedEventArgs_THROWS_EXCEPTION() + { + Assert.Throws(() => new PlaybackActionCommandReceivedEventArgs(null)); + } + + [Test] + [Category("P1")] + [Description("Check whether Command property is instance of PlaybackCommand or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackActionCommandReceivedEventArgs.Command A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Command_READ_ONLY() + { + var args = new PlaybackActionCommandReceivedEventArgs(new PlaybackCommand(MediaControlPlaybackCommand.Play)); + + Assert.IsInstanceOf(args.Command); + Assert.That(() => args.Command.Action, Is.EqualTo(MediaControlPlaybackCommand.Play)); + } + } +} diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackCapabilityUpdatedEventArgs.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackCapabilityUpdatedEventArgs.cs old mode 100644 new mode 100755 index 297de4a..fcf10b5 --- a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackCapabilityUpdatedEventArgs.cs +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackCapabilityUpdatedEventArgs.cs @@ -1,4 +1,5 @@ using NUnit.Framework; +using System; using System.Collections.Generic; namespace Tizen.Multimedia.Remoting.Tests @@ -16,7 +17,7 @@ namespace Tizen.Multimedia.Remoting.Tests [Test] [Category("P1")] - [Description("Constructor")] + [Description("Create PlaybackCapabilityUpdatedEventArgs instance")] [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackCapabilityUpdatedEventArgs.PlaybackCapabilityUpdatedEventArgs C")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "CONSTR")] @@ -27,6 +28,18 @@ namespace Tizen.Multimedia.Remoting.Tests } [Test] + [Category("P2")] + [Description("Check whether PlaybackCapabilityUpdatedEventArgs throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackCapabilityUpdatedEventArgs.PlaybackCapabilityUpdatedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaybackCapabilityUpdatedEventArgs_THROWS_EXCEPTION() + { + Assert.Throws(() => new PlaybackCapabilityUpdatedEventArgs(null)); + } + + [Test] [Category("P1")] [Description("Is always not null")] [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackCapabilityUpdatedEventArgs.Support A")] @@ -35,8 +48,16 @@ namespace Tizen.Multimedia.Remoting.Tests [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] public void Support_READ_ONLY() { - Assert.That(() => new PlaybackActionCommandReceivedEventArgs( - new PlaybackCommand(MediaControlPlaybackCommand.Play)).Command, Is.Not.Null); + var args = new PlaybackCapabilityUpdatedEventArgs( + new Dictionary() + { + {MediaControlPlaybackCommand.Play, MediaControlCapabilitySupport.Supported} + }); + + Assert.IsInstanceOf>(args.Support); + + args.Support.TryGetValue(MediaControlPlaybackCommand.Play, out MediaControlCapabilitySupport isSupported); + Assert.That(() => isSupported, Is.EqualTo(MediaControlCapabilitySupport.Supported)); } } } diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackCommand.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackCommand.cs new file mode 100755 index 0000000..1b63610 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackCommand.cs @@ -0,0 +1,77 @@ +using NUnit.Framework; +using System; +using System.Linq; +using System.Threading.Tasks; +using Tizen.Applications; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.PlaybackCommand class")] + public class PlaybackCommandTests + { + private MediaController _controller; + private MediaControllerManager _manager; + private PlaybackCommand _command; + + [SetUp] + public void SetUp() + { + MediaControlServer.Start(); + + _manager = new MediaControllerManager(); + _controller = _manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + _command = new PlaybackCommand(MediaControlPlaybackCommand.Play); + } + + [TearDown] + public void TearDown() + { + if (MediaControlServer.IsRunning) + { + MediaControlServer.Stop(); + } + + _manager.Dispose(); + } + + [Test] + [Category("P1")] + [Description("Create PlaybackCommand instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackCommand.PlaybackCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaybackCommand_CHECK_CREATE_CONSTRUCTOR() + { + Assert.IsNotNull(_command, "Object should not be null after initializing"); + Assert.IsInstanceOf(_command, "Should return PlaybackCommand instance"); + } + + [Test] + [Category("P2")] + [Description("Check whether PlaybackCommand throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackCommand.PlaybackCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaybackCommand_THROWS_EXCEPTION() + { + Assert.Throws(() => new PlaybackCommand(MediaControlPlaybackCommand.Play - 1)); + Assert.Throws(() => new PlaybackCommand(MediaControlPlaybackCommand.Toggle + 1)); + } + + [Test] + [Category("P1")] + [Description("Check whether Action property is type of MediaControlPlaybackCommand or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackCommand.Action A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Action_READ_ONLY() + { + Assert.That(_command.Action, Is.TypeOf()); + } + } +} \ No newline at end of file diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackPositionCommand.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackPositionCommand.cs new file mode 100755 index 0000000..f397a77 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackPositionCommand.cs @@ -0,0 +1,64 @@ +using NUnit.Framework; +using System.Linq; +using Tizen.Applications; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.PlaybackPositionCommand class")] + public class PlaybackPositionCommandTests + { + private MediaController _controller; + private MediaControllerManager _manager; + private PlaybackPositionCommand _command; + private ulong _position = 10U; + + [SetUp] + public void SetUp() + { + MediaControlServer.Start(); + + _manager = new MediaControllerManager(); + _controller = _manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + _command = new PlaybackPositionCommand(_position); + } + + [TearDown] + public void TearDown() + { + if (MediaControlServer.IsRunning) + { + MediaControlServer.Stop(); + } + + _manager.Dispose(); + } + + [Test] + [Category("P1")] + [Description("Create PlaybackPositionCommand instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackPositionCommand.PlaybackPositionCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaybackPositionCommand_CHECK_CREATE_CONSTRUCTOR() + { + Assert.IsNotNull(_command, "Object should not be null after initializing"); + Assert.IsInstanceOf(_command, "Should return PlaybackPositionCommand instance"); + } + + [Test] + [Category("P1")] + [Description("Check whether Position property is type of ulong or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackPositionCommand.Position A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Position_READ_ONLY() + { + Assert.IsInstanceOf(_command.Position); + Assert.That(() => _command.Position, Is.EqualTo(_position)); + } + } +} \ No newline at end of file diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackPositionCommandReceivedEventArgs.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackPositionCommandReceivedEventArgs.cs new file mode 100755 index 0000000..0ea6b53 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaybackPositionCommandReceivedEventArgs.cs @@ -0,0 +1,50 @@ +using NUnit.Framework; +using System; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.PlaybackPositionCommandReceivedEventArgs class")] + public class PlaybackPositionCommandReceivedEventArgsTests + { + [Test] + [Category("P1")] + [Description("Create PlaybackPositionCommandReceivedEventArgs instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackPositionCommandReceivedEventArgs.PlaybackPositionCommandReceivedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaybackPositionCommandReceivedEventArgs_CONSTRUCTOR() + { + Assert.That(() => new PlaybackPositionCommandReceivedEventArgs(new PlaybackPositionCommand(10)), Throws.Nothing); + } + + [Test] + [Category("P2")] + [Description("Check whether PlaybackPositionCommandReceivedEventArgs throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackPositionCommandReceivedEventArgs.PlaybackPositionCommandReceivedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaybackPositionCommandReceivedEventArgs_THROWS_EXCEPTION() + { + Assert.Throws(() => new PlaybackPositionCommandReceivedEventArgs(null)); + } + + [Test] + [Category("P1")] + [Description("Check whether Command property is instance of PlaybackPositionCommand or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaybackPositionCommandReceivedEventArgs.Command A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Command_READ_ONLY() + { + var position = 10U; + var args = new PlaybackPositionCommandReceivedEventArgs(new PlaybackPositionCommand(position)); + + Assert.IsInstanceOf(args.Command.Position); + Assert.That(() => args.Command.Position, Is.EqualTo(position)); + } + } +} diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaylistCommand.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaylistCommand.cs new file mode 100755 index 0000000..bb8ed84 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaylistCommand.cs @@ -0,0 +1,156 @@ +using NUnit.Framework; +using System; +using System.Linq; +using System.Threading.Tasks; +using Tizen.Applications; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.PlaylistCommand class")] + public class PlaylistCommandTests + { + private MediaController _controller; + private MediaControllerManager _manager; + private PlaylistCommand _command; + private MediaControlPlaybackCommand _action = MediaControlPlaybackCommand.Play; + private string _playlistName = "MyFavor"; + private string _index = "ID1"; + private ulong _position = 10U; + + [SetUp] + public void SetUp() + { + MediaControlServer.Start(); + + _manager = new MediaControllerManager(); + _controller = _manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + _command = new PlaylistCommand(_action, _playlistName, _index, _position); + } + + [TearDown] + public void TearDown() + { + if (MediaControlServer.IsRunning) + { + MediaControlServer.Stop(); + } + + _manager.Dispose(); + } + + [Test] + [Category("P1")] + [Description("Create PlaylistCommand instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistCommand.PlaylistCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("COVPARAM", "MediaControlPlaybackCommand, string, string, UInt64")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaylistCommand_CHECK_CREATE_CONSTRUCTOR() + { + Assert.IsNotNull(_command, "Object should not be null after initializing"); + Assert.IsInstanceOf(_command, "Should return PlaylistCommand instance"); + } + + [Test] + [Category("P1")] + [Description("Create PlaylistCommand instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistCommand.PlaylistCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("COVPARAM", "MediaControlPlaybackCommand, string, string")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaylistCommand_CHECK_CREATE_CONSTRUCTOR_WITHOUT_POSITION() + { + var command = new PlaylistCommand(MediaControlPlaybackCommand.Play, "test", "1"); + Assert.IsNotNull(command, "Object should not be null after initializing"); + Assert.IsInstanceOf(command, "Should return PlaylistCommand instance"); + } + + [Test] + [Category("P2")] + [Description("Check whether PlaylistCommand throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistCommand.PlaylistCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("COVPARAM", "MediaControlPlaybackCommand, string, string, UInt64")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaylistCommand_THROWS_EXCEPTION() + { + Assert.Throws(() => new PlaylistCommand(MediaControlPlaybackCommand.Play - 1, "test", "1", 10)); + Assert.Throws(() => new PlaylistCommand(MediaControlPlaybackCommand.Toggle + 1, "test", "1", 10)); + Assert.Throws(() => new PlaylistCommand(MediaControlPlaybackCommand.Play, null, "1", 10)); + Assert.Throws(() => new PlaylistCommand(MediaControlPlaybackCommand.Play, "test", null, 10)); + } + + [Test] + [Category("P2")] + [Description("Check whether PlaylistCommand throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistCommand.PlaylistCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("COVPARAM", "MediaControlPlaybackCommand, string, string")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaylistCommand_WITHOUT_POSITION_THROWS_EXCEPTION() + { + Assert.Throws(() => new PlaylistCommand(MediaControlPlaybackCommand.Play - 1, "test", "1")); + Assert.Throws(() => new PlaylistCommand(MediaControlPlaybackCommand.Toggle + 1, "test", "1")); + Assert.Throws(() => new PlaylistCommand(MediaControlPlaybackCommand.Play, null, "1")); + Assert.Throws(() => new PlaylistCommand(MediaControlPlaybackCommand.Play, "test", null)); + } + + [Test] + [Category("P1")] + [Description("Check whether Action property is type of MediaControlPlaybackCommand or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistCommand.Action A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Action_READ_ONLY() + { + Assert.IsInstanceOf(_command.Action); + Assert.That(_command.Action, Is.EqualTo(_action)); + } + + [Test] + [Category("P1")] + [Description("Check whether Position property is type of ulong or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistCommand.Position A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Position_READ_ONLY() + { + Assert.IsInstanceOf(_command.Position); + Assert.That(_command.Position, Is.EqualTo(_position)); + } + + [Test] + [Category("P1")] + [Description("Check whether Index property is type of string or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistCommand.Index A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Index_READ_ONLY() + { + Assert.IsInstanceOf(_command.Index); + Assert.That(_command.Index, Is.EqualTo(_index)); + } + + [Test] + [Category("P1")] + [Description("Check whether Name property is type of string or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistCommand.Name A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Name_READ_ONLY() + { + Assert.IsInstanceOf(_command.Name); + Assert.That(_command.Name, Is.EqualTo(_playlistName)); + } + } +} \ No newline at end of file diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaylistCommandReceivedEventArgs.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaylistCommandReceivedEventArgs.cs new file mode 100755 index 0000000..e94e914 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaylistCommandReceivedEventArgs.cs @@ -0,0 +1,54 @@ +using NUnit.Framework; +using System; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.PlaylistCommandReceivedEventArgs class")] + public class PlaylistCommandReceivedEventArgsTests + { + [Test] + [Category("P1")] + [Description("Create PlaylistCommandReceivedEventArgs instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistCommandReceivedEventArgs.PlaylistCommandReceivedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaylistCommandReceivedEventArgs_CONSTRUCTOR() + { + Assert.That(() => new PlaylistCommandReceivedEventArgs( + new PlaylistCommand(MediaControlPlaybackCommand.Play, "test", "1")), Throws.Nothing); + } + + [Test] + [Category("P2")] + [Description("Check whether PlaylistCommandReceivedEventArgs throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistCommandReceivedEventArgs.PlaylistCommandReceivedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaylistCommandReceivedEventArgs_THROWS_EXCEPTION() + { + Assert.Throws(() => new PlaylistCommandReceivedEventArgs(null)); + } + + [Test] + [Category("P1")] + [Description("Check whether Command property is instance of PlaylistCommand or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistCommandReceivedEventArgs.Command A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Command_READ_ONLY() + { + var args = new PlaylistCommandReceivedEventArgs( + new PlaylistCommand(MediaControlPlaybackCommand.Play, "MyFavor", "ID1", 10U)); + + Assert.IsInstanceOf(args.Command); + Assert.That(args.Command.Action, Is.EqualTo(MediaControlPlaybackCommand.Play)); + Assert.That(args.Command.Position, Is.EqualTo(10U)); + Assert.That(args.Command.Index, Is.EqualTo("ID1")); + Assert.That(args.Command.Name, Is.EqualTo("MyFavor")); + } + } +} diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaylistUpdatedEventArgs.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaylistUpdatedEventArgs.cs new file mode 100755 index 0000000..32d0db9 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSPlaylistUpdatedEventArgs.cs @@ -0,0 +1,105 @@ +using NUnit.Framework; +using System; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.PlaylistUpdatedEventArgs class")] + public class PlaylistUpdatedEventArgsTests + { + [SetUp] + public void SetUp() + { + MediaControlServer.Start(); + } + + [TearDown] + public void TearDown() + { + if (MediaControlServer.IsRunning) + { + MediaControlServer.Stop(); + } + } + + [Test] + [Category("P1")] + [Description("Create PlaylistUpdatedEventArgs instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistUpdatedEventArgs.PlaylistUpdatedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaylistUpdatedEventArgs_CONSTRUCTOR() + { + Assert.That(() => new PlaylistUpdatedEventArgs(MediaControlPlaylistMode.Updated, "test", + new MediaControlPlaylist("Song1")), Throws.Nothing); + } + + [Test] + [Category("P2")] + [Description("Check whether PlaylistUpdatedEventArgs throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistUpdatedEventArgs.PlaylistUpdatedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void PlaylistUpdatedEventArgs_THROWS_EXCEPTION() + { + Assert.Throws(() => new PlaylistUpdatedEventArgs( + MediaControlPlaylistMode.Updated - 1, "test", new MediaControlPlaylist("Song1"))); + + Assert.Throws(() => new PlaylistUpdatedEventArgs( + MediaControlPlaylistMode.Updated, null, new MediaControlPlaylist("Song1"))); + + Assert.Throws(() => new PlaylistUpdatedEventArgs( + MediaControlPlaylistMode.Updated, "test", null)); + } + + [Test] + [Category("P1")] + [Description("Check whether Mode property is type of MediaControlPlaylistMode or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistUpdatedEventArgs.Mode A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Mode_READ_ONLY() + { + var args = new PlaylistUpdatedEventArgs(MediaControlPlaylistMode.Updated, "test", + new MediaControlPlaylist("Song1")); + + Assert.IsInstanceOf(args.Mode); + Assert.That(args.Mode, Is.EqualTo(MediaControlPlaylistMode.Updated)); + } + + [Test] + [Category("P1")] + [Description("Check whether Name property is type of string or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistUpdatedEventArgs.Name A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Name_READ_ONLY() + { + var args = new PlaylistUpdatedEventArgs(MediaControlPlaylistMode.Updated, "MyFavor", + new MediaControlPlaylist("Song1")); + + Assert.IsInstanceOf(args.Name); + Assert.That(args.Name, Is.EqualTo("MyFavor")); + } + + [Test] + [Category("P1")] + [Description("Check whether Playlist property is instance of MediaControlPlaylist or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.PlaylistUpdatedEventArgs.Playlist A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Playlist_READ_ONLY() + { + var args = new PlaylistUpdatedEventArgs(MediaControlPlaylistMode.Updated, "test", + new MediaControlPlaylist("Song1")); + + Assert.IsInstanceOf(args.Playlist); + Assert.That(args.Playlist.Name, Is.EqualTo("Song1")); + } + } +} diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSRepeatModeCapabilityUpdatedEventArgs.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSRepeatModeCapabilityUpdatedEventArgs.cs old mode 100644 new mode 100755 index 5b59c75..573dcad --- a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSRepeatModeCapabilityUpdatedEventArgs.cs +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSRepeatModeCapabilityUpdatedEventArgs.cs @@ -1,5 +1,5 @@ using NUnit.Framework; -using System.Collections.Generic; +using System; namespace Tizen.Multimedia.Remoting.Tests { @@ -9,7 +9,7 @@ namespace Tizen.Multimedia.Remoting.Tests { [Test] [Category("P1")] - [Description("Constructor")] + [Description("Create RepeatModeCapabilityUpdatedEventArgs instance")] [Property("SPEC", "Tizen.Multimedia.Remoting.RepeatModeCapabilityUpdatedEventArgs.RepeatModeCapabilityUpdatedEventArgs C")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "CONSTR")] @@ -20,6 +20,19 @@ namespace Tizen.Multimedia.Remoting.Tests } [Test] + [Category("P2")] + [Description("Check whether RepeatModeCapabilityUpdatedEventArgs throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.RepeatModeCapabilityUpdatedEventArgs.RepeatModeCapabilityUpdatedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void RepeatModeCapabilityUpdatedEventArgs_THROWS_EXCEPTION() + { + Assert.Throws(() => new RepeatModeCapabilityUpdatedEventArgs(MediaControlCapabilitySupport.Supported - 1)); + Assert.Throws(() => new RepeatModeCapabilityUpdatedEventArgs(MediaControlCapabilitySupport.NotDecided + 1)); + } + + [Test] [Category("P1")] [Description("Is always not null")] [Property("SPEC", "Tizen.Multimedia.Remoting.RepeatModeCapabilityUpdatedEventArgs.Support A")] @@ -28,7 +41,11 @@ namespace Tizen.Multimedia.Remoting.Tests [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] public void Support_READ_ONLY() { - Assert.That(() => new RepeatModeCapabilityUpdatedEventArgs(MediaControlCapabilitySupport.NotSupported).Support, Is.Not.Null); + var args = new RepeatModeCapabilityUpdatedEventArgs(MediaControlCapabilitySupport.Supported); + + Assert.IsInstanceOf(args.Support); + Assert.That(args.Support, Is.EqualTo(MediaControlCapabilitySupport.Supported)); } } } + diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSRepeatModeCommand.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSRepeatModeCommand.cs new file mode 100755 index 0000000..284b6e0 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSRepeatModeCommand.cs @@ -0,0 +1,77 @@ +using NUnit.Framework; +using System; +using System.Linq; +using Tizen.Applications; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.RepeatModeCommand class")] + public class RepeatModeCommandTests + { + private MediaController _controller; + private MediaControllerManager _manager; + private RepeatModeCommand _command; + + [SetUp] + public void SetUp() + { + MediaControlServer.Start(); + + _manager = new MediaControllerManager(); + _controller = _manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + _command = new RepeatModeCommand(MediaControlRepeatMode.Off); + } + + [TearDown] + public void TearDown() + { + if (MediaControlServer.IsRunning) + { + MediaControlServer.Stop(); + } + + _manager.Dispose(); + } + + [Test] + [Category("P1")] + [Description("Create RepeatModeCommand instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.RepeatModeCommand.RepeatModeCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void RepeatModeCommand_CHECK_CREATE_CONSTRUCTOR() + { + Assert.IsNotNull(_command, "Object should not be null after initializing"); + Assert.IsInstanceOf(_command, "Should return RepeatModeCommand instance"); + } + + [Test] + [Category("P2")] + [Description("Check whether RepeatModeCommand throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.RepeatModeCommand.RepeatModeCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void RepeatModeCommand_THROWS_EXCEPTION() + { + Assert.Throws(() => new RepeatModeCommand(MediaControlRepeatMode.Off - 1)); + Assert.Throws(() => new RepeatModeCommand(MediaControlRepeatMode.OneMedia + 1)); + } + + [Test] + [Category("P1")] + [Description("Check whether Name property is type of MediaControlRepeatMode or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.RepeatModeCommand.Mode A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Mode_READ_ONLY() + { + Assert.IsInstanceOf(_command.Mode); + Assert.That(_command.Mode, Is.EqualTo(MediaControlRepeatMode.Off)); + } + } +} \ No newline at end of file diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSRepeatModeCommandReceivedEventArgs.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSRepeatModeCommandReceivedEventArgs.cs new file mode 100755 index 0000000..b8e0412 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSRepeatModeCommandReceivedEventArgs.cs @@ -0,0 +1,51 @@ +using NUnit.Framework; +using System; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.RepeatModeCommandReceivedEventArgs class")] + public class RepeatModeCommandReceivedEventArgsTests + { + [Test] + [Category("P1")] + [Description("Create RepeatModeCommandReceivedEventArgs instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.RepeatModeCommandReceivedEventArgs.RepeatModeCommandReceivedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void RepeatModeCommandReceivedEventArgs_CONSTRUCTOR() + { + Assert.That(() => new RepeatModeCommandReceivedEventArgs(new RepeatModeCommand(MediaControlRepeatMode.Off)), + Throws.Nothing); + } + + [Test] + [Category("P2")] + [Description("Check whether RepeatModeCommandReceivedEventArgs throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.RepeatModeCommandReceivedEventArgs.RepeatModeCommandReceivedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void RepeatModeCommandReceivedEventArgs_THROWS_EXCEPTION() + { + Assert.Throws(() => new RepeatModeCommandReceivedEventArgs(null)); + } + + [Test] + [Category("P1")] + [Description("Check whether Command property is type of MediaControlRepeatMode or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.RepeatModeCommandReceivedEventArgs.Command A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Command_READ_ONLY() + { + var args = new RepeatModeCommandReceivedEventArgs( + new RepeatModeCommand(MediaControlRepeatMode.Off)); + + Assert.IsInstanceOf(args.Command); + Assert.That(args.Command.Mode, Is.EqualTo(MediaControlRepeatMode.Off)); + } + } +} diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSSearchCommand.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSSearchCommand.cs new file mode 100644 index 0000000..6589b4e --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSSearchCommand.cs @@ -0,0 +1,158 @@ +using NUnit.Framework; +using System; +using System.Linq; +using System.Collections.Generic; +using System.Threading.Tasks; +using Tizen.Applications; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.SearchCommand class")] + public class SearchCommandTests + { + private MediaController _controller; + private MediaControllerManager _manager; + private SearchCommand _command; + + [SetUp] + public void SetUp() + { + MediaControlServer.Start(); + + _manager = new MediaControllerManager(); + _controller = _manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + _command = new SearchCommand(new MediaControlSearchCondition(MediaControlContentType.Image, "image", null)); + } + + [TearDown] + public void TearDown() + { + if (MediaControlServer.IsRunning) + { + MediaControlServer.Stop(); + } + + _manager.Dispose(); + } + + [Test] + [Category("P1")] + [Description("Create SearchCommand instance with the set of search conditions")] + [Property("SPEC", "Tizen.Multimedia.Remoting.SearchCommand.SearchCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("COVPARAM", "List")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SearchCommand_CHECK_CREATE_CONSTRUCTOR_WITH_LIST() + { + var command = new SearchCommand(new List + { + new MediaControlSearchCondition(MediaControlContentType.Image, "test1", null), + new MediaControlSearchCondition(MediaControlContentType.Image, "test2", null) + }); + + Assert.IsNotNull(command, "Object should not be null after initializing"); + Assert.IsInstanceOf(command, "Should return SearchCommand instance"); + } + + [Test] + [Category("P2")] + [Description("Check whether PlaylistCommand throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.SearchCommand.SearchCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("COVPARAM", "MediaControlSearchCondition")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SearchCommand_CHECK_CREATE_CONSTRUCTOR() + { + List condition = null; + Assert.Throws(() => new SearchCommand(condition)); + } + + [Test] + [Category("P1")] + [Description("Create SearchCommand instance with single search condition")] + [Property("SPEC", "Tizen.Multimedia.Remoting.SearchCommand.SearchCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("COVPARAM", "MediaControlSearchCondition")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SearchCommand_CHECK_CONTRUCTOR() + { + Assert.IsNotNull(_command, "Object should not be null after initializing"); + Assert.IsInstanceOf(_command, "Should return SearchCommand instance"); + } + + [Test] + [Category("P2")] + [Description("Check whether SearchCommand throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.SearchCommand.SearchCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("COVPARAM", "MediaControlSearchCondition")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SearchCommand_THROWS_EXCEPTION() + { + MediaControlSearchCondition condition = null; + Assert.Throws(() => new SearchCommand(condition)); + } + + [Test] + [Category("P1")] + [Description("Check whether Conditions property is null or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.SearchCommand.Conditions A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task Conditions_CHECK_EVENT() + { + using (var eventWaiter = EventAwaiter.Create()) + { + MediaControlServer.SearchCommandReceived += eventWaiter; + + await Task.Run(() => + { + _controller.RequestAsync(new SearchCommand( + new MediaControlSearchCondition(MediaControlContentType.Music, MediaControlSearchCategory.Artist, "GD", null)) + ); + }); + + var args = await eventWaiter.GetResultAsync(); + Assert.IsInstanceOf>(args.Command.Conditions); + + foreach (var iter in args.Command.Conditions) + { + Assert.That(iter.ContentType, Is.EqualTo(MediaControlContentType.Music)); + Assert.That(iter.Category, Is.EqualTo(MediaControlSearchCategory.Artist)); + Assert.That(iter.Keyword, Is.EqualTo("GD")); + } + } + } + + [Test] + [Category("P1")] + [Description("Check whether client and server communicate correctly using OnResponseCompleted internally.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.SearchCommand.OnResponseCompleted M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task OnResponseCompleted_AFTER_RESPONSE() + { + SearchCommand searchCommand = null; + + MediaControlServer.SearchCommandReceived += (s, e) => + { + searchCommand = e.Command; + + Assert.That(() => MediaControlServer.Response(searchCommand, 0, new Bundle()), Throws.Nothing); + }; + + await Task.Run(() => + { + _controller.RequestAsync(_command); + }); + } + } +} \ No newline at end of file diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSSearchCommandReceivedEventArgs.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSSearchCommandReceivedEventArgs.cs old mode 100644 new mode 100755 index ed4e31e..e92394e --- a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSSearchCommandReceivedEventArgs.cs +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSSearchCommandReceivedEventArgs.cs @@ -1,4 +1,9 @@ using NUnit.Framework; +using System; +using System.Linq; +using System.Threading; +using Tizen.Applications; +using System.Threading.Tasks; namespace Tizen.Multimedia.Remoting.Tests { @@ -7,10 +12,11 @@ namespace Tizen.Multimedia.Remoting.Tests public class SearchCommandReceivedEventArgsTests { private MediaControlSearchCondition _searchCondition = - new MediaControlSearchCondition(MediaControlContentType.Image, "image", null); + new MediaControlSearchCondition(MediaControlContentType.Music, MediaControlSearchCategory.Artist, "GD", null); + [Test] [Category("P1")] - [Description("Constructor")] + [Description("Create SearchCommandReceivedEventArgs instance")] [Property("SPEC", "Tizen.Multimedia.Remoting.SearchCommandReceivedEventArgs.SearchCommandReceivedEventArgs C")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "CONSTR")] @@ -21,16 +27,65 @@ namespace Tizen.Multimedia.Remoting.Tests } [Test] + [Category("P2")] + [Description("Check whether SearchCommandReceivedEventArgs throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.SearchCommandReceivedEventArgs.SearchCommandReceivedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void SearchCommandReceivedEventArgs_THROWS_EXCEPTION() + { + Assert.Throws(() => new SearchCommandReceivedEventArgs(null)); + } + + [Test] [Category("P1")] [Description("Is always not null")] [Property("SPEC", "Tizen.Multimedia.Remoting.SearchCommandReceivedEventArgs.Command A")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] - public void Command_READ_ONLY() + public async Task Command_READ_ONLY() { - Assert.That(() => new SearchCommandReceivedEventArgs(new SearchCommand(_searchCondition)).Command, - Is.Not.Null); + CountdownEvent countdownEvent = new CountdownEvent(1); + + MediaControlServer.Start(); + + using (var manager = new MediaControllerManager()) + { + EventHandler eventHandler = (s, e) => + { + foreach (var iter in e.Command.Conditions) + { + Assert.That(iter.ContentType, Is.EqualTo(MediaControlContentType.Music)); + Assert.That(iter.Category, Is.EqualTo(MediaControlSearchCategory.Artist)); + Assert.That(iter.Keyword, Is.EqualTo("GD")); + + countdownEvent.Signal(); + } + }; + + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + MediaControlServer.SearchCommandReceived += eventHandler; + + await Task.Run(() => + { + controller.RequestAsync(new SearchCommand(new MediaControlSearchCondition( + MediaControlContentType.Music, MediaControlSearchCategory.Artist, "GD", null)) + ); + }); + + countdownEvent.Wait(4000); + } + + if (MediaControlServer.IsRunning) + { + MediaControlServer.Stop(); + } + + countdownEvent.Dispose(); } } } diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSShuffleModeCapabilityUpdatedEventArgs.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSShuffleModeCapabilityUpdatedEventArgs.cs index 7d83a92..4c770a3 100644 --- a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSShuffleModeCapabilityUpdatedEventArgs.cs +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSShuffleModeCapabilityUpdatedEventArgs.cs @@ -1,4 +1,5 @@ using NUnit.Framework; +using System; namespace Tizen.Multimedia.Remoting.Tests { @@ -8,7 +9,7 @@ namespace Tizen.Multimedia.Remoting.Tests { [Test] [Category("P1")] - [Description("Constructor")] + [Description("Create ShuffleModeCapabilityUpdatedEventArgs instance")] [Property("SPEC", "Tizen.Multimedia.Remoting.ShuffleModeCapabilityUpdatedEventArgs.ShuffleModeCapabilityUpdatedEventArgs C")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "CONSTR")] @@ -20,16 +21,31 @@ namespace Tizen.Multimedia.Remoting.Tests } [Test] + [Category("P2")] + [Description("Check whether ShuffleModeCapabilityUpdatedEventArgs throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.ShuffleModeCapabilityUpdatedEventArgs.ShuffleModeCapabilityUpdatedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void ShuffleModeCapabilityUpdatedEventArgs_THROWS_EXCEPTION() + { + Assert.Throws(() => new ShuffleModeCapabilityUpdatedEventArgs(MediaControlCapabilitySupport.Supported - 1)); + Assert.Throws(() => new ShuffleModeCapabilityUpdatedEventArgs(MediaControlCapabilitySupport.NotDecided + 1)); + } + + [Test] [Category("P1")] - [Description("Is always not null")] + [Description("Check whether Support property is instance of MediaControlCapabilitySupport or not.")] [Property("SPEC", "Tizen.Multimedia.Remoting.ShuffleModeCapabilityUpdatedEventArgs.Support A")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] public void Support_READ_ONLY() { - Assert.That(() => new ShuffleModeCapabilityUpdatedEventArgs(MediaControlCapabilitySupport.NotSupported).Support, - Is.Not.Null); + var args = new ShuffleModeCapabilityUpdatedEventArgs(MediaControlCapabilitySupport.Supported); + + Assert.IsInstanceOf(args.Support); + Assert.That(args.Support, Is.EqualTo(MediaControlCapabilitySupport.Supported)); } } } diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSShuffleModeCommand.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSShuffleModeCommand.cs new file mode 100644 index 0000000..40dbe45 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSShuffleModeCommand.cs @@ -0,0 +1,72 @@ +using NUnit.Framework; +using System.Linq; +using System.Threading.Tasks; +using Tizen.Applications; + +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.ShuffleModeCommand class")] + public class ShuffleModeCommandTests + { + private MediaController _controller; + private MediaControllerManager _manager; + private ShuffleModeCommand _command; + + [SetUp] + public void SetUp() + { + MediaControlServer.Start(); + + _manager = new MediaControllerManager(); + _controller = _manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + _command = new ShuffleModeCommand(true); + } + + [TearDown] + public void TearDown() + { + if (MediaControlServer.IsRunning) + { + MediaControlServer.Stop(); + } + + _manager.Dispose(); + } + + [Test] + [Category("P1")] + [Description("Create ShuffleModeCommand instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.ShuffleModeCommand.ShuffleModeCommand C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void ShuffleModeCommand_CHECK_CREATE_CONSTRUCTOR() + { + Assert.IsNotNull(_command, "Object should not be null after initializing"); + Assert.IsInstanceOf(_command, "Should return ShuffleModeCommand instance"); + + var command = new ShuffleModeCommand(false); + Assert.IsNotNull(command, "Object should not be null after initializing"); + Assert.IsInstanceOf(command, "Should return ShuffleModeCommand instance"); + } + + [Test] + [Category("P1")] + [Description("Check whether Command property is type of bool or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.ShuffleModeCommand.Enabled A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Enabled_READ_ONLY() + { + Assert.IsInstanceOf(_command.Enabled); + Assert.That(_command.Enabled, Is.EqualTo(true)); + + var command = new ShuffleModeCommand(false); + Assert.IsInstanceOf(command.Enabled); + Assert.That(command.Enabled, Is.EqualTo(false)); + } + } +} \ No newline at end of file diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSShuffleModeCommandReceivedEventArgs.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSShuffleModeCommandReceivedEventArgs.cs new file mode 100755 index 0000000..4af4a50 --- /dev/null +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSShuffleModeCommandReceivedEventArgs.cs @@ -0,0 +1,52 @@ +using NUnit.Framework; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System; +using System.Linq; +namespace Tizen.Multimedia.Remoting.Tests +{ + [TestFixture] + [Description("Testing Tizen.Multimedia.Remoting.ShuffleModeCommandReceivedEventArgs class")] + public class ShuffleModeCommandReceivedEventArgsTests + { + [Test] + [Category("P1")] + [Description("Create ShuffleModeCommandReceivedEventArgs instance")] + [Property("SPEC", "Tizen.Multimedia.Remoting.ShuffleModeCommandReceivedEventArgs.ShuffleModeCommandReceivedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void ShuffleModeCommandReceivedEventArgs_CONSTRUCTOR() + { + Assert.That(() => new ShuffleModeCommandReceivedEventArgs(new ShuffleModeCommand(false)), + Throws.Nothing); + } + + [Test] + [Category("P2")] + [Description("Check whether ShuffleModeCommandReceivedEventArgs throws exception if parameter is invalid")] + [Property("SPEC", "Tizen.Multimedia.Remoting.ShuffleModeCommandReceivedEventArgs.ShuffleModeCommandReceivedEventArgs C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTN")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void ShuffleModeCommandReceivedEventArgs_THROWS_EXCEPTION() + { + Assert.Throws(() => new ShuffleModeCommandReceivedEventArgs(null)); + } + + [Test] + [Category("P1")] + [Description("Check whether Command property is instance of ShuffleModeCommand or not.")] + [Property("SPEC", "Tizen.Multimedia.Remoting.ShuffleModeCommandReceivedEventArgs.Command A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Command_READ_ONLY() + { + var args = new ShuffleModeCommandReceivedEventArgs(new ShuffleModeCommand(false)); + + Assert.IsInstanceOf(args.Command); + Assert.That(args.Command.Enabled, Is.EqualTo(false)); + } + } +} -- 2.7.4