From: gichan-jang Date: Tue, 1 Sep 2020 06:00:37 +0000 (+0900) Subject: [Tizen.MachineLearning.Inference][TCSACR-365] Add TCs for getter and setter - template X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=68c903448b5dc387f78325b9b3969327412b0688;p=test%2Ftct%2Fcsharp%2Fapi.git [Tizen.MachineLearning.Inference][TCSACR-365] Add TCs for getter and setter - template Add TCs for GetValue and SetValue methods - template Change-Id: I3f870bafe56b57129b9272e2f0146be679e18c5d Signed-off-by: gichan-jang --- diff --git a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSPipeline.NodeInfo.cs b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSPipeline.NodeInfo.cs index d1e4ee6aa..e7045bf5e 100644 --- a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSPipeline.NodeInfo.cs +++ b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSPipeline.NodeInfo.cs @@ -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 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, "Should return pipeline instance"); + + var valve_handle = pipeline.GetValve("valvex"); + Assert.IsNotNull(valve_handle, "Failed to create valve node instance"); + Assert.IsInstanceOf(valve_handle, "Should return valve node instance"); + + /* Test Code */ + bool retDrop; + retDrop = valve_handle.GetValue("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 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, "Should return pipeline instance"); + + var demux_node = pipeline.GetNormal("demux"); + Assert.IsNotNull(demux_node, "Failed to create normal node instance"); + Assert.IsInstanceOf(demux_node, "Should return normal node instance"); + + /* Test Code */ + string retTensorpick; + retTensorpick = demux_node.GetValue("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 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, "Should return pipeline instance"); + + var vsrc_node = pipeline.GetNormal("vsrc"); + Assert.IsNotNull(vsrc_node, "Failed to create normal node instance"); + Assert.IsInstanceOf(vsrc_node, "Should return normal node instance"); + + /* Test Code */ + int retKx; + retKx = vsrc_node.GetValue("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 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, "Should return pipeline instance"); + + var src_handle = pipeline.GetSource("srcx"); + Assert.IsNotNull(src_handle, "Failed to create source node instance"); + Assert.IsInstanceOf(src_handle, "Should return source node instance"); + + /* Test Code */ + long retMaxLatency; + retMaxLatency = src_handle.GetValue("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 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, "Should return pipeline instance"); + + var switch_handle = pipeline.GetSwitch("is01"); + Assert.IsNotNull(switch_handle, "Failed to create switch instance"); + Assert.IsInstanceOf(switch_handle, "Should return switch instance"); + + /* Test Code */ + uint retNumPad; + retNumPad = switch_handle.GetValue("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 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, "Should return pipeline instance"); + + var sink_handle = pipeline.GetSink("sinkx"); + Assert.IsNotNull(sink_handle, "Failed to create normal node instance"); + Assert.IsInstanceOf(sink_handle, "Should return node instance"); + + /* Test Code */ + ulong retMaxBitrate; + retMaxBitrate = sink_handle.GetValue("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 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, "Should return pipeline instance"); + + var vscale_node = pipeline.GetNormal("vscale"); + Assert.IsNotNull(vscale_node, "Failed to create normal node instance"); + Assert.IsInstanceOf(vscale_node, "Should return normal node instance"); + + /* Test Code */ + double retSharpness; + retSharpness = vscale_node.GetValue("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 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, "Should return pipeline instance"); + + var vscale_node = pipeline.GetNormal("vscale"); + Assert.IsNotNull(vscale_node, "Failed to create normal node instance"); + Assert.IsInstanceOf(vscale_node, "Should return normal node instance"); + + /* Test Code */ + double retSharpness; + retSharpness = vscale_node.GetValue(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 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, "Should return pipeline instance"); + + var vscale_node = pipeline.GetNormal("vscale"); + Assert.IsNotNull(vscale_node, "Failed to create normal node instance"); + Assert.IsInstanceOf(vscale_node, "Should return normal node instance"); + + /* Test Code */ + double retSharpness; + retSharpness = vscale_node.GetValue(""); + + 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 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, "Should return pipeline instance"); + + var vscale_node = pipeline.GetNormal("vscale"); + Assert.IsNotNull(vscale_node, "Failed to create normal node instance"); + Assert.IsInstanceOf(vscale_node, "Should return normal node instance"); + + /* Test Code */ + double retSharpness; + retSharpness = vscale_node.GetValue("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 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, "Should return pipeline instance"); + + var vscale_node = pipeline.GetNormal("vscale"); + Assert.IsNotNull(vscale_node, "Failed to create normal node instance"); + Assert.IsInstanceOf(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("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); + } + } + } } }