#define DICT_KEY_SIZE 255
#define DICT_STR_VALUE_SIZE 1024
+#define DICT_ARRAY_STR_SIZE 3
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 str_n;
+};
+
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_n = 0;
bool _parse_attr_dictionaries(const char *conf_file)
{
const char *str_value = (const char*)json_object_get_string_member(attr_obj, "value");
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)){
+ const char *subTypeStr = (char*)json_object_get_string_member(attr_obj, "subtype");
+ if (0 == strcmp("string", subTypeStr)) {
+ dict_array_str = (struct attr_array_str_entry*)realloc(dict_array_str, ++dict_array_n * sizeof(struct attr_array_str_entry));
+ snprintf(dict_array_str[dict_array_n-1].key, DICT_KEY_SIZE, "%s", str_name);
+
+ JsonArray *attr_array = json_object_get_array_member(attr_obj, "value");
+ dict_array_str[dict_array_n-1].str_n = json_array_get_length(attr_array);
+ assert_geq(DICT_ARRAY_STR_SIZE, dict_array_str[dict_array_n-1].str_n);
+
+ for (unsigned int item = 0; item < dict_array_str[dict_array_n-1].str_n; ++item) {
+ snprintf(dict_array_str[dict_array_n-1].value[item], DICT_STR_VALUE_SIZE, "%s", json_array_get_string_element(attr_array, item));
+ }
+ }
}
else
{
return false;
}
+bool _is_supported_array_str_attr(const char *key, char (*value)[DICT_ARRAY_STR_SIZE][DICT_STR_VALUE_SIZE], int *size)
+{
+ int ind = 0;
+ for(; ind < dict_array_n; ++ind)
+ {
+ if (0 == strcmp(dict_array_str[ind].key, key))
+ {
+ if (value != NULL && size != NULL)
+ {
+ *size = dict_array_str[ind].str_n;
+ for (int item = 0; item < (*size); ++item) {
+ snprintf((*value)[item], 1024, "%s", dict_array_str[ind].value[item]);
+ }
+ }
+ return true;
+ }
+ }
+
+ return false;
+}
+
/**
* @function utc_capi_media_vision_common_startup
* @description Called before each test
dict_str_n = 0;
}
+ if (NULL != dict_array_str)
+ {
+ free(dict_array_str);
+ dict_array_str = NULL;
+ dict_array_n = 0;
+ }
+
printf("capi-media-vision tests CLEANUP is completed\n");
}
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 array_str_size = 0;
+ char **real_array_str_value = NULL;
+ int real_array_str_size = -1;
bool is_supported = false;
bool are_exp_act_equal = false;
+ int item;
switch (attribute_type)
{
printf("Expected value: [%s] | Real value: [%s]\n", str_value, real_str_value);
are_exp_act_equal = 0 == strcmp(str_value, real_str_value);
free(real_str_value);
+ break;
+ case MV_ENGINE_CONFIG_ATTR_TYPE_ARRAY_STRING:
+ is_supported = _is_supported_array_str_attr(attribute_name, &array_str_value, &array_str_size);
+ if (MEDIA_VISION_ERROR_KEY_NOT_AVAILABLE ==
+ mv_engine_config_get_array_string_attribute(
+ engine_config, attribute_name, &real_array_str_value, &real_array_str_size))
+ {
+ printf("Default string attribute %s wasn't set n engine "
+ "configuration by default. Failed\n", attribute_name);
+ *isCorrect = false;
+ for(item = 0; item < real_array_str_size; ++item) {
+ free(real_array_str_value[item]);
+ }
+ free(real_array_str_value);
+ printf("FAILED\n");
+ return true;
+ }
+
+ if (array_str_size != real_array_str_size)
+ are_exp_act_equal = 1;
+ else {
+ for(item = 0; item < real_array_str_size; ++item) {
+ printf("Expected value: [%s] | Real value: [%s]\n",
+ array_str_value[item], real_array_str_value[item]);
+ are_exp_act_equal = 0 == strcmp(array_str_value[item], real_array_str_value[item]);
+ if (are_exp_act_equal != 0) {
+ break;
+ }
+ }
+ }
+
+ for(item = 0; item < real_array_str_size; ++item) {
+ free(real_array_str_value[item]);
+ }
+ free(real_array_str_value);
+
break;
default:
printf("Attribute type received in mv_supported_attribute_cb "
int ret = mv_create_engine_config(&engHandler);
assert_eq(MEDIA_VISION_ERROR_NONE, ret);
- int *size = 0;
+ int size = 0;
char **attributeValue = NULL;
ret = mv_engine_config_get_array_string_attribute(engHandler, "test", &attributeValue, &size);