{
START_TEST;
- power_lock_e power_locks[] = { POWER_LOCK_CPU, POWER_LOCK_DISPLAY, POWER_LOCK_DISPLAY_DIM };
- int enum_size = sizeof(power_locks) / sizeof(power_locks[0]);
+ struct expect_return_by_profile {
+ power_lock_e lock_type;
+ int headed;
+ int headless;
+ } expect_return[] = {
+ {
+ .lock_type = POWER_LOCK_CPU,
+ .headed = DEVICE_ERROR_NONE,
+ .headless = DEVICE_ERROR_NONE,
+ }, {
+ .lock_type = POWER_LOCK_DISPLAY,
+ .headed = DEVICE_ERROR_NONE,
+ .headless = DEVICE_ERROR_NOT_SUPPORTED,
+ }, {
+ .lock_type = POWER_LOCK_DISPLAY_DIM,
+ .headed = DEVICE_ERROR_NONE,
+ .headless = DEVICE_ERROR_NOT_SUPPORTED,
+ },
+ };
+ int enum_size = sizeof(expect_return) / sizeof(expect_return[0]);
int enum_counter = 0;
- if ((bIsDisplayFeatureSupported == false) || (bIsDisplayStateFeatureSupported == false))
- return 0;
-
for ( enum_counter=0; enum_counter<enum_size; enum_counter++)
{
// Target API
- int nRet = device_power_request_lock(power_locks[enum_counter], 10);
- if ( nRet != DEVICE_ERROR_NONE )
+ int nRet = device_power_request_lock(expect_return[enum_counter].lock_type, 10);
+ int nExpectedRet = bIsDisplayFeatureSupported ? expect_return[enum_counter].headed : expect_return[enum_counter].headless;
+ if ( nRet != nExpectedRet )
{
- FPRINTF("[Line : %d][%s] device_power_request_lock failed for enum = %s, error returned = %s\\n",
- __LINE__, API_NAMESPACE, DeviceGetPowerLock(power_locks[enum_counter]), DeviceGetError(nRet));
+ FPRINTF("[Line : %d][%s] device_power_request_lock failed for enum = %s, error returned = %s, expected return = %s\\n",
+ __LINE__, API_NAMESPACE, DeviceGetPowerLock(expect_return[enum_counter].lock_type), DeviceGetError(nRet), DeviceGetError(nExpectedRet));
return 1;
}
// Target API
- nRet = device_power_release_lock(power_locks[enum_counter]);
- if ( nRet != DEVICE_ERROR_NONE )
+ nRet = device_power_release_lock(expect_return[enum_counter].lock_type);
+ if ( nRet != nExpectedRet )
{
- FPRINTF("[Line : %d][%s] device_power_release_lock failed for enum = %s, error returned = %s\\n",
- __LINE__, API_NAMESPACE, DeviceGetPowerLock(power_locks[enum_counter]), DeviceGetError(nRet));
+ FPRINTF("[Line : %d][%s] device_power_release_lock failed for enum = %s, error returned = %s, expected return = %s\\n",
+ __LINE__, API_NAMESPACE, DeviceGetPowerLock(expect_return[enum_counter].lock_type), DeviceGetError(nRet), DeviceGetError(nExpectedRet));
return 1;
}
}