[UTC][capi-media-controller][Non-ACR][Add test for updating empty playlist] 63/240063/4
authorjiyong.min <jiyong.min@samsung.com>
Mon, 3 Aug 2020 03:07:31 +0000 (12:07 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Mon, 3 Aug 2020 06:51:37 +0000 (15:51 +0900)
  1. add test for updating empty playlist to enhance coverity

  2. minor change.
    - remove unuseful macro
    - remove unused variable 'ret' due to build warning

Change-Id: Id39629aa90f73516db7c9c7a08f8bd49a47d3b03

src/utc/media-controller/utc-media-controller-client.c
src/utc/media-controller/utc-media-controller-common.c
src/utc/media-controller/utc-media-controller-common.h
src/utc/media-controller/utc-media-controller-server.c
src/utc/media-controller/utc-media-controller.c

index 66ac7c8940ad08b1712ae49d122b1f43cf9e40fc..3f6e743ef92dc440afd0c736d1e4b1afa14ac840 100644 (file)
 #include "tct_common.h"
 #include "utc-media-controller-common.h"
 
-#define WAIT_CALLBACK_RESULT   wait_for_async()
 
-
-//& set: MediaController
+//& set: MediaControllerClient
 static mc_server_h g_mc_server = NULL;
 static mc_client_h g_mc_client = NULL;
 static char *g_mc_server_name = NULL;
@@ -273,7 +271,7 @@ int utc_mc_client_set_server_updated_cb_p(void)
        ret = mc_server_destroy(g_mc_server);
        g_mc_server = NULL;
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -432,7 +430,7 @@ int utc_mc_client_set_metadata_updated_cb_p(void)
        ret = _mc_register_metadata(g_mc_server);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
 
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -1190,7 +1188,7 @@ int utc_mc_client_set_cmd_reply_received_cb_p(void)
 
        ret = mc_client_send_custom_cmd(g_mc_client, g_mc_server_name, g_mc_test_cmd, NULL, &g_request_id);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        assert_eq(g_mc_custom_data.result, TRUE);
        assert_eq(strcmp(g_mc_custom_data.name, g_mc_test_appname), 0);
@@ -1198,7 +1196,7 @@ int utc_mc_client_set_cmd_reply_received_cb_p(void)
 
        ret = mc_server_send_cmd_reply(g_mc_server, g_mc_custom_data.name, g_mc_custom_data.request_id, g_mc_test_result_code, NULL);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        assert_eq(g_mc_reply_data.result, TRUE);
        assert_eq(strcmp(g_mc_reply_data.name, g_mc_test_appname), 0);
@@ -2923,7 +2921,7 @@ int utc_mc_client_send_playback_action_cmd_p(void)
 
        ret = mc_client_send_playback_action_cmd(g_mc_client, g_mc_server_name, playback_action, &g_request_id);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -2976,7 +2974,7 @@ int utc_mc_client_send_playback_position_cmd_p(void)
 
        ret = mc_client_send_playback_position_cmd(g_mc_client, g_mc_server_name, g_mc_test_playback_position, &g_request_id);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -3032,7 +3030,7 @@ int utc_mc_client_send_shuffle_mode_cmd_p(void)
 
        ret = mc_client_send_shuffle_mode_cmd(g_mc_client, g_mc_server_name, g_mc_test_shuffle_mode, &g_request_id);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -3091,7 +3089,7 @@ int utc_mc_client_send_repeat_mode_cmd_p(void)
 
        ret = mc_client_send_repeat_mode_cmd(g_mc_client, g_mc_server_name, g_mc_test_repeat_mode, &g_request_id);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -3150,7 +3148,7 @@ int utc_mc_client_send_playlist_cmd_p(void)
 
        ret = mc_client_send_playlist_cmd(g_mc_client, g_mc_server_name, g_mc_test_playlist_name, g_mc_test_playlist_index, g_mc_test_playback_action, g_mc_test_playback_position, &g_request_id);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -3212,7 +3210,7 @@ int utc_mc_client_send_custom_cmd_p(void)
 
        ret = mc_client_send_custom_cmd(g_mc_client, g_mc_server_name, g_mc_test_cmd, NULL, NULL);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -3285,7 +3283,7 @@ int utc_mc_client_send_search_cmd_p(void)
 
        ret = mc_client_send_search_cmd(g_mc_client, g_mc_server_name, g_mc_search, NULL);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        /* check the search result */
        assert_neq(get_search, NULL);
@@ -3361,7 +3359,7 @@ int utc_mc_client_send_subtitles_cmd_p(void)
 
        ret = mc_client_send_subtitles_cmd(g_mc_client, g_mc_server_name, true, NULL);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -3418,7 +3416,7 @@ int utc_mc_client_send_360_mode_cmd_p(void)
 
        ret = mc_client_send_360_mode_cmd(g_mc_client, g_mc_server_name, true, NULL);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -3476,7 +3474,7 @@ int utc_mc_client_send_display_mode_cmd_p(void)
 
        ret = mc_client_send_display_mode_cmd(g_mc_client, g_mc_server_name, MC_DISPLAY_MODE_FULL_SCREEN, NULL);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -3538,7 +3536,7 @@ int utc_mc_client_send_display_rotation_cmd_p(void)
 
        ret = mc_client_send_display_rotation_cmd(g_mc_client, g_mc_server_name, MC_DISPLAY_ROTATION_270, NULL);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -3970,7 +3968,7 @@ int utc_mc_client_send_event_reply_p(void)
        for (idx = 0; idx < g_mc_test_result_codes_cnt; idx++) {
                ret = mc_server_send_custom_event(g_mc_server, g_mc_client_name, g_mc_test_event, NULL, &g_request_id);
                assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-               assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+               assert_eq(wait_for_async(), TRUE);
 
                assert_eq(g_mc_custom_data.result, TRUE);
                assert_eq(strcmp(g_mc_custom_data.name, g_mc_test_appname), 0);
@@ -3978,7 +3976,7 @@ int utc_mc_client_send_event_reply_p(void)
 
                ret = mc_client_send_event_reply(g_mc_client, g_mc_custom_data.name, g_mc_custom_data.request_id, g_mc_test_result_codes[idx], NULL);
                assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-               assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+               assert_eq(wait_for_async(), TRUE);
 
                assert_eq(g_mc_reply_data.result, TRUE);
                assert_eq(g_mc_reply_data.result_code, g_mc_test_result_codes[idx]);
index 809fc857963dcb475e64f07e98b567859e1ad151..d86fdc3fcaf7e9cfbdf598f5e4a911d158f0398d 100755 (executable)
@@ -19,7 +19,7 @@
 #define        TIMEOUT_SECONDS 5000
 
 
-//& set: MediaController-Common
+//& set: MediaControllerCommon
 
 
 //Add helper function declarations here
@@ -44,7 +44,7 @@ void signal_async(gboolean async_result)
        }
 }
 
