[TestFixture]
[Description("Tizen.MachineLearning.Inference.SingleShot Tests")]
- public class TSSingleShot
+ public class SingleShotTests
{
private readonly string TAG = "Tizen.MachineLearning.Inference.Tests";
private readonly string _modelPath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "mobilenet_v1_1.0_224_quant.tflite";
Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
Assert.IsNotNull(single, "Failed to create SingleShot instance");
- TensorsInfo in_info = new TensorsInfo();
- in_info.AddTensorInfo(TensorType.Float32, new int[4] { 5, 1, 1, 1 });
+ var in_info = new TensorsInfo();
+ Assert.IsNotNull(in_info, "Failed to create TensorsInfo instance");
Assert.IsInstanceOf<TensorsInfo>(in_info, "Should return TensorsInfo instance");
- Assert.IsNotNull(in_info, "Failed to create tensorsInfo instance");
+ in_info.AddTensorInfo(TensorType.Float32, new int[4] { 5, 1, 1, 1 });
/* TEST CODE */
single.Input = in_info;
Assert.IsNotNull(single, "Failed to create SingleShot instance");
/* In case of 5 : 1 : 1 : 1 */
- TensorsInfo in_info = new TensorsInfo();
- in_info.AddTensorInfo(TensorType.Float32, new int[4] { 5, 1, 1, 1 });
+ var in_info = new TensorsInfo();
+ Assert.IsNotNull(in_info, "Failed to create TensorsInfo instance");
Assert.IsInstanceOf<TensorsInfo>(in_info, "Should return TensorsInfo instance");
- Assert.IsNotNull(in_info, "Failed to create tensorsInfo instance");
+ in_info.AddTensorInfo(TensorType.Float32, new int[4] { 5, 1, 1, 1 });
/* Input data */
var in_data = new float[] { 0, 1, 2, 3, 4 };
}
}
}
+
+ [Test]
+ [Category("P1")]
+ [Description("Get value from SingleShot instance and check exceptions")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.GetValue M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("COVPARAM", "string")]
+ [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+ public void GetValue_NO_EXCEPTION()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+
+ /* TEST CODE */
+ var in_dim = single.GetValue("input");
+ Assert.IsInstanceOf<string>(in_dim, "Should return string");
+ Assert.AreEqual(in_dim, "3:224:224:1", "Failed to get input dimension");
+
+ single.Dispose();
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check exception when getting value with empty name")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.GetValue M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string")]
+ [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+ public void GetValue_CHECK_ArgumentException_Empty_Name()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+
+ /* TEST CODE */
+ var in_dim = single.GetValue("");
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check exception when getting value with null name")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.GetValue M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string")]
+ [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+ public void GetValue_CHECK_ArgumentException_Null_Name()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+
+ /* TEST CODE */
+ var in_dim = single.GetValue(null);
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check exception when getting value with unknown name")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.GetValue M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string")]
+ [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+ public void GetValue_CHECK_NotSupportedException_Unknown_Name()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+
+ /* TEST CODE */
+ var in_dim = single.GetValue("unknown_prop");
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ /* Unknown property name raises not-supported exception */
+ if (_isMachineLeanringInferenceSupported)
+ Assert.Pass("NotSupportedException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Set value and check exceptions")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SetValue M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("COVPARAM", "string, string")]
+ [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+ public void SetValue_NO_EXCEPTION()
+ {
+ Assert.IsTrue(File.Exists(_dynamicModelPath), "Cannot find the add.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_dynamicModelPath, NNFWType.Any, HWType.Any);
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+
+ /* TEST CODE */
+ single.SetValue("input", "5:1:1:1");
+ Assert.AreEqual("5:1:1:1", single.GetValue("input"), "Failed to set input dimension");
+
+ single.Dispose();
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check exception when setting value with unknown name")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SetValue M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, string")]
+ [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+ public void SetValue_CHECK_NotSupportedException_Unknown_Name()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+
+ /* TEST CODE */
+ single.SetValue("unknown_prop", "unknown");
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ /* Unknown property name raises not-supported exception */
+ if (_isMachineLeanringInferenceSupported)
+ Assert.Pass("NotSupportedException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check exception when setting value with empty name")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SetValue M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, string")]
+ [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+ public void SetValue_ArgumentException_Empty_Name()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+
+ /* TEST CODE */
+ single.SetValue("", "ANY");
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check exception when setting value with null name")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SetValue M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, string")]
+ [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+ public void SetValue_ArgumentException_Null_Name()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+
+ /* TEST CODE */
+ single.SetValue(null, "ANY");
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check exception when setting empty value")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SetValue M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, string")]
+ [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+ public void SetValue_ArgumentException_Empty_Value()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+
+ /* TEST CODE */
+ single.SetValue("input", "");
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check exception when setting null value")]
+ [Property("SPEC", "Tizen.MachineLearning.Inference.SingleShot.SetValue M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, string")]
+ [Property("AUTHOR", "Gichan Jang, gichan2.jang@samsung.com")]
+ public void SetValue_ArgumentException_Null_Value()
+ {
+ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file");
+
+ try
+ {
+ var single = new SingleShot(_modelPath, _in_info, _out_info);
+ Assert.IsNotNull(single, "Failed to create SingleShot instance");
+ Assert.IsInstanceOf<SingleShot>(single, "Should return SingleShot instance");
+
+ /* TEST CODE */
+ single.SetValue("input", null);
+
+ Assert.True(false, "DO NOT COME HERE!");
+ }
+ catch (Exception e)
+ {
+ if (e is NotSupportedException)
+ {
+ LogUtils.Write(LogUtils.DEBUG, TAG, "NotSupportedException occurs");
+ Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException");
+ }
+ else if (e is ArgumentException)
+ {
+ Assert.Pass("ArgumentException: passed!");
+ }
+ else
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+ }
}
}