[TCT][player][Non-ACR][Add network connection checking at each streaming tct]
authorEunhae Choi <eunhae1.choi@samsung.com>
Wed, 5 Sep 2018 03:43:43 +0000 (12:43 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Wed, 5 Sep 2018 12:00:14 +0000 (21:00 +0900)
- check online state and print out the result
- check connection statistics and print out the result
  at each streaming tct case

Change-Id: I7233bf19966d360789e3bd737ddb76cbddeb3be2

packaging/itc/native-player-itc.spec
packaging/utc/core-player-tests.spec
src/itc/player/CMakeLists.txt
src/itc/player/ITs-player-common.c
src/itc/player/ITs-player.c
src/utc/player/CMakeLists.txt
src/utc/player/utc-media-player-callback.c
src/utc/player/utc-media-player-streaming.c

index dce6b750fe706869711fdd5f4cacc41a620c8764..8c174b6854b8c4d2a3b9297f2baab58e94d30204 100755 (executable)
@@ -16,6 +16,8 @@ BuildRequires:        pkgconfig(bundle)
 BuildRequires: pkgconfig(appcore-efl)
 BuildRequires: pkgconfig(capi-system-info)
 BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(capi-network-connection)
+BuildRequires: pkgconfig(libcurl)
 
 %description
 Native API Integration TC (%{name})
index 37ecfa13bd0a3bdd22a7596cf413d3ba9c7aaf04..185961caf10db67ec9e1f51d9c2404f6e7710c6a 100755 (executable)
@@ -19,6 +19,9 @@ BuildRequires:        pkgconfig(elementary)
 BuildRequires: pkgconfig(ecore)
 BuildRequires: pkgconfig(evas)
 BuildRequires: pkgconfig(storage)
+BuildRequires: pkgconfig(capi-network-connection)
+BuildRequires: pkgconfig(libcurl)
+
 %description
 Core API unit TC (%{name})
 
index bb9e556f4d44826b7f0410228d24763e9c3abcc8..907a8e7480bd5117dc09288739a1303539b3b665 100755 (executable)
@@ -41,11 +41,13 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
     ${CAPI_LIB}
        capi-appfw-application
        capi-system-info
+       capi-network-connection
        dlog
        glib-2.0
        gobject-2.0
        gthread-2.0
        storage
+       libcurl
 )
 ENDIF()
 IF( DEFINED MOBILE )
@@ -55,11 +57,13 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
        bundle
        capi-appfw-application
        capi-system-info
+       capi-network-connection
        dlog
        ecore
        elementary
        evas
        glib-2.0
+       libcurl
 )
 ENDIF()
 IF( DEFINED WEARABLE )
@@ -69,11 +73,13 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
        bundle
        capi-appfw-application
        capi-system-info
+       capi-network-connection
        dlog
        ecore
        elementary
        evas
        glib-2.0
+       libcurl
 )
 ENDIF()
 
index 6cf0ae6b6875ffb8663895a31205fe6f55af7b58..31573e233db3c6c2d8b6621f63a9146b5c5499d0 100755 (executable)
@@ -15,6 +15,9 @@
 //
 #include "ITs-player-common.h"
 
+extern bool PlayerPrepareWithConnectionCheck(player_h g_player);
+extern bool CheckOnlineStatus(char *media_path);
+
 /** @addtogroup itc-player
 *  @ingroup itc
 *  @{
@@ -121,7 +124,7 @@ char* PlayerGetError(int nRet)
        case PLAYER_ERROR_DRM_NOT_PERMITTED:                                    szErrorVal = "PLAYER_ERROR_DRM_NOT_PERMITTED";                                  break;
        case PLAYER_ERROR_RESOURCE_LIMIT:                                               szErrorVal = "PLAYER_ERROR_RESOURCE_LIMIT";                                             break;
        case PLAYER_ERROR_PERMISSION_DENIED:                                    szErrorVal = "PLAYER_ERROR_PERMISSION_DENIED";                                  break;
-       case PLAYER_ERROR_BUFFER_SPACE:                                                 szErrorVal = "PLAYER_ERROR_BUFFER_SPACE";                                               break; 
+       case PLAYER_ERROR_BUFFER_SPACE:                                                 szErrorVal = "PLAYER_ERROR_BUFFER_SPACE";                                               break;
        default:                                                                                                szErrorVal = "Unknown Error";                                                                   break;
        }
 
@@ -133,7 +136,7 @@ char* PlayerGetError(int nRet)
 * @description                 Creates a player handler, sets an uri and prepares the handler
 * @parameter[IN]       bool bPrepare   [if it is true, player would be prepared. Otherwise, player would not be prepared]
 *                      [IN]    int nMediaType  [if it is 0, player_set_uri would be set with an audio file. if it is 1, player_set_uri would be set with a video file. Otherwise, player_set_uri would be set with a download source file]
-* @return                      true if successful, otherwise false. 
+* @return                      true if successful, otherwise false.
 */
 bool InitializePlayerHandler(bool bPrepare, int nMediaType)
 {
@@ -190,7 +193,7 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType)
                #endif
        }
        else if ( nMediaType == 1 )
-       { 
+       {
                nRet = player_set_uri(g_player, pPath2);
                #if defined(WEARABLE)
                        bValue = false;
@@ -206,7 +209,7 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType)
                #endif
        }
        else if ( nMediaType == 2 )
-       { 
+       {
                char pstrValue[CONFIG_VALUE_LEN_MAX] = {0,};
                if ( true == GetValueFromConfigFile("PLAYER_DOWNLOAD_URL", pstrValue, API_NAMESPACE) )
                {
@@ -230,12 +233,16 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType)
                                        FPRINTF("[Line : %d][%s] player_set_uri API call returned mismatch %s error for unsupported internet feature\\n", __LINE__, API_NAMESPACE,  PlayerGetError(nRet));
                                        return false;
                                }
-                       
+
                        }
                #endif
+
+               if (!CheckOnlineStatus(pstrValue)) {
+                       FPRINTF("[Line : %d][%s][Reference] network is disconnected\\n", __LINE__, API_NAMESPACE);
+               }
        }
        else if ( nMediaType == 3 )
-       { 
+       {
                char pstrValue[CONFIG_VALUE_LEN_MAX] = {0,};
                if ( true == GetValueFromConfigFile("PLAYER_DOWNLOAD_URL_AUDIO", pstrValue, API_NAMESPACE) )
                {
@@ -259,7 +266,7 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType)
                                        FPRINTF("[Line : %d][%s] player_set_uri API call returned mismatch %s error for unsupported internet feature\\n", __LINE__, API_NAMESPACE,  PlayerGetError(nRet));
                                        return false;
                                }
-               
+
                        }
                #endif
        }
@@ -294,6 +301,10 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType)
                                }
                        }
                #endif
+
+               if (!CheckOnlineStatus(pstrValue)) {
+                       FPRINTF("[Line : %d][%s][Reference] network is disconnected\\n", __LINE__, API_NAMESPACE);
+               }
        }
 
        if ( nRet != PLAYER_ERROR_NONE )