-gboolean wait_for_async()
+gboolean wait_for_async(void)
 {
        int timeout_id = 0;
        g_mc_mainloop = g_main_loop_new(NULL, FALSE);
index d72bda8444899005b4e44da91a4cb372883c6c20..19ad4bf4f2e09188dbe4baa97f6e5f287b2474ae 100755 (executable)
@@ -29,6 +29,7 @@
 #define G_META_W 320
 #define G_META_H 240
 
+
 //& set: MediaControllerCommon
 
 //Add global variables here
@@ -154,7 +155,7 @@ void _mc_client_display_rotation_ability_updated_cb(const char *server_name, uns
 
 
 //Add helper function declarations here
-gboolean wait_for_async();
+gboolean wait_for_async(void);
 gboolean _mc_get_display_mode_ability(unsigned int supported_modes);
 gboolean _mc_get_display_rotation_ability(unsigned int supported_rotations);
 void _mc_release_tc_user_data(tc_user_data *user_data);
index 3366d67e10291a49635c21969a10c80e806e4195..ebd4ce253e9c3f265c91500de30d5ed73e0bf243 100644 (file)
@@ -16,9 +16,8 @@
 #include "tct_common.h"
 #include "utc-media-controller-common.h"
 
-#define WAIT_CALLBACK_RESULT   wait_for_async()
-
 
+//& set: MediaControllerServer
 static mc_server_h g_mc_server = NULL;
 static mc_client_h g_mc_client = NULL;
 static char *g_mc_server_name = NULL;
@@ -550,7 +549,7 @@ int utc_mc_server_update_playback_ability_p(void)
 
        ret = mc_server_update_playback_ability(g_mc_server);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -591,7 +590,7 @@ int utc_mc_server_set_shuffle_ability_p(void)
 
        ret = mc_server_set_shuffle_ability(g_mc_server, g_mc_test_ability);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -635,7 +634,7 @@ int utc_mc_server_set_repeat_ability_p(void)
 
        ret = mc_server_set_repeat_ability(g_mc_server, g_mc_test_ability);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -681,7 +680,7 @@ int utc_mc_server_set_ability_support_p(void)
        for (i = 0; i <= MC_ABILITY_SEARCH; i++) {
                ret = mc_server_set_ability_support(g_mc_server, i, g_mc_test_ability);
                assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-               assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+               assert_eq(wait_for_async(), TRUE);
        }
 
        return 0;
@@ -741,7 +740,7 @@ int utc_mc_server_update_playback_info_p(void)
 
        ret = mc_server_update_playback_info(g_mc_server);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -783,7 +782,7 @@ int utc_mc_server_update_metadata_p(void)
        ret = _mc_register_metadata(g_mc_server);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
 
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -824,7 +823,7 @@ int utc_mc_server_update_shuffle_mode_p(void)
 
        ret = mc_server_update_shuffle_mode(g_mc_server, g_mc_test_shuffle_mode);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -868,7 +867,7 @@ int utc_mc_server_update_repeat_mode_p(void)
 
        ret = mc_server_update_repeat_mode(g_mc_server, g_mc_test_repeat_mode);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -912,7 +911,7 @@ int utc_mc_server_update_subtitles_enabled_p(void)
 
        ret = mc_server_update_subtitles_enabled(g_mc_server, true);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -953,7 +952,7 @@ int utc_mc_server_update_360_mode_enabled_p(void)
 
        ret = mc_server_update_360_mode_enabled(g_mc_server, true);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;;
 }
@@ -994,7 +993,7 @@ int utc_mc_server_update_display_mode_p(void)
 
        ret = mc_server_update_display_mode(g_mc_server, MC_DISPLAY_MODE_FULL_SCREEN);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        return 0;
 }
