[MediaController][TCSACR-340] Add the result code, playback state 53/239053/3
authorHaesu Gwon <haesu.gwon@samsung.com>
Tue, 21 Jul 2020 10:46:42 +0000 (19:46 +0900)
committerHaesu Gwon <haesu.gwon@samsung.com>
Wed, 29 Jul 2020 09:23:11 +0000 (18:23 +0900)
Change-Id: Id9df41564600f1685e4c9af72246045d21d98c57

tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaControlServer.cs
tct-suite-vs/Tizen.MediaController.Tests/testcase/TSMediaController.cs

index 2edc091c2a857baeae0bcaf9e1120fd656b6954a..72dabbed3058760992857101212ab396d0406c8e 100644 (file)
@@ -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<ArgumentNullException>(() => 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<CustomCommandReceivedEventArgs> 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<ArgumentNullException>(
+                () => 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<CustomCommandReceivedEventArgs> 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<ArgumentNullException>(
+                () => MediaControlServer.Response(null, MediaControlResult.Success, new Bundle()));
+        }
+
         [Test]
         [Category("P1")]
         [Description("Returns index of current playing media")]
index 0f76844495178c1f7eb096bb8daf7b18cf414284..fcc92956d1742979bc227d8486ddbff2485ef0d0 100644 (file)
@@ -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<CustomCommandReceivedEventArgs> 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<CustomCommandReceivedEventArgs> 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")]