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

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

index 1703811424ccd2feb1ce601719861095abd78d2b..2d8ff74906389f551d02abb1fe1cee3a93d9f176 100644 (file)
@@ -2002,5 +2002,475 @@ namespace Tizen.MachineLearning.Inference.Tests {
                 }
             }
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Get unsigned int type value from switch node and check exception")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string, uint")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_uint_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 switch_handle = pipeline.GetSwitch("is01");
+                Assert.IsNotNull(switch_handle, "Failed to create switch instance");
+                Assert.IsInstanceOf<Pipeline.SwitchNode>(switch_handle, "Should return switch instance");
+
+                /* Test Code */
+                uint retNumPad;
+                switch_handle.GetValue("n-pads", out retNumPad);
+                Assert.AreEqual(retNumPad, 1U, "Failed to get the value of switch 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 unsigned int type value of switch node with null name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, uint")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_uint_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 switch_handle = pipeline.GetSwitch("is01");
+                Assert.IsNotNull(switch_handle, "Failed to create switch node instance");
+                Assert.IsInstanceOf<Pipeline.SwitchNode>(switch_handle, "Should return normal switch instance");
+
+                /* Test Code */
+                uint retNumPad;
+                switch_handle.GetValue(null, out retNumPad);
+
+                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 unsigned int type value of switch node with invalid name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, uint")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_uint_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 switch_handle = pipeline.GetSwitch("is01");
+                Assert.IsNotNull(switch_handle, "Failed to create switch node instance");
+                Assert.IsInstanceOf<Pipeline.SwitchNode>(switch_handle, "Should return normal switch instance");
+
+                /* Test Code */
+                uint retNumPad;
+                switch_handle.GetValue("invalid_prop", out retNumPad);
+
+                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 unsigned int type value of switch node with empty name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, uint")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_uint_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 switch_handle = pipeline.GetSwitch("is01");
+                Assert.IsNotNull(switch_handle, "Failed to create switch node instance");
+                Assert.IsInstanceOf<Pipeline.SwitchNode>(switch_handle, "Should return normal switch instance");
+
+                /* Test Code */
+                uint retNumPad;
+                switch_handle.GetValue("", out retNumPad);
+
+                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 double 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, uint")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_uint_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 */
+                uint retSharpness;
+                /* The type of sharpness is a double, but it failed because it got property value by a uint. */
+                vscale_node.GetValue("sharpness", out retSharpness);
+
+                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 unsigned 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, uint")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_uint_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 */
+                uint retForegroundColor;
+                vsrc_node.SetValue("foreground-color", 123456U);
+                vsrc_node.GetValue("foreground-color", out retForegroundColor);
+
+                Assert.IsTrue(retForegroundColor == 123456U, "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 unsigned 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, uint")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_uint_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, 123456U);
+
+                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 unsigned 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, uint")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_uint_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", 123456U);
+
+                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 unsigned 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, uint")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_uint_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("", 123456U);
+
+                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 long type value for appsrc node with invalid name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string, uint")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void SetValue_uint_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 */
+                /* The type of max-latency is a long, but it failed because it was set as a uint. */
+                src_handle.SetValue("max-latency", 1234567U);
+
+                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);
+                }
+            }
+        }
     }
 }