From: Haesu Gwon Date: Tue, 21 Jul 2020 10:46:42 +0000 (+0900) Subject: [MediaController][TCSACR-340] Add the result code, playback state X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F53%2F239053%2F3;p=test%2Ftct%2Fcsharp%2Fapi.git [MediaController][TCSACR-340] Add the result code, playback state Change-Id: Id9df41564600f1685e4c9af72246045d21d98c57 --- diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlServer.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlServer.cs index 2edc091c2..72dabbed3 100644 --- a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlServer.cs +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlServer.cs @@ -286,7 +286,7 @@ namespace Tizen.Multimedia.Remoting.Tests [Test] [Category("P1")] - [Description("Thows nothing when RequestAsync to client")] + [Description("Throws nothing when RequestAsync to client")] [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.RequestAsync M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] @@ -418,7 +418,7 @@ namespace Tizen.Multimedia.Remoting.Tests [Test] [Category("P1")] - [Description("Thows nothing when response to client")] + [Description("Throws nothing when response to client")] [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.Response M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] @@ -472,6 +472,151 @@ namespace Tizen.Multimedia.Remoting.Tests Assert.Throws(() => MediaControlServer.Response(null, 0)); } + [Test] + [Category("P1")] + [Description("Throws nothing when response to client")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("COVPARAM", "Command, MediaControlResult")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task Response_WITH_MEDIACONTROLRESULT_THROWS_NOTHING() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + foreach(MediaControlResult result in Enum.GetValues(typeof(MediaControlResult))) + { + EventHandler eventHandler = (s, e) => + { + var customCommand = e.Command; + + Assert.That(() => MediaControlServer.Response(customCommand, result), Throws.Nothing); + }; + + try + { + MediaControlServer.CustomCommandReceived += eventHandler; + + await Task.Run(() => + { + var serverResult = controller.RequestCommandAsync(new CustomCommand("Custom")); + Assert.AreEqual(serverResult.Result.result, (int)result, "Should be same value"); + }); + } + 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, MediaControlResult")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Response_WITH_MEDIACONTROLRESULT_THROWS_INVALIDOPERATIONEXCEPTION() + { + MediaControlServer.Stop(); + + Assert.That(() => MediaControlServer.Response(new CustomCommand("custom"), + MediaControlResult.Success), Throws.InvalidOperationException); + } + + [Test] + [Category("P2")] + [Description("Check whether Response throws exception if argument is null")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "Command, MediaControlResult")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Response_WITH_MEDIACONTROLRESULT_THROWS_ARGUMENTNULLEXCEPTION() + { + Assert.Throws( + () => MediaControlServer.Response(null, MediaControlResult.Success)); + } + + [Test] + [Category("P1")] + [Description("Throws nothing when response to client")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("COVPARAM", "Command, MediaControlResult, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task Response_WITH_MEDIACONTROLRESULT_BUNDLE_THROWS_NOTHING() + { + using (var manager = new MediaControllerManager()) + { + var controller = manager.GetActiveControllers().Single( + c => c.ServerAppId == Application.Current.ApplicationInfo.ApplicationId); + + foreach (MediaControlResult result in Enum.GetValues(typeof(MediaControlResult))) + { + EventHandler eventHandler = (s, e) => + { + var customCommand = e.Command; + + Assert.That(() => MediaControlServer.Response(customCommand, result, new Bundle()), + Throws.Nothing); + }; + + try + { + MediaControlServer.CustomCommandReceived += eventHandler; + + await Task.Run(() => + { + var serverResult = controller.RequestCommandAsync(new CustomCommand("Custom")); + Assert.AreEqual(serverResult.Result.result, (int)result, "Should be same value"); + }); + } + 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, MediaControlResult, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Response_WITH_MEDIACONTROLRESULT_BUNDLE_THROWS_INVALIDOPERATIONEXCEPTION() + { + MediaControlServer.Stop(); + + Assert.That(() => MediaControlServer.Response(new CustomCommand("custom"), + MediaControlResult.Success, new Bundle()), Throws.InvalidOperationException); + } + + [Test] + [Category("P2")] + [Description("Check whether Response throws exception if argument is null")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaControlServer.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "Command, MediaControlResult, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Response_WITH_MEDIACONTROLRESULT_BUNDLE_THROWS_ARGUMENTNULLEXCEPTION() + { + Assert.Throws( + () => MediaControlServer.Response(null, MediaControlResult.Success, new Bundle())); + } + [Test] [Category("P1")] [Description("Returns index of current playing media")] diff --git a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaController.cs b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaController.cs index 0f7684449..fcc92956d 100644 --- a/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaController.cs +++ b/tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaController.cs @@ -1117,6 +1117,146 @@ namespace Tizen.Multimedia.Remoting.Tests Assert.That(() => _controller.Response(null, 0, new Bundle()), 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, MediaControlResult")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task Response_WITH_MEDIACONTROLRESULT_THROWS_NOTHING() + { + CustomCommand customCommand = null; + + foreach (MediaControlResult result in Enum.GetValues(typeof(MediaControlResult))) + { + EventHandler eventHandler = (s, e) => + { + customCommand = e.Command; + + Assert.That(() => _controller.Response(customCommand, result), Throws.Nothing); + }; + + try + { + _controller.CustomCommandReceived += eventHandler; + + await Task.Run(() => + { + var clientResult = MediaControlServer.RequestCommandAsync(new CustomCommand("CustomCommand"), + Application.Current.ApplicationInfo.ApplicationId); + + Assert.AreEqual(clientResult.Result.result, (int)result, "Should be same value"); + }); + } + finally + { + _controller.CustomCommandReceived -= eventHandler; + } + } + } + + [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, MediaControlResult")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Response_WITH_MEDIACONTROLRESULT_THROWS_INVALIDOPERATIONEXCEPTION() + { + MediaControlServer.Stop(); + + Assert.That(() => _controller.Response(new CustomCommand("Custom"), + MediaControlResult.Success), Throws.InvalidOperationException); + } + + [Test] + [Category("P2")] + [Description("Check whether Response throws exception if argument is null")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "Command, MediaControlResult")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Response_WITH_MEDIACONTROLRESULT_THROWS_ARGUMENTNULLEXCEPTION() + { + Assert.That(() => _controller.Response(null, + MediaControlResult.Success), 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, MediaControlResult, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public async Task Response_WITH_MEDIACONTROLRESULT_BUNDLE_THROWS_NOTHING() + { + CustomCommand customCommand = null; + + foreach (MediaControlResult result in Enum.GetValues(typeof(MediaControlResult))) + { + EventHandler eventHandler = (s, e) => + { + customCommand = e.Command; + + Assert.That(() => _controller.Response(customCommand, result, new Bundle()), Throws.Nothing); + }; + + try + { + _controller.CustomCommandReceived += eventHandler; + + await Task.Run(() => + { + var clientResult = MediaControlServer.RequestCommandAsync(new CustomCommand("CustomCommand"), + Application.Current.ApplicationInfo.ApplicationId); + + Assert.AreEqual(clientResult.Result.result, (int)result, "Should be same value"); + }); + } + finally + { + _controller.CustomCommandReceived -= eventHandler; + } + } + } + + [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, MediaControlResult, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Response_WITH_MEDIACONTROLRESULT_BUNDLE_THROWS_INVALIDOPERATIONEXCEPTION() + { + MediaControlServer.Stop(); + + Assert.That(() => _controller.Response(new CustomCommand("Custom"), + MediaControlResult.Success, new Bundle()), Throws.InvalidOperationException); + } + + [Test] + [Category("P2")] + [Description("Check whether Response throws exception if argument is null")] + [Property("SPEC", "Tizen.Multimedia.Remoting.MediaController.Response M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "Command, MediaControlResult, Bundle")] + [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")] + public void Response_WITH_MEDIACONTROLRESULT_BUNDLE_THROWS_ARGUMENTNULLEXCEPTION() + { + Assert.That(() => _controller.Response(null, + MediaControlResult.Success, new Bundle()), Throws.ArgumentNullException); + } + [Test] [Category("P1")] [Description("Invoked when server sends custom command")]