From: ABHISHEK JAIN Date: Fri, 11 Oct 2019 11:36:41 +0000 (+0530) Subject: [ITC][account-svc][ACR-1457][Added TCs for getting deleted account information] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2dc21f175e6ee7c5ac9973b1ea8ebf549ea3b39d;p=test%2Ftct%2Fnative%2Fapi.git [ITC][account-svc][ACR-1457][Added TCs for getting deleted account information] Change-Id: I0cd203938bbb9c1a3579cc5037fb5cfd10cc482b Signed-off-by: ABHISHEK JAIN --- diff --git a/src/itc/accounts-svc/ITs-accounts-svc-common.h b/src/itc/accounts-svc/ITs-accounts-svc-common.h index 0d2144b35..26cf3f79b 100755 --- a/src/itc/accounts-svc/ITs-accounts-svc-common.h +++ b/src/itc/accounts-svc/ITs-accounts-svc-common.h @@ -76,6 +76,15 @@ mainloop = NULL;\ } +#define CHECK_HANDLE_CLEANUP(Handle, API, FreeResource) {\ + if ( Handle == NULL )\ + {\ + FPRINTF("[Line : %d][%s] %s failed, error returned = Handle returned is NULL\\n", __LINE__, API_NAMESPACE, API);\ + FreeResource;\ + return 1;\ + }\ +} + /*********************** Global Variables *******************************/ bool g_bAccountLabelCB; diff --git a/src/itc/accounts-svc/ITs-accounts-svc.c b/src/itc/accounts-svc/ITs-accounts-svc.c index dc5b26491..e68a151fb 100755 --- a/src/itc/accounts-svc/ITs-accounts-svc.c +++ b/src/itc/accounts-svc/ITs-accounts-svc.c @@ -3418,5 +3418,119 @@ int ITc_account_type_query_by_provider_feature_p(void) return 0; } +//& purpose: Retrieves deleted account with the account ID. +//& type: auto +/** +* @testcase ITc_account_query_deleted_account_info_by_account_id_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Retrieves deleted account with the account ID. +* @scenario set user name, package name capabity and insert account to DB +* query acc by acc ID, delete account by acc ID, retrive deleted acc by ID +* compare all set attributes with retrived attributes. +* @apicovered account_query_deleted_account_info_by_account_id +* @passcase When Target API is successful and retrived value matches +* @failcase If target API fails or any precondition and postcondition API fails +* @precondition Creates a handle to the account +* @postcondition Destroys the account handle and releases all its resources +*/ +int ITc_account_query_deleted_account_info_by_account_id_p(void) +{ + + START_TEST; + + int nRet = ACCOUNT_ERROR_NONE; + int nAccId = -1; + account_h hRetAccount = NULL; + account_h hDelAccount = NULL; + char* pszRetUsrName = NULL; + char* pszDelUsrName = NULL; + char* pszRetPkgName = NULL; + char* pszDelPkgName = NULL; + + account_capability_state_e eRetCapabilityType = 0; + account_capability_state_e eDelCapabilityType = 0; + char pszSetUserName[] = "TEST_TIZEN"; + + nRet = account_set_user_name(g_account, pszSetUserName); + PRINT_RESULT(ACCOUNT_ERROR_NONE, nRet, "account_set_user_name", AccManagerGetErrorMSG(nRet)); + + nRet = account_set_package_name(g_account, g_pstrAppId); + PRINT_RESULT(ACCOUNT_ERROR_NONE, nRet, "account_set_package_name", AccManagerGetErrorMSG(nRet)); + + nRet = account_set_capability(g_account, (char *)CALENDAR_CAPABILITY, ACCOUNT_CAPABILITY_ENABLED); + PRINT_RESULT(ACCOUNT_ERROR_NONE, nRet, "account_set_capability", AccManagerGetErrorMSG(nRet)); + + nRet = account_insert_to_db(g_account, &nAccId); + PRINT_RESULT(ACCOUNT_ERROR_NONE, nRet, "account_insert_to_db", AccManagerGetErrorMSG(nRet)); + if(nAccId < 0) + { + FPRINTF("[Line : %d][%s] account_insert_to_db failed. nAccId is -1\\n", __LINE__, API_NAMESPACE); + return 1; + } + + nRet = account_create(&hRetAccount); + PRINT_RESULT_CLEANUP(ACCOUNT_ERROR_NONE, nRet, "account_create", AccManagerGetErrorMSG(nRet), account_delete_from_db_by_id(nAccId);); + CHECK_HANDLE_CLEANUP(hRetAccount, "account_create", account_delete_from_db_by_id(nAccId)); + + nRet = account_query_account_by_account_id(nAccId, &hRetAccount); + PRINT_RESULT_CLEANUP(ACCOUNT_ERROR_NONE, nRet, "account_query_account_by_account_id", AccManagerGetErrorMSG(nRet), account_delete_from_db_by_id(nAccId); account_destroy(hRetAccount)); + CHECK_HANDLE_CLEANUP(hRetAccount, "account_query_account_by_account_id", account_delete_from_db_by_id(nAccId); account_destroy(hRetAccount)); + + nRet = account_delete_from_db_by_id(nAccId); + PRINT_RESULT_CLEANUP(ACCOUNT_ERROR_NONE, nRet, "account_delete_from_db_by_id", AccManagerGetErrorMSG(nRet), account_destroy(hRetAccount)); + + nRet = account_create(&hDelAccount); + PRINT_RESULT_CLEANUP(ACCOUNT_ERROR_NONE, nRet, "account_create", AccManagerGetErrorMSG(nRet), account_destroy(hRetAccount)); + CHECK_HANDLE_CLEANUP(hRetAccount, "account_create", account_destroy(hRetAccount)); + + //Target API + nRet = account_query_deleted_account_info_by_account_id(nAccId, &hDelAccount); + PRINT_RESULT_CLEANUP(ACCOUNT_ERROR_NONE, nRet, "account_query_deleted_account_info_by_account_id", AccManagerGetErrorMSG(nRet), account_destroy(hRetAccount); account_destroy(hDelAccount)); + + nRet = account_get_user_name(hRetAccount, &pszRetUsrName); + PRINT_RESULT_CLEANUP(ACCOUNT_ERROR_NONE, nRet, "account_get_user_name", AccManagerGetErrorMSG(nRet), account_destroy(hRetAccount); account_destroy(hDelAccount)); + + nRet = account_get_user_name(hDelAccount, &pszDelUsrName); + PRINT_RESULT_CLEANUP(ACCOUNT_ERROR_NONE, nRet, "account_get_user_name", AccManagerGetErrorMSG(nRet), account_destroy(hRetAccount); account_destroy(hDelAccount); FREE_MEMORY(pszRetUsrName)); + + nRet = account_get_package_name(hRetAccount, &pszRetPkgName); + PRINT_RESULT_CLEANUP(ACCOUNT_ERROR_NONE, nRet, "account_get_package_name", AccManagerGetErrorMSG(nRet), account_destroy(hRetAccount); account_destroy(hDelAccount); FREE_MEMORY(pszRetUsrName); FREE_MEMORY(pszDelUsrName)); + + nRet = account_get_package_name(hDelAccount, &pszDelPkgName); + PRINT_RESULT_CLEANUP(ACCOUNT_ERROR_NONE, nRet, "account_get_package_name", AccManagerGetErrorMSG(nRet), account_destroy(hRetAccount); account_destroy(hDelAccount); FREE_MEMORY(pszRetUsrName); FREE_MEMORY(pszDelUsrName); FREE_MEMORY(pszRetPkgName)); + + nRet = account_get_capability(hRetAccount, (char *)CALENDAR_CAPABILITY, &eRetCapabilityType); + PRINT_RESULT_CLEANUP(ACCOUNT_ERROR_NONE, nRet, "account_get_capability", AccManagerGetErrorMSG(nRet), account_destroy(hRetAccount); account_destroy(hDelAccount); FREE_MEMORY(pszRetUsrName); FREE_MEMORY(pszDelUsrName); FREE_MEMORY(pszRetPkgName); FREE_MEMORY(pszDelPkgName)); + PRINT_RESULT_CLEANUP(ACCOUNT_CAPABILITY_ENABLED, eRetCapabilityType, "account_get_capability", "Set and Get values mismatch Capability State", account_destroy(hRetAccount); account_destroy(hDelAccount); FREE_MEMORY(pszRetUsrName); FREE_MEMORY(pszDelUsrName); FREE_MEMORY(pszRetPkgName); FREE_MEMORY(pszDelPkgName)); + + nRet = account_get_capability(hDelAccount, (char *)CALENDAR_CAPABILITY, &eDelCapabilityType); + PRINT_RESULT_CLEANUP(ACCOUNT_ERROR_NONE, nRet, "account_get_capability", AccManagerGetErrorMSG(nRet), account_delete_from_db_by_id(nAccId); FREE_MEMORY(pszRetUsrName); FREE_MEMORY(pszDelUsrName); FREE_MEMORY(pszRetPkgName); FREE_MEMORY(pszDelPkgName)); + PRINT_RESULT_CLEANUP(ACCOUNT_CAPABILITY_ENABLED, eDelCapabilityType, "account_get_capability", "Set and Get values mismatch Capability State", account_destroy(hRetAccount); account_destroy(hDelAccount); FREE_MEMORY(pszRetUsrName); FREE_MEMORY(pszDelUsrName); FREE_MEMORY(pszRetPkgName); FREE_MEMORY(pszDelPkgName)); + + PRINT_RESULT_CLEANUP(0, strncmp(pszRetUsrName, pszSetUserName, sizeof(pszSetUserName)-1) , "account_get_user_name", "Set and Get user names are different", account_delete_from_db_by_id(nAccId); FREE_MEMORY(pszRetUsrName); FREE_MEMORY(pszDelUsrName); FREE_MEMORY(pszRetPkgName); FREE_MEMORY(pszDelPkgName)); + + PRINT_RESULT_CLEANUP(0, strncmp(pszDelUsrName, pszSetUserName, sizeof(pszSetUserName)-1) , "account_get_user_name", "Set and Get user names are different", account_delete_from_db_by_id(nAccId); FREE_MEMORY(pszRetUsrName); FREE_MEMORY(pszDelUsrName); FREE_MEMORY(pszRetPkgName); FREE_MEMORY(pszDelPkgName)); + + PRINT_RESULT_CLEANUP(0, strncmp(pszRetPkgName, g_pstrAppId, sizeof(pszSetUserName)-1) , "account_get_package_name", "Set and Get package names are different", account_delete_from_db_by_id(nAccId); FREE_MEMORY(pszRetUsrName); FREE_MEMORY(pszDelUsrName); FREE_MEMORY(pszRetPkgName); FREE_MEMORY(pszDelPkgName)); + + PRINT_RESULT_CLEANUP(0, strncmp(pszDelPkgName, g_pstrAppId, sizeof(pszSetUserName)-1) , "account_get_package_name", "Set and Get package names are different", account_delete_from_db_by_id(nAccId); FREE_MEMORY(pszRetUsrName); FREE_MEMORY(pszDelUsrName); FREE_MEMORY(pszRetPkgName); FREE_MEMORY(pszDelPkgName)); + + FREE_MEMORY(pszRetUsrName); + FREE_MEMORY(pszDelUsrName); + FREE_MEMORY(pszRetPkgName); + FREE_MEMORY(pszDelPkgName); + + nRet = account_destroy(hRetAccount); + PRINT_RESULT_NORETURN(ACCOUNT_ERROR_NONE, nRet, "account_destroy", AccManagerGetErrorMSG(nRet)); + + nRet = account_destroy(hDelAccount); + PRINT_RESULT_NORETURN(ACCOUNT_ERROR_NONE, nRet, "account_destroy", AccManagerGetErrorMSG(nRet)); + + return 0; +} + /** @} */ /** @} */ diff --git a/src/itc/accounts-svc/tct-accounts-svc-native_mobile.h b/src/itc/accounts-svc/tct-accounts-svc-native_mobile.h index 2647b3f6c..387b8fe3f 100755 --- a/src/itc/accounts-svc/tct-accounts-svc-native_mobile.h +++ b/src/itc/accounts-svc/tct-accounts-svc-native_mobile.h @@ -70,6 +70,7 @@ extern int ITc_account_type_query_label_by_locale_p(void); extern int ITc_account_delete_from_db_by_package_name_p(void); extern int ITc_account_delete_by_user_name_p(void); extern int ITc_account_type_query_by_provider_feature_p(void); +extern int ITc_account_query_deleted_account_info_by_account_id_p(void); testcase tc_array[] = { {"ITc_account_type_foreach_account_type_from_db_p",ITc_account_type_foreach_account_type_from_db_p,ITs_accounts_svc_startup,ITs_accounts_svc_cleanup}, @@ -120,6 +121,7 @@ testcase tc_array[] = { {"ITc_account_delete_from_db_by_package_name_p",ITc_account_delete_from_db_by_package_name_p,ITs_accounts_svc_startup,ITs_accounts_svc_cleanup}, {"ITc_account_delete_by_user_name_p",ITc_account_delete_by_user_name_p,ITs_accounts_svc_startup,ITs_accounts_svc_cleanup}, {"ITc_account_type_query_by_provider_feature_p",ITc_account_type_query_by_provider_feature_p,ITs_accounts_svc_startup,ITs_accounts_svc_cleanup}, + {"ITc_account_query_deleted_account_info_by_account_id_p", ITc_account_query_deleted_account_info_by_account_id_p, ITs_accounts_svc_startup, ITs_accounts_svc_cleanup}, {NULL, NULL} }; diff --git a/src/itc/accounts-svc/tct-accounts-svc-native_tizeniot.h b/src/itc/accounts-svc/tct-accounts-svc-native_tizeniot.h index 2647b3f6c..387b8fe3f 100755 --- a/src/itc/accounts-svc/tct-accounts-svc-native_tizeniot.h +++ b/src/itc/accounts-svc/tct-accounts-svc-native_tizeniot.h @@ -70,6 +70,7 @@ extern int ITc_account_type_query_label_by_locale_p(void); extern int ITc_account_delete_from_db_by_package_name_p(void); extern int ITc_account_delete_by_user_name_p(void); extern int ITc_account_type_query_by_provider_feature_p(void); +extern int ITc_account_query_deleted_account_info_by_account_id_p(void); testcase tc_array[] = { {"ITc_account_type_foreach_account_type_from_db_p",ITc_account_type_foreach_account_type_from_db_p,ITs_accounts_svc_startup,ITs_accounts_svc_cleanup}, @@ -120,6 +121,7 @@ testcase tc_array[] = { {"ITc_account_delete_from_db_by_package_name_p",ITc_account_delete_from_db_by_package_name_p,ITs_accounts_svc_startup,ITs_accounts_svc_cleanup}, {"ITc_account_delete_by_user_name_p",ITc_account_delete_by_user_name_p,ITs_accounts_svc_startup,ITs_accounts_svc_cleanup}, {"ITc_account_type_query_by_provider_feature_p",ITc_account_type_query_by_provider_feature_p,ITs_accounts_svc_startup,ITs_accounts_svc_cleanup}, + {"ITc_account_query_deleted_account_info_by_account_id_p", ITc_account_query_deleted_account_info_by_account_id_p, ITs_accounts_svc_startup, ITs_accounts_svc_cleanup}, {NULL, NULL} }; diff --git a/src/itc/accounts-svc/tct-accounts-svc-native_wearable.h b/src/itc/accounts-svc/tct-accounts-svc-native_wearable.h index 2647b3f6c..387b8fe3f 100755 --- a/src/itc/accounts-svc/tct-accounts-svc-native_wearable.h +++ b/src/itc/accounts-svc/tct-accounts-svc-native_wearable.h @@ -70,6 +70,7 @@ extern int ITc_account_type_query_label_by_locale_p(void); extern int ITc_account_delete_from_db_by_package_name_p(void); extern int ITc_account_delete_by_user_name_p(void); extern int ITc_account_type_query_by_provider_feature_p(void); +extern int ITc_account_query_deleted_account_info_by_account_id_p(void); testcase tc_array[] = { {"ITc_account_type_foreach_account_type_from_db_p",ITc_account_type_foreach_account_type_from_db_p,ITs_accounts_svc_startup,ITs_accounts_svc_cleanup}, @@ -120,6 +121,7 @@ testcase tc_array[] = { {"ITc_account_delete_from_db_by_package_name_p",ITc_account_delete_from_db_by_package_name_p,ITs_accounts_svc_startup,ITs_accounts_svc_cleanup}, {"ITc_account_delete_by_user_name_p",ITc_account_delete_by_user_name_p,ITs_accounts_svc_startup,ITs_accounts_svc_cleanup}, {"ITc_account_type_query_by_provider_feature_p",ITc_account_type_query_by_provider_feature_p,ITs_accounts_svc_startup,ITs_accounts_svc_cleanup}, + {"ITc_account_query_deleted_account_info_by_account_id_p", ITc_account_query_deleted_account_info_by_account_id_p, ITs_accounts_svc_startup, ITs_accounts_svc_cleanup}, {NULL, NULL} };