From: gichan-jang Date: Tue, 1 Sep 2020 05:59:52 +0000 (+0900) Subject: [Tizen.MachineLearning.Inference][TCSACR-365] Add TCs for getter and setter - double X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9fa12dd21a98b4bb25b58c925550fde669e1cd32;p=test%2Ftct%2Fcsharp%2Fapi.git [Tizen.MachineLearning.Inference][TCSACR-365] Add TCs for getter and setter - double Add TCs for GetValue and SetValue methods - double Change-Id: Icd1e48e85b9a0862ba66a61a146da7a7b57faa0e 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 8a85c82a2..d1e4ee6aa 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 @@ -2915,5 +2915,472 @@ namespace Tizen.MachineLearning.Inference.Tests { } } } + + [Test] + [Category("P1")] + [Description("Get double 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, double")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void GetValue_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; + vscale_node.GetValue("sharpness", out retSharpness); + /* 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 double 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, double")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void GetValue_double_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; + vscale_node.GetValue(null, 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("P2")] + [Description("Check ArgumentException when getting double 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, double")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void GetValue_double_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; + vscale_node.GetValue("invalid_prop", 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("P2")] + [Description("Check ArgumentException when getting double 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, double")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void GetValue_double_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; + vscale_node.GetValue("", 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("P2")] + [Description("Check ArgumentException when getting boolean type value of valve node with invalid retrun value")] + [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.GetValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, double")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void GetValue_double_ArgumentException_invalid_type() + { + 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 */ + double retDrop; + /* The type of drop is a bool, but it failed because it got property value by a double. */ + valve_handle.GetValue("drop", 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("P1")] + [Description("Set double 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, double")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void SetValue_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; + vscale_node.SetValue("sharpness", 0.72); + vscale_node.GetValue("sharpness", out retSharpness); + + Assert.IsTrue(retSharpness == 0.72, "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 double 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, double")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void SetValue_double_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 */ + vscale_node.SetValue(null, 0.72); + + 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, double")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void SetValue_double_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 */ + vscale_node.SetValue("invalid_prop", 0.72); + + 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 empty name")] + [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, double")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void SetValue_double_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 */ + vscale_node.SetValue("", 0.72); + + 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 long type value for tensor sink node with invalid name")] + [Property("SPEC", "Tizen.MachineLearning.Inference.Pipeline.NodeInfo.SetValue M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("COVPARAM", "string, double")] + [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")] + public void SetValue_double_ArgumentException_invalid_type() + { + 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 normal node instance"); + + /* Test Code */ + /* The type of max-bitrate is a ulong, but it failed because it was set as a double. */ + sink_handle.SetValue("max-bitrate", 1.0); + + 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); + } + } + } } }