From: bipin.k Date: Fri, 31 May 2019 11:26:33 +0000 (+0530) Subject: [ITC][stc][ACR-1357,ACR-1358][Deprecate CAPI and Add new CAPIs to get all statistics... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0aa408dba122d958ebca0b7692a90ccea90cec10;p=test%2Ftct%2Fnative%2Fapi.git [ITC][stc][ACR-1357,ACR-1358][Deprecate CAPI and Add new CAPIs to get all statistics info] Change-Id: If53129b6da063524ab70ac318a96e3deb2708ac4 Signed-off-by: bipin.k --- diff --git a/src/itc/stc/ITs-stc-common.h b/src/itc/stc/ITs-stc-common.h index 9dbd89e92..ac0fc35e0 100755 --- a/src/itc/stc/ITs-stc-common.h +++ b/src/itc/stc/ITs-stc-common.h @@ -91,6 +91,8 @@ typedef enum { STATS_INFO_ROAMING_TYPE, STATS_INFO_PROTOCOL_TYPE, STATS_INFO_PROCESS_STATE, + STATS_INFO_GET_ALL, + STATS_INFO_FOREACH_ALL, } stc_stats_info_e; //Add helper function declarations here @@ -107,9 +109,16 @@ stc_h g_hSTC; stc_stats_rule_h g_hRule; bool g_bCallbackCalled; bool g_bCallbackGetValue; +int g_iTargetApiCallback; +stc_stats_info_e g_eStatsInfo; gboolean StcTimeout(gpointer data); char* StcGetError(int nRet); time_t StcMakeTime(int year, int mon, int day, int hour, int min); +#define STC_YEAR 2000 +#define STC_MONTH 1 +#define STC_DAY 1 +#define STC_HOUR 1 +#define STC_MIN 1 /** @} */ #endif //_ITS_STC_COMMON_H_ diff --git a/src/itc/stc/ITs-stc.c b/src/itc/stc/ITs-stc.c index ee8457861..ff906ac29 100755 --- a/src/itc/stc/ITs-stc.c +++ b/src/itc/stc/ITs-stc.c @@ -24,7 +24,7 @@ /** * @function StcForeachStatsCallback -* @description callback for stc_foreach_stats +* @description callback for stc_foreach_all_stats * @parameter stc_error_e * @parameter stc_stats_info_h * @parameter void* @@ -33,11 +33,56 @@ stc_callback_ret_e StcForeachStatsCallback(stc_error_e result, stc_stats_info_h info, void *user_data) { g_bCallbackCalled = true; - FPRINTF("[Line : %d][%s] Callback invoked\\n", __LINE__, API_NAMESPACE); + + switch (g_eStatsInfo) { + case STATS_INFO_FOREACH_ALL: + { + FPRINTF("[Line : %d][%s] Callback invoked stc_foreach_all_stats \\n", __LINE__, API_NAMESPACE); + } + break; + default: + FPRINTF("[Line : %d][%s] Callback invoked StcForeachStatsCallback :default case \\n", __LINE__, API_NAMESPACE); + break; + } + QUIT_GMAIN_LOOP; return STC_CALLBACK_CANCEL; } +/** +* @function StcGetStatsFinishedCallback +* @description callback for stc_get_all_stats +* @parameter stc_error_e +* @parameter stc_all_stats_info_h +* @parameter void* +* @return void +*/ +void StcGetStatsFinishedCallback(stc_error_e result, stc_all_stats_info_h info, void *user_data) +{ + + switch (g_eStatsInfo) { + case STATS_INFO_GET_ALL: + { + FPRINTF("[Line : %d][%s] Callback invoked for STATS_INFO_GET_ALL\\n", __LINE__, API_NAMESPACE); + g_bCallbackCalled = true; + QUIT_GMAIN_LOOP; + } + break; + case STATS_INFO_FOREACH_ALL: + { + int nRet = stc_foreach_all_stats(info, StcForeachStatsCallback, user_data); + g_iTargetApiCallback = nRet; + PRINT_RESULT_NORETURN(STC_ERROR_NONE, nRet, "stc_foreach_all_stas", StcGetError(nRet)); + } + break; + default: + FPRINTF("[Line : %d][%s] StcGetStatsFinishedCallback Callback invoked:default case\\n", __LINE__, API_NAMESPACE); + break; + } + + return; +} + /** * @function StcGetStatsCallback * @description callback for stc_get_stats @@ -399,7 +444,7 @@ int StcGetStatisticsInformation(void *user_data, stc_stats_info_cb callback) { time_t from, to; - from = StcMakeTime(2000, 1, 1, 1, 1); + from = StcMakeTime(STC_YEAR, STC_MONTH, STC_DAY, STC_HOUR, STC_MIN); time(&to); int nRet = stc_stats_rule_set_time_interval(g_hRule, from, to); @@ -411,7 +456,7 @@ int StcGetStatisticsInformation(void *user_data, stc_stats_info_cb callback) g_bCallbackCalled = false; g_bCallbackGetValue = false; - nRet = stc_foreach_stats(g_hSTC, g_hRule, callback, user_data); + nRet = stc_foreach_stats(g_hSTC, g_hRule, callback, NULL);; PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_foreach_stats", StcGetError(nRet)); RUN_GMAIN_LOOP; @@ -850,45 +895,98 @@ gboolean StcTimeout(gpointer data) //& purpose Gets the statistics information of each application asynchronously //& type: auto /** -* @testcase ITs_stc_foreach_stats_p -* @since_tizen 4.0 -* @author SRID(manmohan.k) +* @testcase ITs_stc_foreach_all_stats_p +* @since_tizen 5.5 +* @author SRID(bipin.k) * @reviewer SRID(shobhit.v) * @type auto * @description Gets the statistics information of each application asynchronously * @scenario Sets callback for statistics info API \n * @scenario Check for callback invocation \n -* @apicovered stc_foreach_stats -* @passcase If callback gets called successfully -* @failcase If fails to called callback +* @apicovered stc_foreach_all_stats,stc_get_all_stats +* @passcase If stc_get_all_stats and stc_foreach_all_stats API passes and the callback is invoked. +* @failcase If stc_get_all_stats or stc_foreach_all_stats API fails,or callback is not invoked. * @precondition NA * @postcondition NA */ -int ITs_stc_foreach_stats_p(void) +int ITs_stc_foreach_all_stats_p(void) { START_TEST; - time_t from, to; + stc_stats_info_e eInfo = STATS_INFO_FOREACH_ALL; + + int nRet = stc_stats_rule_set_app_id(g_hRule, STC_ALL_APP); + PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_stats_rule_set_app_id", StcGetError(nRet)); - from = StcMakeTime(2000, 1, 1, 1, 1); + from = StcMakeTime(STC_YEAR, STC_MONTH, STC_DAY, STC_HOUR, STC_MIN); time(&to); - int nRet = stc_stats_rule_set_time_interval(g_hRule, from, to); + nRet = stc_stats_rule_set_time_interval(g_hRule, from, to); PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_stats_rule_set_time_interval", StcGetError(nRet)); - nRet = stc_stats_rule_set_app_id(g_hRule, STC_ALL_APP); + g_bCallbackCalled = false; + g_iTargetApiCallback = -1; + g_eStatsInfo = eInfo; + + nRet = stc_get_all_stats(g_hSTC, g_hRule, StcGetStatsFinishedCallback, NULL); + PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_get_all_stats", StcGetError(nRet)); + + RUN_GMAIN_LOOP; + if(g_iTargetApiCallback != STC_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] Target Api failed in the callback= %s\\n", __LINE__, API_NAMESPACE, "StcGetStatsFinishedCallback"); + return 1; + } + if(g_bCallbackCalled == false) + { + FPRINTF("[Line : %d][%s] Callback not invoked for %s\\n", __LINE__, API_NAMESPACE, "stc_get_all_stats"); + return 1; + } + return 0; +} +//& purpose Gets the All statistics information by interface type asynchronously +//& type: auto +/** +* @testcase ITs_stc_get_all_stats_p +* @since_tizen 5.5 +* @author SRID(bipin.k) +* @reviewer SRID(shobhit.v) +* @type auto +* @description Gets All statistics information by interface type asynchronously +* @scenario Sets callback for statistics info API \n +* @scenario Check for callback invocation \n +* @apicovered stc_get_all_stats +* @passcase If stc_for_all_stats API passes and callback is invoked. +* @failcase If stc_for_all_stats API fails or callback is not invoked. +* @precondition NA +* @postcondition NA +*/ +int ITs_stc_get_all_stats_p(void) +{ + START_TEST; + time_t from, to; + stc_stats_info_e eInfo = STATS_INFO_GET_ALL; + + int nRet = stc_stats_rule_set_app_id(g_hRule, STC_ALL_APP); PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_stats_rule_set_app_id", StcGetError(nRet)); + from = StcMakeTime(STC_YEAR, STC_MONTH, STC_DAY, STC_HOUR, STC_MIN); + time(&to); + + nRet = stc_stats_rule_set_time_interval(g_hRule, from, to); + PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_stats_rule_set_time_interval", StcGetError(nRet)); + g_bCallbackCalled = false; + g_eStatsInfo = eInfo; - nRet = stc_foreach_stats(g_hSTC, g_hRule, StcForeachStatsCallback, (void *)STATS_INFO_IFACE_NAME); - PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_foreach_stats", StcGetError(nRet)); + nRet = stc_get_all_stats(g_hSTC, g_hRule, StcGetStatsFinishedCallback, NULL); + PRINT_RESULT(STC_ERROR_NONE, nRet, "stc_get_all_stats", StcGetError(nRet)); RUN_GMAIN_LOOP; if(g_bCallbackCalled == false) { - FPRINTF("[Line : %d][%s] Callback not invoked for %s\\n", __LINE__, API_NAMESPACE, "stc_foreach_stats"); + FPRINTF("[Line : %d][%s] Callback not invoked for %s\\n", __LINE__, API_NAMESPACE, "stc_get_all_stats"); return 1; } @@ -918,7 +1016,7 @@ int ITs_stc_get_stats_p(void) time_t from, to; - from = StcMakeTime(2000, 1, 1, 1, 1); + from = StcMakeTime(STC_YEAR, STC_MONTH, STC_DAY, STC_HOUR, STC_MIN); time(&to); int nRet = stc_stats_rule_set_time_interval(g_hRule, from, to); diff --git a/src/itc/stc/tct-stc-native_mobile.h b/src/itc/stc/tct-stc-native_mobile.h index 0fd7543a4..a9d0cda0e 100755 --- a/src/itc/stc/tct-stc-native_mobile.h +++ b/src/itc/stc/tct-stc-native_mobile.h @@ -28,7 +28,7 @@ extern int ITs_stc_stats_rule_set_get_app_id_p(void); extern int ITs_stc_stats_rule_set_get_time_interval_p(void); extern int ITs_stc_stats_rule_set_get_iface_type_p(void); extern int ITs_stc_stats_rule_set_get_time_period_p(void); -extern int ITs_stc_foreach_stats_p(void); +extern int ITs_stc_foreach_all_stats_p(void); extern int ITs_stc_get_stats_p(void); extern int ITs_stc_stats_info_get_app_id_p(void); extern int ITs_stc_stats_info_get_iface_name_p(void); @@ -39,6 +39,7 @@ extern int ITs_stc_stats_info_get_roaming_type_p(void); extern int ITs_stc_stats_info_get_protocol_type_p(void); extern int ITs_stc_stats_info_get_process_state_p(void); extern int ITs_stc_stats_info_clone_destroy_p(void); +extern int ITs_stc_get_all_stats_p(void); testcase tc_array[] = { {"ITs_stc_initialize_deinitialize_p",ITs_stc_initialize_deinitialize_p,ITs_stc_startup,ITs_stc_cleanup}, @@ -47,7 +48,7 @@ testcase tc_array[] = { {"ITs_stc_stats_rule_set_get_time_interval_p",ITs_stc_stats_rule_set_get_time_interval_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_rule_set_get_iface_type_p",ITs_stc_stats_rule_set_get_iface_type_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_rule_set_get_time_period_p",ITs_stc_stats_rule_set_get_time_period_p,ITs_stc_startup,ITs_stc_cleanup}, - {"ITs_stc_foreach_stats_p",ITs_stc_foreach_stats_p,ITs_stc_startup,ITs_stc_cleanup}, + {"ITs_stc_foreach_all_stats_p",ITs_stc_foreach_all_stats_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_get_stats_p",ITs_stc_get_stats_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_info_get_app_id_p",ITs_stc_stats_info_get_app_id_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_info_get_iface_name_p",ITs_stc_stats_info_get_iface_name_p,ITs_stc_startup,ITs_stc_cleanup}, @@ -58,6 +59,7 @@ testcase tc_array[] = { {"ITs_stc_stats_info_get_protocol_type_p",ITs_stc_stats_info_get_protocol_type_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_info_get_process_state_p",ITs_stc_stats_info_get_process_state_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_info_clone_destroy_p", ITs_stc_stats_info_clone_destroy_p, ITs_stc_startup,ITs_stc_cleanup}, + {"ITs_stc_get_all_stats_p", ITs_stc_get_all_stats_p, ITs_stc_startup,ITs_stc_cleanup}, {NULL, NULL} }; diff --git a/src/itc/stc/tct-stc-native_tizeniot.h b/src/itc/stc/tct-stc-native_tizeniot.h index 0fd7543a4..0d4841013 100755 --- a/src/itc/stc/tct-stc-native_tizeniot.h +++ b/src/itc/stc/tct-stc-native_tizeniot.h @@ -28,7 +28,7 @@ extern int ITs_stc_stats_rule_set_get_app_id_p(void); extern int ITs_stc_stats_rule_set_get_time_interval_p(void); extern int ITs_stc_stats_rule_set_get_iface_type_p(void); extern int ITs_stc_stats_rule_set_get_time_period_p(void); -extern int ITs_stc_foreach_stats_p(void); +extern int ITs_stc_foreach_stats_all_p(void); extern int ITs_stc_get_stats_p(void); extern int ITs_stc_stats_info_get_app_id_p(void); extern int ITs_stc_stats_info_get_iface_name_p(void); @@ -39,6 +39,7 @@ extern int ITs_stc_stats_info_get_roaming_type_p(void); extern int ITs_stc_stats_info_get_protocol_type_p(void); extern int ITs_stc_stats_info_get_process_state_p(void); extern int ITs_stc_stats_info_clone_destroy_p(void); +extern int ITs_stc_get_all_stats_p(void); testcase tc_array[] = { {"ITs_stc_initialize_deinitialize_p",ITs_stc_initialize_deinitialize_p,ITs_stc_startup,ITs_stc_cleanup}, @@ -47,7 +48,7 @@ testcase tc_array[] = { {"ITs_stc_stats_rule_set_get_time_interval_p",ITs_stc_stats_rule_set_get_time_interval_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_rule_set_get_iface_type_p",ITs_stc_stats_rule_set_get_iface_type_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_rule_set_get_time_period_p",ITs_stc_stats_rule_set_get_time_period_p,ITs_stc_startup,ITs_stc_cleanup}, - {"ITs_stc_foreach_stats_p",ITs_stc_foreach_stats_p,ITs_stc_startup,ITs_stc_cleanup}, + {"ITs_stc_foreach_stats_all_p",ITs_stc_foreach_all_stats_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_get_stats_p",ITs_stc_get_stats_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_info_get_app_id_p",ITs_stc_stats_info_get_app_id_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_info_get_iface_name_p",ITs_stc_stats_info_get_iface_name_p,ITs_stc_startup,ITs_stc_cleanup}, @@ -58,6 +59,7 @@ testcase tc_array[] = { {"ITs_stc_stats_info_get_protocol_type_p",ITs_stc_stats_info_get_protocol_type_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_info_get_process_state_p",ITs_stc_stats_info_get_process_state_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_info_clone_destroy_p", ITs_stc_stats_info_clone_destroy_p, ITs_stc_startup,ITs_stc_cleanup}, + {"ITs_stc_get_all_stats_p", ITs_stc_get_all_stats_p, ITs_stc_startup,ITs_stc_cleanup}, {NULL, NULL} }; diff --git a/src/itc/stc/tct-stc-native_wearable.h b/src/itc/stc/tct-stc-native_wearable.h index 0fd7543a4..0d4841013 100755 --- a/src/itc/stc/tct-stc-native_wearable.h +++ b/src/itc/stc/tct-stc-native_wearable.h @@ -28,7 +28,7 @@ extern int ITs_stc_stats_rule_set_get_app_id_p(void); extern int ITs_stc_stats_rule_set_get_time_interval_p(void); extern int ITs_stc_stats_rule_set_get_iface_type_p(void); extern int ITs_stc_stats_rule_set_get_time_period_p(void); -extern int ITs_stc_foreach_stats_p(void); +extern int ITs_stc_foreach_stats_all_p(void); extern int ITs_stc_get_stats_p(void); extern int ITs_stc_stats_info_get_app_id_p(void); extern int ITs_stc_stats_info_get_iface_name_p(void); @@ -39,6 +39,7 @@ extern int ITs_stc_stats_info_get_roaming_type_p(void); extern int ITs_stc_stats_info_get_protocol_type_p(void); extern int ITs_stc_stats_info_get_process_state_p(void); extern int ITs_stc_stats_info_clone_destroy_p(void); +extern int ITs_stc_get_all_stats_p(void); testcase tc_array[] = { {"ITs_stc_initialize_deinitialize_p",ITs_stc_initialize_deinitialize_p,ITs_stc_startup,ITs_stc_cleanup}, @@ -47,7 +48,7 @@ testcase tc_array[] = { {"ITs_stc_stats_rule_set_get_time_interval_p",ITs_stc_stats_rule_set_get_time_interval_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_rule_set_get_iface_type_p",ITs_stc_stats_rule_set_get_iface_type_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_rule_set_get_time_period_p",ITs_stc_stats_rule_set_get_time_period_p,ITs_stc_startup,ITs_stc_cleanup}, - {"ITs_stc_foreach_stats_p",ITs_stc_foreach_stats_p,ITs_stc_startup,ITs_stc_cleanup}, + {"ITs_stc_foreach_stats_all_p",ITs_stc_foreach_all_stats_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_get_stats_p",ITs_stc_get_stats_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_info_get_app_id_p",ITs_stc_stats_info_get_app_id_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_info_get_iface_name_p",ITs_stc_stats_info_get_iface_name_p,ITs_stc_startup,ITs_stc_cleanup}, @@ -58,6 +59,7 @@ testcase tc_array[] = { {"ITs_stc_stats_info_get_protocol_type_p",ITs_stc_stats_info_get_protocol_type_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_info_get_process_state_p",ITs_stc_stats_info_get_process_state_p,ITs_stc_startup,ITs_stc_cleanup}, {"ITs_stc_stats_info_clone_destroy_p", ITs_stc_stats_info_clone_destroy_p, ITs_stc_startup,ITs_stc_cleanup}, + {"ITs_stc_get_all_stats_p", ITs_stc_get_all_stats_p, ITs_stc_startup,ITs_stc_cleanup}, {NULL, NULL} };