#define DICT_KEY_SIZE 255
#define DICT_STR_VALUE_SIZE 1024
+#define DICT_ARRAY_STR_SIZE 10
static bool isVisionSupported = false;
static int gStartupError;
char value[DICT_STR_VALUE_SIZE];
};
+struct attr_array_str_entry
+{
+ char key[DICT_KEY_SIZE];
+ char value[DICT_ARRAY_STR_SIZE][DICT_STR_VALUE_SIZE];
+ int size;
+};
+
static mv_engine_config_h engine_config = NULL;
static bool _is_broken_config = false;
static int dict_bool_n = 0;
static struct attr_str_entry *dict_str = NULL;
static int dict_str_n = 0;
+static struct attr_array_str_entry *dict_array_str = NULL;
+static int dict_array_str_n = 0;
bool _parse_attr_dictionaries(const char *conf_file)
{
assert_geq(DICT_STR_VALUE_SIZE, strlen(str_value));
snprintf(dict_str[dict_str_n-1].value, DICT_STR_VALUE_SIZE, "%s", str_value);
}
+ else if (0 == strcmp("array", str_type))
+ {
+ dict_array_str = (struct attr_array_str_entry*)realloc(dict_array_str, ++dict_array_str_n * sizeof(struct attr_array_str_entry));
+ snprintf(dict_array_str[dict_array_str_n-1].key, DICT_KEY_SIZE, "%s", str_name);
+ JsonArray *attr_array = json_object_get_array_member(attr_obj, "value");
+ assert_geq(DICT_ARRAY_STR_SIZE, json_array_get_length(attr_array));
+ for (unsigned int item = 0; item < json_array_get_length(attr_array); ++item)
+ {
+ const char *str_value = (const char*)json_array_get_string_element(attr_array, item);
+ assert_geq(DICT_STR_VALUE_SIZE, strlen(str_value));
+ snprintf(dict_array_str[dict_array_str_n].value[item], DICT_STR_VALUE_SIZE, "%s", str_value);
+ }
+ dict_array_str[dict_array_str_n].size = json_array_get_length(attr_array);
+ }
else
{
printf("Attribute %s wasn't parsed from json file. Type isn't supported.", str_name);
return false;
}
+bool _is_supported_array_str_attr(const char *key, char **value)
+{
+ int ind = 0;
+ for(; ind < dict_array_str_n; ++ind)
+ {
+ if (0 == strcmp(dict_array_str[ind].key, key))
+ {
+ if (value != NULL)
+ {
+ snprintf(value, 1024, "%s", dict_str[ind].value);
+ }
+ return true;
+ }
+ }
+
+ return false;
+}
+
/**
* @function utc_capi_media_vision_common_startup
* @description Called before each test
bool isImageRecognitionSupported = false;
bool isBarcodeDetectionSupported = false;
bool isBarcodeGenerationSupported = false;
+ bool isVisionInferenceImageSupported = false;
+ bool isVisionInferenceFaceSupported = false;
system_info_get_platform_bool("http://tizen.org/feature/vision.face_recognition", &isFaceRecognitionSupported);
system_info_get_platform_bool("http://tizen.org/feature/vision.image_recognition", &isImageRecognitionSupported);
system_info_get_platform_bool("http://tizen.org/feature/vision.barcode_detection", &isBarcodeDetectionSupported);
system_info_get_platform_bool("http://tizen.org/feature/vision.barcode_generation", &isBarcodeGenerationSupported);
+ system_info_get_platform_bool("http://tizen.org/feature/vision.inference.image", &isVisionInferenceImageSupported);
+ system_info_get_platform_bool("http://tizen.org/feature/vision.inference.face", &isVisionInferenceFaceSupported);
if (isFaceRecognitionSupported || isImageRecognitionSupported ||
- isBarcodeDetectionSupported || isBarcodeGenerationSupported)
+ isBarcodeDetectionSupported || isBarcodeGenerationSupported ||
+ isVisionInferenceImageSupported || isVisionInferenceFaceSupported)
isVisionSupported = true;
else
isVisionSupported = false;
bool real_bool_value = true;
char str_value[DICT_STR_VALUE_SIZE] = "a";
char *real_str_value;
+ char array_str_value[DICT_ARRAY_STR_SIZE][DICT_STR_VALUE_SIZE] = {"a",};
+ int real_array_size;
+ char **real_array_str_value;
bool is_supported = false;
bool are_exp_act_equal = false;
return 0;
}
+/**
+ * @brief Positive test case of mv_engine_config_set_array_string_attribute()
+ * @testcase utc_mediavision_mv_engine_config_set_array_string_attribute_p
+ * @since_tizen 5.5
+ * @description Set array string type attribute
+ */
+int utc_mediavision_mv_engine_config_set_array_string_attribute_p(void)
+{
+ printf("Inside mv_engine_config_set_array_string_attribute_p\n");
+
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ mv_engine_config_h engHandler = NULL;
+
+ int ret = mv_create_engine_config(&engHandler);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ const char *attributeValue[2] = {"output/node1", "output/node2"};
+
+ ret = mv_engine_config_set_array_string_attribute(engHandler, "MV_INFERENCE_OUTPUT_NODE_NAMES", attributeValue, 2);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_destroy_engine_config(engHandler);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("Before return mv_engine_config_set_array_string_attribute_p\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_engine_config_set_array_string_attribute()
+ * @testcase utc_mediavision_mv_engine_config_set_array_string_attribute_n
+ * @since_tizen 5.5
+ * @description Set array string type attribute but fail
+ * because engine configuration handle is null
+ */
+int utc_mediavision_mv_engine_config_set_array_string_attribute_n(void)
+{
+ printf("Inside mv_engine_config_set_array_string_attribute_n\n");
+
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ mv_engine_config_h engHandler = NULL;
+ const char *attributeValue[2] = {"output/node1", "output/node2"};
+
+ const int ret = mv_engine_config_set_array_string_attribute(engHandler, "MV_INFERENCE_OUTPUT_NODE_NAMES", attributeValue, 2);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ printf("Before return mv_engine_config_set_string_attribute_n\n");
+
+ return 0;
+}
+
/**
* @brief Positive test case of mv_engine_config_get_double_attribute()
* @testcase utc_mediavision_mv_engine_config_get_double_attribute_p
return 0;
}
+/**
+ * @brief Positive test case of mv_engine_config_get_array_string_attribute()
+ * @testcase utc_mediavision_mv_engine_config_get_array_string_attribute_p
+ * @since_tizen 5.5
+ * @description Get array string attribute
+ */
+int utc_mediavision_mv_engine_config_get_array_string_attribute_p(void)
+{
+ printf("Inside mv_engine_config_get_array_string_attribute_p\n");
+
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ mv_engine_config_h engHandler = NULL;
+
+ int ret = mv_create_engine_config(&engHandler);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ const int expectedSize = 2;
+ const char *expectedParameterValue[2] = {"output/node1", "output/node2"};
+
+ ret = mv_engine_config_set_array_string_attribute(engHandler, "MV_INFERENCE_OUTPUT_NODE_NAMES", expectedParameterValue, 2);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ int actualSize = 0;
+ char **actualParameterValue = NULL;
+
+ ret = mv_engine_config_get_array_string_attribute(engHandler, "MV_INFERENCE_OUTPUT_NODE_NAMES", &actualParameterValue, &actualSize);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(expectedSize, actualSize);
+ for (int i = 0; i < expectedSize; ++i) {
+ assert_eq(strcmp(expectedParameterValue[i], actualParameterValue[i]), 0);
+ }
+
+ ret = mv_destroy_engine_config(engHandler);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ for (int i = 0; i < actualSize; ++i) {
+ free(actualParameterValue[i]);
+ }
+ free(actualParameterValue);
+
+ printf("Before return mv_engine_config_get_string_attribute_p\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_engine_config_get_array_string_attribute()
+ * @testcase utc_mediavision_mv_engine_config_get_array_string_attribute_n
+ * @since_tizen 5.5
+ * @description Get array string attribute but fail
+ * because key is not available
+ */
+int utc_mediavision_mv_engine_config_get_array_string_attribute_n(void)
+{
+ printf("Inside mv_engine_config_get_array_string_attribute_n\n");
+
+ if (!isVisionSupported) {
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ mv_engine_config_h engHandler = NULL;
+
+ int ret = mv_create_engine_config(&engHandler);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ int *size = 0;
+ char **attributeValue = NULL;
+
+ ret = mv_engine_config_get_array_string_attribute(engHandler, "test", &attributeValue, &size);
+ assert_eq(MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE, ret);
+
+ ret = mv_destroy_engine_config(engHandler);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+ assert_eq(0, size);
+ assert_eq(NULL, attributeValue);
+
+ printf("Before return mv_engine_config_get_array_string_attribute_n\n");
+
+ return 0;
+}
+
/**
* @brief Positive test case of mv_engine_config_foreach_supported_attribute()
* @testcase utc_mediavision_mv_engine_config_foreach_supported_attribute_p