@@ -304,7 +315,11 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType)
 
        if ( bPrepare )
        {
-               nRet = player_prepare(g_player);
+               if (nMediaType == 5 ) { /* need to check connection statistics */
+                       nRet = PlayerPrepareWithConnectionCheck(g_player);
+               } else {
+                       nRet = player_prepare(g_player);
+               }
                player_get_state(g_player,&state);
                PlayerGetState(state);
                if ( nRet != PLAYER_ERROR_NONE )
@@ -327,7 +342,7 @@ bool InitializePlayerHandler(bool bPrepare, int nMediaType)
 * @function            WinDel
 * @description                 Callback function registered by evas_object_smart_callback_add API
 * @parameter[IN]       void*, Evas_Object*, void*
-* @return                      NA. 
+* @return                      NA.
 */
 void WinDel(void *data, Evas_Object *obj, void *event)
 {
@@ -338,7 +353,7 @@ void WinDel(void *data, Evas_Object *obj, void *event)
 * @function            CreateEvasWindow
 * @description                 Creates an Evas window object
 * @parameter[IN]       NA
-* @return                      Evas_Object if successful, otherwise NULL. 
+* @return                      Evas_Object if successful, otherwise NULL.
 */
 void CreateEvasWindow()
 {
@@ -394,7 +409,7 @@ char* MediaPacketGetError(int nRet)
        char *szErrorVal = NULL;
 
        switch ( nRet )
-       {               
+       {
        case MEDIA_PACKET_ERROR_NONE:                                           szErrorVal = "MEDIA_PACKET_ERROR_NONE";                                                 break;
        case MEDIA_PACKET_ERROR_INVALID_PARAMETER:                      szErrorVal = "MEDIA_PACKET_ERROR_INVALID_PARAMETER";                    break;
        case MEDIA_PACKET_ERROR_OUT_OF_MEMORY:                          szErrorVal = "MEDIA_PACKET_ERROR_OUT_OF_MEMORY";                                break;
@@ -416,7 +431,7 @@ char* MediaFormatGetError(int nRet)
        char *szErrorVal = NULL;
 
        switch ( nRet )
-       {               
+       {
        case MEDIA_FORMAT_ERROR_NONE:                                           szErrorVal = "MEDIA_FORMAT_ERROR_NONE";                                                 break;
        case MEDIA_FORMAT_ERROR_OUT_OF_MEMORY:                          szErrorVal = "MEDIA_FORMAT_ERROR_OUT_OF_MEMORY";                                break;
        case MEDIA_FORMAT_ERROR_INVALID_PARAMETER:                      szErrorVal = "MEDIA_FORMAT_ERROR_INVALID_PARAMETER";                    break;
index 3a67fa77e8ccda6bbaf984bb8e3bb159eff4292c..5c78afeeca3cf82d558419e20ec68d8c2218d573 100755 (executable)
@@ -13,7 +13,9 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 //
+#include <curl/curl.h>
 #include "ITs-player-common.h"
+#include "net_connection.h"
 
 /** @addtogroup itc-player
 *  @ingroup itc
@@ -41,6 +43,8 @@ bool g_bPlayerMediaStreamBufferStatus;
 bool g_bPlayerCallbackParameter;
 bool g_bPlayerInterruptCbCallback;
 
+static connection_h g_connection = NULL;
+
 #ifdef TIZENIOT // For TIZENIOT
        int g_nTimeoutId;
        GMainLoop *g_pMainLoop;
@@ -680,6 +684,160 @@ static void PlayerPreparedCB(void *user_data)
 }
 #endif // End MOBILE or WEARABLE
 
+bool CheckOnlineStatus(char *media_path)
+{
+       bool ret = true;
+       CURL *curl = NULL;
+       CURLcode res = CURLE_OK;
+
+       curl = curl_easy_init();
+       if(curl) {
+               curl_easy_setopt(curl, CURLOPT_URL, media_path);
+               curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 10000L);
+
+               res = curl_easy_perform(curl);
+               if(res != CURLE_OK) {
+                       FPRINTF("[Line : %d][%s] curl_easy_perform() failed: %s\n", __LINE__, API_NAMESPACE, curl_easy_strerror(res));
+                       ret = false;
+               }
+
+               curl_easy_cleanup(curl);
+       }
+
+       return ret;
+
+}
+
+bool CheckConnectionStatistics(connection_h connection, long long *size)
+{
+#define _FEATURE_NAME_WIFI      "http://tizen.org/feature/network.wifi"
+#define _FEATURE_NAME_TELEPHONY "http://tizen.org/feature/network.telephony"
+
+       long long rv = 0;
+       int err = CONNECTION_ERROR_NONE;
+       connection_type_e type = CONNECTION_TYPE_DISCONNECTED;
+       bool wifi_supported = false;
+       bool telepony_supported = false;
+
+       system_info_get_platform_bool(_FEATURE_NAME_WIFI, &wifi_supported);
+       system_info_get_platform_bool(_FEATURE_NAME_TELEPHONY, &telepony_supported);
+
+       if (wifi_supported) {
+               type = CONNECTION_TYPE_WIFI;
+       } else if (telepony_supported) {
+               type = CONNECTION_TYPE_CELLULAR;
+       } else {
+               FPRINTF("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
+               return false;
+       }
+
+       err = connection_get_statistics(connection, type, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
+
+       if (err != CONNECTION_ERROR_NONE) {
+               FPRINTF("[Line : %d][%s] Failed to check connection statistics.\\n", __LINE__, API_NAMESPACE);
+               return false;
+       } else {
+               FPRINTF("[Line : %d][%s] WiFi last recv data size [%lld]\\n", __LINE__, API_NAMESPACE, rv);
+       }
+
+       *size = rv;
+       return true;
+}
+
+
+int PlayerPrepareWithConnectionCheck(player_h g_player)
+{
+       int ret = PLAYER_ERROR_NONE;
+       long long before = 0, after = 0;
+
+       if (connection_create(&g_connection) != CONNECTION_ERROR_NONE) {
+               FPRINTF("[Line : %d][%s] Failed to create connection handle\\n", __LINE__, API_NAMESPACE);
+       } else {
+               FPRINTF("[Line : %d][%s] Success to create connection handle %p\\n", __LINE__, API_NAMESPACE, g_connection);
+       }
+
+       if (g_connection && !CheckConnectionStatistics(g_connection, &before)) {
+               FPRINTF("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE);
+       }
+
+       ret = player_prepare(g_player);
+       if (g_connection) {
+               if (!CheckConnectionStatistics(g_connection, &after)) {
+                       FPRINTF("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE);
+               } else {
+                       FPRINTF("[Line : %d][%s][Reference] total received data [%lld]\\n",
+                                                                       __LINE__, API_NAMESPACE, (after-before));
+               }
+       }
+
+       if (g_connection && connection_destroy(g_connection) != CONNECTION_ERROR_NONE) {
+               FPRINTF("[Line : %d][%s] Failed to destroy connection handle\\n", __LINE__, API_NAMESPACE);
+       }
+
+       return ret;
+}
+
+
+static int PlayerStartWithConnectionCheck(player_h g_player, char* media_path)
+{
+       int ret = PLAYER_ERROR_NONE;
+       long long before = 0, after = 0;
+
+       if (!CheckOnlineStatus(media_path)) {
+               FPRINTF("[Line : %d][%s][Reference] network is disconnected\\n", __LINE__, API_NAMESPACE);
+       }
+
+       if (connection_create(&g_connection) != CONNECTION_ERROR_NONE) {
+               FPRINTF("[Line : %d][%s] Failed to create connection handle\\n", __LINE__, API_NAMESPACE);
+       } else {
+               FPRINTF("[Line : %d][%s] Success to create connection handle %p\\n", __LINE__, API_NAMESPACE, g_connection);
+       }
+
+       if (g_connection && !CheckConnectionStatistics(g_connection, &before)) {
+               FPRINTF("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE);
+       }
+
+       ret = player_prepare(g_player);
+       if (ret != PLAYER_ERROR_NONE) {
+               if (g_connection) {
+                       if (!CheckConnectionStatistics(g_connection, &after)) {
+                               FPRINTF("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE);
+                       } else {
+                               FPRINTF("[Line : %d][%s][Reference] total received data [%lld]\\n",
+                                                                       __LINE__, API_NAMESPACE, (after-before));
+                       }
+               }
+
+               FPRINTF("[Line : %d][%s] player_prepare failed, error returned = %s\\n",
+                                                       __LINE__, API_NAMESPACE, PlayerGetError(ret));
+               goto EXIT;
+       }
+
+       sleep(3);
+
+       /* progressive download case have to include player_start for checking network env */
+       ret = player_start(g_player);
+
+       if (g_connection) {
+               if (!CheckConnectionStatistics(g_connection, &after)) {
+                       FPRINTF("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE);
+               } else {
+                       FPRINTF("[Line : %d][%s][Reference] total received data [%lld]\\n", __LINE__, API_NAMESPACE, (after-before));
+               }
+       }
+
+       if (ret != PLAYER_ERROR_NONE) {
+               FPRINTF("[Line : %d][%s] player_start failed, error returned = %s\\n",
+                                                       __LINE__, API_NAMESPACE, PlayerGetError(ret));
+       }
+
+EXIT:
+       if (g_connection && connection_destroy(g_connection) != CONNECTION_ERROR_NONE) {
+               FPRINTF("[Line : %d][%s] Failed to destroy connection handle\\n", __LINE__, API_NAMESPACE);
+       }
+
+       return ret;
+}
 
 
 /** @addtogroup itc-player-testcases
@@ -951,7 +1109,7 @@ int ITc_player_set_unset_buffering_cb_p(void)
 
        sleep(3);
 
-       nRet = player_prepare(g_player);
+       nRet = PlayerPrepareWithConnectionCheck(g_player);
        PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
 
        nRet = player_get_state(g_player,&state);
@@ -1130,13 +1288,8 @@ int ITc_player_get_progressive_download_status_p(void)
 
        sleep(3);
 
-       nRet = player_prepare(g_player);
-       PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
-
-       sleep(3);
-
-       nRet = player_start(g_player);
-       PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_start", PlayerGetError(nRet), player_unprepare(g_player));
+       nRet = PlayerStartWithConnectionCheck(g_player, pstrValue);
+       PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "start playback", PlayerGetError(nRet), player_unprepare(g_player));
 
        nRet = player_get_state(g_player,&state);
        PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_get_state", PlayerGetError(nRet), player_stop(g_player);player_unprepare(g_player));
@@ -1249,13 +1402,8 @@ int ITc_player_get_streaming_download_progress_p(void)
 
        sleep(3);
 
-       nRet = player_prepare(g_player);
-       PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
-
-       sleep(3);
-
-       nRet = player_start(g_player);
-       PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_start", PlayerGetError(nRet), player_unprepare(g_player));
+       nRet = PlayerStartWithConnectionCheck(g_player, pstrValue);
+       PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "start playback", PlayerGetError(nRet), player_unprepare(g_player));
 
        nRet = player_get_state(g_player,&state);
        PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_get_state", PlayerGetError(nRet), player_stop(g_player);player_unprepare(g_player));
@@ -3144,23 +3292,8 @@ int ITc_player_set_unset_progressive_download_message_cb_p(void)
 
        sleep(3);
 
-       nRet = player_prepare(g_player);
-       PRINT_RESULT(PLAYER_ERROR_NONE, nRet, "player_prepare", PlayerGetError(nRet));
-
-       nRet = player_get_state(g_player,&state);
-       PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_get_state", PlayerGetError(nRet), player_unprepare(g_player));
-
-       PlayerGetState(state);
-       if ( state != PLAYER_STATE_READY )
-       {
-               FPRINTF("[Line : %d][%s] Player state does not change after player_prepare() call", __LINE__, API_NAMESPACE);
-               return 1;
-       }
-
-       sleep(3);
-
-       nRet = player_start(g_player);
-       PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_start", PlayerGetError(nRet), player_unprepare(g_player));
+       nRet = PlayerStartWithConnectionCheck(g_player, pstrValue);
+       PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "start playback", PlayerGetError(nRet), player_unprepare(g_player));
 
        nRet = player_get_state(g_player,&state);
        PRINT_RESULT_CLEANUP(PLAYER_ERROR_NONE, nRet, "player_get_state", PlayerGetError(nRet), player_stop(g_player);player_unprepare(g_player));
index 07d4c9c5ff6b30a942df45dbb617a502627655c2..7eb0bbf5aff91fd0dcc91a0b0ad888aefe93c774 100644 (file)
@@ -37,17 +37,20 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
     ${CAPI_LIB}
     capi-appfw-application
     capi-system-info
+    capi-network-connection
     glib-2.0
     gthread-2.0
     gobject-2.0
     storage
     dlog
+    libcurl
 )
 ELSE()
 PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
     ${CAPI_LIB}
     capi-appfw-application
     capi-system-info
+    capi-network-connection
     glib-2.0
     gthread-2.0
     gobject-2.0
@@ -56,6 +59,7 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
     evas
     storage
     dlog
+    libcurl
 )
 ENDIF()
 INCLUDE_DIRECTORIES(
index c9a45332569aeb247ecf8b1bcb3dd39034121180..f83aba99706087c05afa981ba30390f1957c9148 100644 (file)
 #include <storage.h>
 #include <string.h>
 #include "tct_common.h"
+#include "net_connection.h"
 
 #define API_NAMESPACE                  "[PLAYER]"
 
 extern bool get_value_from_config(char* key, char* value);
 extern bool check_network_supportable(void);
+extern bool check_connection_statistics(connection_h connection, long long *size);
+extern bool check_online_status(char *media_path);
 
 //& set: MediaPlayerCallback
 
-static player_h player;
+static player_h player = NULL;
+static connection_h connection = NULL;
 
 static bool _is_broken = false;
 static bool _is_pass = false;
@@ -64,6 +68,46 @@ static void wait_for_async()
        g_mainloop = NULL;
 }
 
+static int _player_prepare_with_connection_check(char *media_path)
+{
+       int ret = PLAYER_ERROR_NONE;
+       long long before = 0, after = 0;
+
+       if (!check_online_status(media_path)) {
+               PRINT_UTC_LOG("[Line : %d][%s][Reference] network is disconnected\\n", __LINE__, API_NAMESPACE);
+       }
+
+       if (connection_create(&connection) != CONNECTION_ERROR_NONE) {
+               PRINT_UTC_LOG("[Line : %d][%s] Failed to create connection handle\\n", __LINE__, API_NAMESPACE);
+       } else {
+               PRINT_UTC_LOG("[Line : %d][%s] Success to create connection handle %p\\n", __LINE__, API_NAMESPACE, connection);
+       }
+
+       if (connection && !check_connection_statistics(connection, &before)) {
+               PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE);
+       }
+
+       ret = player_prepare(player);
+
+       if (connection) {
+               if (!check_connection_statistics(connection, &after)) {
+                       PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE);
+               } else {
+                       PRINT_UTC_LOG("[Line : %d][%s][Reference] total received data [%lld]\\n", __LINE__, API_NAMESPACE, (after-before));
+               }
+       }
+
+       if (ret != PLAYER_ERROR_NONE) {
+               PRINT_UTC_LOG("[Line : %d][%s] Failed to player_prepare 0x%X\\n", __LINE__, API_NAMESPACE, ret);
+       }
+
+       if (connection && (connection_destroy(connection) != CONNECTION_ERROR_NONE)) {
+               PRINT_UTC_LOG("[Line : %d][%s] Failed to destroy connection handle\\n", __LINE__, API_NAMESPACE);
+       }
+
+       return ret;
+}
+
 /**
  * @function           utc_media_player_callback_startup
  * @description                Called before each test
@@ -192,39 +236,39 @@ static  void player_subtitle_update_cb(unsigned long duration, char *text, void
  */
 int utc_media_player_set_buffering_cb_p(void)
 {
-    assert(!_is_broken);
+       assert(!_is_broken);
 
-    int repeat = 0;
+       int repeat = 0;
        bool _is_network_supportable = check_network_supportable();
 
-    int ret = player_set_uri(player, media_download_path);
-    if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
-        (!_is_network_supportable)) {
-        PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
-    assert_eq(ret, PLAYER_ERROR_NONE);
+       int ret = player_set_uri(player, media_download_path);
+       if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
+               (!_is_network_supportable)) {
+               PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
+               return 0;
+       }
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    ret = player_set_buffering_cb(player, player_buffer_cb, NULL);
-    if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
-        (!_is_network_supportable)) {
-        PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
-    assert_eq(ret, PLAYER_ERROR_NONE);
+       ret = player_set_buffering_cb(player, player_buffer_cb, NULL);
+       if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
+               (!_is_network_supportable)) {
+               PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
+               return 0;
+       }
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    ret = player_prepare(player);
-    assert_eq(ret, PLAYER_ERROR_NONE);
+       ret = _player_prepare_with_connection_check(media_download_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    for (repeat = 0 ; repeat < 11 ; repeat++) {
-        wait_for_async();
-        if (_is_pass)
-            break;
-    }
-    assert(_is_pass);
-    _is_pass = false;
+       for (repeat = 0 ; repeat < 11 ; repeat++) {
+               wait_for_async();
+               if (_is_pass)
+                       break;
+       }
+       assert(_is_pass);
+       _is_pass = false;
 
-    return 0;
+       return 0;
 }
 
 /**
index 0dec3ff7153826a7f88a4aee36a8f812bebec1a1..4cafb072ce7d4c2508fe106cc13db8a6ae3dc620 100644 (file)
 // limitations under the License.
 //
 #include "assert.h"
-#include <media/player.h>
 #include <glib.h>
 #include <Elementary.h>
 #include <storage.h>
 #include <system_info.h>
+#include <media/player.h>
+#include <curl/curl.h>
 #include "tct_common.h"
+#include "net_connection.h"
 
 #define API_NAMESPACE    "[PLAYER]"
 
 static char* download = "test.pd";
 static char* download_path = NULL;
 
-static player_h player;
+static player_h player = NULL;
+static connection_h connection = NULL;
+static bool wifi_supported = false;
+static bool telepony_supported = false;
+static bool ethernet_supported = false;
 
 static bool _is_broken = false;
 static bool _is_pass = false;
@@ -125,25 +131,150 @@ bool get_value_from_config(char* key, char* value)
         return true;
 }
 
+bool check_online_status(char *media_path)
+{
+       bool ret = true;
+       CURL *curl = NULL;
+       CURLcode res = CURLE_OK;
+
+       curl = curl_easy_init();
+       if(curl) {
+               curl_easy_setopt(curl, CURLOPT_URL, media_path);
+               curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 10000L);
+
+               res = curl_easy_perform(curl);
+               if(res != CURLE_OK) {
+                       PRINT_UTC_LOG("[Line : %d][%s] curl_easy_perform() failed: %s\n", __LINE__, API_NAMESPACE, curl_easy_strerror(res));
+                       ret = false;
+               }
+
+               curl_easy_cleanup(curl);
+       }
+
+       return ret;
+
+}
+
+bool check_connection_statistics(connection_h connection, long long *size)
+{
+       long long rv = 0;
+       int err = CONNECTION_ERROR_NONE;
+       connection_type_e type = CONNECTION_TYPE_DISCONNECTED;
+
+       if (wifi_supported) {
+               type = CONNECTION_TYPE_WIFI;
+       } else if (telepony_supported) {
+               type = CONNECTION_TYPE_CELLULAR;
+       } else {
+               PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
+               return false;
+       }
+
+       err = connection_get_statistics(connection, type, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
+
+       if (err != CONNECTION_ERROR_NONE) {
+               PRINT_UTC_LOG("[Line : %d][%s] Failed to check connection statistics.\\n", __LINE__, API_NAMESPACE);
+               return false;
+       } else {
+               PRINT_UTC_LOG("[Line : %d][%s] WiFi last recv data size [%lld]\\n", __LINE__, API_NAMESPACE, rv);
+       }
+
+       *size = rv;
+       return true;
+}
+
+static int _player_prepare_with_connection_check(gchar *media_path)
+{
+       int ret = PLAYER_ERROR_NONE;
+       long long before = 0, after = 0;
+
+       if (!check_online_status(media_path)) {
+               PRINT_UTC_LOG("[Line : %d][%s][Reference] network is disconnected\\n", __LINE__, API_NAMESPACE);
+       }
+
+       if (connection && !check_connection_statistics(connection, &before)) {
+               PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE);
+       }
+
+       ret = player_prepare(player);
+
+       if (connection) {
+               if (!check_connection_statistics(connection, &after)) {
+                       PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE);
+               } else {
+                       PRINT_UTC_LOG("[Line : %d][%s][Reference] total received data [%lld]\\n", __LINE__, API_NAMESPACE, (after-before));
+               }
+       }
+
+       if (ret != PLAYER_ERROR_NONE) {
+               PRINT_UTC_LOG("[Line : %d][%s] Failed to player_prepare 0x%X\\n", __LINE__, API_NAMESPACE, ret);
+       }
+
+       return ret;
+}
+
+static int _player_prepare_start_with_connection_check(gchar *media_path)
+{
+       int ret = PLAYER_ERROR_NONE;
+       long long before = 0, after = 0;
+
+       if (!check_online_status(media_path)) {
+               PRINT_UTC_LOG("[Line : %d][%s][Reference] network is disconnected\\n", __LINE__, API_NAMESPACE);
+       }
+
+       if (connection && !check_connection_statistics(connection, &before)) {
+               PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE);
+       }
+
+       ret = player_prepare(player);
+
+       if (ret != PLAYER_ERROR_NONE) {
+               if (connection) {
+                       if (!check_connection_statistics(connection, &after)) {
+                               PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE);
+                       } else {
+                               PRINT_UTC_LOG("[Line : %d][%s][Reference] total received data [%lld]\\n",
+                                                                                                               __LINE__, API_NAMESPACE, (after-before));
+                       }
+               }
+
+               PRINT_UTC_LOG("[Line : %d][%s] Failed to player_prepare 0x%X\\n", __LINE__, API_NAMESPACE, ret);
+               return ret;
+       }
+
+       /* progressive download case have to include player_start for checking network env */
+       ret = player_start(player);
+
+       if (connection) {
+               if (!check_connection_statistics(connection, &after)) {
+                       PRINT_UTC_LOG("[Line : %d][%s] Failed to get connection statistics\\n", __LINE__, API_NAMESPACE);
+               } else {
+                       PRINT_UTC_LOG("[Line : %d][%s][Reference] total received data [%lld]\\n", __LINE__, API_NAMESPACE, (after-before));
+               }
+       }
+
+       if (ret != PLAYER_ERROR_NONE) {
+               PRINT_UTC_LOG("[Line : %d][%s] Failed to player_start 0x%X\\n", __LINE__, API_NAMESPACE, ret);
+       }
+
+       return ret;
+}
 
 bool check_network_supportable(void)
 {
-#define _FEATURE_NAME_WIFI             "http://tizen.org/feature/network.wifi"
-#define _FEATURE_NAME_TELEPHONY        "http://tizen.org/feature/network.telephony"
-#define _FEATURE_NAME_ETHERNET "http://tizen.org/feature/network.ethernet"
-    bool wifi_supported = FALSE;
-    bool telepony_supported = FALSE;
-    bool ethernet_supported = FALSE;
+#define _FEATURE_NAME_WIFI      "http://tizen.org/feature/network.wifi"
+#define _FEATURE_NAME_TELEPHONY "http://tizen.org/feature/network.telephony"
+#define _FEATURE_NAME_ETHERNET  "http://tizen.org/feature/network.ethernet"
 
-    system_info_get_platform_bool(_FEATURE_NAME_WIFI, &wifi_supported);
-    system_info_get_platform_bool(_FEATURE_NAME_TELEPHONY, &telepony_supported);
-    system_info_get_platform_bool(_FEATURE_NAME_ETHERNET, &ethernet_supported);
+       system_info_get_platform_bool(_FEATURE_NAME_WIFI, &wifi_supported);
+       system_info_get_platform_bool(_FEATURE_NAME_TELEPHONY, &telepony_supported);
+       system_info_get_platform_bool(_FEATURE_NAME_ETHERNET, &ethernet_supported);
 
-    if (wifi_supported || telepony_supported || ethernet_supported)
-        return true;
+       if (wifi_supported || telepony_supported || ethernet_supported)
+               return true;
 
-    PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
-    return false;
+       PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
+       return false;
 }
 
 /**
@@ -161,26 +292,21 @@ void utc_media_player_streaming_startup(void)
 
     _is_network_supportable = check_network_supportable();
 
-    if ( true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE ))
-    {
+    if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) {
         PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received = %s\\n", __LINE__, API_NAMESPACE,  pszValue);
         unsigned int size_of_path = strlen(pszValue) + strlen(download) + 11;
         download_path = (char*)malloc(size_of_path);
         snprintf(download_path, size_of_path, "%s/res/res/%s", pszValue, download);
-    }
-    else
-    {
+    } else {
         PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for 'DEVICE_SUITE_TARGET_30'\\n", __LINE__, API_NAMESPACE);
     }
 
-    if ( true != get_value_from_config("PLAYER_DOWNLOAD_PROGRESS_URL", g_media_path) )
-    {
+    if (true != get_value_from_config("PLAYER_DOWNLOAD_PROGRESS_URL", g_media_path)) {
         PRINT_UTC_LOG("[Line : %d][%s] Failed to get value from config\\n", __LINE__, API_NAMESPACE);
         _is_broken = true;
     }
 
-    if ( true != get_value_from_config("PLAYER_ADAPTIVE_STREAMING_URL", g_media_adaptive_path) )
-    {
+    if (true != get_value_from_config("PLAYER_ADAPTIVE_STREAMING_URL", g_media_adaptive_path)) {
         PRINT_UTC_LOG("[Line : %d][%s] Failed to get value from config\\n", __LINE__, API_NAMESPACE);
         _is_broken = true;
     }
@@ -190,6 +316,12 @@ void utc_media_player_streaming_startup(void)
         _is_broken = true;
         return;
     }
+
+    if (connection_create(&connection) != CONNECTION_ERROR_NONE) {
+        PRINT_UTC_LOG("[Line : %d][%s] Failed to create connection handle\\n", __LINE__, API_NAMESPACE);
+    } else {
+               PRINT_UTC_LOG("[Line : %d][%s] Success to create connection handle %p\\n", __LINE__, API_NAMESPACE, connection);
+    }
 }
 
 /**
@@ -200,14 +332,18 @@ void utc_media_player_streaming_startup(void)
  */
 void utc_media_player_streaming_cleanup(void)
 {
+    if (connection && connection_destroy(connection) != CONNECTION_ERROR_NONE) {
+        PRINT_UTC_LOG("[Line : %d][%s] Failed to destroy connection handle\\n", __LINE__, API_NAMESPACE);
+    }
+
     player_destroy(player);
-    if(download_path)
+    if (download_path)
       free(download_path);
 }
 
 static  void _player_pd_message_cb(player_pd_message_type_e type, void *user_data)
 {
-    if(type==PLAYER_PD_STARTED || type==PLAYER_PD_COMPLETED)
+    if (type == PLAYER_PD_STARTED || type == PLAYER_PD_COMPLETED)
         _is_pass = TRUE;
 }
 
@@ -218,42 +354,38 @@ static  void _player_pd_message_cb(player_pd_message_type_e type, void *user_dat
  */
 int utc_media_player_get_streaming_download_progress_p(void)
 {
-    assert(!_is_broken);
-    int start;
-    int current;
+       assert(!_is_broken);
 
-    int ret = player_set_streaming_cookie(player, COOKIE_EXAMPLE, sizeof(COOKIE_EXAMPLE));
-    assert_eq(ret, PLAYER_ERROR_NONE);
+       int ret = PLAYER_ERROR_NONE;
+       int start;
+       int current;
 
-    int ret2 = player_set_uri(player, g_media_path);
-    assert_eq(ret2, PLAYER_ERROR_NONE);
+       ret = player_set_streaming_cookie(player, COOKIE_EXAMPLE, sizeof(COOKIE_EXAMPLE));
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret3 = player_prepare(player);
-    // if wifi isn't connected or internet modules don't exist, this error will be returned.
-    // and it is wrongly detected as a fail. so we will skip the test on these cases.
-    if(ret3==PLAYER_ERROR_CONNECTION_FAILED) {
-        PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
-    assert_eq(ret3, PLAYER_ERROR_NONE);
+       ret = player_set_uri(player, g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret4 = player_start(player);
-    assert_eq(ret4, PLAYER_ERROR_NONE);
+       ret = _player_prepare_with_connection_check(g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret5 = player_get_streaming_download_progress(player, &start, &current);
-    assert_eq(ret5, PLAYER_ERROR_NONE);
+       ret = player_start(player);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret6 = player_stop(player);
-    assert_eq(ret6, PLAYER_ERROR_NONE);
+       ret = player_get_streaming_download_progress(player, &start, &current);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret7 = player_unprepare(player);
-    assert_eq(ret7, PLAYER_ERROR_NONE);
+       ret = player_stop(player);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    if (start < 0 || start > 100 || current < 0 || current > 100) {
-        assert(false);
-    }
+       ret = player_unprepare(player);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    return 0;
+       if (start < 0 || start > 100 || current < 0 || current > 100) {
+               assert(false);
+       }
+
+       return 0;
 }
 
 /**
@@ -263,37 +395,32 @@ int utc_media_player_get_streaming_download_progress_p(void)
  */
 int utc_media_player_get_streaming_download_progress_n(void)
 {
-    int start;
-    int current;
+       int ret = PLAYER_ERROR_NONE;
+       int start;
+       int current;
 
-    int ret = player_set_streaming_cookie(player, COOKIE_EXAMPLE, sizeof(COOKIE_EXAMPLE));
-    assert_eq(ret, PLAYER_ERROR_NONE);
+       ret = player_set_streaming_cookie(player, COOKIE_EXAMPLE, sizeof(COOKIE_EXAMPLE));
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret2 = player_set_uri(player, g_media_path);
-    assert_eq(ret2, PLAYER_ERROR_NONE);
+       ret = player_set_uri(player, g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret3 = player_prepare(player);
-    // if wifi isn't connected or internet modules don't exist, this error will be returned.
-    // and it is wrongly detected as a fail. so we will skip the test on these cases.
-    if(ret3==PLAYER_ERROR_CONNECTION_FAILED) {
-        PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
-    assert_eq(ret3, PLAYER_ERROR_NONE);
+       ret = _player_prepare_with_connection_check(g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret4 = player_start(player);
-    assert_eq(ret4, PLAYER_ERROR_NONE);
+       ret = player_start(player);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret5 = player_get_streaming_download_progress(NULL, &start, &current);
-    assert_eq(ret5, PLAYER_ERROR_INVALID_PARAMETER);
+       ret = player_get_streaming_download_progress(NULL, &start, &current);
+       assert_eq(ret, PLAYER_ERROR_INVALID_PARAMETER);
 
-    int ret6 = player_stop(player);
-    assert_eq(ret6, PLAYER_ERROR_NONE);
+       ret = player_stop(player);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret7 = player_unprepare(player);
-    assert_eq(ret7, PLAYER_ERROR_NONE);
+       ret = player_unprepare(player);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    return 0;
+       return 0;
 }
 
 /**
@@ -303,17 +430,18 @@ int utc_media_player_get_streaming_download_progress_n(void)
  */
 int utc_media_player_get_streaming_download_progress_n2(void)
 {
+       int ret = PLAYER_ERROR_NONE;
     int start;
     int current;
 
-    int ret = player_set_streaming_cookie(player, COOKIE_EXAMPLE, sizeof(COOKIE_EXAMPLE));
+    ret = player_set_streaming_cookie(player, COOKIE_EXAMPLE, sizeof(COOKIE_EXAMPLE));
     assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret2 = player_set_uri(player, g_media_path);
-    assert_eq(ret2, PLAYER_ERROR_NONE);
+    ret = player_set_uri(player, g_media_path);
+    assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret5 = player_get_streaming_download_progress(player, &start, &current);
-    assert_eq(ret5, PLAYER_ERROR_INVALID_STATE);
+    ret = player_get_streaming_download_progress(player, &start, &current);
+    assert_eq(ret, PLAYER_ERROR_INVALID_STATE);
 
     return 0;
 }
@@ -325,38 +453,37 @@ int utc_media_player_get_streaming_download_progress_n2(void)
  */
 int utc_media_player_get_progressive_download_status_p(void)
 {
-    assert(!_is_broken);
-    unsigned long current;
-    unsigned long total_size;
+       assert(!_is_broken);
 
-    int ret = player_set_uri(player, g_media_path);
-    assert_eq(ret, PLAYER_ERROR_NONE);
+       int ret = PLAYER_ERROR_NONE;
+       unsigned long current;
+       unsigned long total_size;
 
-    int ret2 = player_set_progressive_download_path(player, download_path);
-    // if wifi isn't connected or internet modules don't exist, this error will be returned.
-    // and it is wrongly detected as a fail. so we will skip the test on these cases.
-    if ((ret2==PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
-        (!_is_network_supportable)) {
-        PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
-    assert_eq(ret2, PLAYER_ERROR_NONE);
+       ret = player_set_uri(player, g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret3 = player_prepare(player);
-    assert_eq(ret3, PLAYER_ERROR_NONE);
+       ret = player_set_progressive_download_path(player, download_path);
+       // if wifi isn't connected or internet modules don't exist, this error will be returned.
+       // and it is wrongly detected as a fail. so we will skip the test on these cases.
+       if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
+               (!_is_network_supportable)) {
+               PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
+               return 0;
+       }
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret4 = player_start(player);
-    assert_eq(ret4, PLAYER_ERROR_NONE);
+       ret = _player_prepare_start_with_connection_check(g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret5 = player_get_progressive_download_status(player, &current, &total_size);
-    assert_eq(ret5, PLAYER_ERROR_NONE);
+       ret = player_get_progressive_download_status(player, &current, &total_size);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    wait_for_async();
+       wait_for_async();
 
-    int ret7 = player_unprepare(player);
-    assert_eq(ret7, PLAYER_ERROR_NONE);
+       ret = player_unprepare(player);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    return 0;
+       return 0;
 }
 
 /**
@@ -366,37 +493,35 @@ int utc_media_player_get_progressive_download_status_p(void)
  */
 int utc_media_player_get_progressive_download_status_n(void)
 {
-    unsigned long current;
-    unsigned long total_size;
+       int ret = PLAYER_ERROR_NONE;
+       unsigned long current;
+       unsigned long total_size;
 
-    int ret = player_set_uri(player, g_media_path);
-    assert_eq(ret, PLAYER_ERROR_NONE);
+       ret = player_set_uri(player, g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret2 = player_set_progressive_download_path(player, download_path);
-    // if wifi isn't connected or internet modules don't exist, this error will be returned.
-    // and it is wrongly detected as a fail. so we will skip the test on these cases.
-    if ((ret2==PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
-        (!_is_network_supportable)) {
-        PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
-    assert_eq(ret2, PLAYER_ERROR_NONE);
+       ret = player_set_progressive_download_path(player, download_path);
+       // if wifi isn't connected or internet modules don't exist, this error will be returned.
+       // and it is wrongly detected as a fail. so we will skip the test on these cases.
+       if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
+               (!_is_network_supportable)) {
+               PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
+               return 0;
+       }
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret3 = player_prepare(player);
-    assert_eq(ret3, PLAYER_ERROR_NONE);
+       ret = _player_prepare_start_with_connection_check(g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret4 = player_start(player);
-    assert_eq(ret4, PLAYER_ERROR_NONE);
+       ret = player_get_progressive_download_status(NULL, &current, &total_size);
+       assert_eq(ret, PLAYER_ERROR_INVALID_PARAMETER);
 
-    int ret5 = player_get_progressive_download_status(NULL, &current, &total_size);
-    assert_eq(ret5, PLAYER_ERROR_INVALID_PARAMETER);
+       wait_for_async();
 
-    wait_for_async();
+       ret = player_unprepare(player);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret7 = player_unprepare(player);
-    assert_eq(ret7, PLAYER_ERROR_NONE);
-
-    return 0;
+       return 0;
 }
 
 /**
@@ -406,26 +531,27 @@ int utc_media_player_get_progressive_download_status_n(void)
  */
 int utc_media_player_get_progressive_download_status_n2(void)
 {
-    unsigned long current;
-    unsigned long total_size;
-
-    int ret = player_set_uri(player, g_media_path);
-    assert_eq(ret, PLAYER_ERROR_NONE);
-
-    int ret2 = player_set_progressive_download_path(player, download_path);
-    // if wifi isn't connected or internet modules don't exist, this error will be returned.
-    // and it is wrongly detected as a fail. so we will skip the test on these cases.
-    if ((ret2==PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
-        (!_is_network_supportable)) {
-        PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
-    assert_eq(ret2, PLAYER_ERROR_NONE);
-
-    int ret5 = player_get_progressive_download_status(player, &current, &total_size);
-    assert_eq(ret5, PLAYER_ERROR_INVALID_STATE);
-
-    return 0;
+       int ret = PLAYER_ERROR_NONE;
+       unsigned long current;
+       unsigned long total_size;
+
+       ret = player_set_uri(player, g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
+
+       ret = player_set_progressive_download_path(player, download_path);
+       // if wifi isn't connected or internet modules don't exist, this error will be returned.
+       // and it is wrongly detected as a fail. so we will skip the test on these cases.
+       if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
+           (!_is_network_supportable)) {
+               PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
+               return 0;
+       }
+       assert_eq(ret, PLAYER_ERROR_NONE);
+
+       ret = player_get_progressive_download_status(player, &current, &total_size);
+       assert_eq(ret, PLAYER_ERROR_INVALID_STATE);
+
+       return 0;
 }
 
 /**
@@ -435,20 +561,22 @@ int utc_media_player_get_progressive_download_status_n2(void)
  */
 int utc_media_player_set_progressive_download_path_p(void)
 {
-    int ret = player_set_uri(player, g_media_path);
-    assert_eq(ret, PLAYER_ERROR_NONE);
-
-    int ret2 = player_set_progressive_download_path(player, download_path);
-    // if wifi isn't connected or internet modules don't exist, this error will be returned.
-    // and it is wrongly detected as a fail. so we will skip the test on these cases.
-    if ((ret2==PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
-        (!_is_network_supportable)) {
-        PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
-    assert_eq(ret2, PLAYER_ERROR_NONE);
-
-    return 0;
+       int ret = PLAYER_ERROR_NONE;
+
+       ret = player_set_uri(player, g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
+
+       ret = player_set_progressive_download_path(player, download_path);
+       // if wifi isn't connected or internet modules don't exist, this error will be returned.
+       // and it is wrongly detected as a fail. so we will skip the test on these cases.
+       if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
+               (!_is_network_supportable)) {
+               PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
+               return 0;
+       }
+       assert_eq(ret, PLAYER_ERROR_NONE);
+
+       return 0;
 }
 
 /**
@@ -458,15 +586,17 @@ int utc_media_player_set_progressive_download_path_p(void)
  */
 int utc_media_player_set_progressive_download_path_n(void)
 {
-    assert(!_is_broken);
+       assert(!_is_broken);
 
-    int ret = player_set_uri(player, g_media_path);
-    assert_eq(ret, PLAYER_ERROR_NONE);
+       int ret = PLAYER_ERROR_NONE;
 
-    int ret2 = player_set_progressive_download_path(NULL, download_path);
-    assert_eq(ret2, PLAYER_ERROR_INVALID_PARAMETER);
+       ret = player_set_uri(player, g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    return 0;
+       ret = player_set_progressive_download_path(NULL, download_path);
+       assert_eq(ret, PLAYER_ERROR_INVALID_PARAMETER);
+
+       return 0;
 }
 
 /**
@@ -476,44 +606,40 @@ int utc_media_player_set_progressive_download_path_n(void)
  */
 int utc_media_player_set_progressive_download_message_cb_p(void)
 {
-    assert(!_is_broken);
+       assert(!_is_broken);
+       int ret = PLAYER_ERROR_NONE;
 
-    int ret = player_set_uri(player, g_media_path);
-    if (PLAYER_ERROR_NONE != ret)
-        PRINT_UTC_LOG("[Line : %d][%s] player_set_uri is failed\\n", __LINE__, API_NAMESPACE);
-
-    ret = player_set_display(player, PLAYER_DISPLAY_TYPE_NONE, NULL);
-    if (PLAYER_ERROR_NONE != ret)
-      PRINT_UTC_LOG("[Line : %d][%s] player_set_display failed\\n", __LINE__, API_NAMESPACE);
-
-    ret = player_set_progressive_download_path(player, download_path);
-    if (PLAYER_ERROR_NONE != ret)
-        PRINT_UTC_LOG("[Line : %d][%s] player_set_progressive_download_path is failed\\n", __LINE__, API_NAMESPACE);
-
-    ret = player_set_progressive_download_message_cb(player, _player_pd_message_cb, NULL);
-    // if wifi isn't connected or internet modules don't exist, this error will be returned.
-    // and it is wrongly detected as a fail. so we will skip the test on these cases.
-    if ((ret==PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
-        (!_is_network_supportable)) {
-        PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
-    assert_eq(ret, PLAYER_ERROR_NONE);
+       ret = player_set_uri(player, g_media_path);
+       if (PLAYER_ERROR_NONE != ret)
+               PRINT_UTC_LOG("[Line : %d][%s] player_set_uri is failed\\n", __LINE__, API_NAMESPACE);
 
-    ret = player_prepare(player);
-    if (PLAYER_ERROR_NONE != ret)
-        PRINT_UTC_LOG("[Line : %d][%s] player isn't prepared\\n", __LINE__, API_NAMESPACE);
+       ret = player_set_display(player, PLAYER_DISPLAY_TYPE_NONE, NULL);
+       if (PLAYER_ERROR_NONE != ret)
+               PRINT_UTC_LOG("[Line : %d][%s] player_set_display failed\\n", __LINE__, API_NAMESPACE);
 
-    ret = player_start(player);
-    if (PLAYER_ERROR_NONE != ret)
-        PRINT_UTC_LOG("[Line : %d][%s] player isn't started\\n", __LINE__, API_NAMESPACE);
+       ret = player_set_progressive_download_path(player, download_path);
+       if (PLAYER_ERROR_NONE != ret)
+               PRINT_UTC_LOG("[Line : %d][%s] player_set_progressive_download_path is failed\\n", __LINE__, API_NAMESPACE);
 
-    wait_for_async();
+       ret = player_set_progressive_download_message_cb(player, _player_pd_message_cb, NULL);
+       // if wifi isn't connected or internet modules don't exist, this error will be returned.
+       // and it is wrongly detected as a fail. so we will skip the test on these cases.
+       if ((ret == PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE) &&
+               (!_is_network_supportable)) {
+               PRINT_UTC_LOG("[Line : %d][%s] network is not supportable.\\n", __LINE__, API_NAMESPACE);
+               return 0;
+       }
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    if(_is_pass)
-      PRINT_UTC_LOG("[Line : %d][%s] pd_message_callback is called!\\n", __LINE__, API_NAMESPACE);
+       ret = _player_prepare_start_with_connection_check(g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    return 0;
+       wait_for_async();
+
+       if(_is_pass)
+               PRINT_UTC_LOG("[Line : %d][%s] pd_message_callback is called!\\n", __LINE__, API_NAMESPACE);
+
+       return 0;
 }
 
 /**
@@ -536,34 +662,25 @@ int utc_media_player_set_progressive_download_message_cb_n(void)
  */
 int utc_media_player_set_progressive_download_message_cb_n2(void)
 {
-    int ret = player_set_uri(player, g_media_path);
-    if (PLAYER_ERROR_NONE != ret)
-        PRINT_UTC_LOG("[Line : %d][%s] player_set_uri is failed\\n", __LINE__, API_NAMESPACE);
+       int ret = player_set_uri(player, g_media_path);
+       if (PLAYER_ERROR_NONE != ret)
+               PRINT_UTC_LOG("[Line : %d][%s] player_set_uri is failed\\n", __LINE__, API_NAMESPACE);
 
-    ret = player_set_display(player, PLAYER_DISPLAY_TYPE_NONE, NULL);
-    if (PLAYER_ERROR_NONE != ret)
-      PRINT_UTC_LOG("[Line : %d][%s] player_set_display failed\\n", __LINE__, API_NAMESPACE);
+       ret = player_set_display(player, PLAYER_DISPLAY_TYPE_NONE, NULL);
+       if (PLAYER_ERROR_NONE != ret)
+               PRINT_UTC_LOG("[Line : %d][%s] player_set_display failed\\n", __LINE__, API_NAMESPACE);
 
-    ret = player_set_progressive_download_path(player, download_path);
-    if (PLAYER_ERROR_NONE != ret)
-        PRINT_UTC_LOG("[Line : %d][%s] player_set_progressive_download_path is failed\\n", __LINE__, API_NAMESPACE);
+       ret = player_set_progressive_download_path(player, download_path);
+       if (PLAYER_ERROR_NONE != ret)
+               PRINT_UTC_LOG("[Line : %d][%s] player_set_progressive_download_path is failed\\n", __LINE__, API_NAMESPACE);
 
-    ret = player_prepare(player);
-    // if wifi isn't connected or internet modules don't exist, this error will be returned.
-    // and it is wrongly detected as a fail. so we will skip the test on these cases.
-    if(ret==PLAYER_ERROR_CONNECTION_FAILED) {
-        PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
+       ret = _player_prepare_start_with_connection_check(g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    ret = player_start(player);
-    if (PLAYER_ERROR_NONE != ret)
-        PRINT_UTC_LOG("[Line : %d][%s] player isn't started\\n", __LINE__, API_NAMESPACE);
+       ret = player_set_progressive_download_message_cb(player, _player_pd_message_cb, NULL);
+       assert_eq(ret, PLAYER_ERROR_INVALID_STATE);
 
-    ret = player_set_progressive_download_message_cb(player, _player_pd_message_cb, NULL);
-    assert_eq(ret, PLAYER_ERROR_INVALID_STATE);
-
-    return 0;
+       return 0;
 }
 
 /**
@@ -637,25 +754,20 @@ void _player_adaptive_variant_cb(int bandwidth, int width, int height, void *use
  */
 int utc_media_player_foreach_adaptive_variant_p(void)
 {
-    assert(!_is_broken);
+       assert(!_is_broken);
+       int ret = PLAYER_ERROR_NONE;
 
-    int ret = player_set_uri(player, g_media_adaptive_path);
-    assert_eq(ret, PLAYER_ERROR_NONE);
+       ret = player_set_uri(player, g_media_adaptive_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret2 = player_prepare(player);
-    // if wifi isn't connected or internet modules don't exist, this error will be returned.
-    // and it is wrongly detected as a fail. so we will skip the test on these cases.
-    if (ret2 == PLAYER_ERROR_CONNECTION_FAILED) {
-        PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
-    assert_eq(ret2, PLAYER_ERROR_NONE);
+       ret = _player_prepare_with_connection_check(g_media_adaptive_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret3 = player_foreach_adaptive_variant(player, (player_adaptive_variant_cb)_player_adaptive_variant_cb, player);
-    assert_eq(ret3, PLAYER_ERROR_NONE);
-    assert(_is_pass);
+       ret = player_foreach_adaptive_variant(player, (player_adaptive_variant_cb)_player_adaptive_variant_cb, player);
+       assert_eq(ret, PLAYER_ERROR_NONE);
+       assert(_is_pass);
 
-    return 0;
+       return 0;
 }
 
 /**
@@ -665,24 +777,19 @@ int utc_media_player_foreach_adaptive_variant_p(void)
  */
 int utc_media_player_foreach_adaptive_variant_n(void)
 {
-    assert(!_is_broken);
+       assert(!_is_broken);
+       int ret = PLAYER_ERROR_NONE;
 
-    int ret = player_set_uri(player, g_media_adaptive_path);
-    assert_eq(ret, PLAYER_ERROR_NONE);
+       ret = player_set_uri(player, g_media_adaptive_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret2 = player_prepare(player);
-    // if wifi isn't connected or internet modules don't exist, this error will be returned.
-    // and it is wrongly detected as a fail. so we will skip the test on these cases.
-    if (ret2 == PLAYER_ERROR_CONNECTION_FAILED) {
-        PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
-    assert_eq(ret2, PLAYER_ERROR_NONE);
+       ret = _player_prepare_with_connection_check(g_media_adaptive_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret3 = player_foreach_adaptive_variant(player, NULL, player);
-    assert_eq(ret3, PLAYER_ERROR_INVALID_PARAMETER);
+       ret = player_foreach_adaptive_variant(player, NULL, player);
+       assert_eq(ret, PLAYER_ERROR_INVALID_PARAMETER);
 
-    return 0;
+       return 0;
 }
 
 /**
@@ -692,32 +799,28 @@ int utc_media_player_foreach_adaptive_variant_n(void)
  */
 int utc_media_player_set_get_max_adaptive_variant_limit_p(void)
 {
-    assert(!_is_broken);
-    int bandwidth = 500000, width = 1920, height = 1080;
-    int get_bandwidth = 0, get_width = 0, get_height = 0;
+       assert(!_is_broken);
 
-    int ret = player_set_uri(player, g_media_adaptive_path);
-    assert_eq(ret, PLAYER_ERROR_NONE);
+       int ret = PLAYER_ERROR_NONE;
+       int bandwidth = 500000, width = 1920, height = 1080;
+       int get_bandwidth = 0, get_width = 0, get_height = 0;
 
-    int ret2 = player_prepare(player);
-    // if wifi isn't connected or internet modules don't exist, this error will be returned.
-    // and it is wrongly detected as a fail. so we will skip the test on these cases.
-    if (ret2 == PLAYER_ERROR_CONNECTION_FAILED) {
-        PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
-    assert_eq(ret2, PLAYER_ERROR_NONE);
+       ret = player_set_uri(player, g_media_adaptive_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret3 = player_set_max_adaptive_variant_limit(player, bandwidth, width, height);
-    assert_eq(ret3, PLAYER_ERROR_NONE);
+       ret = _player_prepare_with_connection_check(g_media_adaptive_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret4 = player_get_max_adaptive_variant_limit(player, &get_bandwidth, &get_width, &get_height);
-    assert_eq(ret4, PLAYER_ERROR_NONE);
-    assert_eq(bandwidth, get_bandwidth);
-    assert_eq(width, get_width);
-    assert_eq(height, get_height);
+       ret = player_set_max_adaptive_variant_limit(player, bandwidth, width, height);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    return 0;
+       ret = player_get_max_adaptive_variant_limit(player, &get_bandwidth, &get_width, &get_height);
+       assert_eq(ret, PLAYER_ERROR_NONE);
+       assert_eq(bandwidth, get_bandwidth);
+       assert_eq(width, get_width);
+       assert_eq(height, get_height);
+
+       return 0;
 }
 
 /**
@@ -760,31 +863,26 @@ int utc_media_player_get_max_adaptive_variant_limit_n(void)
  */
 int utc_media_player_set_get_streaming_buffering_time_p(void)
 {
-    assert(!_is_broken);
-    int btime = 50000, rbtime = 100000;
-    int get_btime = 0, get_rbtime = 0;
+       assert(!_is_broken);
+       int ret = PLAYER_ERROR_NONE;
+       int btime = 50000, rbtime = 100000;
+       int get_btime = 0, get_rbtime = 0;
 
-    int ret = player_set_uri(player, g_media_path);
-    assert_eq(ret, PLAYER_ERROR_NONE);
+       ret = player_set_uri(player, g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret2 = player_set_streaming_buffering_time(player, btime, rbtime);
-    assert_eq(ret2, PLAYER_ERROR_NONE);
+       ret = player_set_streaming_buffering_time(player, btime, rbtime);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret3 = player_prepare(player);
-    // if wifi isn't connected or internet modules don't exist, this error will be returned.
-    // and it is wrongly detected as a fail. so we will skip the test on these cases.
-    if (ret3 == PLAYER_ERROR_CONNECTION_FAILED) {
-        PRINT_UTC_LOG("[Line : %d][%s] check network status\\n", __LINE__, API_NAMESPACE);
-        return 0;
-    }
-    assert_eq(ret3, PLAYER_ERROR_NONE);
+       ret = _player_prepare_with_connection_check(g_media_path);
+       assert_eq(ret, PLAYER_ERROR_NONE);
 
-    int ret4 = player_get_streaming_buffering_time(player, &get_btime, &get_rbtime);
-    assert_eq(ret4, PLAYER_ERROR_NONE);
-    assert_eq(btime, get_btime);
-    assert_eq(rbtime, get_rbtime);
+       ret = player_get_streaming_buffering_time(player, &get_btime, &get_rbtime);
+       assert_eq(ret, PLAYER_ERROR_NONE);
+       assert_eq(btime, get_btime);
+       assert_eq(rbtime, get_rbtime);
 
-    return 0;
+       return 0;
 }
 
 /**