//& 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)
* @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;
}
//& 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)
* @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,
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,
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;
}
//& 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)
* @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,
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;
//& 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)
* @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)
* @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,
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;