[Tizen.MachineLearning.Inference][TCSACR-365] Add TCs for getter and setter - int 24/242824/1
authorgichan-jang <gichan2.jang@samsung.com>
Tue, 1 Sep 2020 05:44:44 +0000 (14:44 +0900)
committergichan-jang <gichan2.jang@samsung.com>
Tue, 1 Sep 2020 05:52:24 +0000 (14:52 +0900)
Add TCs for GetValue and SetValue methods - int

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

index 5cc85f86792054b6d21580013bd55eba8cd04086..4d5cc78ef73f22edb4d5685480cd3aa73e91f82d 100644 (file)
@@ -1089,5 +1089,475 @@ namespace Tizen.MachineLearning.Inference.Tests {
                 }
             }
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Get int type value from normal node and check exception")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string, int")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_int_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");
+
+                var vsrc_node = pipeline.GetNormal("vsrc");
+                Assert.IsNotNull(vsrc_node, "Failed to create normal node instance");
+                Assert.IsInstanceOf<Pipeline.Node>(vsrc_node, "Should return normal node instance");
+
+                /* Test Code */
+                int retKx;
+                vsrc_node.GetValue("kx", out retKx);
+                /* default value of kx is 0 */
+                Assert.IsTrue(retKx == 0, "Failed to get the value of normal node");
+
+                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 int type value of normal node with null name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, int")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_int_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");
+
+                var vsrc_node = pipeline.GetNormal("vsrc");
+                Assert.IsNotNull(vsrc_node, "Failed to create normal node instance");
+                Assert.IsInstanceOf<Pipeline.Node>(vsrc_node, "Should return normal node instance");
+
+                /* Test Code */
+                int retKx;
+                vsrc_node.GetValue(null, out retKx);
+
+                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 int type value of normal node with invalid name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, int")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_int_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");
+
+                var vsrc_node = pipeline.GetNormal("vsrc");
+                Assert.IsNotNull(vsrc_node, "Failed to create normal node instance");
+                Assert.IsInstanceOf<Pipeline.Node>(vsrc_node, "Should return normal node instance");
+
+                /* Test Code */
+                int retKx;
+                vsrc_node.GetValue("invalid_prop", out retKx);
+
+                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 int type value of normal node with empty name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, int")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_int_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");
+
+                var vsrc_node = pipeline.GetNormal("vsrc");
+                Assert.IsNotNull(vsrc_node, "Failed to create normal node instance");
+                Assert.IsInstanceOf<Pipeline.Node>(vsrc_node, "Should return normal node instance");
+
+                /* Test Code */
+                int retKx;
+                vsrc_node.GetValue("", out retKx);
+
+                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 long type value of appsrc node with invalid retrun value")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, int")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_int_ArgumentException_invalid_type()
+        {
+            try
+            {
+                var pipeline = new Pipeline(_appsrcPipeline);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                var src_handle = pipeline.GetSource("srcx");
+                Assert.IsNotNull(src_handle, "Failed to create source node instance");
+                Assert.IsInstanceOf<Pipeline.SourceNode>(src_handle, "Should return source node instance");
+
+                /* Test Code */
+                int retMaxLatency;
+                /* The type of max-latency is a long, but it failed because it got property value by a int. */
+                src_handle.GetValue("max-latency", out retMaxLatency);
+
+                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("P1")]
+        [Description("Set int type value for normal node and check exception")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string, int")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_int_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");
+
+                var vsrc_node = pipeline.GetNormal("vsrc");
+                Assert.IsNotNull(vsrc_node, "Failed to create normal node instance");
+                Assert.IsInstanceOf<Pipeline.Node>(vsrc_node, "Should return normal node instance");
+
+                /* Test Code */
+                int retKx;
+                vsrc_node.SetValue("kx", -1234);
+                vsrc_node.GetValue("kx", out retKx);
+
+                Assert.IsTrue(retKx == -1234, "Failed to get the value of normal node");
+
+                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 setting int type value for normal node with null name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, int")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_int_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");
+
+                var vsrc_node = pipeline.GetNormal("vsrc");
+                Assert.IsNotNull(vsrc_node, "Failed to create normal node instance");
+                Assert.IsInstanceOf<Pipeline.Node>(vsrc_node, "Should return normal node instance");
+
+                /* Test Code */
+                vsrc_node.SetValue(null, -1234);
+
+                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 setting int type value for normal node with invalid name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, int")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_int_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");
+
+                var vsrc_node = pipeline.GetNormal("vsrc");
+                Assert.IsNotNull(vsrc_node, "Failed to create normal node instance");
+                Assert.IsInstanceOf<Pipeline.Node>(vsrc_node, "Should return normal node instance");
+
+                /* Test Code */
+                vsrc_node.SetValue("invalid_prop", -1234);
+
+                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 setting int type value for normal node with empty name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, int")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_int_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");
+
+                var vsrc_node = pipeline.GetNormal("vsrc");
+                Assert.IsNotNull(vsrc_node, "Failed to create normal node instance");
+                Assert.IsInstanceOf<Pipeline.Node>(vsrc_node, "Should return normal node instance");
+
+                /* Test Code */
+                vsrc_node.SetValue("", -1234);
+
+                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 setting string type value for normal node with invalid name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, int")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_int_ArgumentException_invalid_type()
+        {
+            try
+            {
+                string desc = "videotestsrc ! video/x-raw,format=RGB,width=640,height=480 ! videorate max-rate=1 ! " +
+                    "tensor_converter ! tensor_mux ! tensor_demux name=demux ! tensor_sink";
+
+                var pipeline = new Pipeline(desc);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                var demux_node = pipeline.GetNormal("demux");
+                Assert.IsNotNull(demux_node, "Failed to create normal node instance");
+                Assert.IsInstanceOf<Pipeline.Node>(demux_node, "Should return normal node instance");
+
+                /* Test Code */
+                /* The type of tensorpick is a string, but it failed because it was set as a int. */
+                demux_node.SetValue("tensorpick", 1);
+
+                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);
+                }
+            }
+        }
     }
 }