[UTC][capi-media-vision][ACR-1471][Updated TC for new enumeration] 87/216087/1
authorTae-Young Chung <ty83.chung@samsung.com>
Mon, 21 Oct 2019 04:04:34 +0000 (13:04 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Mon, 21 Oct 2019 04:05:21 +0000 (13:05 +0900)
Change-Id: Ia674ce7e12a587042c2f0804c28168f14158c682
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
src/utc/capi-media-vision/utc-mv_common.c

index 106e8d5357daff19a91b47b246d6719d28c811ca..8e30734da4e1882f5f4c438fd074f0ad08e92b7a 100755 (executable)
@@ -26,6 +26,7 @@
 
 #define DICT_KEY_SIZE 255
 #define DICT_STR_VALUE_SIZE 1024
+#define DICT_ARRAY_STR_SIZE 3
 
 static bool isVisionSupported = false;
 static int gStartupError;
@@ -57,6 +58,13 @@ struct attr_str_entry
     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;
 
@@ -68,6 +76,8 @@ static struct attr_bool_entry *dict_bool = NULL;
 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)
 {
@@ -172,6 +182,20 @@ 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
         {
@@ -257,6 +281,27 @@ bool _is_supported_str_attr(const char *key, char *value)
     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
@@ -355,6 +400,13 @@ void utc_capi_media_vision_common_cleanup(void)
         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");
 }
 
@@ -404,8 +456,13 @@ bool _attribute_supported_callback(
     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)
     {
@@ -472,6 +529,42 @@ bool _attribute_supported_callback(
             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 "
@@ -1961,7 +2054,7 @@ int utc_mediavision_mv_engine_config_get_array_string_attribute_n(void)
     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);