[Tizen.MachineLearning.Inference][TCSACR-365] Add TCs for getter and setter - bool 03/242803/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 05:41:07 +0000 (14:41 +0900)
Add TCs for GetValue and SetValue methods - bool

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

index 443b0263dd67865b82edb0f802376c00a940f3d2..11800cade4e593bb96730fea2e06cd9babe9cc4d 100644 (file)
@@ -190,5 +190,446 @@ namespace Tizen.MachineLearning.Inference.Tests {
                 }
             }
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Get boolean type value from valve node and check exception")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string, bool")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_bool_NO_Exception()
+        {
+            try
+            {
+                var pipeline = new Pipeline(_valvePipeline);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                var valve_handle = pipeline.GetValve("valvex");
+                Assert.IsNotNull(valve_handle, "Failed to create valve node instance");
+                Assert.IsInstanceOf<Pipeline.ValveNode>(valve_handle, "Should return valve node instance");
+
+                /* Test Code */
+                bool retDrop;
+                valve_handle.GetValue("drop", out retDrop);
+                /* default value of drop is false */
+                Assert.IsTrue(retDrop == false, "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 boolean type value of valve node with null name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, bool")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_bool_ArgumentException_null_name()
+        {
+            try
+            {
+                var pipeline = new Pipeline(_valvePipeline);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                var valve_handle = pipeline.GetValve("valvex");
+                Assert.IsNotNull(valve_handle, "Failed to create valve node instance");
+                Assert.IsInstanceOf<Pipeline.ValveNode>(valve_handle, "Should return valve node instance");
+
+                /* Test Code */
+                bool retDrop;
+                valve_handle.GetValue(null, out retDrop);
+
+                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 boolean type value of valve node with invalid name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, bool")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_bool_ArgumentException_invalid_name()
+        {
+            try
+            {
+                var pipeline = new Pipeline(_valvePipeline);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                var valve_handle = pipeline.GetValve("valvex");
+                Assert.IsNotNull(valve_handle, "Failed to create valve node instance");
+                Assert.IsInstanceOf<Pipeline.ValveNode>(valve_handle, "Should return valve node instance");
+
+                /* Test Code */
+                bool retDrop;
+                valve_handle.GetValue("invalid_prop", out retDrop);
+
+                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 boolean type value of valve node with empty name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, bool")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_bool_ArgumentException_empty_name()
+        {
+            try
+            {
+                var pipeline = new Pipeline(_valvePipeline);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                var valve_handle = pipeline.GetValve("valvex");
+                Assert.IsNotNull(valve_handle, "Failed to create valve node instance");
+                Assert.IsInstanceOf<Pipeline.ValveNode>(valve_handle, "Should return valve node instance");
+
+                /* Test Code */
+                bool retDrop;
+                valve_handle.GetValue("", out retDrop);
+
+                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 string type value of normal node with invalid retrun value")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, bool")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_bool_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 */
+                bool retTensorpick;
+                /* The type of tensorpick is a string, but it failed because it got property value by a bool. */
+                demux_node.GetValue("tensorpick", out retTensorpick);
+
+                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 boolean type value for valve node and check exception")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string, bool")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_bool_NO_Exception()
+        {
+            try
+            {
+                var pipeline = new Pipeline(_valvePipeline);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                var valve_handle = pipeline.GetValve("valvex");
+                Assert.IsNotNull(valve_handle, "Failed to create valve node instance");
+                Assert.IsInstanceOf<Pipeline.ValveNode>(valve_handle, "Should return valve node instance");
+
+                /* Test Code */
+                bool retDrop;
+                valve_handle.SetValue("drop", true);
+                valve_handle.GetValue("drop", out retDrop);
+                Assert.IsTrue(retDrop == true, "Failed to set 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 boolean type value for valve node with null name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, bool")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_bool_ArgumentException_null_name()
+        {
+            try
+            {
+                var pipeline = new Pipeline(_valvePipeline);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                var valve_handle = pipeline.GetValve("valvex");
+                Assert.IsNotNull(valve_handle, "Failed to create valve node instance");
+                Assert.IsInstanceOf<Pipeline.ValveNode>(valve_handle, "Should return valve node instance");
+
+                /* Test Code */
+                valve_handle.SetValue(null, false);
+
+                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 boolean type value for valve node with invalid name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, bool")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_bool_ArgumentException_invalid_name()
+        {
+            try
+            {
+                var pipeline = new Pipeline(_valvePipeline);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                var valve_handle = pipeline.GetValve("valvex");
+                Assert.IsNotNull(valve_handle, "Failed to create valve node instance");
+                Assert.IsInstanceOf<Pipeline.ValveNode>(valve_handle, "Should return valve node instance");
+
+                /* Test Code */
+                valve_handle.SetValue("invalid_name", false);
+
+                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 boolean type value for valve node with empty name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, bool")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_bool_ArgumentException_empty_name()
+        {
+            try
+            {
+                var pipeline = new Pipeline(_valvePipeline);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                var valve_handle = pipeline.GetValve("valvex");
+                Assert.IsNotNull(valve_handle, "Failed to create valve node instance");
+                Assert.IsInstanceOf<Pipeline.ValveNode>(valve_handle, "Should return valve node instance");
+
+                /* Test Code */
+                valve_handle.SetValue("", false);
+
+                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 double 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, bool")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_bool_ArgumentException_invalid_type()
+        {
+            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 vscale_node = pipeline.GetNormal("vscale");
+                Assert.IsNotNull(vscale_node, "Failed to create normal node instance");
+                Assert.IsInstanceOf<Pipeline.Node>(vscale_node, "Should return normal node instance");
+
+                /* Test Code */
+                /* The type of sharpness is a double, but it failed because it was set as bool. */
+                vscale_node.SetValue("sharpness", false);
+
+                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);
+                }
+            }
+        }
     }
 }