From: MOHIT MIGLANI Date: Thu, 16 Apr 2020 12:13:16 +0000 (+0530) Subject: [ITC][battery-monitor][ACR-1533][Changed TC Names for APIs] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6b4a9d61dfde58a94029c9b56a84a6f26d29035b;p=test%2Ftct%2Fnative%2Fapi.git [ITC][battery-monitor][ACR-1533][Changed TC Names for APIs] Change-Id: I24e15dbd106ff26ffd5929847c2349ab011fcf47 Signed-off-by: MOHIT MIGLANI --- diff --git a/src/itc/battery-monitor/ITs-battery-monitor-common.c b/src/itc/battery-monitor/ITs-battery-monitor-common.c index 2174f0a83..4328a16a9 100755 --- a/src/itc/battery-monitor/ITs-battery-monitor-common.c +++ b/src/itc/battery-monitor/ITs-battery-monitor-common.c @@ -46,5 +46,32 @@ char* BatteryMonitorGetError(int nRet) return szErrorVal; } +/** +* @function BatteryMonitorGetTime +* @description returns start and end time +* @parameter start and end pointers +* @return integer value 0 on success and 1 on failure +*/ + +int BatteryMonitorGetTime(time_t *start, time_t *end) +{ + time_t ret_time; + long int crr_time = 0; + int tmin = 604800; + time_t start_time; + time_t end_time; + time(&ret_time); + if (ret_time == -1) { + return 1; + } + crr_time = ret_time; + start_time = 0; + end_time = 0; + start_time = (crr_time - tmin/2); + end_time = (crr_time - 1); + *start = start_time; + *end = end_time; + return 0; +} /** @} */ diff --git a/src/itc/battery-monitor/ITs-battery-monitor-common.h b/src/itc/battery-monitor/ITs-battery-monitor-common.h index a051f2e2d..a3d7c9b89 100755 --- a/src/itc/battery-monitor/ITs-battery-monitor-common.h +++ b/src/itc/battery-monitor/ITs-battery-monitor-common.h @@ -26,6 +26,7 @@ #include #include "battery_monitor.h" #include +#include /** @addtogroup itc-battery-monitor * @ingroup itc @@ -43,6 +44,6 @@ bool g_bBatteryFeatureNotSupported; char* BatteryMonitorGetError(int nRet); - +int BatteryMonitorGetTime(time_t *start, time_t *end); /** @} */ #endif //_ITS_BATTERY_MONITOR_COMMON_H_ diff --git a/src/itc/battery-monitor/ITs-battery-monitor.c b/src/itc/battery-monitor/ITs-battery-monitor.c index e67d8d52a..d1b995136 100755 --- a/src/itc/battery-monitor/ITs-battery-monitor.c +++ b/src/itc/battery-monitor/ITs-battery-monitor.c @@ -66,7 +66,7 @@ void ITs_battery_monitor_cleanup(void) //& type : auto //& purpose: Creates and Destroy a handle to the Battery Consumption for getting resource based usage. /** -* @testcase ITc_battery_monitor_create_destroy_p +* @testcase ITc_battery_monitor_battery_usage_data_destroy_p * @since_tizen 5.5 * @author SRID(j.abhishek) * @reviewer SRID(shobhit.v) @@ -74,32 +74,39 @@ void ITs_battery_monitor_cleanup(void) * @description Creates and Destroy a handle to the Battery Consumption for getting resource based usage. * @scenario Create battery monitor handle and destroy created handle\n * and check for Pass/Fail. -* @apicovered battery_monitor_create, battery_monitor_destroy -* @passcase battery_monitor_create, battery_monitor_destroy are successful and return correct value -* @failcase battery_monitor_create, battery_monitor_destroy gets failed or return null value +* @apicovered battery_monitor_create, battery_monitor_battery_usage_data_destroy +* @passcase battery_monitor_create, battery_monitor_battery_usage_data_destroy are successful and return correct value +* @failcase battery_monitor_create, battery_monitor_battery_usage_data_destroy gets failed or return null value * @precondition N/A * @postcondition N/A */ -int ITc_battery_monitor_create_destroy_p(void) +int ITc_battery_monitor_battery_usage_data_destroy_p(void) { START_TEST_NO_CHECK; int nRet = -1; - battery_monitor_h hBatteryMonitor = NULL; - - //Targer API - nRet = battery_monitor_create(&hBatteryMonitor); - if ( g_bBatteryFeatureNotSupported ) - { - PRINT_RESULT(BATTERY_MONITOR_ERROR_NOT_SUPPORTED, nRet, "battery_monitor_create", BatteryMonitorGetError(nRet)); - return 0; - } - PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_create", BatteryMonitorGetError(nRet)); - CHECK_HANDLE(hBatteryMonitor, "battery_monitor_create"); - - //Targer API - nRet = battery_monitor_destroy(hBatteryMonitor); - PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_destroy", BatteryMonitorGetError(nRet)); + battery_usage_data_h hBatteryMonitorAPP = NULL; + time_t start_time; + time_t end_time; + nRet = BatteryMonitorGetTime(&start_time, &end_time); + if(nRet == 1) + { + FPRINTF("[Line : %d][%s] error returned = failed precondition, time\\n", __LINE__, API_NAMESPACE); + return 1; + } + nRet = battery_monitor_get_power_usage_by_app_for_all_resources(TEST_APP_ID, start_time, end_time, &hBatteryMonitorAPP); + if ( g_bBatteryFeatureNotSupported ) + { + PRINT_RESULT(BATTERY_MONITOR_ERROR_NOT_SUPPORTED, nRet, "battery_monitor_get_power_usage_by_app_for_all_resources", BatteryMonitorGetError(nRet)); + return 0; + } + + + PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_get_power_usage_by_app_for_all_resources", BatteryMonitorGetError(nRet)); + CHECK_HANDLE(hBatteryMonitorAPP, "battery_monitor_get_power_usage_by_app_for_all_resources"); + + nRet = battery_monitor_battery_usage_data_destroy(hBatteryMonitorAPP); + PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_battery_usage_data_destroy", BatteryMonitorGetError(nRet)); return 0; } @@ -107,7 +114,7 @@ int ITc_battery_monitor_create_destroy_p(void) //& type : auto //& purpose: Gets the battery-percent for specific resource from available data. /** -* @testcase ITc_battery_monitor_get_usage_for_resource_id_p +* @testcase ITc_battery_monitor_usage_data_get_power_usage_per_resource_p * @since_tizen 5.5 * @author SRID(j.abhishek) * @reviewer SRID(shobhit.v) @@ -115,19 +122,28 @@ int ITc_battery_monitor_create_destroy_p(void) * @description Gets the battery-percent for specific resource from available data. * @scenario Create battery monitor handle\n * get battery percent using this handle and check for Pass/Fail. -* @apicovered battery_monitor_create, battery_monitor_get_usage_for_resource_id, battery_monitor_destroy -* @passcase battery_monitor_create, battery_monitor_get_usage_for_resource_id are successful and return correct value -* @failcase battery_monitor_create, battery_monitor_get_usage_for_resource_id gets failed or return null value +* @apicovered battery_monitor_create, battery_monitor_usage_data_get_power_usage_per_resource, battery_monitor_battery_usage_data_destroy +* @passcase battery_monitor_create, battery_monitor_usage_data_get_power_usage_per_resource are successful and return correct value +* @failcase battery_monitor_create, battery_monitor_usage_data_get_power_usage_per_resource gets failed or return null value * @precondition N/A * @postcondition Destroy battery monitor handle. */ -int ITc_battery_monitor_get_usage_for_resource_id_p(void) +int ITc_battery_monitor_usage_data_get_power_usage_per_resource_p(void) { START_TEST_NO_CHECK; int nRet = -1; - int nBatteryUsage = 0; - battery_monitor_h hBatteryMonitor = NULL; + double nBatteryUsage = 0.0; + battery_usage_data_h hBatteryMonitorAPP = NULL; + time_t start_time; + time_t end_time; + nRet = BatteryMonitorGetTime(&start_time, &end_time); + if(nRet == 1) + { + FPRINTF("[Line : %d][%s] error returned = failed precondition, time\\n", __LINE__, API_NAMESPACE); + return 1; + } + battery_monitor_resource_id_e eResourceID[] = { BATTERY_MONITOR_RESOURCE_ID_BLE, @@ -136,64 +152,74 @@ int ITc_battery_monitor_get_usage_for_resource_id_p(void) BATTERY_MONITOR_RESOURCE_ID_DISPLAY, BATTERY_MONITOR_RESOURCE_ID_DEVICE_NETWORK, BATTERY_MONITOR_RESOURCE_ID_GPS_SENSOR, - BATTERY_MONITOR_RESOURCE_ID_HRM_SENSOR + BATTERY_MONITOR_RESOURCE_ID_MAX }; + nRet = battery_monitor_get_power_usage_by_app_for_all_resources(TEST_APP_ID, start_time, end_time, &hBatteryMonitorAPP); + if ( g_bBatteryFeatureNotSupported ) + { + PRINT_RESULT(BATTERY_MONITOR_ERROR_NOT_SUPPORTED, nRet, "battery_monitor_get_power_usage_by_app_for_all_resources", BatteryMonitorGetError(nRet)); + return 0; + } + + if(nRet == BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND) + { + FPRINTF("[Line : %d][%s] record is not found\\n", __LINE__, API_NAMESPACE); + return 0; + } + PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_get_power_usage_by_app_for_all_resources", BatteryMonitorGetError(nRet)); + CHECK_HANDLE(hBatteryMonitorAPP, "battery_monitor_get_power_usage_by_app_for_all_resources"); int nEnumSize = sizeof(eResourceID) / sizeof(eResourceID[0]); int nEnumCounter; - nRet = battery_monitor_create(&hBatteryMonitor); - if ( g_bBatteryFeatureNotSupported ) - { - PRINT_RESULT(BATTERY_MONITOR_ERROR_NOT_SUPPORTED, nRet, "battery_monitor_create", BatteryMonitorGetError(nRet)); - return 0; - } - PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_create", BatteryMonitorGetError(nRet)); - CHECK_HANDLE(hBatteryMonitor, "battery_monitor_create"); - for(nEnumCounter = 0; nEnumCounter < nEnumSize; nEnumCounter++) { //Targer API - nRet = battery_monitor_get_usage_for_resource_id(hBatteryMonitor, eResourceID[nEnumCounter], &nBatteryUsage); - PRINT_RESULT_CLEANUP(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_get_usage_for_resource_id", BatteryMonitorGetError(nRet), battery_monitor_destroy(hBatteryMonitor)); - FPRINTF("[Line : %d][%s] battery_monitor_get_usage_for_resource_id returned battary usage[%d] for resource ID [%d] \\n", __LINE__, API_NAMESPACE, nBatteryUsage, eResourceID[nEnumCounter]); + nRet = battery_monitor_usage_data_get_power_usage_per_resource(hBatteryMonitorAPP, eResourceID[nEnumCounter], &nBatteryUsage); + PRINT_RESULT_CLEANUP(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_usage_data_get_power_usage_per_resource", BatteryMonitorGetError(nRet), battery_monitor_battery_usage_data_destroy(hBatteryMonitorAPP)); + FPRINTF("[Line : %d][%s] battery_monitor_usage_data_get_power_usage_per_resource returned battary usage[%f] for resource ID [%d] \\n", __LINE__, API_NAMESPACE, nBatteryUsage, eResourceID[nEnumCounter]); } - nRet = battery_monitor_destroy(hBatteryMonitor); - PRINT_RESULT_NORETURN(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_destroy", BatteryMonitorGetError(nRet)); + nRet = battery_monitor_battery_usage_data_destroy(hBatteryMonitorAPP); + PRINT_RESULT_NORETURN(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_battery_usage_data_destroy", BatteryMonitorGetError(nRet)); return 0; } //& type : auto -//& purpose: Gets the battery_monitor_h with battery consumption by the specified application. +//& purpose: Gets the battery_data_usage_h with battery consumption by the specified application. /** -* @testcase ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p +* @testcase ITc_battery_monitor_get_power_usage_by_app_for_all_resources_p * @since_tizen 5.5 * @author SRID(j.abhishek) * @reviewer SRID(shobhit.v) * @type auto -* @description Gets the battery_monitor_h with battery consumption by the specified application. -* @scenario Gets the battery monitor handle and call battery_monitor_get_usage_for_resource_id\n +* @description Gets the battery_data_usage_h with battery consumption by the specified application. +* @scenario Gets the battery monitor handle and call battery_monitor_usage_data_get_power_usage_per_resource\n * battery consumption by the specified application and check for Pass/Fail. -* @apicovered battery_monitor_get_usage_by_app_id_for_all_resource_id, battery_monitor_destroy -* @passcase battery_monitor_get_usage_by_app_id_for_all_resource_id is successful and return correct value -* @failcase battery_monitor_get_usage_by_app_id_for_all_resource_id gets failed or return null value +* @apicovered battery_monitor_get_power_usage_by_app_for_all_resources, battery_monitor_battery_usage_data_destroy +* @passcase battery_monitor_get_power_usage_by_app_for_all_resources is successful and return correct value +* @failcase battery_monitor_get_power_usage_by_app_for_all_resources gets failed or return null value * @precondition N/A * @postcondition Destroy gathered battery monitor handle. */ -int ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p(void) +int ITc_battery_monitor_get_power_usage_by_app_for_all_resources_p(void) { START_TEST_NO_CHECK; int nRet = -1; - int nBatteryUsage = 0; - battery_monitor_h hBatteryMonitorAPP = NULL; + double nBatteryUsage = 0.0; + battery_usage_data_h hBatteryMonitorAPP = NULL; + time_t start_time; + time_t end_time; + nRet = BatteryMonitorGetTime(&start_time, &end_time); + if(nRet == 1) + { + FPRINTF("[Line : %d][%s] error returned = failed precondition, time\\n", __LINE__, API_NAMESPACE); + return 1; + } + - battery_monitor_duration_type_e eMonitorDuration[] = { - BATTERY_MONITOR_DURATION_TYPE_1DAY, - BATTERY_MONITOR_DURATION_TYPE_1WEEK - }; battery_monitor_resource_id_e eResourceID[] = { BATTERY_MONITOR_RESOURCE_ID_BLE, @@ -202,37 +228,38 @@ int ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p(void) BATTERY_MONITOR_RESOURCE_ID_DISPLAY, BATTERY_MONITOR_RESOURCE_ID_DEVICE_NETWORK, BATTERY_MONITOR_RESOURCE_ID_GPS_SENSOR, - BATTERY_MONITOR_RESOURCE_ID_HRM_SENSOR + BATTERY_MONITOR_RESOURCE_ID_MAX }; - int nDurationEnumSize = sizeof(eMonitorDuration) / sizeof(eMonitorDuration[0]); - int nDurationEnumCounter; int nIDEnumSize = sizeof(eResourceID) / sizeof(eResourceID[0]); int nIDEnumCounter; - for(nDurationEnumCounter = 0; nDurationEnumCounter < nDurationEnumSize; nDurationEnumCounter++) + //Targer API + nRet = battery_monitor_get_power_usage_by_app_for_all_resources(TEST_APP_ID, start_time, end_time, &hBatteryMonitorAPP); + if ( g_bBatteryFeatureNotSupported ) { - //Targer API - nRet = battery_monitor_get_usage_by_app_id_for_all_resource_id(TEST_APP_ID, eMonitorDuration[nDurationEnumCounter], &hBatteryMonitorAPP); - if ( g_bBatteryFeatureNotSupported ) - { - PRINT_RESULT(BATTERY_MONITOR_ERROR_NOT_SUPPORTED, nRet, "battery_monitor_get_usage_by_app_id_for_all_resource_id", BatteryMonitorGetError(nRet)); - return 0; - } - PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_get_usage_by_app_id_for_all_resource_id", BatteryMonitorGetError(nRet)); - CHECK_HANDLE(hBatteryMonitorAPP, "battery_monitor_get_usage_by_app_id_for_all_resource_id"); + PRINT_RESULT(BATTERY_MONITOR_ERROR_NOT_SUPPORTED, nRet, "battery_monitor_get_power_usage_by_app_for_all_resources", BatteryMonitorGetError(nRet)); + return 0; + } + if(nRet == BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND) + { + FPRINTF("[Line : %d][%s] record not found\\n", __LINE__, API_NAMESPACE); + return 0; + } + PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_get_power_usage_by_app_for_all_resources", BatteryMonitorGetError(nRet)); + CHECK_HANDLE(hBatteryMonitorAPP, "battery_monitor_get_power_usage_by_app_for_all_resources"); - for(nIDEnumCounter = 0; nIDEnumCounter < nIDEnumSize; nIDEnumCounter++) - { - nRet = battery_monitor_get_usage_for_resource_id(hBatteryMonitorAPP, eResourceID[nIDEnumCounter], &nBatteryUsage); - PRINT_RESULT_CLEANUP(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_get_usage_for_resource_id", BatteryMonitorGetError(nRet), battery_monitor_destroy(hBatteryMonitorAPP)); - FPRINTF("[Line : %d][%s] battery_monitor_get_usage_for_resource_id returned battary usage[%d] for Monitor duration[%d] and resource ID [%d] \\n", __LINE__, API_NAMESPACE, nBatteryUsage, eMonitorDuration[nDurationEnumCounter], eResourceID[nIDEnumCounter]); - } - nRet = battery_monitor_destroy(hBatteryMonitorAPP); - PRINT_RESULT_NORETURN(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_destroy", BatteryMonitorGetError(nRet)); - hBatteryMonitorAPP = NULL; + for(nIDEnumCounter = 0; nIDEnumCounter < nIDEnumSize; nIDEnumCounter++) + { + nRet = battery_monitor_usage_data_get_power_usage_per_resource(hBatteryMonitorAPP, eResourceID[nIDEnumCounter], &nBatteryUsage); + PRINT_RESULT_CLEANUP(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_usage_data_get_power_usage_per_resource", BatteryMonitorGetError(nRet), battery_monitor_battery_usage_data_destroy(hBatteryMonitorAPP)); + FPRINTF("[Line : %d][%s] battery_monitor_usage_data_get_power_usage_per_resource returned battary usage[%f] for resource ID [%d] \\n", __LINE__, API_NAMESPACE, nBatteryUsage, eResourceID[nIDEnumCounter]); } + nRet = battery_monitor_battery_usage_data_destroy(hBatteryMonitorAPP); + PRINT_RESULT_NORETURN(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_battery_usage_data_destroy", BatteryMonitorGetError(nRet)); + hBatteryMonitorAPP = NULL; + return 0; } @@ -240,7 +267,7 @@ int ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p(void) //& type : auto //& purpose: Gets the battery consumption for the specific resource for the given application. /** -* @testcase ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p +* @testcase ITc_battery_monitor_get_power_usage_by_app_per_resource_p * @since_tizen 5.5 * @author SRID(j.abhishek) * @reviewer SRID(shobhit.v) @@ -248,23 +275,27 @@ int ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p(void) * @description Gets the battery consumption for the specific resource for the given application. * @scenario Get battery usage using different recource id for different duration\n * check for Pass/Fail. -* @apicovered battery_monitor_get_usage_by_app_id_for_resource_id -* @passcase battery_monitor_get_usage_by_app_id_for_resource_id is successful and return correct value -* @failcase battery_monitor_get_usage_by_app_id_for_resource_id gets failed or return null value +* @apicovered battery_monitor_get_power_usage_by_app_per_resource +* @passcase battery_monitor_get_power_usage_by_app_per_resource is successful and return correct value +* @failcase battery_monitor_get_power_usage_by_app_per_resource gets failed or return null value * @precondition N/A * @postcondition N/A */ -int ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p(void) +int ITc_battery_monitor_get_power_usage_by_app_per_resource_p(void) { START_TEST_NO_CHECK; int nRet = -1; - int nBatteryUsage = 0; + double nBatteryUsage = 0.0; + time_t start_time; + time_t end_time; + nRet = BatteryMonitorGetTime(&start_time, &end_time); + if(nRet == 1) + { + FPRINTF("[Line : %d][%s] error returned = failed precondition, time\\n", __LINE__, API_NAMESPACE); + return 1; + } - battery_monitor_duration_type_e eMonitorDuration[] = { - BATTERY_MONITOR_DURATION_TYPE_1DAY, - BATTERY_MONITOR_DURATION_TYPE_1WEEK - }; battery_monitor_resource_id_e eResourceID[] = { BATTERY_MONITOR_RESOURCE_ID_BLE, @@ -273,29 +304,29 @@ int ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p(void) BATTERY_MONITOR_RESOURCE_ID_DISPLAY, BATTERY_MONITOR_RESOURCE_ID_DEVICE_NETWORK, BATTERY_MONITOR_RESOURCE_ID_GPS_SENSOR, - BATTERY_MONITOR_RESOURCE_ID_HRM_SENSOR + BATTERY_MONITOR_RESOURCE_ID_MAX }; - int nDurationEnumSize = sizeof(eMonitorDuration) / sizeof(eMonitorDuration[0]); - int nDurationEnumCounter; - int nIDEnumSize = sizeof(eResourceID) / sizeof(eResourceID[0]); int nIDEnumCounter; for(nIDEnumCounter = 0; nIDEnumCounter < nIDEnumSize; nIDEnumCounter++) { - for(nDurationEnumCounter = 0; nDurationEnumCounter < nDurationEnumSize; nDurationEnumCounter++) + //Targer API + nRet = battery_monitor_get_power_usage_by_app_per_resource(TEST_APP_ID, eResourceID[nIDEnumCounter], start_time, end_time, &nBatteryUsage); + if ( g_bBatteryFeatureNotSupported ) { - //Targer API - nRet = battery_monitor_get_usage_by_app_id_for_resource_id(TEST_APP_ID, eResourceID[nIDEnumCounter], eMonitorDuration[nDurationEnumCounter], &nBatteryUsage); - if ( g_bBatteryFeatureNotSupported ) - { - PRINT_RESULT(BATTERY_MONITOR_ERROR_NOT_SUPPORTED, nRet, "battery_monitor_get_usage_by_app_id_for_resource_id", BatteryMonitorGetError(nRet)); - return 0; - } - PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_get_usage_by_app_id_for_resource_id", BatteryMonitorGetError(nRet)); - FPRINTF("[Line : %d][%s] battery_monitor_get_usage_by_app_id_for_resource_id returned battary usage[%d] for Monitor duration[%d] and resource ID [%d] \\n", __LINE__, API_NAMESPACE, nBatteryUsage, eMonitorDuration[nDurationEnumCounter], eResourceID[nIDEnumCounter]); + PRINT_RESULT(BATTERY_MONITOR_ERROR_NOT_SUPPORTED, nRet, "battery_monitor_get_power_usage_by_app_per_resource", BatteryMonitorGetError(nRet)); + return 0; } + if(nRet == BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND) + { + FPRINTF("[Line : %d][%s] record is not found\\n", __LINE__, API_NAMESPACE); + return 0; + } + PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_get_power_usage_by_app_per_resource", BatteryMonitorGetError(nRet)); + FPRINTF("[Line : %d][%s] battery_monitor_get_power_usage_by_app_per_resource returned battary usage[%f] resource ID [%d] \\n", __LINE__, API_NAMESPACE, nBatteryUsage, eResourceID[nIDEnumCounter]); + } return 0; @@ -304,7 +335,7 @@ int ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p(void) //& type : auto //& purpose: Gets the total battery usage in percent by an application for certain time duration /** -* @testcase ITc_battery_monitor_get_total_usage_by_app_id_p +* @testcase ITc_battery_monitor_get_power_usage_by_app_p * @since_tizen 5.5 * @author SRID(j.abhishek) * @reviewer SRID(shobhit.v) @@ -312,47 +343,50 @@ int ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p(void) * @description Gets the total battery usage in percent by an application for certain time duration. * @scenario Use test app id and different duration to get battery usage\n * check for Pass/Fail. -* @apicovered battery_monitor_get_total_usage_by_app_id -* @passcase battery_monitor_get_total_usage_by_app_id is successful and return correct value -* @failcase battery_monitor_get_total_usage_by_app_id gets failed or return null value +* @apicovered battery_monitor_get_power_usage_by_app +* @passcase battery_monitor_get_power_usage_by_app is successful and return correct value +* @failcase battery_monitor_get_power_usage_by_app gets failed or return null value * @precondition N/A * @postcondition N/A */ -int ITc_battery_monitor_get_total_usage_by_app_id_p(void) +int ITc_battery_monitor_get_power_usage_by_app_p(void) { START_TEST_NO_CHECK; int nRet = -1; - int nBatteryUsage = 0; - - battery_monitor_duration_type_e eMonitorDuration[] = { - BATTERY_MONITOR_DURATION_TYPE_1DAY, - BATTERY_MONITOR_DURATION_TYPE_1WEEK - }; + double nBatteryUsage = 0.0; + time_t start_time; + time_t end_time; + nRet = BatteryMonitorGetTime(&start_time, &end_time); + if(nRet == 1) + { + FPRINTF("[Line : %d][%s] error returned = failed precondition, time\\n", __LINE__, API_NAMESPACE); + return 1; + } - int nEnumSize = sizeof(eMonitorDuration) / sizeof(eMonitorDuration[0]); - int nEnumCounter; - for(nEnumCounter = 0; nEnumCounter < nEnumSize; nEnumCounter++) + //Targer API + nRet = battery_monitor_get_power_usage_by_app(TEST_APP_ID, start_time, end_time, &nBatteryUsage); + if ( g_bBatteryFeatureNotSupported ) { - //Targer API - nRet = battery_monitor_get_total_usage_by_app_id(TEST_APP_ID, eMonitorDuration[nEnumCounter], &nBatteryUsage); - if ( g_bBatteryFeatureNotSupported ) - { - PRINT_RESULT(BATTERY_MONITOR_ERROR_NOT_SUPPORTED, nRet, "battery_monitor_get_total_usage_by_app_id", BatteryMonitorGetError(nRet)); - return 0; - } - PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_get_total_usage_by_app_id", BatteryMonitorGetError(nRet)); - FPRINTF("[Line : %d][%s] battery_monitor_get_total_usage_by_app_id returned battary usage[%d] for Monitor duration[%d] \\n", __LINE__, API_NAMESPACE, nBatteryUsage, eMonitorDuration[nEnumCounter]); + PRINT_RESULT(BATTERY_MONITOR_ERROR_NOT_SUPPORTED, nRet, "battery_monitor_get_power_usage_by_app", BatteryMonitorGetError(nRet)); + return 0; } - - return 0; + if(nRet == BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND) + { + FPRINTF("[Line : %d][%s] record not found\\n", __LINE__, API_NAMESPACE); + return 0; + } + PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_get_power_usage_by_app", BatteryMonitorGetError(nRet)); + FPRINTF("[Line : %d][%s] battery_monitor_get_power_usage_by_app returned battary usage[%f] \\n", __LINE__, API_NAMESPACE, nBatteryUsage); + + return 0; } //& type : auto //& purpose: Gets the battery-percent usage by a resource for certain time duration. /** -* @testcase ITc_battery_monitor_get_total_usage_by_resource_id_p +* @testcase ITc_battery_monitor_get_power_usage_by_resource_p * @since_tizen 5.5 * @author SRID(j.abhishek) * @reviewer SRID(shobhit.v) @@ -361,23 +395,26 @@ int ITc_battery_monitor_get_total_usage_by_app_id_p(void) * @description Gets the battery-percent usage by a resource for certain time duration. * @scenario Based on different resource ID get battery usage for different duration\n * check for Pass/Fail. -* @apicovered battery_monitor_get_total_usage_by_resource_id -* @passcase battery_monitor_get_total_usage_by_resource_id is successful and return correct value -* @failcase battery_monitor_get_total_usage_by_resource_id gets failed or return null value +* @apicovered battery_monitor_get_power_usage_by_resource +* @passcase battery_monitor_get_power_usage_by_resource is successful and return correct value +* @failcase battery_monitor_get_power_usage_by_resource gets failed or return null value * @precondition N/A * @postcondition N/A */ -int ITc_battery_monitor_get_total_usage_by_resource_id_p(void) +int ITc_battery_monitor_get_power_usage_by_resource_p(void) { START_TEST_NO_CHECK; int nRet = -1; - int nBatteryUsage = 0; - - battery_monitor_duration_type_e eMonitorDuration[] = { - BATTERY_MONITOR_DURATION_TYPE_1DAY, - BATTERY_MONITOR_DURATION_TYPE_1WEEK - }; + double nBatteryUsage = 0.0; + time_t start_time; + time_t end_time; + nRet = BatteryMonitorGetTime(&start_time, &end_time); + if(nRet == 1) + { + FPRINTF("[Line : %d][%s] error returned = failed precondition, time\\n", __LINE__, API_NAMESPACE); + return 1; + } battery_monitor_resource_id_e eResourceID[] = { BATTERY_MONITOR_RESOURCE_ID_BLE, @@ -386,28 +423,27 @@ int ITc_battery_monitor_get_total_usage_by_resource_id_p(void) BATTERY_MONITOR_RESOURCE_ID_DISPLAY, BATTERY_MONITOR_RESOURCE_ID_DEVICE_NETWORK, BATTERY_MONITOR_RESOURCE_ID_GPS_SENSOR, + BATTERY_MONITOR_RESOURCE_ID_MAX }; - int nDurationEnumSize = sizeof(eMonitorDuration) / sizeof(eMonitorDuration[0]); - int nDurationEnumCounter; - int nIDEnumSize = sizeof(eResourceID) / sizeof(eResourceID[0]); int nIDEnumCounter; for(nIDEnumCounter = 0; nIDEnumCounter < nIDEnumSize; nIDEnumCounter++) { - for(nDurationEnumCounter = 0; nDurationEnumCounter < nDurationEnumSize; nDurationEnumCounter++) + nRet = battery_monitor_get_power_usage_by_resource(eResourceID[nIDEnumCounter], start_time, end_time, &nBatteryUsage); + if ( g_bBatteryFeatureNotSupported ) { - //Targer API - nRet = battery_monitor_get_total_usage_by_resource_id(eResourceID[nIDEnumCounter], eMonitorDuration[nDurationEnumCounter], &nBatteryUsage); - if ( g_bBatteryFeatureNotSupported ) - { - PRINT_RESULT(BATTERY_MONITOR_ERROR_NOT_SUPPORTED, nRet, "battery_monitor_get_total_usage_by_resource_id", BatteryMonitorGetError(nRet)); - return 0; - } - PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_get_total_usage_by_resource_id", BatteryMonitorGetError(nRet)); - FPRINTF("[Line : %d][%s] battery_monitor_get_total_usage_by_resource_id returned battary usage[%d] for Monitor duration[%d] and resource ID [%d] \\n", __LINE__, API_NAMESPACE, nBatteryUsage, eMonitorDuration[nDurationEnumCounter], eResourceID[nIDEnumCounter]); + PRINT_RESULT(BATTERY_MONITOR_ERROR_NOT_SUPPORTED, nRet, "battery_monitor_get_power_usage_by_resource", BatteryMonitorGetError(nRet)); + return 0; } + if(nRet == BATTERY_MONITOR_ERROR_RECORD_NOT_FOUND) + { + FPRINTF("[Line : %d][%s] record not found\\n", __LINE__, API_NAMESPACE); + return 0; + } + PRINT_RESULT(BATTERY_MONITOR_ERROR_NONE, nRet, "battery_monitor_get_power_usage_by_resource", BatteryMonitorGetError(nRet)); + FPRINTF("[Line : %d][%s] battery_monitor_get_power_usage_by_resource returned battary usage[%f] for resource ID [%d] \\n", __LINE__, API_NAMESPACE, nBatteryUsage, eResourceID[nIDEnumCounter]); } return 0; diff --git a/src/itc/battery-monitor/tct-battery-monitor-native_mobile.h b/src/itc/battery-monitor/tct-battery-monitor-native_mobile.h index fe2c8073c..9e13ce80b 100755 --- a/src/itc/battery-monitor/tct-battery-monitor-native_mobile.h +++ b/src/itc/battery-monitor/tct-battery-monitor-native_mobile.h @@ -23,20 +23,20 @@ extern void ITs_battery_monitor_startup(void); extern void ITs_battery_monitor_cleanup(void); -extern int ITc_battery_monitor_create_destroy_p(void); -extern int ITc_battery_monitor_get_usage_for_resource_id_p(void); -extern int ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p(void); -extern int ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p(void); -extern int ITc_battery_monitor_get_total_usage_by_app_id_p(void); -extern int ITc_battery_monitor_get_total_usage_by_resource_id_p(void); +extern int ITc_battery_monitor_battery_usage_data_destroy_p(void); +extern int ITc_battery_monitor_usage_data_get_power_usage_per_resource_p(void); +extern int ITc_battery_monitor_get_power_usage_by_app_for_all_resources_p(void); +extern int ITc_battery_monitor_get_power_usage_by_app_per_resource_p(void); +extern int ITc_battery_monitor_get_power_usage_by_app_p(void); +extern int ITc_battery_monitor_get_power_usage_by_resource_p(void); testcase tc_array[] = { - {"ITc_battery_monitor_create_destroy_p", ITc_battery_monitor_create_destroy_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, - {"ITc_battery_monitor_get_usage_for_resource_id_p", ITc_battery_monitor_get_usage_for_resource_id_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_battery_usage_data_destroy_p", ITc_battery_monitor_battery_usage_data_destroy_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_usage_data_get_power_usage_per_resource_p", ITc_battery_monitor_usage_data_get_power_usage_per_resource_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, {"ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p", ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, {"ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p", ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, - {"ITc_battery_monitor_get_total_usage_by_app_id_p", ITc_battery_monitor_get_total_usage_by_app_id_p, ITs_battery_monitor_startup,ITs_battery_monitor_cleanup}, - {"ITc_battery_monitor_get_total_usage_by_resource_id_p", ITc_battery_monitor_get_total_usage_by_resource_id_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_get_power_usage_by_app_p", ITc_battery_monitor_get_power_usage_by_app_p, ITs_battery_monitor_startup,ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_get_power_usage_by_resource_p", ITc_battery_monitor_get_power_usage_by_resource_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, {NULL, NULL, NULL, NULL} }; diff --git a/src/itc/battery-monitor/tct-battery-monitor-native_tizeniot.h b/src/itc/battery-monitor/tct-battery-monitor-native_tizeniot.h index fe2c8073c..96af27dc4 100755 --- a/src/itc/battery-monitor/tct-battery-monitor-native_tizeniot.h +++ b/src/itc/battery-monitor/tct-battery-monitor-native_tizeniot.h @@ -23,20 +23,20 @@ extern void ITs_battery_monitor_startup(void); extern void ITs_battery_monitor_cleanup(void); -extern int ITc_battery_monitor_create_destroy_p(void); -extern int ITc_battery_monitor_get_usage_for_resource_id_p(void); -extern int ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p(void); -extern int ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p(void); -extern int ITc_battery_monitor_get_total_usage_by_app_id_p(void); -extern int ITc_battery_monitor_get_total_usage_by_resource_id_p(void); +extern int ITc_battery_monitor_battery_usage_data_destroy_p(void); +extern int ITc_battery_monitor_usage_data_get_power_usage_per_resource_p(void); +extern int ITc_battery_monitor_get_power_usage_by_app_for_all_resources_p(void); +extern int ITc_battery_monitor_get_power_usage_by_app_per_resource_p(void); +extern int ITc_battery_monitor_get_power_usage_by_app_p(void); +extern int ITc_battery_monitor_get_power_usage_by_resource_p(void); testcase tc_array[] = { - {"ITc_battery_monitor_create_destroy_p", ITc_battery_monitor_create_destroy_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, - {"ITc_battery_monitor_get_usage_for_resource_id_p", ITc_battery_monitor_get_usage_for_resource_id_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, - {"ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p", ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, - {"ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p", ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, - {"ITc_battery_monitor_get_total_usage_by_app_id_p", ITc_battery_monitor_get_total_usage_by_app_id_p, ITs_battery_monitor_startup,ITs_battery_monitor_cleanup}, - {"ITc_battery_monitor_get_total_usage_by_resource_id_p", ITc_battery_monitor_get_total_usage_by_resource_id_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_battery_usage_data_destroy_p", ITc_battery_monitor_battery_usage_data_destroy_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_usage_data_get_power_usage_per_resource_p", ITc_battery_monitor_usage_data_get_power_usage_per_resource_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_get_power_usage_by_app_for_all_resources_p", ITc_battery_monitor_get_power_usage_by_app_for_all_resources_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_get_power_usage_by_app_per_resource_p", ITc_battery_monitor_get_power_usage_by_app_per_resource_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_get_power_usage_by_app_p", ITc_battery_monitor_get_power_usage_by_app_p, ITs_battery_monitor_startup,ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_get_power_usage_by_resource_p", ITc_battery_monitor_get_power_usage_by_resource_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, {NULL, NULL, NULL, NULL} }; diff --git a/src/itc/battery-monitor/tct-battery-monitor-native_wearable.h b/src/itc/battery-monitor/tct-battery-monitor-native_wearable.h index fe2c8073c..96af27dc4 100755 --- a/src/itc/battery-monitor/tct-battery-monitor-native_wearable.h +++ b/src/itc/battery-monitor/tct-battery-monitor-native_wearable.h @@ -23,20 +23,20 @@ extern void ITs_battery_monitor_startup(void); extern void ITs_battery_monitor_cleanup(void); -extern int ITc_battery_monitor_create_destroy_p(void); -extern int ITc_battery_monitor_get_usage_for_resource_id_p(void); -extern int ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p(void); -extern int ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p(void); -extern int ITc_battery_monitor_get_total_usage_by_app_id_p(void); -extern int ITc_battery_monitor_get_total_usage_by_resource_id_p(void); +extern int ITc_battery_monitor_battery_usage_data_destroy_p(void); +extern int ITc_battery_monitor_usage_data_get_power_usage_per_resource_p(void); +extern int ITc_battery_monitor_get_power_usage_by_app_for_all_resources_p(void); +extern int ITc_battery_monitor_get_power_usage_by_app_per_resource_p(void); +extern int ITc_battery_monitor_get_power_usage_by_app_p(void); +extern int ITc_battery_monitor_get_power_usage_by_resource_p(void); testcase tc_array[] = { - {"ITc_battery_monitor_create_destroy_p", ITc_battery_monitor_create_destroy_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, - {"ITc_battery_monitor_get_usage_for_resource_id_p", ITc_battery_monitor_get_usage_for_resource_id_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, - {"ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p", ITc_battery_monitor_get_usage_by_app_id_for_all_resource_id_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, - {"ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p", ITc_battery_monitor_get_usage_by_app_id_for_resource_id_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, - {"ITc_battery_monitor_get_total_usage_by_app_id_p", ITc_battery_monitor_get_total_usage_by_app_id_p, ITs_battery_monitor_startup,ITs_battery_monitor_cleanup}, - {"ITc_battery_monitor_get_total_usage_by_resource_id_p", ITc_battery_monitor_get_total_usage_by_resource_id_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_battery_usage_data_destroy_p", ITc_battery_monitor_battery_usage_data_destroy_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_usage_data_get_power_usage_per_resource_p", ITc_battery_monitor_usage_data_get_power_usage_per_resource_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_get_power_usage_by_app_for_all_resources_p", ITc_battery_monitor_get_power_usage_by_app_for_all_resources_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_get_power_usage_by_app_per_resource_p", ITc_battery_monitor_get_power_usage_by_app_per_resource_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_get_power_usage_by_app_p", ITc_battery_monitor_get_power_usage_by_app_p, ITs_battery_monitor_startup,ITs_battery_monitor_cleanup}, + {"ITc_battery_monitor_get_power_usage_by_resource_p", ITc_battery_monitor_get_power_usage_by_resource_p, ITs_battery_monitor_startup, ITs_battery_monitor_cleanup}, {NULL, NULL, NULL, NULL} };