[Tizen.MachineLearning.Inference][TCSACR-365] Add TCs for get normal node 04/242804/2
authorgichan-jang <gichan2.jang@samsung.com>
Fri, 21 Aug 2020 02:19:28 +0000 (11:19 +0900)
committergichan-jang <gichan2.jang@samsung.com>
Tue, 1 Sep 2020 02:45:04 +0000 (11:45 +0900)
Add TCs for GetNormal method

Change-Id: Ia9c97cd2b055bf1caeb7082ef7c3c7fe4515fc63
Signed-off-by: gichan-jang <gichan2.jang@samsung.com>
tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSPipeline.cs

index 3860209b4eb71b8db687817524f062b09522088b..f43339b8d53edff788813badf36dfc4dd61583f7 100644 (file)
@@ -994,5 +994,174 @@ namespace Tizen.MachineLearning.Inference.Tests {
                 }
             }
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Get node instance and check exception")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.GetNormal M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetNormal_NO_Exception()
+        {
+            try
+            {
+                string desc = "videotestsrc name=vsrc is-live=true ! videoconvert ! videoscale name=vscale ! " +
+                    "video/x-raw,format=RGBx,width=224,height=224,framerate=60/1 ! tensor_converter ! " +
+                    "valve name=valvex ! input-selector name=is01 ! tensor_sink name=sinkx";
+
+                var pipeline = new Pipeline(desc);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                /* Test Code */
+                var is_node = pipeline.GetNormal("is01");
+                Assert.IsNotNull(is_node, "Failed to create normal node instance");
+                Assert.IsInstanceOf<Pipeline.Node>(is_node, "Should return normal node instance");
+
+                pipeline.Dispose();
+            }
+            catch (Exception e)
+            {
+                if (e is NotSupportedException)
+                {
+                    LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+                    Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+                }
+                else
+                {
+                    Assert.IsTrue(false, e.Message);
+                }
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Check ArgumentException when getting normal node instance with null name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.GetNormal M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetNormal_ArgumentException_null_name()
+        {
+            try
+            {
+                string desc = "videotestsrc name=vsrc is-live=true ! videoconvert ! videoscale name=vscale ! " +
+                    "video/x-raw,format=RGBx,width=224,height=224,framerate=60/1 ! tensor_converter ! " +
+                    "valve name=valvex ! input-selector name=is01 ! tensor_sink name=sinkx";
+
+                var pipeline = new Pipeline(desc);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                /* Test Code */
+                var is_node = pipeline.GetNormal(null);
+
+                Assert.True(false, "DO NOT COME HERE!");
+
+            }
+            catch (Exception e)
+            {
+                if (e is NotSupportedException)
+                {
+                    LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+                    Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+                }
+                else if (e is ArgumentException)
+                {
+                    Assert.Pass("ArgumentException: passed!");
+                }
+                else
+                {
+                    Assert.Fail(e.Message);
+                }
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Check ArgumentException when getting normal node instance with invalid name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.GetNormal M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetNormal_ArgumentException_invalid_name()
+        {
+            try
+            {
+                string desc = "videotestsrc name=vsrc is-live=true ! videoconvert ! videoscale name=vscale ! " +
+                    "video/x-raw,format=RGBx,width=224,height=224,framerate=60/1 ! tensor_converter ! " +
+                    "valve name=valvex ! input-selector name=is01 ! tensor_sink name=sinkx";
+
+                var pipeline = new Pipeline(desc);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                /* Test Code */
+                var is_node = pipeline.GetNormal("invalid_name");
+
+                Assert.True(false, "DO NOT COME HERE!");
+
+            }
+            catch (Exception e)
+            {
+                if (e is NotSupportedException)
+                {
+                    LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+                    Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+                }
+                else if (e is ArgumentException)
+                {
+                    Assert.Pass("ArgumentException: passed!");
+                }
+                else
+                {
+                    Assert.Fail(e.Message);
+                }
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Check ArgumentException when getting normal node instance with empty name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.GetNormal M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetNormal_ArgumentException_empty_name()
+        {
+            try
+            {
+                string desc = "videotestsrc name=vsrc is-live=true ! videoconvert ! videoscale name=vscale ! " +
+                    "video/x-raw,format=RGBx,width=224,height=224,framerate=60/1 ! tensor_converter ! " +
+                    "valve name=valvex ! input-selector name=is01 ! tensor_sink name=sinkx";
+
+                var pipeline = new Pipeline(desc);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                /* Test Code */
+                var is_node = pipeline.GetNormal("");
+
+                Assert.True(false, "DO NOT COME HERE!");
+
+            }
+            catch (Exception e)
+            {
+                if (e is NotSupportedException)
+                {
+                    LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs");
+                    Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+                }
+                else if (e is ArgumentException)
+                {
+                    Assert.Pass("ArgumentException: passed!");
+                }
+                else
+                {
+                    Assert.Fail(e.Message);
+                }
+            }
+        }
     }
 }