@@ -1035,7 +1034,7 @@ int utc_mc_server_update_display_rotation_p(void)
 
        ret = mc_server_update_display_rotation(g_mc_server, MC_DISPLAY_ROTATION_270);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
 
        return 0;
@@ -1931,7 +1930,7 @@ int utc_mc_server_send_cmd_reply_p(void)
        for (idx = 0; idx < g_mc_test_result_codes_cnt; idx++) {
                ret = mc_client_send_custom_cmd(g_mc_client, g_mc_server_name, g_mc_test_cmd, NULL, &g_request_id);
                assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-               assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+               assert_eq(wait_for_async(), TRUE);
 
                assert_eq(g_mc_custom_data.result, TRUE);
                assert_eq(strcmp(g_mc_custom_data.name, g_mc_test_appname), 0);
@@ -1939,7 +1938,7 @@ int utc_mc_server_send_cmd_reply_p(void)
 
                ret = mc_server_send_cmd_reply(g_mc_server, g_mc_custom_data.name, g_mc_custom_data.request_id, g_mc_test_result_codes[idx], NULL);
                assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-               assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+               assert_eq(wait_for_async(), TRUE);
 
                assert_eq(g_mc_reply_data.result, TRUE);
                assert_eq(g_mc_reply_data.result_code, g_mc_test_result_codes[idx]);
@@ -2108,6 +2107,9 @@ int utc_mc_server_update_playlist_done_p(void)
        ret = mc_server_create_playlist(g_mc_server, g_mc_test_playlist_name, &playlist);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
 
+       ret = mc_server_update_playlist_done(g_mc_server, playlist);
+       assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
+
        ret = mc_server_add_item_to_playlist(g_mc_server, playlist, g_mc_test_playlist_idx, MC_META_MEDIA_TITLE, g_mc_test_playlist_metadata[0]);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
        ret = mc_server_add_item_to_playlist(g_mc_server, playlist, g_mc_test_playlist_idx, MC_META_MEDIA_ARTIST, g_mc_test_playlist_metadata[1]);
@@ -2134,7 +2136,7 @@ int utc_mc_server_update_playlist_done_p(void)
        ret = mc_server_update_playlist_done(g_mc_server, playlist);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
 
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        ret = mc_playlist_destroy(playlist);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
@@ -2406,7 +2408,7 @@ int utc_mc_server_send_custom_event_p(void)
 
        ret = mc_server_send_custom_event(g_mc_server, g_mc_client_name, g_mc_test_event, NULL, NULL);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
-       assert_eq(WAIT_CALLBACK_RESULT, TRUE);
+       assert_eq(wait_for_async(), TRUE);
 
        ret = mc_client_unset_custom_event_received_cb(g_mc_client);
        assert_eq(ret, MEDIA_CONTROLLER_ERROR_NONE);
index 2ea305b99823986c672c4d7bc119b2b40a1207e9..ed26d34eccf577883cdf4e3428d79a3c8272acad 100755 (executable)
@@ -16,8 +16,6 @@
 #include "tct_common.h"
 #include "utc-media-controller-common.h"
 
-#define WAIT_CALLBACK_RESULT   wait_for_async()
-
 
 //& set: MediaController
 static mc_server_h g_mc_server = NULL;
@@ -1225,8 +1223,6 @@ int utc_mc_playback_action_is_supported_n(void)
  */
 void utc_mc_search_startup(void)
 {
-       mc_error_e ret = MEDIA_CONTROLLER_ERROR_NONE;
-
        // do nothing...
 
        return;