+ media_content_remove_db_updated_cb(noti_h_2);
+
+ return ret;
+}
+
+bool media_face_test_cb(media_face_h face, void *user_data)
+{
+ get_face_meta(face);
+
+ if (user_data != NULL) {
+ media_face_h new_face = NULL;
+ media_face_clone(&new_face, face);
+
+ GList **list = (GList**)user_data;
+ *list = g_list_append(*list, new_face);
+ }
+
+ return true;
+}
+
+int test_face(void)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ filter_h filter = NULL;
+ GList *all_item_list = NULL;
+ int i = 0;
+
+ ret = media_filter_create(&filter);
+ content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_filter_create");
+
+ ret = media_filter_set_condition(filter, "MEDIA_TYPE = 0", MEDIA_CONTENT_COLLATE_DEFAULT);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ media_filter_destroy(filter);
+ content_error("Fail to set condition");
+ return ret;
+ }
+
+ ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ content_error("media_info_foreach_media_from_db failed: %d", ret);
+ media_filter_destroy(filter);
+ return ret;
+ }
+
+ for (i = 0; i < g_list_length(all_item_list); i++) {
+ media_info_h media_handle = NULL;
+ char *media_id = NULL;
+ int face_count = 0;
+
+ media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
+
+ ret = media_info_get_media_id(media_handle, &media_id);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_info_get_media_id failed: %d", ret);
+
+ ret = media_info_get_face_count_from_db(media_id, filter, &face_count);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_info_get_face_count_from_db failed: %d", ret);
+
+ content_error("media_id [%s] face_count [%d]", media_id, face_count);
+
+ ret = media_info_foreach_face_from_db(media_id, filter, media_face_test_cb, NULL);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_info_foreach_face_from_db failed: %d", ret);
+
+ media_info_destroy(media_handle);
+ }
+
+ media_filter_destroy(filter);
+
+ return ret;
+}
+
+int test_face_add_del(void)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char *media_id = "ecca7366-e085-41d8-a12b-cbdfc2b9c5fc";
+
+ /* Insert Test */
+ media_face_h face = NULL;
+
+ char *face_tag = "test_face_tag";
+
+ ret = media_face_create(media_id, &face);
+ content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_face_create");
+
+ ret = media_face_set_face_rect(face, 10, 12, 50, 100);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_face_set_face_rect failed: %d", ret);
+
+ ret = media_face_set_orientation(face, 5);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_face_set_orientation failed: %d", ret);
+
+ ret = media_face_set_tag(face, face_tag);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_face_set_tag failed: %d", ret);
+
+ ret = media_face_insert_to_db(face);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_face_insert_to_db failed: %d", ret);
+
+ ret = media_face_destroy(face);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_face_destroy failed: %d", ret);
+
+ /* Update Test */
+ GList *all_item_list = NULL;
+ filter_h filter = NULL;
+ ret = media_filter_create(&filter);
+ content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_filter_create");
+
+ ret = media_filter_set_condition(filter, "MEDIA_FACE_TAG IS NOT NULL", MEDIA_CONTENT_COLLATE_DEFAULT);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ media_filter_destroy(filter);
+ content_error("Fail to set condition");
+ return ret;
+ }
+
+ ret = media_info_foreach_face_from_db(media_id, filter, media_face_test_cb, &all_item_list);
+
+ if (g_list_length(all_item_list) > 0) {
+ media_face_h face_handle = NULL;
+ face_handle = (media_face_h)g_list_nth_data(all_item_list, 0);
+
+ ret = media_face_set_face_rect(face_handle, 20, 22, 70, 70);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_face_set_face_rect failed: %d", ret);
+ ret = media_face_set_orientation(face_handle, 3);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_face_set_orientation failed: %d", ret);
+ ret = media_face_set_tag(face_handle, NULL);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_face_set_tag failed: %d", ret);
+ ret = media_face_update_to_db(face_handle);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_face_update_to_db failed: %d", ret);
+
+ media_face_destroy(face_handle);
+ }
+
+ media_filter_destroy(filter);
+
+ /* Delete Test */
+ char *face_id = "5e58a3a8-f0b2-4c29-b799-b49a70dc2313";
+
+ /* Delete Test*/
+ ret = media_face_delete_from_db(face_id);
+
+ return ret;
+}
+
+#ifdef _USE_TVPD_MODE
+filter_h g_tv_filter = NULL;
+
+int test_tv_filter_create(void)
+{
+ content_debug("\n============Filter Create============\n\n");
+
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ ret = media_filter_create(&g_tv_filter);
+
+ ret = media_filter_set_storage(g_tv_filter, "0a22a163-e634-4a2e-ba14-0469a969eea0");
+
+ ret = media_filter_set_order(g_tv_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_STORAGE_ID, MEDIA_CONTENT_COLLATE_DEFAULT);
+
+ return ret;
+}
+
+int test_tv_filter_destroy(void)
+{
+ content_debug("\n============Filter Destroy============\n\n");
+
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ ret = media_filter_destroy(g_tv_filter);
+
+ return ret;
+}
+
+bool pvr_item_cb(media_pvr_h pvr, void *user_data)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char *c_value = NULL;
+ int i_value = 0;
+ bool b_value = false;
+ unsigned long long l_value = 0;
+
+ if (pvr == NULL) {
+ content_debug("NO Item");
+ return true;
+ }
+
+ ret = media_pvr_get_media_id(pvr, &c_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_media_id");
+ content_debug("media_id [%s]", c_value);
+ SAFE_FREE(c_value);
+
+ ret = media_pvr_get_channel_name(pvr, &c_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_channel_name");
+ content_debug("channel_name [%s]", c_value);
+ SAFE_FREE(c_value);
+
+ ret = media_pvr_get_program_title(pvr, &c_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_program_title");
+ content_debug("program_title [%s]", c_value);
+ SAFE_FREE(c_value);
+
+ ret = media_pvr_get_program_crid(pvr, &c_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_program_crid");
+ content_debug("program_crid [%s]", c_value);
+ SAFE_FREE(c_value);
+
+ ret = media_pvr_get_guidance(pvr, &c_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_guidance");
+ content_debug("guidance [%s]", c_value);
+ SAFE_FREE(c_value);
+
+ ret = media_pvr_get_synopsis(pvr, &c_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_synopsis");
+ content_debug("synopsis [%s]", c_value);
+ SAFE_FREE(c_value);
+
+ ret = media_pvr_get_genre(pvr, &c_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_synopsis");
+ content_debug("genre [%s]", c_value);
+ SAFE_FREE(c_value);
+
+ ret = media_pvr_get_language(pvr, &c_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_language");
+ content_debug("language [%s]", c_value);
+ SAFE_FREE(c_value);
+
+ ret = media_pvr_get_path(pvr, &c_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_path");
+ content_debug("path [%s]", c_value);
+ SAFE_FREE(c_value);
+
+ ret = media_pvr_get_storage_id(pvr, &c_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_storage_id");
+ content_debug("storage_id [%s]", c_value);
+ SAFE_FREE(c_value);
+
+ ret = media_pvr_get_size(pvr, &l_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_size");
+ content_debug("size [%lld]", l_value);
+
+ ret = media_pvr_get_timezone(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_timezone");
+ content_debug("timezone [%d]", i_value);
+
+ ret = media_pvr_get_ptc(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_ptc");
+ content_debug("ptc [%d]", i_value);
+
+ ret = media_pvr_get_major(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_major");
+ content_debug("[%d]", i_value);
+
+ ret = media_pvr_get_minor(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_minor");
+ content_debug("minor [%d]", i_value);
+
+ ret = media_pvr_get_channel_type(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_channel_type");
+ content_debug("channel_type [%d]", i_value);
+
+ ret = media_pvr_get_program_num(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_program_num");
+ content_debug("program_num [%d]", i_value);
+
+ unsigned int ui_value = 0;
+ ret = media_pvr_get_service_profile(pvr, &ui_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_service_profile");
+ content_debug("service_profile [%u]", ui_value);
+
+ ret = media_pvr_get_duration(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_duration");
+ content_debug("duration [%d]", i_value);
+
+ ret = media_pvr_get_embargo_time(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_embargo_time");
+ content_debug("embargo_time [%d]", i_value);
+
+ ret = media_pvr_get_expiry_time(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_expiry_time");
+ content_debug("expiry_time [%d]", i_value);
+
+ ret = media_pvr_get_parental_rating(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_parental_rating");
+ content_debug("parental_rating [%d]", i_value);
+
+ ret = media_pvr_get_start_time(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_start_time");
+ content_debug("start_time [%d]", i_value);
+
+ ret = media_pvr_get_program_start_time(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_program_start_time");
+ content_debug("program_start_time [%d]", i_value);
+
+ ret = media_pvr_get_program_end_time(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_program_end_time");
+ content_debug("program_end_time [%d]", i_value);
+
+ ret = media_pvr_get_program_date(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_program_date");
+ content_debug("program_date [%d]", i_value);
+
+ ret = media_pvr_get_timer_record(pvr, &b_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_timer_record");
+ content_debug("timer_record [%d]", b_value);
+
+ ret = media_pvr_get_series_record(pvr, &b_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_series_record");
+ content_debug("series_record [%d]", b_value);
+
+ ret = media_pvr_get_hd(pvr, &i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_hd");
+ content_debug("hd [%d]", i_value);
+
+ ret = media_pvr_get_subtitle(pvr, &b_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_subtitle");
+ content_debug("subtitle [%d]", b_value);
+
+ ret = media_pvr_get_ttx(pvr, &b_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_ttx");
+ content_debug("ttx [%d]", b_value);
+
+ ret = media_pvr_get_ad(pvr, &b_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_ad");
+ content_debug("ad [%d]", b_value);
+
+ ret = media_pvr_get_hard_of_hearing_radio(pvr, &b_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_hard_of_hearing_radio");
+ content_debug("hard_of_hearing_radio [%d]", b_value);
+
+ ret = media_pvr_get_data_service(pvr, &b_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_data_service");
+ content_debug("data_service [%d]", b_value);
+
+ ret = media_pvr_get_content_lock(pvr, &b_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_content_lock");
+ content_debug("content_lock [%d]", b_value);
+
+ ret = media_pvr_get_content_watch(pvr, &b_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_content_watch");
+ content_debug("content_watch [%d]", b_value);
+
+ ret = media_pvr_get_has_audio_only(pvr, &b_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_has_audio_only");
+ content_debug("has_audio_only [%d]", b_value);
+
+ ret = media_pvr_get_is_local_record(pvr, &b_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_is_local_record");
+ content_debug("is_local_record [%d]", b_value);
+
+ ret = media_pvr_get_resolution(pvr, (media_pvr_resolution_e*)&i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_resolution");
+ content_debug("resolution [%d]", i_value);
+
+ ret = media_pvr_get_aspectratio(pvr, (media_pvr_aspectratio_e*)&i_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_aspectratio");
+ content_debug("aspectratio [%d]", i_value);
+
+ ret = media_pvr_get_highlight(pvr, &b_value);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_get_highlight");
+ content_debug("highlight [%d]", b_value);
+
+
+ return TRUE;
+}
+
+int test_pvr()
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ int media_count = 0;
+
+ content_debug("\n============PVR Test============\n\n");
+
+ test_tv_filter_create();
+
+ ret = media_pvr_get_media_count_from_db(g_tv_filter, &media_count);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_pvr_get_media_count_from_db failed: %d", ret);
+ else
+ content_debug("media_count : [%d]", media_count);
+
+ ret = media_pvr_foreach_media_from_db(g_tv_filter, pvr_item_cb, NULL);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_pvr_foreach_media_from_db is failed");
+
+ test_tv_filter_destroy();
+
+ return ret;
+}
+
+int test_pvr_update_db(void)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_pvr_h pvr = NULL;
+
+ ret = media_pvr_get_pvr_from_db("ff9b5a9a-a7b4-47f4-8255-84e007e25f13", &pvr);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("media_pvr_get_pvr_from_db failed: %d", ret);
+
+ ret = media_pvr_set_content_lock(pvr, TRUE);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_set_content_lock");
+
+ ret = media_pvr_set_content_watch(pvr, TRUE);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_set_content_watch");
+
+ ret = media_pvr_set_program_title(pvr, "TEST TITLE");
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_set_program_title");
+
+ ret = media_pvr_set_highlight(pvr, TRUE);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_set_highlight");
+
+ ret = media_pvr_update_to_db(pvr);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ content_error("Fail to media_pvr_update_to_db");
+
+ if (pvr != NULL)
+ media_pvr_destroy(pvr);