From: ABHISHEK JAIN Date: Tue, 23 Jul 2019 13:22:38 +0000 (+0530) Subject: [ITC][notification][ACR-1384][New TCs for notification-ex APIs] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aab619e60c39b3ada7106be9268c5d55f3af7ab5;p=test%2Ftct%2Fnative%2Fapi.git [ITC][notification][ACR-1384][New TCs for notification-ex APIs] Change-Id: I1656bc94efef0b840965520601e55fddf9aa9330 Signed-off-by: ABHISHEK JAIN --- diff --git a/src/itc/notification/CMakeLists.txt b/src/itc/notification/CMakeLists.txt index 30615ea1f..dd3fd4608 100755 --- a/src/itc/notification/CMakeLists.txt +++ b/src/itc/notification/CMakeLists.txt @@ -5,8 +5,9 @@ SET(RPM_NAME "native-${PKG_NAME}-itc") SET(CAPI_LIB "notification gobject-2.0") SET(TC_SOURCES - ITs-notification-common.c + ITs-notification-common.c ITs-notification.c + ITs-notification-ex.c ) PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED diff --git a/src/itc/notification/ITs-notification-common.c b/src/itc/notification/ITs-notification-common.c index 5b6f730ff..30e8c0e62 100755 --- a/src/itc/notification/ITs-notification-common.c +++ b/src/itc/notification/ITs-notification-common.c @@ -167,4 +167,315 @@ char* Application_AppControlGetError(int nRet) return szErrorVal; } +/** + * @function Timeout + * @description Called if some callback is not invoked for a particular timeout + * @parameter gpointer data + * @return gboolean + */ +gboolean Timeout(gpointer data) +{ + GMainLoop *pMainLoop = NULL; + pMainLoop = (GMainLoop *)data; + if ( pMainLoop != NULL ) + { + g_main_loop_quit(pMainLoop); + } + return false; +} + +/** +* @function NotificationExGetError +* @description Maps error enums to string values +* @parameter nRet : error code returned +* @return error string +*/ +char* NotificationExGetError(int nRet) +{ + char *szErrorVal = "Unknown Error"; + switch ( nRet ) + { + case NOTI_EX_ERROR_NONE: szErrorVal = "NOTI_EX_ERROR_NONE"; break; + case NOTI_EX_ERROR_INVALID_PARAMETER: szErrorVal = "NOTI_EX_ERROR_INVALID_PARAMETER"; break; + case NOTI_EX_ERROR_OUT_OF_MEMORY: szErrorVal = "NOTI_EX_ERROR_OUT_OF_MEMORY"; break; + case NOTI_EX_ERROR_IO_ERROR: szErrorVal = "NOTI_EX_ERROR_IO_ERROR"; break; + case NOTI_EX_ERROR_PERMISSION_DENIED: szErrorVal = "NOTI_EX_ERROR_PERMISSION_DENIED"; break; + case NOTI_EX_ERROR_INVALID_OPERATION: szErrorVal = "NOTI_EX_ERROR_INVALID_OPERATION"; break; + case NOTI_EX_ERROR_FROM_DB: szErrorVal = "NOTI_EX_ERROR_FROM_DB"; break; + case NOTI_EX_ERROR_ALREADY_EXIST_ID: szErrorVal = "NOTI_EX_ERROR_ALREADY_EXIST_ID"; break; + case NOTI_EX_ERROR_FROM_DBUS: szErrorVal = "NOTI_EX_ERROR_FROM_DBUS"; break; + case NOTI_EX_ERROR_NOT_EXIST_ID: szErrorVal = "NOTI_EX_ERROR_NOT_EXIST_ID"; break; + case NOTI_EX_ERROR_SERVICE_NOT_READY: szErrorVal = "NOTI_EX_ERROR_SERVICE_NOT_READY"; break; + case NOTI_EX_ERROR_MAX_EXCEEDED: szErrorVal = "NOTI_EX_ERROR_MAX_EXCEEDED"; break; + } + return szErrorVal; +} + +void EventinfoReporterEventsErrorCB(noti_ex_reporter_h handle, noti_ex_error_e error, int req_id, void *data) +{ + g_CallBackHit = true; +#if DEBUG + FPRINTF("[Line : %d][%s] EventinfoReporterEventsErrorCB Callback Invoked\\n", __LINE__, API_NAMESPACE); +#endif +} + +void ReporterEventsErrorCB(noti_ex_reporter_h hExReporter, noti_ex_error_e eExError, int nReqID, void *data) +{ + g_CallBackHit = true; +#if DEBUG + FPRINTF("[Line : %d][%s] ReporterEventsErrorCB Callback Invoked\\n", __LINE__, API_NAMESPACE); +#endif +} + +/** +* @function SendNotification +* @description Helper function, sends notification to invoke callback. +* @parameter None +* @return '0' if pass, Error value in case any API fails. +*/ +int SendNotification() +{ + int nReqID; + int nRet = NOTI_EX_ERROR_NONE; + + if (g_hEventinfoReporter == NULL) { + noti_ex_reporter_events_s hEvent = {0}; + hEvent.error = EventinfoReporterEventsErrorCB; + nRet = noti_ex_reporter_create(&g_hEventinfoReporter, hEvent, NULL); + CHECK_HANDLE(g_hEventinfoReporter, "noti_ex_reporter_create"); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_create", NotificationExGetError(nRet)); + } + nRet = noti_ex_reporter_delete_all(g_hEventinfoReporter, &nReqID); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_delete_all", NotificationExGetError(nRet)); + + noti_ex_item_h hGroupItem = NULL; + noti_ex_item_h hButtonItem1 = NULL; + noti_ex_item_h hButtonItem2 = NULL; + + nRet = noti_ex_item_group_create(&hGroupItem, "testgroup"); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_group_create", NotificationExGetError(nRet)); + + nRet = noti_ex_item_button_create(&hButtonItem1, "testbtn1", "test1"); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_button_create", NotificationExGetError(nRet)); + nRet = noti_ex_item_group_add_child(hGroupItem, hButtonItem1); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_group_add_child", NotificationExGetError(nRet)); + + nRet = noti_ex_item_button_create(&hButtonItem2, "testbtn2", "test2"); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_button_create", NotificationExGetError(nRet)); + nRet = noti_ex_item_group_add_child(hGroupItem, hButtonItem2); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_group_add_child", NotificationExGetError(nRet)); + + nRet = noti_ex_item_set_channel(hGroupItem, "test_channel"); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_set_channel", NotificationExGetError(nRet)); + + nRet = noti_ex_reporter_post(g_hEventinfoReporter, hGroupItem, &nReqID); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_post", NotificationExGetError(nRet)); + + return nRet; +} + +/** +* @function CreateNotificationList +* @description Helper function, create notification and update list. +* @parameter None +* @return '0' if pass, Error value in case any API fails. +*/ +int CreateNotificationList(noti_ex_item_h **pszhItemList) +{ + int nRet = NOTI_EX_ERROR_NONE; + + if (g_hEventinfoReporter == NULL) { + noti_ex_reporter_events_s hReporterEvent = {0}; + hReporterEvent.error = ReporterEventsErrorCB; + nRet = noti_ex_reporter_create(&g_hEventinfoReporter, hReporterEvent, NULL); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_create", NotificationExGetError(nRet)); + } + noti_ex_item_h *hItemlist = (noti_ex_item_h*)calloc(2, sizeof(noti_ex_item_h)); + + noti_ex_item_h hGroupItem = NULL; + noti_ex_item_h hButtonItem1 = NULL; + noti_ex_item_h hButtonItem2 = NULL; + + nRet = noti_ex_item_group_create(&hGroupItem, "testgroup"); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_group_create", NotificationExGetError(nRet), FREE_MEMORY(hItemlist)); + + nRet = noti_ex_item_button_create(&hButtonItem1, "testbtn1", "test1"); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_button_create", NotificationExGetError(nRet), FREE_MEMORY(hItemlist)); + nRet = noti_ex_item_group_add_child(hGroupItem, hButtonItem1); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_group_add_child", NotificationExGetError(nRet), FREE_MEMORY(hItemlist)); + + + nRet = noti_ex_item_button_create(&hButtonItem2, "testbtn2", "test2"); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_button_create", NotificationExGetError(nRet), FREE_MEMORY(hItemlist)); + nRet = noti_ex_item_group_add_child(hGroupItem, hButtonItem2); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_group_add_child", NotificationExGetError(nRet), FREE_MEMORY(hItemlist)); + hItemlist[0] = hGroupItem; + + nRet = noti_ex_item_group_create(&hGroupItem, "testgroup2"); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_group_create", NotificationExGetError(nRet), FREE_MEMORY(hItemlist)); + + nRet = noti_ex_item_button_create(&hButtonItem1, "testbtn3", "test3"); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_button_create", NotificationExGetError(nRet), FREE_MEMORY(hItemlist)); + nRet = noti_ex_item_group_add_child(hGroupItem, hButtonItem1); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_group_add_child", NotificationExGetError(nRet), FREE_MEMORY(hItemlist)); + + + nRet = noti_ex_item_button_create(&hButtonItem2, "testbtn4", "test4"); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_button_create", NotificationExGetError(nRet), FREE_MEMORY(hItemlist)); + nRet = noti_ex_item_group_add_child(hGroupItem, hButtonItem2); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_group_add_child", NotificationExGetError(nRet), FREE_MEMORY(hItemlist)); + hItemlist[1] = hGroupItem; + + *pszhItemList = hItemlist; + return nRet; +} + +/** +* @function CreateChatMsgAttributes +* @description Helper function, create handles prior creation of chat message handle. +* @parameter None +* @return '0' if pass, Error value in case any API fails. +*/ +int CreateChatMsgAttributes() +{ + g_pszNameID = "name_id"; + g_pszNameText = "test_name"; + g_pszTextID = "text_id"; + g_pszTextText = "test_text"; + g_pszImageID = "text_id"; + g_pszImagePath = "test_image_path"; + g_pszTimeID = "time_id"; + g_pszChatID = "chat_id"; + g_eChatMsgType = NOTI_EX_ITEM_CHAT_MESSAGE_TYPE_USER; + + int nRet = NOTI_EX_ERROR_NONE; + nRet = noti_ex_item_text_create(&g_hItemName, g_pszNameID, g_pszNameText, NULL); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_text_create", NotificationExGetError(nRet)); + CHECK_HANDLE(g_hItemName, "noti_ex_item_text_create"); + + nRet = noti_ex_item_text_create(&g_hItemText, g_pszTextID, g_pszTextText, NULL); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_text_create", NotificationExGetError(nRet), noti_ex_item_destroy(g_hItemName)); + CHECK_HANDLE_CLEANUP(g_hItemText, "noti_ex_item_text_create", noti_ex_item_destroy(g_hItemName)); + + nRet = noti_ex_item_image_create(&g_hItemImage, g_pszImageID, g_pszImagePath); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_image_create", NotificationExGetError(nRet), noti_ex_item_destroy(g_hItemName); noti_ex_item_destroy(g_hItemText)); + CHECK_HANDLE_CLEANUP(g_hItemImage, "noti_ex_item_image_create", noti_ex_item_destroy(g_hItemName); noti_ex_item_destroy(g_hItemText)); + + time(&g_tCurrTime); + + nRet = noti_ex_item_time_create(&g_hItemTime, g_pszTimeID, g_tCurrTime); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_time_create", NotificationExGetError(nRet), noti_ex_item_destroy(g_hItemName); noti_ex_item_destroy(g_hItemText); noti_ex_item_destroy(g_hItemImage)); + CHECK_HANDLE_CLEANUP(g_hItemName, "noti_ex_item_time_create", noti_ex_item_destroy(g_hItemName); noti_ex_item_destroy(g_hItemText); noti_ex_item_destroy(g_hItemImage)); + return nRet; +} + +/** +* @function DestroyChatMsgAttributes +* @description Helper function, Destroys chat message related handles. +* @parameter None +* @return '0' if pass, Error value in case any API fails. +*/ +int DestroyChatMsgAttributes() +{ + int nRet = NOTI_EX_ERROR_NONE; + nRet = noti_ex_item_destroy(g_hItemName); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_destroy", NotificationExGetError(nRet)); + + nRet = noti_ex_item_destroy(g_hItemText); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_destroy", NotificationExGetError(nRet)); + + nRet = noti_ex_item_destroy(g_hItemImage); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_destroy", NotificationExGetError(nRet)); + + nRet = noti_ex_item_destroy(g_hItemTime); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_destroy", NotificationExGetError(nRet)); + + nRet = noti_ex_item_destroy(g_hItemChatMsg); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_destroy", NotificationExGetError(nRet)); + return nRet; +} + +/** +* @function CreateStyleAttributes +* @description Helper function, create all required handles for style handle creation. +* @parameter None +* @return '0' if pass, Error value in case any API fails. +*/ +int CreateStyleAttributes() +{ + g_cAlpha = 1; + g_cRed = 2; + g_cGreen = 3; + g_cBlue = 4; + g_nLeft = 1; + g_nTop = 2; + g_nRight = 3; + g_nBottom = 4; + g_nX = 1; + g_nY = 2; + g_nW = 3; + g_nH = 4; + int nRet = NOTI_EX_ERROR_NONE; + + nRet = noti_ex_color_create(&g_hColor, g_cAlpha, g_cRed, g_cGreen, g_cBlue); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_color_create", NotificationExGetError(nRet)); + CHECK_HANDLE(g_hColor, "noti_ex_color_create"); + + nRet = noti_ex_padding_create(&g_hPadding, g_nLeft, g_nTop, g_nRight, g_nBottom); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_padding_create", NotificationExGetError(nRet), noti_ex_color_destroy(g_hColor)); + CHECK_HANDLE_CLEANUP(g_hPadding, "noti_ex_padding_create", noti_ex_color_destroy(g_hColor)); + + nRet = noti_ex_geometry_create(&g_hGeometry, g_nX, g_nY, g_nW, g_nH); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_geometry_create", NotificationExGetError(nRet), noti_ex_color_destroy(g_hColor); noti_ex_padding_destroy(g_hPadding)); + CHECK_HANDLE_CLEANUP(g_hGeometry, "noti_ex_geometry_create", noti_ex_color_destroy(g_hColor); noti_ex_padding_destroy(g_hPadding)); + + nRet = noti_ex_style_create(&g_hStyle, g_hColor, g_hPadding, g_hGeometry); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_style_create", NotificationExGetError(nRet), noti_ex_color_destroy(g_hColor); noti_ex_padding_destroy(g_hPadding); noti_ex_geometry_destroy(g_hGeometry)); + CHECK_HANDLE_CLEANUP(g_hStyle, "noti_ex_style_create", noti_ex_color_destroy(g_hColor); noti_ex_padding_destroy(g_hPadding); noti_ex_geometry_destroy(g_hGeometry)); + + return nRet; +} + +/** +* @function DestroyStyleAttributes +* @description Helper function, destroys style and its related handle created. +* @parameter None +* @return '0' if pass, Error value in case any API fails. +*/ +int DestroyStyleAttributes() +{ + int nRet = NOTI_EX_ERROR_NONE; + + nRet = noti_ex_style_destroy(g_hStyle); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_style_destroy", NotificationExGetError(nRet)); + + nRet = noti_ex_color_destroy(g_hColor); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_color_destroy", NotificationExGetError(nRet)); + + nRet = noti_ex_padding_destroy(g_hPadding); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_padding_destroy", NotificationExGetError(nRet)); + + nRet = noti_ex_geometry_destroy(g_hGeometry); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_geometry_destroy", NotificationExGetError(nRet)); + + return nRet; +} + +/** +* @function CreateButton +* @description Helper function, to create button ex-item. +* @parameter None +* @return nRet, API return value. +*/ +int CreateButton() +{ + int nRet = NOTI_EX_ERROR_NONE; + g_hItemButton = NULL; + g_pszButtonID = "buttonID"; + g_pszButtonTitle = "buttonTitle"; + + nRet = noti_ex_item_button_create(&g_hItemButton, g_pszButtonID, g_pszButtonTitle); + return nRet; +} + /** @} */ //end of itc-notification diff --git a/src/itc/notification/ITs-notification-common.h b/src/itc/notification/ITs-notification-common.h index 5a9930f32..1cbc4412c 100755 --- a/src/itc/notification/ITs-notification-common.h +++ b/src/itc/notification/ITs-notification-common.h @@ -20,6 +20,9 @@ #include #include +#include +#include +#include /** @addtogroup itc-notification * @ingroup itc * @{ @@ -37,6 +40,8 @@ #define WAIT_CALLBACK 5 #define NOTIFICATION_TAG "notification_tag" #define PATH_LEN 1024 +#define GROUP_NOTI_ID "test_group" +#define TIMEOUT_CB 10000 #define FREE_NOTIFICATION(notification) if(notification != NULL) {notification_free(notification);} #define DELETE_NOTIFICATION(notification) if(notification != NULL) {notification_delete(notification);} @@ -52,13 +57,93 @@ }\ } +#define RUN_POLLING_LOOP {\ + g_pNotificationMainLoop = g_main_loop_new(NULL, false);\ + nTimeoutId = g_timeout_add(TIMEOUT_CB, Timeout, g_pNotificationMainLoop);\ + g_main_loop_run(g_pNotificationMainLoop);\ + g_source_remove(nTimeoutId);\ + g_pNotificationMainLoop = NULL;\ +} + +#define PRINT_RESULT_CALLBACK_NORETURN(eCompare, eRetVal, API, Error) {\ + if ( eRetVal == eCompare )\ +{\ + if ( DEBUG )\ +{\ + FPRINTF("[Line : %d][%s] %s passed\\n", __LINE__, API_NAMESPACE, API);\ +}\ +}\ + else \ +{\ + FPRINTF("[Line : %d][%s] %s failed, error returned = %s [%d]\\n", __LINE__, API_NAMESPACE, API, Error, eRetVal);\ + g_bAPIFailed = true;\ +}\ +} + +typedef enum ExEventInfoAPI +{ + EX_EVENT_INFO_CLONE = 0, + EX_EVENT_INFO_DESTROY, + EX_EVENT_INFO_GET_EVENT_TYPE, + EX_EVENT_INFO_GET_OWNER, + EX_EVENT_INFO_GET_CHANNEL, + EX_EVENT_INFO_GET_ITEM_ID, + EX_EVENT_INFO_GET_REQUEST_ID +}eExEventInfoAPI; + +eExEventInfoAPI g_eEventInfoAPI; + notification_h g_NotificationHandle; bool g_bFeatureSupported; +GMainLoop *g_pNotificationMainLoop; +bool g_CallBackHit; +bool g_bAPIFailed; + +noti_ex_reporter_h g_hEventinfoReporter; +noti_ex_manager_h g_hEventinfoManager; +noti_ex_manager_h g_hExManager; +noti_ex_item_h g_hItemButton; +noti_ex_item_h g_hItemChatMsg; +noti_ex_item_h g_hItemName; +noti_ex_item_h g_hItemText; +noti_ex_item_h g_hItemImage; +noti_ex_item_h g_hItemTime; +noti_ex_style_h g_hStyle; +noti_ex_color_h g_hColor; +noti_ex_padding_h g_hPadding; +noti_ex_geometry_h g_hGeometry; +time_t g_tCurrTime; + +const char *g_pszNameID; +const char *g_pszNameText; +const char *g_pszTextID; +const char *g_pszTextText; +const char *g_pszImageID; +const char *g_pszImagePath; +const char *g_pszTimeID; +const char *g_pszChatID; +const char *g_pszButtonID; +const char *g_pszButtonTitle; + +unsigned char g_cAlpha, g_cRed, g_cGreen, g_cBlue; +int g_nLeft, g_nTop, g_nRight, g_nBottom, g_nX, g_nY, g_nW, g_nH; +noti_ex_item_chat_message_type_e g_eChatMsgType; + +char* NotificationExGetError(int nRet); +int SendNotification(void); +gboolean Timeout(gpointer data); bool CreateNotification(notification_type_e eNotificationType); void FreeAndDeleteNotificationResourceHandle(); char* NotificationGetError(int nRet); char* Application_AppControlGetError(int nRet); +void ReporterEventsErrorCB(noti_ex_reporter_h hExReporter, noti_ex_error_e eExError, int nReqID, void *data); +int CreateNotificationList(noti_ex_item_h **pszhItemList); +int CreateChatMsgAttributes(); +int DestroyChatMsgAttributes(); +int CreateStyleAttributes(); +int DestroyStyleAttributes(); +int CreateButton(); //This function outputs the application data path bool NotificationGetDataPath(char* pPath); @@ -68,4 +153,4 @@ bool NotificationAppendToAppDataPath(char* pInputPath, char* pFinalPath); /** @} */ //end of itc-notification -#endif //_ITS_NOTIFICATION_COMMON_H_ \ No newline at end of file +#endif //_ITS_NOTIFICATION_COMMON_H_ diff --git a/src/itc/notification/ITs-notification-ex.c b/src/itc/notification/ITs-notification-ex.c new file mode 100644 index 000000000..2a4e79a20 --- /dev/null +++ b/src/itc/notification/ITs-notification-ex.c @@ -0,0 +1,5782 @@ +// +// Copyright (c) 2019 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +#include "ITs-notification-common.h" + +/** @addtogroup itc-notification_ex +* @ingroup itc +* @{ +*/ + +//& set: notification-ex + +/****************************************************Callback Start****************************************************/ + +/** +* @function NotiExItemGroupForeachChildCb +* @description Callback Function +* @parameters noti_ex_item_h hItem, void *pszData +* @return int +*/ +static int NotiExItemGroupForeachChildCb(noti_ex_item_h hItem, void *pszData) +{ + int nRet; + char *pszGetID = NULL; + g_CallBackHit = false; + + FPRINTF("[Line : %d][%s] NotiExItemGroupForeachChildCb Callback Invoked\\n", __LINE__, API_NAMESPACE); + g_CallBackHit = true; + + nRet = noti_ex_item_get_id(hItem, &pszGetID); + if (nRet != NOTI_EX_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] Error in running API noti_ex_item_get_id\\n", __LINE__, API_NAMESPACE); + return 1; + } + + if ( strncmp(pszGetID, g_pszButtonID, sizeof(g_pszButtonID)-1) ) + { + FPRINTF("[Line : %d][%s] Chiled id [%s] but recieved id is [%s] \\n", __LINE__, API_NAMESPACE, g_pszButtonID, pszGetID); + return 1; + } + return 0; +} + +void EventinfoManagerEventsErrorCB(noti_ex_reporter_h hNotiReporter, noti_ex_error_e eNotiError, int nReqID, void *pszData) +{ + g_CallBackHit = true; +#if DEBUG + FPRINTF("[Line : %d][%s] EventinfoManagerEventsErrorCB Callback Invoked\\n", __LINE__, API_NAMESPACE); +#endif +} + +void EventinfoGettestEventsAddCB(noti_ex_manager_h hNotiManager, noti_ex_event_info_h hNotiInfo, noti_ex_item_h *hNotiItem, int nCount, void *pszData) +{ + int nRet; + noti_ex_event_info_type_e eEventInfoType; + noti_ex_event_info_h hEventInfo = NULL; + char *pszOwner = NULL; + char *pszChannel = NULL; + char *pszItemID = NULL; + int nReqID; + + g_CallBackHit = false; + g_bAPIFailed = false; + + FPRINTF("[Line : %d][%s] EventinfoGettestEventsAddCB callback hit \\n", __LINE__, API_NAMESPACE); + + if(EX_EVENT_INFO_CLONE == g_eEventInfoAPI) + { + nRet = noti_ex_event_info_clone(hNotiInfo, &hEventInfo); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_event_info_clone", NotificationExGetError(nRet)); + } + + if(EX_EVENT_INFO_GET_EVENT_TYPE == g_eEventInfoAPI) + { + nRet = noti_ex_event_info_get_event_type(hNotiInfo, &eEventInfoType); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_event_info_get_event_type", NotificationExGetError(nRet)); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_EVENT_POST, eEventInfoType, "noti_ex_event_info_get_event_type", "Error: Event infor type is not NOTI_EX_EVENT_POST"); + } + + if(EX_EVENT_INFO_GET_OWNER == g_eEventInfoAPI) + { + nRet = noti_ex_event_info_get_owner(hNotiInfo, &pszOwner); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_event_info_get_owner", NotificationExGetError(nRet)); + FREE_MEMORY(pszOwner); + } + + if(EX_EVENT_INFO_GET_CHANNEL == g_eEventInfoAPI) + { + nRet = noti_ex_event_info_get_channel(hNotiInfo, &pszChannel); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_event_info_get_channel", NotificationExGetError(nRet)); + FREE_MEMORY(pszChannel); + } + + if(EX_EVENT_INFO_GET_ITEM_ID == g_eEventInfoAPI) + { + nRet = noti_ex_event_info_get_item_id(hNotiInfo, &pszItemID); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_event_info_get_item_id", NotificationExGetError(nRet)); + FREE_MEMORY(pszItemID); + } + + if(EX_EVENT_INFO_GET_REQUEST_ID == g_eEventInfoAPI) + { + nRet = noti_ex_event_info_get_request_id(hNotiInfo, &nReqID); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_event_info_get_request_id", NotificationExGetError(nRet)); + } + + if(EX_EVENT_INFO_DESTROY == g_eEventInfoAPI) + { + nRet = noti_ex_event_info_destroy(hEventInfo); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_event_info_destroy", NotificationExGetError(nRet)); + } + + nRet = noti_ex_manager_delete_all(g_hEventinfoManager, &nReqID); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_manager_delete_all", NotificationExGetError(nRet)); + + g_CallBackHit = true; +} + +void ManagerEventsAddCB(noti_ex_manager_h hManager, noti_ex_event_info_h hEventInfo, noti_ex_item_h *hAddedItem, int nCnt, void *pszData) +{ + g_CallBackHit = true; +#if DEBUG + FPRINTF("[Line : %d][%s] ManagerEventsAddCB Callback Invoked\\n", __LINE__, API_NAMESPACE); +#endif +} + +void ManagerEventsUpdateCB(noti_ex_manager_h hManager, noti_ex_event_info_h hEventInfo, noti_ex_item_h hUpdatedItem, void *pszData) +{ + g_CallBackHit = true; +#if DEBUG + FPRINTF("[Line : %d][%s] ManagerEventsUpdateCB Callback Invoked\\n", __LINE__, API_NAMESPACE); +#endif +} + +void ManagerEventsDeleteCB(noti_ex_manager_h hManager, noti_ex_event_info_h hEventnfo, noti_ex_item_h hDeletedItem, void *pszData) +{ + g_CallBackHit = true; +#if DEBUG + FPRINTF("[Line : %d][%s] ManagerEventsDeleteCB Callback Invoked\\n", __LINE__, API_NAMESPACE); +#endif +} + +void ManagerEventsErrorCB(noti_ex_manager_h hManager, noti_ex_error_e eNotiError, int nReqID, void *pszData) +{ + g_CallBackHit = true; +#if DEBUG + FPRINTF("[Line : %d][%s] ManagerEventsErrorCB Callback Invoked\\n", __LINE__, API_NAMESPACE); +#endif +} + +void GettestEventsAddCB(noti_ex_manager_h hExManager, noti_ex_event_info_h hEventInfo, noti_ex_item_h *hAddedItem, int nCnt, void *pszData) +{ + noti_ex_item_h *hItems; + int nItemsCnt; + int nReqID; + int nRet = NOTI_EX_ERROR_NONE; + + g_bAPIFailed = false; + g_CallBackHit = true; + FPRINTF("[Line : %d][%s] GettestEventsAddCB Callback hit\\n", __LINE__, API_NAMESPACE); + + nRet = noti_ex_manager_get(hExManager, &hItems, &nItemsCnt); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_manager_get", NotificationExGetError(nRet)); + PRINT_RESULT_CALLBACK_NORETURN(1, nItemsCnt, "noti_ex_manager_get", "nItemsCnt is different than 1"); + + nRet = noti_ex_manager_delete_all(g_hExManager, &nReqID); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_manager_delete_all", NotificationExGetError(nRet)); +} + +void DeletetestEventsAddCB(noti_ex_manager_h hExManager, noti_ex_event_info_h hEventInfo, noti_ex_item_h *hDeletedItem, int nCnt, void *pszData) +{ + int nReqID; + int nRet = NOTI_EX_ERROR_NONE; + + FPRINTF("[Line : %d][%s] DeletetestEventsAddCB Callback hit\\n", __LINE__, API_NAMESPACE); + g_CallBackHit = true; + g_bAPIFailed = false; + + nRet = noti_ex_manager_delete_all(g_hExManager, &nReqID); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_manager_delete_all", NotificationExGetError(nRet)); +} + +void SendErrorEventsAddCB(noti_ex_manager_h hExManager, noti_ex_event_info_h hEventInfo, noti_ex_item_h *hAddedItem, int nCnt, void *pszData) +{ + int nReqID; + int nRet = NOTI_EX_ERROR_NONE; + + FPRINTF("[Line : %d][%s] SendErrorEventsAddCB Callback hit\\n", __LINE__, API_NAMESPACE); + g_CallBackHit = true; + g_bAPIFailed = false; + + nRet = noti_ex_manager_send_error(g_hExManager, hEventInfo, NOTI_EX_ERROR_INVALID_PARAMETER); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_manager_send_error", NotificationExGetError(nRet)); + + nRet = noti_ex_manager_delete_all(g_hExManager, &nReqID); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_manager_delete_all", NotificationExGetError(nRet)); +} + +void ReporterEventsEventCB(noti_ex_reporter_h hExReporter, noti_ex_event_info_h hEventInfo, noti_ex_item_h *hAddedItem, int nCnt, void *pszData) +{ + g_CallBackHit = true; +#if DEBUG + FPRINTF("[Line : %d][%s] ReporterEventsEventCB Callback Invoked\\n", __LINE__, API_NAMESPACE); +#endif +} + +void SendErrorManagerEventsAddCB(noti_ex_manager_h hExManager, noti_ex_event_info_h hEventInfo, noti_ex_item_h *hAddedItem, int nCnt, void *pszData) +{ + int nReqID; + int nRet = NOTI_EX_ERROR_NONE; + + FPRINTF("[Line : %d][%s] SendErrorManagerEventsAddCB Callback hit\\n", __LINE__, API_NAMESPACE); + g_CallBackHit = true; + g_bAPIFailed = false; + + nRet = noti_ex_manager_update(g_hExManager, hAddedItem[0], &nReqID); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_manager_update", NotificationExGetError(nRet)); +} + +void SendErrorEventsEventCB(noti_ex_reporter_h hExManager, noti_ex_event_info_h hEventInfo, noti_ex_item_h *hAddedItem, int nCnt, void *pszData) +{ + int nReqID; + int nRet = NOTI_EX_ERROR_NONE; + + FPRINTF("[Line : %d][%s] SendErrorEventsEventCB Callback hit\\n", __LINE__, API_NAMESPACE); + g_CallBackHit = true; + g_bAPIFailed = false; + + nRet = noti_ex_reporter_send_error(g_hEventinfoReporter, hEventInfo, NOTI_EX_ERROR_IO_ERROR); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_send_error", NotificationExGetError(nRet)); + + nRet = noti_ex_reporter_delete_all(g_hEventinfoReporter, &nReqID); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_delete_all", NotificationExGetError(nRet)); +} + +void PostEventsAddCB(noti_ex_manager_h hExManager, noti_ex_event_info_h hEventInfo, noti_ex_item_h *hAddedItem, int nCnt, void *pszData) +{ + int nReqID; + int nRet = NOTI_EX_ERROR_NONE; + + FPRINTF("[Line : %d][%s] PostEventsAddCB Callback hit\\n", __LINE__, API_NAMESPACE); + g_CallBackHit = true; + + nRet = noti_ex_reporter_delete_all(g_hEventinfoReporter, &nReqID); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_delete_all", NotificationExGetError(nRet)); +} + +void PostEventsListAddCB(noti_ex_manager_h hExManager, noti_ex_event_info_h hEventInfo, noti_ex_item_h *hAddedItem, int nCnt, void *pszData) +{ + int nReqID; + int nRet = NOTI_EX_ERROR_NONE; + + FPRINTF("[Line : %d][%s] PostEventsListAddCB Callback hit\\n", __LINE__, API_NAMESPACE); + g_CallBackHit = true; + + nRet = noti_ex_reporter_delete_all(g_hEventinfoReporter, &nReqID); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_delete_all", NotificationExGetError(nRet)); +} + +void UpdateEventsAddCB(noti_ex_manager_h hExManager, noti_ex_event_info_h hEventInfo, noti_ex_item_h *hAddedItem, int nCnt, void *pszData) +{ + int nReqID; + int nRet = NOTI_EX_ERROR_NONE; + + FPRINTF("[Line : %d][%s] UpdateEventsAddCB Callback hit\\n", __LINE__, API_NAMESPACE); + g_CallBackHit = true; + g_bAPIFailed = false; + + nRet = noti_ex_reporter_update(g_hEventinfoReporter, hAddedItem[0], &nReqID); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_update", NotificationExGetError(nRet)); + + nRet = noti_ex_reporter_delete_all(g_hEventinfoReporter, &nReqID); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_delete_all", NotificationExGetError(nRet)); +} + +void DeleteEventsAddCB(noti_ex_manager_h hExManager, noti_ex_event_info_h hEventInfo, noti_ex_item_h *hAddedItem, int nCnt, void *pszData) +{ + int nReqID; + int nRet = NOTI_EX_ERROR_NONE; + + FPRINTF("[Line : %d][%s] DeleteEventsAddCB Callback hit\\n", __LINE__, API_NAMESPACE); + g_CallBackHit = true; + g_bAPIFailed = false; + + nRet = noti_ex_reporter_delete(g_hEventinfoReporter, hAddedItem[0], &nReqID); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_delete", NotificationExGetError(nRet)); +} + +void DeleteallEventsAddCB(noti_ex_manager_h hExManager, noti_ex_event_info_h hEventInfo, noti_ex_item_h *hAddedItem, int nCnt, void *pszData) +{ + int nReqID; + int nRet = NOTI_EX_ERROR_NONE; + + FPRINTF("[Line : %d][%s] DeleteallEventsAddCB Callback hit\\n", __LINE__, API_NAMESPACE); + g_CallBackHit = true; + g_bAPIFailed = false; + + nRet = noti_ex_reporter_delete_all(g_hEventinfoReporter, &nReqID); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_delete_all", NotificationExGetError(nRet)); +} + +void FindbyrootidEventsAddCB(noti_ex_manager_h hExManager, noti_ex_event_info_h hEventInfo, noti_ex_item_h *hAddedItem, int nCnt, void *pszData) +{ + int nReqID; + int nRet = NOTI_EX_ERROR_NONE; + noti_ex_item_h hItem; + + FPRINTF("[Line : %d][%s] FindbyrootidEventsAddCB Callback hit\\n", __LINE__, API_NAMESPACE); + g_CallBackHit = true; + g_bAPIFailed = false; + + nRet = noti_ex_reporter_find_by_root_id(g_hEventinfoReporter, "testgroup", &hItem); + PRINT_RESULT_CALLBACK_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_find_by_root_id", NotificationExGetError(nRet)); + + nRet = noti_ex_reporter_delete_all(g_hEventinfoReporter, &nReqID); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_reporter_delete_all", NotificationExGetError(nRet)); +} + +/*****************************************************Callback End*****************************************************/ + +/** +* @function ITs_notification_ex_startup +* @description Called before each test +* @parameter NA +* @return NA +*/ +void ITs_notification_ex_startup(void) +{ + struct stat stBuff; + if ( stat(ERR_LOG, &stBuff) == 0 ) + { + remove(ERR_LOG); + } +#if DEBUG + FPRINTF("[Line : %d][%s] TEST SUIT start-up: ITs_notification_ex_startup \\n", __LINE__, API_NAMESPACE); +#endif + return; +} + +/** +* @function ITs_notification_ex_cleanup +* @description Called after each test +* @parameter NA +* @return NA +*/ +void ITs_notification_ex_cleanup(void) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] TEST SUIT clean-up: ITs_notification_ex_cleanup \\n", __LINE__, API_NAMESPACE); +#endif + return; +} + +/** @addtogroup itc-notification-ex-testcases +* @brief Integration testcases for module notification-ex +* @ingroup itc-notification-ex +* @{ +*/ + +//& type : auto +//& purpose: Creates a notification app control. +/** +* @testcase ITc_noti_ex_action_app_control_create_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Creates notification-ex app control handler. +* @scenario Create notification\n +* Check return value and also check handle is null or not. +* @apicovered noti_ex_action_app_control_create +* @passcase noti_ex_action_app_control_create is successful and return correct value +* @failcase noti_ex_action_app_control_create gets failed or return null value +* @precondition Create app control and set app id to a dummy app id. +* @postcondition Destroy app control and app control action handler. +*/ +int ITc_noti_ex_action_app_control_create_p(void) +{ + START_TEST; + + int nRet = APP_CONTROL_ERROR_NONE; + app_control_h hAppControl; + noti_ex_action_h hAction = NULL; + + nRet = app_control_create(&hAppControl); + PRINT_RESULT(APP_CONTROL_ERROR_NONE, nRet, "app_control_create", Application_AppControlGetError(nRet)); + CHECK_HANDLE(hAppControl, "app_control_create"); + + const char* pszSetAppID = "org.tizen.app"; //dummy app id + nRet = app_control_set_app_id(hAppControl, pszSetAppID); + PRINT_RESULT_CLEANUP(APP_CONTROL_ERROR_NONE, nRet, "app_control_set_app_id", Application_AppControlGetError(nRet), app_control_destroy(hAppControl)); + + if ( false == CreateNotification(NOTIFICATION_TYPE_NOTI) ) + { + app_control_destroy(hAppControl); + return 1; + } + + //Target API + nRet = noti_ex_action_app_control_create(&hAction, hAppControl, NULL); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_app_control_create", NotificationExGetError(nRet), app_control_destroy(hAppControl)); + CHECK_HANDLE_CLEANUP(hAction, "noti_ex_action_app_control_create", app_control_destroy(hAppControl)); + + nRet = app_control_destroy(hAppControl); + PRINT_RESULT_NORETURN(APP_CONTROL_ERROR_NONE, nRet, "app_control_destroy", Application_AppControlGetError(nRet)); + + nRet = noti_ex_action_destroy(hAction); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_destroy", NotificationExGetError(nRet)); + + return 0; +} + +//& type : auto +//& purpose: Sets and Gets new app control handle from action +/** +* @testcase ITc_noti_ex_action_app_control_set_get_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Sets and Gets new app control handle from action. +* @scenario Create notification\n +* Gets new app control from action handler and check for Pass/Fail. +* @apicovered noti_ex_action_app_control_set, noti_ex_action_app_control_get +* @passcase noti_ex_action_app_control_set, noti_ex_action_app_control_get are successful and return correct value +* @failcase noti_ex_action_app_control_set, noti_ex_action_app_control_get gets failed or return null value +* @precondition Create app control and set app id to a dummy app id. +* @postcondition Destroy app control and app control action handler. +*/ +int ITc_noti_ex_action_app_control_set_get_p(void) +{ + START_TEST; + + int nRet = APP_CONTROL_ERROR_NONE; + app_control_h hAppControl; + app_control_h hAppControlSet; + app_control_h hAppControlGet = NULL; + noti_ex_action_h hAction = NULL; + + nRet = app_control_create(&hAppControl); + PRINT_RESULT(APP_CONTROL_ERROR_NONE, nRet, "app_control_create", Application_AppControlGetError(nRet)); + CHECK_HANDLE(hAppControl, "app_control_create"); + + const char* pszSetAppID = "org.tizen.app"; //dummy app id + nRet = app_control_set_app_id(hAppControl, pszSetAppID); + PRINT_RESULT_CLEANUP(APP_CONTROL_ERROR_NONE, nRet, "app_control_set_app_id", Application_AppControlGetError(nRet), app_control_destroy(hAppControl)); + + if ( false == CreateNotification(NOTIFICATION_TYPE_NOTI) ) + { + app_control_destroy(hAppControl); + return 1; + } + + nRet = noti_ex_action_app_control_create(&hAction, hAppControl, NULL); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_app_control_create", NotificationExGetError(nRet), app_control_destroy(hAppControl)); + CHECK_HANDLE_CLEANUP(hAction, "noti_ex_action_app_control_creat", app_control_destroy(hAppControl)); + + nRet = app_control_create(&hAppControlSet); + PRINT_RESULT_CLEANUP(APP_CONTROL_ERROR_NONE, nRet, "app_control_create", Application_AppControlGetError(nRet), app_control_destroy(hAppControl); noti_ex_action_destroy(hAction)); + CHECK_HANDLE_CLEANUP(hAppControlSet, "app_control_create", app_control_destroy(hAppControl); noti_ex_action_destroy(hAction)); + + const char* pNewAppID = "org.tizen.newapp"; //dummy app id + nRet = app_control_set_app_id(hAppControlSet, pNewAppID); + PRINT_RESULT_CLEANUP(APP_CONTROL_ERROR_NONE, nRet, "app_control_set_app_id", Application_AppControlGetError(nRet), app_control_destroy(hAppControl); noti_ex_action_destroy(hAction)); + + //Target API + nRet = noti_ex_action_app_control_set(hAction, hAppControlSet); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_app_control_set", NotificationExGetError(nRet), app_control_destroy(hAppControl); noti_ex_action_destroy(hAction)); + + //Target API + nRet = noti_ex_action_app_control_get(hAction, &hAppControlGet); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_app_control_get", NotificationExGetError(nRet), app_control_destroy(hAppControl); noti_ex_action_destroy(hAction)); + CHECK_HANDLE_CLEANUP(hAppControlGet, "noti_ex_action_app_control_get", app_control_destroy(hAppControl); noti_ex_action_destroy(hAction)); + + nRet = app_control_destroy(hAppControl); + PRINT_RESULT_NORETURN(APP_CONTROL_ERROR_NONE, nRet, "app_control_destroy", Application_AppControlGetError(nRet)); + + nRet = noti_ex_action_destroy(hAction); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_destroy", NotificationExGetError(nRet)); + + return 0; +} + +//& type : auto +//& purpose: Creates and delete the notification_ex action handle to control visibility +/** +* @testcase ITc_noti_ex_action_visibility_create_destroy_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Creates and delete the notification_ex action handle to control visibility. +* @scenario Creates the notification_ex action handle to control visibility\n +* and delete created handle, check handle for Pass/Fail. +* @apicovered noti_ex_action_visibility_create, noti_ex_action_destroy +* @passcase noti_ex_action_visibility_create, noti_ex_action_destroy is successful and return correct value +* @failcase noti_ex_action_visibility_create, noti_ex_action_destroy failed or return null value +* @precondition NA. +* @postcondition Destroy handle. +*/ +int ITc_noti_ex_action_visibility_create_destroy_p(void) +{ + START_TEST; + + int nRet = NOTI_EX_ERROR_NONE; + noti_ex_action_h hAction = NULL; + const char* pszExtra = "extra"; + + //Target API + nRet = noti_ex_action_visibility_create(&hAction, pszExtra); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_visibility_create", NotificationExGetError(nRet)); + CHECK_HANDLE(hAction, "noti_ex_action_visibility_create"); + + nRet = noti_ex_action_destroy(hAction); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_destroy", NotificationExGetError(nRet)); + + return 0; +} + + +//& type : auto +//& purpose: Sets the visibility state for notification_ex item. +/** +* @testcase ITc_noti_ex_action_visibility_set_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Sets the visibility state for notification_ex item. +* @scenario Creates the notification_ex action handle to control visibility\n +* Sets the visibility state for notification_ex item and check for Pass/Fail. +* @apicovered noti_ex_action_visibility_set +* @passcase noti_ex_action_visibility_set is successful and return correct value +* @failcase noti_ex_action_visibility_set failed or return null value +* @precondition NA. +* @postcondition Destroy handle. +*/ +int ITc_noti_ex_action_visibility_set_p(void) +{ + START_TEST; + + int nRet = NOTI_EX_ERROR_NONE; + noti_ex_action_h hAction = NULL; + const char* pszExtra = "extra"; + const char* pszID = "textID"; + bool bIsVisible = true; + + nRet = noti_ex_action_visibility_create(&hAction, pszExtra); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_visibility_create", NotificationExGetError(nRet)); + CHECK_HANDLE(hAction, "noti_ex_action_visibility_create"); + + //Target API + nRet = noti_ex_action_visibility_set(hAction, pszID, bIsVisible); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_visibility_set", NotificationExGetError(nRet), noti_ex_action_destroy(hAction)); + + nRet = noti_ex_action_destroy(hAction); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_destroy", NotificationExGetError(nRet)); + + return 0; +} + +//& type : auto +//& purpose: Gets the type of an action. The action type is equal to one of the values of #noti_ex_action_type_e. +/** +* @testcase ITc_noti_ex_action_get_type_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Gets the type of an action. The action type is equal to one of the values of #noti_ex_action_type_e. +* @scenario Creates the notification_ex action handle and Gets the type of an action\n +* Check for Pass/Fail. +* @apicovered noti_ex_action_get_type +* @passcase noti_ex_action_get_type is successful and return correct value +* @failcase noti_ex_action_get_type failed or return null value +* @precondition NA. +* @postcondition Destroy handle. +*/ +int ITc_noti_ex_action_get_type_p(void) +{ + START_TEST; + + int nRet = NOTI_EX_ERROR_NONE; + noti_ex_action_h hAction = NULL; + const char* pszExtra = "extra"; + int nType; + + nRet = noti_ex_action_visibility_create(&hAction, pszExtra); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_visibility_create", NotificationExGetError(nRet)); + CHECK_HANDLE(hAction, "noti_ex_action_visibility_create"); + + //Target API + nRet = noti_ex_action_get_type(hAction, &nType); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_get_type", NotificationExGetError(nRet), noti_ex_action_destroy(hAction)); + PRINT_RESULT_CLEANUP(NOTI_EX_ACTION_TYPE_VISIBILITY, nType, "noti_ex_action_get_type", "return type of action handle is different", noti_ex_action_destroy(hAction)); + + nRet = noti_ex_action_destroy(hAction); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_destroy", NotificationExGetError(nRet)); + + return 0; +} + +//& type : auto +//& purpose: Gets the local state of an action. +/** +* @testcase ITc_noti_ex_action_is_local_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Gets the local state of an action. +* @scenario Creates the notification_ex action handle and Gets the local state of an action\n +* Check for Pass/Fail. +* @apicovered noti_ex_action_is_local +* @passcase noti_ex_action_is_local is successful and return correct value +* @failcase noti_ex_action_is_local failed or return null value +* @precondition NA. +* @postcondition Destroy handle. +*/ +int ITc_noti_ex_action_is_local_p(void) +{ + START_TEST; + + int nRet = NOTI_EX_ERROR_NONE; + noti_ex_action_h hAction = NULL; + bool bIsLocal = false; + + nRet = noti_ex_action_visibility_create(&hAction, NULL); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_visibility_create", NotificationExGetError(nRet)); + CHECK_HANDLE(hAction, "noti_ex_action_visibility_create"); + + //Target API + nRet = noti_ex_action_is_local(hAction, &bIsLocal); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_is_local", NotificationExGetError(nRet), noti_ex_action_destroy(hAction)); + PRINT_RESULT_CLEANUP(true, bIsLocal, "noti_ex_action_is_local", "bIsLocal is not set true", noti_ex_action_destroy(hAction)); + + nRet = noti_ex_action_destroy(hAction); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_destroy", NotificationExGetError(nRet)); + + return 0; +} + +//& type : auto +//& purpose: Executes the action for a notification_ex item. +/** +* @testcase ITc_noti_ex_action_execute_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Executes the action for a notification_ex item. +* @scenario Creates the notification_ex action handle and Executes the action \n +* for a notification_ex item. Check for Pass/Fail. +* @apicovered noti_ex_action_execute +* @passcase noti_ex_action_execute is successful and return correct value +* @failcase noti_ex_action_execute failed or return null value +* @precondition NA. +* @postcondition Destroy handle. +*/ +int ITc_noti_ex_action_execute_p(void) +{ + START_TEST; + + int nRet = NOTI_EX_ERROR_NONE; + noti_ex_action_h hAction = NULL; + + nRet = noti_ex_action_visibility_create(&hAction, NULL); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_visibility_create", NotificationExGetError(nRet)); + CHECK_HANDLE(hAction, "noti_ex_action_visibility_create"); + + nRet = CreateButton(); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_button_create", NotificationExGetError(nRet), noti_ex_action_destroy(hAction)); + CHECK_HANDLE_CLEANUP(g_hItemButton, "noti_ex_item_button_create", noti_ex_action_destroy(hAction)); + + nRet = noti_ex_item_set_action(g_hItemButton, hAction); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_set_action", NotificationExGetError(nRet), noti_ex_action_destroy(hAction); noti_ex_item_destroy(g_hItemButton)); + + //Target API + nRet = noti_ex_action_execute(hAction, g_hItemButton); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_execute", NotificationExGetError(nRet), noti_ex_action_destroy(hAction); noti_ex_item_destroy(g_hItemButton)); + + nRet = noti_ex_action_destroy(hAction); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_destroy", NotificationExGetError(nRet)); + + return 0; +} + +//& type : auto +//& purpose: Gets the extra data for an action. +/** +* @testcase ITc_noti_ex_action_get_extra_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Gets the extra data for an action. +* @scenario Creates the notification_ex action handle and Gets the extra data\n +* for an action. Check for Pass/Fail. +* @apicovered noti_ex_action_get_extra +* @passcase noti_ex_action_get_extra is successful and return correct value +* @failcase noti_ex_action_get_extra failed or return null value +* @precondition NA. +* @postcondition Destroy handle. +*/ +int ITc_noti_ex_action_get_extra_p(void) +{ + START_TEST; + + int nRet = NOTI_EX_ERROR_NONE; + noti_ex_action_h hAction = NULL; + const char* pszSetExtra = "test"; + char* pszGetExtra = NULL; + + nRet = noti_ex_action_visibility_create(&hAction, pszSetExtra); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_visibility_create", NotificationExGetError(nRet)); + CHECK_HANDLE(hAction, "noti_ex_action_visibility_create"); + + //Target API + nRet = noti_ex_action_get_extra(hAction, &pszGetExtra); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_get_extra", NotificationExGetError(nRet), noti_ex_action_destroy(hAction)); + CHECK_HANDLE_CLEANUP(pszGetExtra, "noti_ex_action_get_extra", noti_ex_action_destroy(hAction)); + + if (strncmp(pszSetExtra, pszGetExtra, sizeof(pszGetExtra)-1)) + { + FPRINTF("[Line : %d][%s] noti_ex_action_get_extra: return extra string is different from set extra [%s]\\n", __LINE__, API_NAMESPACE, pszGetExtra); + + nRet = noti_ex_action_destroy(hAction); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_destroy", NotificationExGetError(nRet)); + + return 1; + } + + nRet = noti_ex_action_destroy(hAction); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_action_destroy", NotificationExGetError(nRet)); + + return 0; +} + +//& type : auto +//& purpose: Creates the notification_ex item handle with a button. +/** +* @testcase ITc_noti_ex_item_button_create_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Creates the notification_ex item handle with a button. +* @scenario Creates the notification_ex item handle with a button \n +* Check for Pass/Fail. +* @apicovered noti_ex_item_button_create +* @passcase noti_ex_item_button_create is successful and return correct value +* @failcase noti_ex_item_button_create failed or return null value +* @precondition NA. +* @postcondition Destroy handle. +*/ +int ITc_noti_ex_item_button_create_p(void) +{ + START_TEST; + + int nRet = NOTI_EX_ERROR_NONE; + + //Taregt API + nRet = CreateButton(); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_button_create", NotificationExGetError(nRet)); + CHECK_HANDLE(g_hItemButton, "noti_ex_item_button_create"); + + nRet = noti_ex_item_destroy(g_hItemButton); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_destroy", NotificationExGetError(nRet)); + + return 0; +} + +//& type : auto +//& purpose: Gets the title of a button item. +/** +* @testcase ITc_noti_ex_item_button_get_title_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Gets the title of a button item. +* @scenario Creates the notification_ex item handle with a button \n +* Gets the title and compare with Set title. Check for Pass/Fail. +* @apicovered noti_ex_item_button_get_title +* @passcase noti_ex_item_button_get_title is successful and return correct value +* @failcase noti_ex_item_button_get_title failed or return null value +* @precondition NA. +* @postcondition Free Title pointer memory and destroy handle. +*/ +int ITc_noti_ex_item_button_get_title_p(void) +{ + START_TEST; + + int nRet = NOTI_EX_ERROR_NONE; + char* pszGetTitle = NULL; + + nRet = CreateButton(); + PRINT_RESULT(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_button_create", NotificationExGetError(nRet)); + CHECK_HANDLE(g_hItemButton, "noti_ex_item_button_create"); + + //Taregt API + nRet = noti_ex_item_button_get_title(g_hItemButton, &pszGetTitle); + PRINT_RESULT_CLEANUP(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_button_get_title", NotificationExGetError(nRet), noti_ex_item_destroy(g_hItemButton)); + CHECK_HANDLE_CLEANUP(pszGetTitle, "noti_ex_item_button_get_title", noti_ex_item_destroy(g_hItemButton)); + + if (strncmp(g_pszButtonTitle, pszGetTitle, sizeof(pszGetTitle)-1)) + { + FPRINTF("[Line : %d][%s] noti_ex_item_button_get_title: return title is different from set title [%s]\\n", __LINE__, API_NAMESPACE, pszGetTitle); + FREE_MEMORY(pszGetTitle); + + nRet = noti_ex_item_destroy(g_hItemButton); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_destroy", NotificationExGetError(nRet)); + + return 1; + } + + FREE_MEMORY(pszGetTitle); + + nRet = noti_ex_item_destroy(g_hItemButton); + PRINT_RESULT_NORETURN(NOTI_EX_ERROR_NONE, nRet, "noti_ex_item_destroy", NotificationExGetError(nRet)); + + return 0; +} + +//& type : auto +//& purpose: Creates the notification_ex item handle for the chat message. +/** +* @testcase ITc_noti_ex_item_chat_message_create_p +* @since_tizen 5.5 +* @author SRID(j.abhishek) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Creates the notification_ex item handle for the chat message. +* @scenario Creates the notification_ex item handle for the chat message \n +* Check for handle and check for Pass/Fail. +* @apicovered noti_ex_item_chat_message_create +* @passcase noti_ex_item_chat_message_create is successful and return correct value +* @failcase noti_ex_item_chat_message_create failed or return null value +* @precondition Name, Text and Image must be created before creating chat message. +* @postcondition Free Title pointer memory and destroy handle. +*/ +int ITc_noti_ex_item_chat_message_create_p(void) +{ + START_TEST; + + int nRet = NOTI_EX_ERROR_NONE; + noti_ex_item_h hItemChatMsg = NULL; + + nRet = CreateChatMsgAttributes(); + if(nRet) + { + FPRINTF("[Line : %d][%s] One of the API inside CreateChatMsgAttributes() is failed \\n", __LINE__, API_NAMESPACE); + return 1; + } + + noti_ex_item_chat_message_type_e eChatMsgType[] = { + NOTI_EX_ITEM_CHAT_MESSAGE_TYPE_USER, + NOTI_EX_ITEM_CHAT_MESSAGE_TYPE_SENDER + }; + + int nEnumSize = sizeof(eChatMsgType) / sizeof(eChatMsgType[0]); + int nEnumCounter; + + for ( nEnumCounter=0; nEnumCounter