From: Minje Ahn Date: Tue, 23 Nov 2021 03:40:47 +0000 (+0900) Subject: [UTC][media-content][Non-ACR] media-face code cleanup X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1c472d69143a3efa89f8756fbae2f631ac158372;p=test%2Ftct%2Fnative%2Fapi.git [UTC][media-content][Non-ACR] media-face code cleanup Change-Id: I04b1732098b79fb7c7a6f1f42a98a87ff6df0611 Signed-off-by: Minje Ahn --- diff --git a/src/utc/media-content/utc-media-face.c b/src/utc/media-content/utc-media-face.c index d8d9342c4..b06c2eade 100755 --- a/src/utc/media-content/utc-media-face.c +++ b/src/utc/media-content/utc-media-face.c @@ -16,6 +16,7 @@ #include #include #include +#include //& set: MediaFace @@ -23,67 +24,26 @@ static media_face_h g_face = NULL; static media_face_h g_face_dst = NULL; static char *g_media_id = NULL; static char *g_face_id = NULL; +static char g_image_path[PATH_MAX + 1] = { 0, }; +static int startup_ret = MEDIA_CONTENT_ERROR_NONE; -static char *img_path = NULL; -static const char *img_file = "image.jpg"; - -static media_content_error_e startup_ret = MEDIA_CONTENT_ERROR_NONE; - -static bool __storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data) +static bool __face_cb(media_face_h face, void *user_data) { - if (type == STORAGE_TYPE_INTERNAL) { - img_path = (char *)malloc(strlen(path) + strlen(img_file) + 6); - memset(img_path, 0x00, strlen(path) + strlen(img_file) + 6); - snprintf(img_path, strlen(path) + strlen(img_file) + 6, "%s/res/%s", path, img_file); + if (media_face_clone(&g_face, face) != MEDIA_CONTENT_ERROR_NONE) { + FPRINTF("[Line : %d] media_face_clone failed.\\n", __LINE__); return false; } - return true; -} -static bool face_cb(media_face_h face, void *user_data) -{ - media_content_error_e ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_face_clone(&g_face, face); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - startup_ret = ret; - return false; - } - - ret = media_face_get_face_id(g_face, &g_face_id); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - startup_ret = ret; + if (media_face_get_face_id(g_face, &g_face_id) != MEDIA_CONTENT_ERROR_NONE) { + FPRINTF("[Line : %d] media_face_get_face_id failed.\\n", __LINE__); return false; } return false; } -static bool sub_face_cb(media_face_h face, void *user_data) +static bool __sub_face_cb(media_face_h face, void *user_data) { - char *face_id = NULL; - - if (face) { - media_face_get_face_id(face, &face_id); - } - - if (face_id) { - free(face_id); - face_id = NULL; - } - - return false; -} - -static bool media_item_cb(media_info_h media, void *user_data) -{ - int ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_info_get_media_id(media, &g_media_id); - if ((ret != MEDIA_CONTENT_ERROR_NONE) || (g_media_id == NULL)) { - return false; - } - return false; } @@ -95,104 +55,69 @@ static bool media_item_cb(media_info_h media, void *user_data) */ void utc_media_face_startup(void) { - int ret = MEDIA_CONTENT_ERROR_NONE; - filter_h filter = NULL; - char condition[50] = { 0, }; + char *root_path = NULL; + media_info_h media = NULL; - g_face = NULL; - g_face_dst = NULL; - g_media_id = NULL; - g_face_id = NULL; - - if (storage_foreach_device_supported(__storage_device_supported_cb, NULL) != STORAGE_ERROR_NONE) { - fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); - fprintf(stderr, " media_content_connect failed (code: %d)\n", ret); - startup_ret = ret; - return; + if (storage_get_root_directory(0, &root_path) == STORAGE_ERROR_NONE) { + snprintf(g_image_path, PATH_MAX, "%s/res/image.jpg", root_path); + FREE_MEMORY(root_path); } - ret = media_content_connect(); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); - fprintf(stderr, "media_content_connect failed (code: %d)\n", ret); - startup_ret = ret; + startup_ret = media_content_connect(); + if (startup_ret != MEDIA_CONTENT_ERROR_NONE) { + FPRINTF("[Line : %d] media_content_connect failed.\\n", __LINE__); return; } - ret = media_content_scan_file(img_path); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - startup_ret = ret; - return; + startup_ret = media_info_get_media_from_db_by_path(g_image_path, &media); + if (startup_ret != MEDIA_CONTENT_ERROR_NONE) { + startup_ret = media_info_insert_to_db(g_image_path, &media); + if (startup_ret != MEDIA_CONTENT_ERROR_NONE) { + FPRINTF("[Line : %d] media_content_connect failed.\\n", __LINE__); + return; + } } - snprintf(condition, sizeof(condition), "MEDIA_DISPLAY_NAME='%s'", img_file); - - media_filter_create(&filter); - media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT); - media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_DISPLAY_NAME, MEDIA_CONTENT_COLLATE_DEFAULT); - if (filter == NULL) { - fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); - fprintf(stderr, " media_filter_create failed (code: %d)\n", ret); - startup_ret = ret; - return; - } - - ret = media_info_foreach_media_from_db(filter, media_item_cb, NULL); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); - fprintf(stderr, " media_info_foreach_media_from_db failed (code: %d)\n", ret); - startup_ret = ret; + startup_ret = media_info_get_media_id(media, &g_media_id); + media_info_destroy(media); + if (startup_ret != MEDIA_CONTENT_ERROR_NONE) { + FPRINTF("[Line : %d] media_info_get_media_id failed.\\n", __LINE__); return; } - media_filter_destroy(filter); - filter = NULL; - - ret = media_face_create(g_media_id, &g_face); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); - fprintf(stderr, " media_face_create failed (code: %d)\n", ret); - startup_ret = ret; + startup_ret = media_face_create(g_media_id, &g_face); + if (startup_ret != MEDIA_CONTENT_ERROR_NONE) { + FPRINTF("[Line : %d] media_face_create failed.\\n", __LINE__); return; } - ret = media_face_set_face_rect(g_face, 10, 10, 10, 10); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); - fprintf(stderr, " media_face_set_face_rect failed (code: %d)\n", ret); - startup_ret = ret; + startup_ret = media_face_set_face_rect(g_face, 10, 10, 10, 10); + if (startup_ret != MEDIA_CONTENT_ERROR_NONE) { + FPRINTF("[Line : %d] media_face_set_face_rect failed.\\n", __LINE__); return; } - ret = media_face_set_tag(g_face, "Test"); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); - fprintf(stderr, " media_face_set_tag failed (code: %d)\n", ret); - startup_ret = ret; + startup_ret = media_face_set_tag(g_face, "Test"); + if (startup_ret != MEDIA_CONTENT_ERROR_NONE) { + FPRINTF("[Line : %d] media_face_set_tag failed.\\n", __LINE__); return; } - ret = media_face_insert_to_db(g_face); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); - fprintf(stderr, " media_face_insert_to_db failed (code: %d)\n", ret); - startup_ret = ret; + startup_ret = media_face_insert_to_db(g_face); + if (startup_ret != MEDIA_CONTENT_ERROR_NONE) { + FPRINTF("[Line : %d] media_face_insert_to_db failed.\\n", __LINE__); return; } - ret = media_face_destroy(g_face); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); - fprintf(stderr, " media_face_destroy failed (code: %d)\n", ret); - startup_ret = ret; + startup_ret = media_face_destroy(g_face); + if (startup_ret != MEDIA_CONTENT_ERROR_NONE) { + FPRINTF("[Line : %d] media_face_destroy failed.\\n", __LINE__); return; } - ret = media_info_foreach_face_from_db(g_media_id, NULL, face_cb, NULL); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); - fprintf(stderr, " media_info_foreach_face_from_db failed (code: %d)\n", ret); - startup_ret = ret; + startup_ret = media_info_foreach_face_from_db(g_media_id, NULL, __face_cb, NULL); + if (startup_ret != MEDIA_CONTENT_ERROR_NONE) { + FPRINTF("[Line : %d] media_info_foreach_face_from_db failed.\\n", __LINE__); return; } } @@ -205,15 +130,11 @@ void utc_media_face_startup(void) */ void utc_media_face_cleanup(void) { - if (g_media_id) { - free(g_media_id); - g_media_id = NULL; - } + FREE_MEMORY(g_media_id); if (g_face_id) { media_face_delete_from_db(g_face_id); - free(g_face_id); - g_face_id = NULL; + FREE_MEMORY(g_face_id); } if (g_face) { @@ -226,10 +147,8 @@ void utc_media_face_cleanup(void) g_face_dst = NULL; } - if (img_path) { - free(img_path); - img_path = NULL; - } + memset(&g_image_path, 0, PATH_MAX + 1); + media_content_disconnect(); } @@ -242,23 +161,7 @@ int utc_media_face_clone_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - char *face_id = NULL; - - ret = media_face_clone(&g_face_dst, g_face); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - media_face_get_face_id(g_face_dst, &face_id); - if (strncmp(g_face_id, face_id, strlen(face_id)) == 0) { - ret = MEDIA_CONTENT_ERROR_NONE; - } else { - ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION; - } - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - - if (face_id) { - free(face_id); - face_id = NULL; - } + assert_eq(media_face_clone(&g_face_dst, g_face), MEDIA_CONTENT_ERROR_NONE); return 0; } @@ -272,10 +175,9 @@ int utc_media_face_clone_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; + assert_eq(media_face_clone(&g_face_dst, NULL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = media_face_clone(&g_face_dst, NULL); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_clone(NULL, g_face), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } @@ -289,10 +191,7 @@ int utc_media_face_destroy_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_face_clone(&g_face_dst, g_face); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_clone(&g_face_dst, g_face), MEDIA_CONTENT_ERROR_NONE); return 0; } @@ -306,10 +205,7 @@ int utc_media_face_destroy_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_face_destroy(NULL); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_destroy(NULL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } @@ -323,16 +219,10 @@ int utc_media_face_get_face_id_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; char *face_id = NULL; - ret = media_face_get_face_id(g_face, &face_id); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - - if (face_id) { - free(face_id); - face_id = NULL; - } + assert_eq(media_face_get_face_id(g_face, &face_id), MEDIA_CONTENT_ERROR_NONE); + FREE_MEMORY(face_id); return 0; } @@ -346,11 +236,11 @@ int utc_media_face_get_face_id_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; char *face_id = NULL; - ret = media_face_get_face_id(NULL, &face_id); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_get_face_id(NULL, &face_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + + assert_eq(media_face_get_face_id(g_face, NULL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } @@ -364,16 +254,10 @@ int utc_media_face_get_media_id_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; char *media_id = NULL; - ret = media_face_get_media_id(g_face, &media_id); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - - if (media_id) { - free(media_id); - media_id = NULL; - } + assert_eq(media_face_get_media_id(g_face, &media_id), MEDIA_CONTENT_ERROR_NONE); + FREE_MEMORY(media_id); return 0; } @@ -387,11 +271,11 @@ int utc_media_face_get_media_id_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; char *media_id = NULL; - ret = media_face_get_media_id(NULL, &media_id); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_get_media_id(NULL, &media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + + assert_eq(media_face_get_media_id(g_face, NULL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } @@ -405,17 +289,16 @@ int utc_media_face_get_face_rect_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - unsigned int rect_x = -1; - unsigned int rect_y = -1; - unsigned int rect_w = -1; - unsigned int rect_h = -1; + unsigned int rect_x = 0; + unsigned int rect_y = 0; + unsigned int rect_w = 0; + unsigned int rect_h = 0; - ret = media_face_get_face_rect(g_face, &rect_x, &rect_y, &rect_w, &rect_h); - if (rect_x <= 0 || rect_y <= 0 || rect_w <= 0 || rect_h <= 0) - ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION; - - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_get_face_rect(g_face, &rect_x, &rect_y, &rect_w, &rect_h), MEDIA_CONTENT_ERROR_NONE); + assert_eq(rect_x, 10); + assert_eq(rect_y, 10); + assert_eq(rect_w, 10); + assert_eq(rect_h, 10); return 0; } @@ -429,14 +312,20 @@ int utc_media_face_get_face_rect_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - unsigned int rect_x = -1; - unsigned int rect_y = -1; - unsigned int rect_w = -1; - unsigned int rect_h = -1; + unsigned int rect_x = 0; + unsigned int rect_y = 0; + unsigned int rect_w = 0; + unsigned int rect_h = 0; + + assert_eq(media_face_get_face_rect(NULL, &rect_x, &rect_y, &rect_w, &rect_h), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + + assert_eq(media_face_get_face_rect(g_face, NULL, &rect_y, &rect_w, &rect_h), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = media_face_get_face_rect(NULL, &rect_x, &rect_y, &rect_w, &rect_h); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_get_face_rect(g_face, &rect_x, NULL, &rect_w, &rect_h), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + + assert_eq(media_face_get_face_rect(g_face, &rect_x, &rect_y, NULL, &rect_h), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + + assert_eq(media_face_get_face_rect(g_face, &rect_x, &rect_y, &rect_w, NULL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } @@ -450,11 +339,9 @@ int utc_media_face_get_orientation_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - media_content_orientation_e orient; + media_content_orientation_e orient = MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE; - ret = media_face_get_orientation(g_face, &orient); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_get_orientation(g_face, &orient), MEDIA_CONTENT_ERROR_NONE); return 0; } @@ -468,11 +355,11 @@ int utc_media_face_get_orientation_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - media_content_orientation_e orient; + media_content_orientation_e orient = MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE; + + assert_eq(media_face_get_orientation(NULL, &orient), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = media_face_get_orientation(NULL, &orient); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_get_orientation(g_face, NULL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } @@ -486,16 +373,10 @@ int utc_media_face_get_tag_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; char *tag = NULL; - ret = media_face_get_tag(g_face, &tag); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - - if (tag) { - free(tag); - tag = NULL; - } + assert_eq(media_face_get_tag(g_face, &tag), MEDIA_CONTENT_ERROR_NONE); + FREE_MEMORY(tag); return 0; } @@ -509,11 +390,11 @@ int utc_media_face_get_tag_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; char *tag = NULL; - ret = media_face_get_tag(NULL, &tag); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_get_tag(NULL, &tag), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + + assert_eq(media_face_get_tag(g_face, NULL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } @@ -527,10 +408,7 @@ int utc_media_face_create_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_face_create(g_media_id, &g_face_dst); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_create(g_media_id, &g_face_dst), MEDIA_CONTENT_ERROR_NONE); return 0; } @@ -544,33 +422,13 @@ int utc_media_face_create_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; + assert_eq(media_face_create(NULL, &g_face_dst), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = media_face_destroy(NULL); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_create(g_face, NULL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } -static bool _set_face_rect_cb(media_face_h face, void *user_data) -{ - int ret = MEDIA_CONTENT_ERROR_NONE; - unsigned int rect_x = -1; - unsigned int rect_y = -1; - unsigned int rect_w = -1; - unsigned int rect_h = -1; - - ret = media_face_get_face_rect(g_face, &rect_x, &rect_y, &rect_w, &rect_h); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - - if (rect_x != 20 || rect_y != 20 || rect_w != 20 || rect_h != 20) { - ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION; - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - } - - return false; -} - /** * @testcase utc_media_face_set_face_rect_p * @since_tizen 3.0 @@ -580,15 +438,9 @@ int utc_media_face_set_face_rect_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - ret = media_face_set_face_rect(g_face, 20, 20, 20, 20); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_set_face_rect(g_face, 20, 20, 20, 20), MEDIA_CONTENT_ERROR_NONE); - ret = media_face_update_to_db(g_face); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - - ret = media_info_foreach_face_from_db(g_media_id, NULL, _set_face_rect_cb, NULL); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_update_to_db(g_face), MEDIA_CONTENT_ERROR_NONE); return 0; } @@ -602,30 +454,11 @@ int utc_media_face_set_face_rect_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_face_set_face_rect(NULL, 20, 20, 20, 20); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_set_face_rect(NULL, 20, 20, 20, 20), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } -static bool _set_orientation_cb(media_face_h face, void *user_data) -{ - int ret = MEDIA_CONTENT_ERROR_NONE; - media_content_orientation_e orient; - - ret = media_face_get_orientation(g_face, &orient); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - - if (orient != MEDIA_CONTENT_ORIENTATION_NORMAL) { - ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION; - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - } - - return false; -} - /** * @testcase utc_media_face_set_orientation_p * @since_tizen 3.0 @@ -635,15 +468,9 @@ int utc_media_face_set_orientation_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - ret = media_face_set_orientation(g_face, MEDIA_CONTENT_ORIENTATION_NORMAL); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - - ret = media_face_update_to_db(g_face); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_set_orientation(g_face, MEDIA_CONTENT_ORIENTATION_NORMAL), MEDIA_CONTENT_ERROR_NONE); - ret = media_info_foreach_face_from_db(g_media_id, NULL, _set_orientation_cb, NULL); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_update_to_db(g_face), MEDIA_CONTENT_ERROR_NONE); return 0; } @@ -657,30 +484,11 @@ int utc_media_face_set_orientation_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_face_set_orientation(NULL, MEDIA_CONTENT_ORIENTATION_NORMAL); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_set_orientation(NULL, MEDIA_CONTENT_ORIENTATION_NORMAL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } -static bool _set_tag_cb(media_face_h face, void *user_data) -{ - int ret = MEDIA_CONTENT_ERROR_NONE; - char *tag = NULL; - - ret = media_face_get_tag(g_face, &tag); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - - if (strncmp(tag, "new_tag", strlen("new_tag")) != 0) { - ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION; - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - } - - return false; -} - /** * @testcase utc_media_face_set_tag_p * @since_tizen 3.0 @@ -690,15 +498,9 @@ int utc_media_face_set_tag_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - ret = media_face_set_tag(g_face, "new_tag"); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_set_tag(g_face, "new_tag"), MEDIA_CONTENT_ERROR_NONE); - ret = media_face_update_to_db(g_face); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - - ret = media_info_foreach_face_from_db(g_media_id, NULL, _set_tag_cb, NULL); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_update_to_db(g_face), MEDIA_CONTENT_ERROR_NONE); return 0; } @@ -712,10 +514,7 @@ int utc_media_face_set_tag_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_face_set_tag(NULL, "new_tag"); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_set_tag(NULL, "new_tag"), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } @@ -730,26 +529,16 @@ int utc_media_face_insert_to_db_p(void) assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); char *face_id = NULL; - int ret = MEDIA_CONTENT_ERROR_NONE; - ret = media_face_clone(&g_face_dst, g_face); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - - ret = media_face_set_face_rect(g_face_dst, 15, 15, 15, 15); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_clone(&g_face_dst, g_face), MEDIA_CONTENT_ERROR_NONE); - ret = media_face_insert_to_db(g_face_dst); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_set_face_rect(g_face_dst, 15, 15, 15, 15), MEDIA_CONTENT_ERROR_NONE); - ret = media_face_get_face_id(g_face_dst, &face_id); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_insert_to_db(g_face_dst), MEDIA_CONTENT_ERROR_NONE); - ret = media_face_delete_from_db(face_id); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_get_face_id(g_face_dst, &face_id), MEDIA_CONTENT_ERROR_NONE); - if (face_id) { - free(face_id); - face_id = NULL; - } + assert_eq(media_face_delete_from_db(face_id), MEDIA_CONTENT_ERROR_NONE); + FREE_MEMORY(face_id); return 0; } @@ -763,10 +552,7 @@ int utc_media_face_insert_to_db_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_face_insert_to_db(NULL); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_insert_to_db(NULL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } @@ -780,9 +566,7 @@ int utc_media_face_update_to_db_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - ret = media_face_update_to_db(g_face); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_update_to_db(g_face), MEDIA_CONTENT_ERROR_NONE); return 0; } @@ -796,10 +580,7 @@ int utc_media_face_update_to_db_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_face_update_to_db(NULL); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_update_to_db(NULL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } @@ -814,26 +595,16 @@ int utc_media_face_delete_from_db_p(void) assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); char *face_id = NULL; - int ret = MEDIA_CONTENT_ERROR_NONE; - ret = media_face_clone(&g_face_dst, g_face); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_clone(&g_face_dst, g_face), MEDIA_CONTENT_ERROR_NONE); - ret = media_face_set_face_rect(g_face_dst, 15, 15, 15, 15); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_set_face_rect(g_face_dst, 15, 15, 15, 15), MEDIA_CONTENT_ERROR_NONE); - ret = media_face_insert_to_db(g_face_dst); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_insert_to_db(g_face_dst), MEDIA_CONTENT_ERROR_NONE); - ret = media_face_get_face_id(g_face_dst, &face_id); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_get_face_id(g_face_dst, &face_id), MEDIA_CONTENT_ERROR_NONE); - ret = media_face_delete_from_db(face_id); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); - - if (face_id) { - free(face_id); - face_id = NULL; - } + assert_eq(media_face_delete_from_db(face_id), MEDIA_CONTENT_ERROR_NONE); + FREE_MEMORY(face_id); return 0; } @@ -847,10 +618,7 @@ int utc_media_face_delete_from_db_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_face_delete_from_db(NULL); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_delete_from_db(NULL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } @@ -864,11 +632,9 @@ int utc_media_face_get_face_count_from_db_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; int face_cnt = 0; - ret = media_face_get_face_count_from_db(NULL, &face_cnt); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_get_face_count_from_db(NULL, &face_cnt), MEDIA_CONTENT_ERROR_NONE); return 0; } @@ -882,10 +648,7 @@ int utc_media_face_get_face_count_from_db_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_face_get_face_count_from_db(NULL, NULL); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_get_face_count_from_db(NULL, NULL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; } @@ -899,10 +662,7 @@ int utc_media_face_foreach_face_from_db_p(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_face_foreach_face_from_db(NULL, sub_face_cb, NULL); - assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); + assert_eq(media_face_foreach_face_from_db(NULL, __sub_face_cb, NULL), MEDIA_CONTENT_ERROR_NONE); return 0; } @@ -916,10 +676,7 @@ int utc_media_face_foreach_face_from_db_n(void) { assert_eq(startup_ret, MEDIA_CONTENT_ERROR_NONE); - int ret = MEDIA_CONTENT_ERROR_NONE; - - ret = media_face_foreach_face_from_db(NULL, NULL, NULL); - assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + assert_eq(media_face_foreach_face_from_db(NULL, NULL, NULL), MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; }