From: Priya Kohli Date: Fri, 14 Aug 2020 07:35:11 +0000 (+0530) Subject: [ITC][rpc-port][ACR-1587][Added support for synchronous connection request and privat... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f5604c4995ed9bb1417a4e735441fa1f97beb57b;p=test%2Ftct%2Fnative%2Fapi.git [ITC][rpc-port][ACR-1587][Added support for synchronous connection request and private file sharing] Change-Id: Ifa690490edcf3a662c49e06d7ec08d88d10bf8fe Signed-off-by: Priya Kohli --- diff --git a/src/itc/rpc-port/ITs-rpc-port-common.c b/src/itc/rpc-port/ITs-rpc-port-common.c index 9d8c74b8b..948e97991 100755 --- a/src/itc/rpc-port/ITs-rpc-port-common.c +++ b/src/itc/rpc-port/ITs-rpc-port-common.c @@ -59,4 +59,36 @@ gboolean Timeout(gpointer data) FPRINTF("[Line : %d][%s] Callback Timeout\\n", __LINE__, API_NAMESPACE); return false; } + +/** + * @function GetFilePath + * @description Gets the file path + * @parameter const char *pszFileName, char *pszBuf, unsigned int nSize + * @return void + */ +void GetFilePath(const char *pszFileName, char *pszBuf, unsigned int nSize) +{ + char *pszDataPath; + pszDataPath = app_get_data_path(); + + snprintf(pszBuf, nSize, "%s%s", pszDataPath, pszFileName); +} + +/** + * @function CreateFile + * @description Creates the file + * @parameter const char *pszFilePath, const char *pszMessage + * @return void + */ +void CreateFile(const char *pszFilePath, const char *pszMessage) +{ + FILE * fp = fopen (pszFilePath, "w+"); + + if (fp) + { + fprintf(fp, pszMessage); + fclose(fp); + } +} + /** @} */ diff --git a/src/itc/rpc-port/ITs-rpc-port-common.h b/src/itc/rpc-port/ITs-rpc-port-common.h index 6614e37d1..39bd135fa 100755 --- a/src/itc/rpc-port/ITs-rpc-port-common.h +++ b/src/itc/rpc-port/ITs-rpc-port-common.h @@ -23,6 +23,7 @@ #include #include #include +#include /** @addtogroup itc-rpc-port * @ingroup itc @@ -35,7 +36,7 @@ static GMainLoop *g_pMainLoop = NULL; #define API_NAMESPACE "DLOG_ITC" #define TIMEOUT_CB 20000 - +#define PATH_LEN 1024 #define START_TEST {\ FPRINTF("[Line : %d][%s] Starting test : %s\\n", __LINE__, API_NAMESPACE, __FUNCTION__);\ @@ -85,6 +86,8 @@ bool g_bCallbackCalled; bool g_bcallBackDisConnect; bool g_callbackMsgreceived; gboolean Timeout(gpointer data); +void GetFilePath(const char *pszFileName, char *pszBuf, unsigned int nSize); +void CreateFile(const char *pszFilePath, const char *pszMessage); /** @} */ #endif //_ITS_RPC-PORT_COMMON_H_ diff --git a/src/itc/rpc-port/ITs-rpc-port.c b/src/itc/rpc-port/ITs-rpc-port.c index 560bfef8a..852ad10a3 100755 --- a/src/itc/rpc-port/ITs-rpc-port.c +++ b/src/itc/rpc-port/ITs-rpc-port.c @@ -34,6 +34,13 @@ const char g_szReceivetest[] = "receivetest"; const char g_szPorttest[] = "porttest"; const char g_szPort_Name[] = "Message"; static char g_szProxygetporttest[] = "proxygetporttest"; +const char g_szSharingArraytest[] = "sharingarraytest"; +const char g_szSetSharingtest[] = "setsharingtest"; +const char g_szUnsetSharingttest[] = "unsetsharingtest"; + +static int nRet; + + /** * @function Rpc_Message_On_Connected_cb * @description Callback function for rpc_port_proxy_add_connected_event_cb. @@ -46,6 +53,7 @@ static void Rpc_Message_On_Connected_cb(const char *endpoint, const char *port_n g_bCallbackCalled = true; char *pszWrite = NULL; + if (data == g_szDisconnecttest) { FPRINTF("[Line : %d][%s] connected to test disconnect %s\\n", __LINE__, API_NAMESPACE,endpoint); pszWrite = "disconnect"; @@ -58,7 +66,7 @@ static void Rpc_Message_On_Connected_cb(const char *endpoint, const char *port_n FPRINTF("[Line : %d][%s] connected to test read and write data %s\\n", __LINE__, API_NAMESPACE,endpoint); pszWrite = "write"; } - if ((data == g_szDisconnecttest) || (data == g_szPorttest) || (data == g_szReceivetest)) + if ((data == g_szDisconnecttest) || (data == g_szPorttest) || (data == g_szReceivetest)) { rpc_port_parcel_h hParcel; g_hReceivedPort = port; @@ -71,24 +79,51 @@ static void Rpc_Message_On_Connected_cb(const char *endpoint, const char *port_n normal_exit(0); FPRINTF("[Line : %d][%s] Leaving Callback Rpc_Message_On_Connected_cb \\n", __LINE__, API_NAMESPACE); return; - } - if (data == g_szProxygetporttest) + } + if (data == g_szProxygetporttest) { rpc_port_h callback_port; int ret; ret = rpc_port_proxy_get_port(g_hproxyhandle, RPC_PORT_PORT_CALLBACK, &callback_port); - if (ret != RPC_PORT_ERROR_NONE) + if (ret != RPC_PORT_ERROR_NONE) { FPRINTF("[Line : %d][%s] rpc_port_proxy_get_port fail %s\\n", __LINE__, API_NAMESPACE,endpoint); normal_exit(1); return; - } - else + } + else { normal_exit(0); return; } } + if (data == g_szSharingArraytest) + { + char pszFile1[PATH_LEN]; + char pszFile2[PATH_LEN]; + const char *pszFiles[3] = { NULL, }; + int nCount = 2; + + GetFilePath("file_name1.txt", pszFile1, sizeof(pszFile1)); + GetFilePath("file_name2.txt", pszFile2, sizeof(pszFile2)); + CreateFile(pszFile1, "test1"); + CreateFile(pszFile2, "test2"); + + pszFiles[0] = pszFile1; + pszFiles[1] = pszFile2; + nRet = rpc_port_set_private_sharing_array(port, pszFiles, nCount); + } + if (data == g_szSetSharingtest) + { + char pszFile[PATH_LEN]; + GetFilePath("file_name.txt", pszFile, sizeof(pszFile)); + CreateFile(pszFile, "test"); + nRet = rpc_port_set_private_sharing(port, pszFile); + } + if (data == g_szUnsetSharingttest) + { + nRet = rpc_port_unset_private_sharing(port); + } if (strncmp(endpoint, g_szService_App_Id,strlen(endpoint))) { FPRINTF("[Line : %d][%s] Mismatch App Id \\n", __LINE__, API_NAMESPACE); @@ -124,7 +159,7 @@ static void Rpc_Message_On_Connected_cb2(const char *endpoint, const char *port_ FPRINTF("[Line : %d][%s] connected to test read and write data %s\\n", __LINE__, API_NAMESPACE,endpoint); pszWrite = "write"; } - if ((data == g_szDisconnecttest) || (data == g_szPorttest) || (data == g_szReceivetest)) + if ((data == g_szDisconnecttest) || (data == g_szPorttest) || (data == g_szReceivetest)) { rpc_port_parcel_h hParcel; g_hReceivedPort = port; @@ -136,7 +171,7 @@ static void Rpc_Message_On_Connected_cb2(const char *endpoint, const char *port_ rpc_port_parcel_destroy(hParcel); g_main_loop_quit(g_pMainLoop); return; - } + } if (data == g_szProxygetporttest) { rpc_port_h callback_port; int ret; @@ -247,7 +282,7 @@ static void Rpc_Message_On_Received_cb(const char *endpoint, const char *port_na int nRet = -1; int nRetRead; - + nRetRead = rpc_port_proxy_get_port(g_hproxyhandle, RPC_PORT_PORT_CALLBACK, &hreceivedport); if ( nRetRead != RPC_PORT_ERROR_NONE ) { @@ -256,7 +291,7 @@ static void Rpc_Message_On_Received_cb(const char *endpoint, const char *port_na normal_exit(1); return; } - + nRetRead = rpc_port_parcel_create_from_port(&parcel_received, hreceivedport); if(nRetRead != RPC_PORT_ERROR_NONE) { @@ -367,7 +402,7 @@ int ITc_rpc_port_proxy_get_port_p(void) rpc_port_h *hPort = NULL; g_bCallbackCalled = false; int nTimeoutId = -1; - rpc_port_port_type_e ePortType[]= { + rpc_port_port_type_e ePortType[]= { RPC_PORT_PORT_MAIN, /**< Main channel */ RPC_PORT_PORT_CALLBACK, /**< The channel for callbacks */ }; @@ -675,7 +710,7 @@ int ITc_rpc_port_proxy_add_rejected_event_cb_p(void) int ITc_rpc_port_proxy_add_received_event_cb_p(void) { START_TEST; - + rpc_port_proxy_h hPortProxy = NULL; g_bCallbackCalled = false; g_callbackMsgreceived = false; @@ -708,5 +743,140 @@ int ITc_rpc_port_proxy_add_received_event_cb_p(void) return 0; } +/** +* @testcase ITc_rpc_port_proxy_connect_sync_p +* @since_tizen 6.0 +* @author SRID(priya.kohli) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Connects to rpc port synchronously. +* @scenario Check whether the result is RPC_PORT_ERROR_NONE or NOT +* and check if connected callback is called. +* @apicovered rpc_port_proxy_connect_sync +* @passcase When rpc_port_proxy_connect_sync is successful. +* @failcase If target API fails or any precondition API fails +* @precondition None +* @postcondition None +*/ +int ITc_rpc_port_proxy_connect_sync_p(void) +{ + START_TEST; + + int nRetVal = -1; + g_bCallbackCalled = false; + + nRetVal = rpc_port_proxy_add_connected_event_cb(g_hproxyhandle,Rpc_Message_On_Connected_cb, NULL); + PRINT_RESULT(RPC_PORT_ERROR_NONE, nRetVal, "rpc_port_proxy_add_connected_event_cb", RpcPortGetError(nRetVal)); + + nRetVal = rpc_port_proxy_connect_sync(g_hproxyhandle,g_szService_App_Id, g_szPort_Name); + PRINT_RESULT(RPC_PORT_ERROR_NONE, nRetVal, "rpc_port_proxy_connect_sync", RpcPortGetError(nRetVal)); + PRINT_RESULT(true, g_bCallbackCalled, "rpc_port_proxy_connect_sync", RpcPortGetError(nRetVal)); + + return 0; +} + +/** +* @testcase ITc_rpc_port_set_private_sharing_array_p +* @since_tizen 6.0 +* @author SRID(priya.kohli) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Shares files for the stub application. +* @scenario Check whether the result is RPC_PORT_ERROR_NONE or NOT +* Sets the paths of private sharing files. +* @apicovered rpc_port_set_private_sharing_array +* @passcase When rpc_port_set_private_sharing_array is successful. +* @failcase If target API fails or any precondition API fails +* @precondition None +* @postcondition None +*/ +int ITc_rpc_port_set_private_sharing_array_p(void) +{ + START_TEST; + + int nRetVal = -1; + nRet = -1; + g_bCallbackCalled = false; + + nRetVal = rpc_port_proxy_add_connected_event_cb(g_hproxyhandle,Rpc_Message_On_Connected_cb, g_szSharingArraytest); + PRINT_RESULT(RPC_PORT_ERROR_NONE, nRetVal, "rpc_port_proxy_add_connected_event_cb", RpcPortGetError(nRetVal)); + + nRetVal = rpc_port_proxy_connect_sync(g_hproxyhandle,g_szService_App_Id, g_szPort_Name); + PRINT_RESULT(RPC_PORT_ERROR_NONE, nRetVal, "rpc_port_proxy_connect_sync", RpcPortGetError(nRetVal)); + PRINT_RESULT(RPC_PORT_ERROR_NONE, nRet, "rpc_port_set_private_sharing_array", RpcPortGetError(nRetVal)); + PRINT_RESULT(true, g_bCallbackCalled, "rpc_port_set_private_sharing_array", RpcPortGetError(nRetVal)); + + return 0; +} + +/** +* @testcase ITc_rpc_port_set_private_sharing_p +* @since_tizen 6.0 +* @author SRID(priya.kohli) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Shares a file for the stub application. +* @scenario Check whether the result is RPC_PORT_ERROR_NONE or NOT +* Sets the path of the private sharing file. +* @apicovered rpc_port_set_private_sharing +* @passcase When rpc_port_set_private_sharing is successful. +* @failcase If target API fails or any precondition API fails +* @precondition None +* @postcondition None +*/ +int ITc_rpc_port_set_private_sharing_p(void) +{ + START_TEST; + + int nRetVal = -1; + nRet = -1; + g_bCallbackCalled = false; + + + nRetVal = rpc_port_proxy_add_connected_event_cb(g_hproxyhandle,Rpc_Message_On_Connected_cb, g_szSetSharingtest); + PRINT_RESULT(RPC_PORT_ERROR_NONE, nRetVal, "rpc_port_proxy_add_connected_event_cb", RpcPortGetError(nRetVal)); + + nRetVal = rpc_port_proxy_connect_sync(g_hproxyhandle,g_szService_App_Id, g_szPort_Name); + PRINT_RESULT(RPC_PORT_ERROR_NONE, nRetVal, "rpc_port_proxy_connect_sync", RpcPortGetError(nRetVal)); + PRINT_RESULT(RPC_PORT_ERROR_NONE, nRet, "rpc_port_set_private_sharing", RpcPortGetError(nRetVal)); + PRINT_RESULT(true, g_bCallbackCalled, "rpc_port_set_private_sharing", RpcPortGetError(nRetVal)); + + return 0; +} + +/** +* @testcase ITc_rpc_port_unset_private_sharing_p +* @since_tizen 6.0 +* @author SRID(priya.kohli) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Unshares the file. +* @scenario Check whether the result is RPC_PORT_ERROR_NONE or NOT +* Unsets the private sharing. +* @apicovered rpc_port_unset_private_sharing +* @passcase When rpc_port_unset_private_sharing is successful. +* @failcase If target API fails or any precondition API fails +* @precondition None +* @postcondition None +*/ +int ITc_rpc_port_unset_private_sharing_p(void) +{ + START_TEST; + + int nRetVal = -1; + nRet = -1; + g_bCallbackCalled = false; + + nRetVal = rpc_port_proxy_add_connected_event_cb(g_hproxyhandle,Rpc_Message_On_Connected_cb, g_szUnsetSharingttest); + PRINT_RESULT(RPC_PORT_ERROR_NONE, nRetVal, "rpc_port_proxy_add_connected_event_cb", RpcPortGetError(nRetVal)); + + nRetVal = rpc_port_proxy_connect_sync(g_hproxyhandle,g_szService_App_Id, g_szPort_Name); + PRINT_RESULT(RPC_PORT_ERROR_NONE, nRetVal, "rpc_port_proxy_connect_sync", RpcPortGetError(nRetVal)); + PRINT_RESULT(RPC_PORT_ERROR_NONE, nRet, "rpc_port_unset_private_sharing", RpcPortGetError(nRetVal)); + PRINT_RESULT(true, g_bCallbackCalled, "rpc_port_unset_private_sharing", RpcPortGetError(nRetVal)); + + return 0; +} + +/** @} */ /** @} */ -/** @} */ \ No newline at end of file diff --git a/src/itc/rpc-port/tct-rpc-port-native_mobile.h b/src/itc/rpc-port/tct-rpc-port-native_mobile.h index 95b94eb68..27a22c543 100755 --- a/src/itc/rpc-port/tct-rpc-port-native_mobile.h +++ b/src/itc/rpc-port/tct-rpc-port-native_mobile.h @@ -56,6 +56,10 @@ extern int ITc_rpc_port_stub_get_port_p(void); extern int ITc_rpc_port_stub_add_disconnected_event_cb_p(void); extern int ITc_rpc_port_write_p(void); extern int ITc_rpc_port_read_p(void); +extern int ITc_rpc_port_proxy_connect_sync_p(void); +extern int ITc_rpc_port_set_private_sharing_array_p(void); +extern int ITc_rpc_port_set_private_sharing_p(void); +extern int ITc_rpc_port_unset_private_sharing_p(void); testcase tc_array[] = { {"ITc_rpc_port_proxy_get_port_p",ITc_rpc_port_proxy_get_port_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, @@ -88,6 +92,10 @@ testcase tc_array[] = { {"ITc_rpc_port_write_p",ITc_rpc_port_write_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, {"ITc_rpc_port_read_p",ITc_rpc_port_read_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, {"ITc_rpc_port_stub_add_disconnected_event_cb_p",ITc_rpc_port_stub_add_disconnected_event_cb_p,ITs_rpc_port_stub_startup,ITs_rpc_port_stub_cleanup}, + {"ITc_rpc_port_proxy_connect_sync_p",ITc_rpc_port_proxy_connect_sync_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, + {"ITc_rpc_port_set_private_sharing_array_p",ITc_rpc_port_set_private_sharing_array_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, + {"ITc_rpc_port_set_private_sharing_p",ITc_rpc_port_set_private_sharing_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, + {"ITc_rpc_port_unset_private_sharing_p",ITc_rpc_port_unset_private_sharing_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, {NULL, NULL} }; diff --git a/src/itc/rpc-port/tct-rpc-port-native_tizeniot.h b/src/itc/rpc-port/tct-rpc-port-native_tizeniot.h index 95b94eb68..27a22c543 100755 --- a/src/itc/rpc-port/tct-rpc-port-native_tizeniot.h +++ b/src/itc/rpc-port/tct-rpc-port-native_tizeniot.h @@ -56,6 +56,10 @@ extern int ITc_rpc_port_stub_get_port_p(void); extern int ITc_rpc_port_stub_add_disconnected_event_cb_p(void); extern int ITc_rpc_port_write_p(void); extern int ITc_rpc_port_read_p(void); +extern int ITc_rpc_port_proxy_connect_sync_p(void); +extern int ITc_rpc_port_set_private_sharing_array_p(void); +extern int ITc_rpc_port_set_private_sharing_p(void); +extern int ITc_rpc_port_unset_private_sharing_p(void); testcase tc_array[] = { {"ITc_rpc_port_proxy_get_port_p",ITc_rpc_port_proxy_get_port_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, @@ -88,6 +92,10 @@ testcase tc_array[] = { {"ITc_rpc_port_write_p",ITc_rpc_port_write_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, {"ITc_rpc_port_read_p",ITc_rpc_port_read_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, {"ITc_rpc_port_stub_add_disconnected_event_cb_p",ITc_rpc_port_stub_add_disconnected_event_cb_p,ITs_rpc_port_stub_startup,ITs_rpc_port_stub_cleanup}, + {"ITc_rpc_port_proxy_connect_sync_p",ITc_rpc_port_proxy_connect_sync_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, + {"ITc_rpc_port_set_private_sharing_array_p",ITc_rpc_port_set_private_sharing_array_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, + {"ITc_rpc_port_set_private_sharing_p",ITc_rpc_port_set_private_sharing_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, + {"ITc_rpc_port_unset_private_sharing_p",ITc_rpc_port_unset_private_sharing_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, {NULL, NULL} }; diff --git a/src/itc/rpc-port/tct-rpc-port-native_wearable.h b/src/itc/rpc-port/tct-rpc-port-native_wearable.h index 95b94eb68..27a22c543 100755 --- a/src/itc/rpc-port/tct-rpc-port-native_wearable.h +++ b/src/itc/rpc-port/tct-rpc-port-native_wearable.h @@ -56,6 +56,10 @@ extern int ITc_rpc_port_stub_get_port_p(void); extern int ITc_rpc_port_stub_add_disconnected_event_cb_p(void); extern int ITc_rpc_port_write_p(void); extern int ITc_rpc_port_read_p(void); +extern int ITc_rpc_port_proxy_connect_sync_p(void); +extern int ITc_rpc_port_set_private_sharing_array_p(void); +extern int ITc_rpc_port_set_private_sharing_p(void); +extern int ITc_rpc_port_unset_private_sharing_p(void); testcase tc_array[] = { {"ITc_rpc_port_proxy_get_port_p",ITc_rpc_port_proxy_get_port_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, @@ -88,6 +92,10 @@ testcase tc_array[] = { {"ITc_rpc_port_write_p",ITc_rpc_port_write_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, {"ITc_rpc_port_read_p",ITc_rpc_port_read_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, {"ITc_rpc_port_stub_add_disconnected_event_cb_p",ITc_rpc_port_stub_add_disconnected_event_cb_p,ITs_rpc_port_stub_startup,ITs_rpc_port_stub_cleanup}, + {"ITc_rpc_port_proxy_connect_sync_p",ITc_rpc_port_proxy_connect_sync_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, + {"ITc_rpc_port_set_private_sharing_array_p",ITc_rpc_port_set_private_sharing_array_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, + {"ITc_rpc_port_set_private_sharing_p",ITc_rpc_port_set_private_sharing_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, + {"ITc_rpc_port_unset_private_sharing_p",ITc_rpc_port_unset_private_sharing_p,ITs_rpc_port_proxy_startup,ITs_rpc_port_proxy_cleanup}, {NULL, NULL} };