[Tizen.MachineLearning.Inference][TCSACR-365] Add TCs for getter and setter - template 29/242829/2
authorgichan-jang <gichan2.jang@samsung.com>
Tue, 1 Sep 2020 06:00:37 +0000 (15:00 +0900)
committergichan-jang <gichan2.jang@samsung.com>
Tue, 8 Sep 2020 09:52:55 +0000 (18:52 +0900)
Add TCs for GetValue and SetValue methods - template

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

index d1e4ee6aa0f2e1b673d47db1f6148e6f625dd395..e7045bf5e756bbdc5570f41aa5ad6f5910f38a9e 100644 (file)
@@ -3382,5 +3382,507 @@ namespace Tizen.MachineLearning.Inference.Tests {
                 }
             }
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Get the value of node's property and check exception")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue<T> M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_template_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;
+                retDrop = valve_handle.GetValue<bool>("drop");
+                /* 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("P1")]
+        [Description("Get the value of node's property and check exception")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue<T> M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_template_string_NO_Exception()
+        {
+            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 */
+                string retTensorpick;
+                retTensorpick = demux_node.GetValue<string>("tensorpick");
+                /* default value of tensorpick is "" */
+                Assert.IsTrue(retTensorpick == "", "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("P1")]
+        [Description("Get the value of node's property and check exception")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue<T> M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_template_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;
+                retKx = vsrc_node.GetValue<int>("kx");
+                /* 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("P1")]
+        [Description("Get the value of node's property and check exception")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue<T> M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_template_long_NO_Exception()
+        {
+            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 */
+                long retMaxLatency;
+                retMaxLatency = src_handle.GetValue<long>("max-latency");
+                /* default value of max latency is -1 */
+                Assert.IsTrue(retMaxLatency == -1, "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("P1")]
+        [Description("Get the value of node's property and check exception")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue<T> M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_template_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;
+                retNumPad = switch_handle.GetValue<uint>("n-pads");
+                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("P1")]
+        [Description("Get the value of node's property and check exception")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue<T> M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_template_ulong_NO_Exception()
+        {
+            try
+            {
+                var pipeline = new Pipeline(_generalPipeline);
+                Assert.IsNotNull(pipeline, "Failed to create pipeline instance");
+                Assert.IsInstanceOf<Pipeline>(pipeline, "Should return pipeline instance");
+
+                var sink_handle = pipeline.GetSink("sinkx");
+                Assert.IsNotNull(sink_handle, "Failed to create normal node instance");
+                Assert.IsInstanceOf<Pipeline.SinkNode>(sink_handle, "Should return node instance");
+
+                /* Test Code */
+                ulong retMaxBitrate;
+                retMaxBitrate = sink_handle.GetValue<ulong>("max-bitrate");
+                /* default value of max bitrate is 0 */
+                Assert.IsTrue(retMaxBitrate == 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("P1")]
+        [Description("Get the value of node's property and check exception")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue<T> M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_template_double_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 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 */
+                double retSharpness;
+                retSharpness = vscale_node.GetValue<double>("sharpness");
+
+                /* default value of sharpness is 1 */
+                Assert.IsTrue(retSharpness == 1.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 the value of node's property with null name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue<T> M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_template_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 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 */
+                double retSharpness;
+                retSharpness = vscale_node.GetValue<double>(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 the value of node's property with empty name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue<T> M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_template_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 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 */
+                double retSharpness;
+                retSharpness = vscale_node.GetValue<double>("");
+
+                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 the value of node's property with invalid name")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue<T> M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_template_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 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 */
+                double retSharpness;
+                retSharpness = vscale_node.GetValue<double>("invalid_prop");
+
+                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 the value of node's property with invalid type")]
+        [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue<T> M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("COVPARAM", "string")]
+        [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+        public void GetValue_template_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 */
+                int retSharpness;
+                /* The type of sharpness is a double, but it failed because it got property value by a int. */
+                retSharpness = vscale_node.GetValue<int>("sharpness");
+
+                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);
+                }
+            }
+        }
     }
 }