[ITC][account-svc][ACR-1457][Added TCs for getting deleted account information] 14/215614/4
authorABHISHEK JAIN <j.abhishek@samsung.com>
Fri, 11 Oct 2019 11:36:41 +0000 (17:06 +0530)
committershobhit verma <shobhit.v@samsung.com>
Mon, 14 Oct 2019 06:36:58 +0000 (06:36 +0000)
Change-Id: I0cd203938bbb9c1a3579cc5037fb5cfd10cc482b
Signed-off-by: ABHISHEK JAIN <j.abhishek@samsung.com>
src/itc/accounts-svc/ITs-accounts-svc-common.h
src/itc/accounts-svc/ITs-accounts-svc.c
src/itc/accounts-svc/tct-accounts-svc-native_mobile.h
src/itc/accounts-svc/tct-accounts-svc-native_tizeniot.h
src/itc/accounts-svc/tct-accounts-svc-native_wearable.h

index 0d2144b355e50ed0b40f55900aa4db9bea90263e..26cf3f79b9cd333569936ebe41449bd5f2aea712 100755 (executable)
        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;
index dc5b26491cb6d3136b725a0f08b4228fb6540d52..e68a151fb68ee9aec0f7775808b20af9be7adaaa 100755 (executable)
@@ -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;
+}
+
 /** @} */
 /** @} */
index 2647b3f6c6f7ed25a47b689843fbd500c03c0ea7..387b8fe3f21ef2fd8296a4a88087a7ff2a1a5179 100755 (executable)
@@ -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}
 };
 
index 2647b3f6c6f7ed25a47b689843fbd500c03c0ea7..387b8fe3f21ef2fd8296a4a88087a7ff2a1a5179 100755 (executable)
@@ -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}
 };
 
index 2647b3f6c6f7ed25a47b689843fbd500c03c0ea7..387b8fe3f21ef2fd8296a4a88087a7ff2a1a5179 100755 (executable)
@@ -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}
 };