From 963776a58b53cebabac0c1e13e88349261feaa56 Mon Sep 17 00:00:00 2001 From: Arvin Mittal Date: Thu, 23 Jun 2016 13:59:53 +0530 Subject: [PATCH] [ITC][device][ACR-622][Added testcases for new API] Change-Id: I07eae7300f305f6a884584fda31553eaa65766cc Signed-off-by: Arvin Mittal --- src/itc/device/CMakeLists.txt | 1 + src/itc/device/ITs-device_battery.c | 150 +++++++++++++++++++++++++- src/itc/device/tct-device-native_common_iot.h | 10 ++ src/itc/device/tct-device-native_mobile.h | 8 ++ src/itc/device/tct-device-native_tv.h | 10 ++ src/itc/device/tct-device-native_wearable.h | 8 ++ 6 files changed, 185 insertions(+), 2 deletions(-) diff --git a/src/itc/device/CMakeLists.txt b/src/itc/device/CMakeLists.txt index 2a3cfb7..0e90549 100755 --- a/src/itc/device/CMakeLists.txt +++ b/src/itc/device/CMakeLists.txt @@ -48,6 +48,7 @@ SET(TC_SOURCES ITs-device_display.c ITs-device_power.c ITs-device_ir.c + ITs-device_battery.c ) ENDIF() diff --git a/src/itc/device/ITs-device_battery.c b/src/itc/device/ITs-device_battery.c index db834ec..153dd0b 100755 --- a/src/itc/device/ITs-device_battery.c +++ b/src/itc/device/ITs-device_battery.c @@ -20,7 +20,6 @@ * @{ */ -#ifndef COMMON_IOT //& set: Device bool g_bDeviceBatteryLevelCallback; @@ -68,6 +67,7 @@ void ITs_device_battery_cleanup(void) * @{ */ +#if (defined(MOBILE) || defined(WEARABLE)) //& purpose: To get the battery charge percentage. //& type: auto /** @@ -171,6 +171,152 @@ int ITc_device_battery_get_level_status_p(void) return 0; } -#endif //COMMON_IOT +#endif //MOBILE || WEARABLE + +//& purpose: To get the battery health information. +//& type: auto +/** +* @testcase ITc_device_battery_get_health_p +* @since_tizen 3.0 +* @author SRID(arvin.mittal) +* @reviewer SRID(a.pandia1) +* @type auto +* @description To get the battery health information. +* @scenario Gets the battery health information. +* @apicovered device_battery_get_health +* @passcase When device_battery_get_health is successful +* @failcase If target API device_battery_get_health fails +* @precondition NA +* @postcondition NA +*/ +int ITc_device_battery_get_health_p(void) +{ + START_TEST; + + device_battery_health_e eDeviceBatteryHealth = -1; + + // Target API + int nRet = device_battery_get_health(&eDeviceBatteryHealth); + PRINT_RESULT(DEVICE_ERROR_NONE, nRet, "device_battery_get_health", DeviceGetError(nRet)); + + if ( eDeviceBatteryHealth < DEVICE_BATTERY_HEALTH_GOOD || eDeviceBatteryHealth > DEVICE_BATTERY_HEALTH_OVER_VOLTAGE) + { + FPRINTF("[Line : %d][%s] device_battery_get_health failed with invalid value\\n", __LINE__, API_NAMESPACE); + return 1; + } + + return 0; +} + +//& purpose: To get the battery power source information. +//& type: auto +/** +* @testcase ITc_device_battery_get_power_source_p +* @since_tizen 3.0 +* @author SRID(arvin.mittal) +* @reviewer SRID(a.pandia1) +* @type auto +* @description To get the battery power source information. +* @scenario Gets the battery power source information. +* @apicovered device_battery_get_power_source +* @passcase When device_battery_get_power_source is successful +* @failcase If target API device_battery_get_power_source fails +* @precondition NA +* @postcondition NA +*/ +int ITc_device_battery_get_power_source_p(void) +{ + START_TEST; + + device_battery_power_source_e eDeviceBatteryPowerSource = -1; + + // Target API + int nRet = device_battery_get_power_source(&eDeviceBatteryPowerSource); + PRINT_RESULT(DEVICE_ERROR_NONE, nRet, "device_battery_get_power_source", DeviceGetError(nRet)); + + //If device is connected via USB then DEVICE_BATTERY_POWER_SOURCE_USB is used, otherwise it needs to be changed. + if ( eDeviceBatteryPowerSource < DEVICE_BATTERY_POWER_SOURCE_NONE || eDeviceBatteryPowerSource > DEVICE_BATTERY_POWER_SOURCE_WIRELESS) + { + FPRINTF("[Line : %d][%s] device_battery_get_power_source failed with wrong value\\n", __LINE__, API_NAMESPACE); + return 1; + } + + return 0; +} + +//& purpose: To get the battery properties. +//& type: auto +/** +* @testcase ITc_device_battery_get_property_p +* @since_tizen 3.0 +* @author SRID(arvin.mittal) +* @reviewer SRID(a.pandia1) +* @type auto +* @description To get the battery properties. +* @scenario Gets the battery properties. +* @apicovered device_battery_get_property +* @passcase When device_battery_get_property is successful +* @failcase If target API device_battery_get_property fails +* @precondition NA +* @postcondition NA +*/ +int ITc_device_battery_get_property_p(void) +{ + START_TEST; + + device_battery_property_e eDeviceBatteryProperty[] = {DEVICE_BATTERY_PROPERTY_CAPACITY, DEVICE_BATTERY_PROPERTY_CURRENT_NOW, DEVICE_BATTERY_PROPERTY_CURRENT_AVERAGE}; + int nDeviceBatteryPropertyArraySize = sizeof(eDeviceBatteryProperty) / sizeof(eDeviceBatteryProperty[0]); + int nValue; + int nRet, nLoopCount; + // Target API + for(nLoopCount = 0; nLoopCount < nDeviceBatteryPropertyArraySize; nLoopCount++) + { + nValue = -1; + nRet = device_battery_get_property(eDeviceBatteryProperty[nLoopCount], &nValue); + PRINT_RESULT(DEVICE_ERROR_NONE, nRet, "device_battery_get_property", DeviceGetError(nRet)); + if (nValue < 0) + { + FPRINTF("[Line : %d][%s] device_battery_get_property failed with invalid value\\n", __LINE__, API_NAMESPACE); + return 1; + } + } + + return 0; +} + +//& purpose: To get the battery power source information. +//& type: auto +/** +* @testcase ITc_device_battery_get_status_p +* @since_tizen 3.0 +* @author SRID(arvin.mittal) +* @reviewer SRID(a.pandia1) +* @type auto +* @description To get the battery power source information. +* @scenario Gets the battery power source information. +* @apicovered device_battery_get_status +* @passcase When device_battery_get_status is successful +* @failcase If target API device_battery_get_status fails +* @precondition NA +* @postcondition NA +*/ +int ITc_device_battery_get_status_p(void) +{ + START_TEST; + + device_battery_status_e eDeviceBatteryStatus = -1; + + // Target API + int nRet = device_battery_get_status(&eDeviceBatteryStatus); + PRINT_RESULT(DEVICE_ERROR_NONE, nRet, "device_battery_get_status", DeviceGetError(nRet)); + + if ( eDeviceBatteryStatus < DEVICE_BATTERY_STATUS_CHARGING || eDeviceBatteryStatus > DEVICE_BATTERY_STATUS_NOT_CHARGING) + { + FPRINTF("[Line : %d][%s] device_battery_get_status failed with wrong value\\n", __LINE__, API_NAMESPACE); + return 1; + } + + return 0; +} /** @} */ /** @} */ \ No newline at end of file diff --git a/src/itc/device/tct-device-native_common_iot.h b/src/itc/device/tct-device-native_common_iot.h index 9804b99..e3aae9e 100755 --- a/src/itc/device/tct-device-native_common_iot.h +++ b/src/itc/device/tct-device-native_common_iot.h @@ -23,6 +23,8 @@ extern void ITs_device_display_startup(void); extern void ITs_device_display_cleanup(void); extern void ITs_device_power_startup(void); extern void ITs_device_power_cleanup(void); +extern void ITs_device_battery_startup(void); +extern void ITs_device_battery_cleanup(void); extern int ITc_device_display_get_numbers_p(void); extern int ITc_device_display_get_max_brightness_p(void); @@ -30,6 +32,10 @@ extern int ITc_device_display_set_get_brightness_p(void); extern int ITc_device_display_change_get_state_p(void); extern int ITc_device_power_request_release_lock_p(void); extern int ITc_power_wakeup_p(void); +extern int ITc_device_battery_get_health_p(void); +extern int ITc_device_battery_get_power_source_p(void); +extern int ITc_device_battery_get_property_p(void); +extern int ITc_device_battery_get_status_p(void); testcase tc_array[] = { {"ITc_device_display_get_numbers_p", ITc_device_display_get_numbers_p, ITs_device_display_startup, ITs_device_display_cleanup}, @@ -38,6 +44,10 @@ testcase tc_array[] = { {"ITc_device_display_change_get_state_p", ITc_device_display_change_get_state_p, ITs_device_display_startup, ITs_device_display_cleanup}, {"ITc_device_power_request_release_lock_p", ITc_device_power_request_release_lock_p, ITs_device_power_startup, ITs_device_power_cleanup}, {"ITc_power_wakeup_p", ITc_power_wakeup_p, ITs_device_power_startup, ITs_device_power_cleanup}, + {"ITc_device_battery_get_health_p", ITc_device_battery_get_health_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_power_source_p", ITc_device_battery_get_power_source_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_property_p", ITc_device_battery_get_property_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_status_p", ITc_device_battery_get_status_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, {NULL, NULL} }; diff --git a/src/itc/device/tct-device-native_mobile.h b/src/itc/device/tct-device-native_mobile.h index c7fe74c..3a5e609 100755 --- a/src/itc/device/tct-device-native_mobile.h +++ b/src/itc/device/tct-device-native_mobile.h @@ -41,6 +41,10 @@ extern int ITc_device_haptic_open_close_p(void); extern int ITc_device_battery_get_percent_p(void); extern int ITc_device_battery_is_charging_p(void); extern int ITc_device_battery_get_level_status_p(void); +extern int ITc_device_battery_get_health_p(void); +extern int ITc_device_battery_get_power_source_p(void); +extern int ITc_device_battery_get_property_p(void); +extern int ITc_device_battery_get_status_p(void); extern int ITc_device_display_get_numbers_p(void); extern int ITc_device_display_get_max_brightness_p(void); extern int ITc_device_display_set_get_brightness_p(void); @@ -61,6 +65,10 @@ testcase tc_array[] = { {"ITc_device_battery_get_percent_p", ITc_device_battery_get_percent_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, {"ITc_device_battery_is_charging_p", ITc_device_battery_is_charging_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, {"ITc_device_battery_get_level_status_p", ITc_device_battery_get_level_status_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_health_p", ITc_device_battery_get_health_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_power_source_p", ITc_device_battery_get_power_source_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_property_p", ITc_device_battery_get_property_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_status_p", ITc_device_battery_get_status_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, {"ITc_device_display_get_numbers_p", ITc_device_display_get_numbers_p, ITs_device_display_startup, ITs_device_display_cleanup}, {"ITc_device_display_get_max_brightness_p", ITc_device_display_get_max_brightness_p, ITs_device_display_startup, ITs_device_display_cleanup}, {"ITc_device_display_set_get_brightness_p", ITc_device_display_set_get_brightness_p, ITs_device_display_startup, ITs_device_display_cleanup}, diff --git a/src/itc/device/tct-device-native_tv.h b/src/itc/device/tct-device-native_tv.h index d789309..2c68ab5 100755 --- a/src/itc/device/tct-device-native_tv.h +++ b/src/itc/device/tct-device-native_tv.h @@ -27,6 +27,8 @@ extern void ITs_device_startup(void); extern void ITs_device_cleanup(void); extern void ITs_device_ir_startup(void); extern void ITs_device_ir_cleanup(void); +extern void ITs_device_battery_startup(void); +extern void ITs_device_battery_cleanup(void); extern int ITc_device_display_get_numbers_p(void); extern int ITc_device_display_change_get_state_p(void); @@ -35,6 +37,10 @@ extern int ITc_power_wakeup_p(void); extern int ITc_device_add_remove_callback_p(void); extern int ITc_device_ir_is_available_p(void); extern int ITc_device_ir_transmit_p(void); +extern int ITc_device_battery_get_health_p(void); +extern int ITc_device_battery_get_power_source_p(void); +extern int ITc_device_battery_get_property_p(void); +extern int ITc_device_battery_get_status_p(void); testcase tc_array[] = { @@ -45,6 +51,10 @@ testcase tc_array[] = { {"ITc_device_add_remove_callback_p", ITc_device_add_remove_callback_p, ITs_device_startup, ITs_device_cleanup}, {"ITc_device_ir_is_available_p", ITc_device_ir_is_available_p, ITs_device_ir_startup, ITs_device_ir_cleanup}, {"ITc_device_ir_transmit_p", ITc_device_ir_transmit_p, ITs_device_ir_startup, ITs_device_ir_cleanup}, + {"ITc_device_battery_get_health_p", ITc_device_battery_get_health_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_power_source_p", ITc_device_battery_get_power_source_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_property_p", ITc_device_battery_get_property_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_status_p", ITc_device_battery_get_status_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, {NULL, NULL} }; diff --git a/src/itc/device/tct-device-native_wearable.h b/src/itc/device/tct-device-native_wearable.h index d627345..f6fc6d6 100755 --- a/src/itc/device/tct-device-native_wearable.h +++ b/src/itc/device/tct-device-native_wearable.h @@ -37,6 +37,10 @@ extern void ITs_device_ir_cleanup(void); extern int ITc_device_battery_get_percent_p(void); extern int ITc_device_battery_is_charging_p(void); extern int ITc_device_battery_get_level_status_p(void); +extern int ITc_device_battery_get_health_p(void); +extern int ITc_device_battery_get_power_source_p(void); +extern int ITc_device_battery_get_property_p(void); +extern int ITc_device_battery_get_status_p(void); extern int ITc_device_display_get_numbers_p(void); extern int ITc_device_display_get_max_brightness_p(void); extern int ITc_device_display_set_get_brightness_p(void); @@ -57,6 +61,10 @@ testcase tc_array[] = { {"ITc_device_battery_get_percent_p", ITc_device_battery_get_percent_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, {"ITc_device_battery_is_charging_p", ITc_device_battery_is_charging_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, {"ITc_device_battery_get_level_status_p", ITc_device_battery_get_level_status_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_health_p", ITc_device_battery_get_health_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_power_source_p", ITc_device_battery_get_power_source_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_property_p", ITc_device_battery_get_property_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, + {"ITc_device_battery_get_status_p", ITc_device_battery_get_status_p, ITs_device_battery_startup, ITs_device_battery_cleanup}, {"ITc_device_display_get_numbers_p", ITc_device_display_get_numbers_p, ITs_device_display_startup, ITs_device_display_cleanup}, {"ITc_device_display_get_max_brightness_p", ITc_device_display_get_max_brightness_p, ITs_device_display_startup, ITs_device_display_cleanup}, {"ITc_device_display_set_get_brightness_p", ITc_device_display_set_get_brightness_p, ITs_device_display_startup, ITs_device_display_cleanup}, -- 2.7.4