diff options
author | lokilee73 <changjoo.lee@samsung.com> | 2020-08-20 13:21:28 +0900 |
---|---|---|
committer | Hyotaek Shim <hyotaek.shim@samsung.com> | 2020-08-21 02:27:13 +0000 |
commit | 7d2a08b3f6c2445b766ecade848a04b80023797e (patch) | |
tree | 8b9bd76cb9656b03b058fabf60e4330e631df404 | |
parent | 2dbc6aee70a1f06b9643de3bd84a3ba4760f82bb (diff) | |
download | deviced-7d2a08b3f6c2445b766ecade848a04b80023797e.tar.gz deviced-7d2a08b3f6c2445b766ecade848a04b80023797e.tar.bz2 deviced-7d2a08b3f6c2445b766ecade848a04b80023797e.zip |
Add internal CAPIs to auto test
ex)
device_touchscreen_disable
device_touchscreen_enable
device_display_get_brightness_state
device_display_get_max_brightness_state
device_display_set_brightness_state
device_display_change_state_by_reason
device_multi_led_get_number
device_multi_led_control
device_battery_get_info_direct
Change-Id: I0fc8b3ed05d508b2a13e3275e1669837c656c2db
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
-rw-r--r-- | src/auto-test/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/auto-test/auto-test.conf | 4 | ||||
-rw-r--r-- | src/auto-test/internal-api.c | 210 |
3 files changed, 219 insertions, 0 deletions
diff --git a/src/auto-test/CMakeLists.txt b/src/auto-test/CMakeLists.txt index 56238659..4463f003 100644 --- a/src/auto-test/CMakeLists.txt +++ b/src/auto-test/CMakeLists.txt @@ -25,8 +25,13 @@ SET(SRCS battery-monitor-test.c udev.c brightness.c + internal-api.c ) +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED + capi-system-device) + FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) diff --git a/src/auto-test/auto-test.conf b/src/auto-test/auto-test.conf index 6ae94442..a155478c 100644 --- a/src/auto-test/auto-test.conf +++ b/src/auto-test/auto-test.conf @@ -9,6 +9,7 @@ extcon=1 ir=1 time=1 udev=1 +internal-api=1 [wearable] battery-monitor=1 @@ -22,6 +23,7 @@ extcon=1 ir=0 time=1 udev=1 +internal-api=1 [tv] battery-monitor=0 @@ -34,6 +36,7 @@ extcon=1 ir=0 time=1 udev=1 +internal-api=0 [common] battery-monitor=0 @@ -46,3 +49,4 @@ extcon=1 ir=0 time=1 udev=1 +internal-api=1
\ No newline at end of file diff --git a/src/auto-test/internal-api.c b/src/auto-test/internal-api.c new file mode 100644 index 00000000..1c8a502e --- /dev/null +++ b/src/auto-test/internal-api.c @@ -0,0 +1,210 @@ +/* + * test + * + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "test.h" +#include <device/touchscreen-internal.h> +#include <device/display-internal.h> +#include <device/led-internal.h> +#include <device/battery-internal.h> + +#define PALM_STR "palm" + +static unsigned int blue[] = {0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF}; + +static void __cb(void *data, GVariant *result, GError *err) +{ + int temp = 0; + + if (!result) + { + _E("Can't get result of touchscreen request.:%s", err->message); + return; + } + + if (!dh_get_param_from_var(result, "(i)", &temp)) { + _E("Failed to get variant(%s): no call back message", g_variant_get_type_string(result)); + goto out; + } + _I("replay message(%d)", temp); + +out: + g_variant_unref(result); +} + +static bool check_result(int val) +{ + if (val == DEVICE_ERROR_NONE || val == DEVICE_ERROR_NOT_SUPPORTED) + return true; + else + return false; +} + +static bool touchscreen_disable(void) +{ + int ret; + + ret = device_touchscreen_disable(__cb); + + return check_result(ret); +} + +static bool touchscreen_enable(void) +{ + int ret; + + ret = device_touchscreen_enable(__cb); + + return check_result(ret); +} + +static bool display_get_brightness_state(display_state_e state, int *brightness) +{ + int ret; + + ret = device_display_get_brightness_state(0, state, brightness); + + return check_result(ret); +} + +static bool display_get_max_brightness_state(display_state_e state, int *brightness) +{ + int ret; + + ret = device_display_get_max_brightness_state(0, state, brightness); + + return check_result(ret); +} + +static bool display_set_brightness_state(display_state_e state, int brightness) +{ + int ret; + + ret = device_display_set_brightness_state(0, state, brightness); + + return check_result(ret); +} + +static bool display_change_state_by_reason(display_state_e type, const char *reason, int timeout, device_dbus_pending_cb cb) +{ + int ret; + + ret = device_display_change_state_by_reason(type, reason, timeout, cb); + + return check_result(ret); +} + +static bool multi_led_get_number(void) +{ + int ret; + int number_of_led; + + ret = device_multi_led_get_number(&number_of_led); + + return check_result(ret); +} + +static bool multi_led_control(unsigned int color[]) +{ + int ret; + + ret = device_multi_led_control(color); + + return check_result(ret); +} + +static bool battery_get_info_direct(struct device_battery_info *info) +{ + int ret; + + ret = device_battery_get_info_direct(info); + + return check_result(ret); +} + +static void internal_api_test_all(int *success, int *fail) +{ + struct device_battery_info info; + int brightness; + int s = 0; + int f = 0; + + //touchscreen + (touchscreen_disable()) ? s++ : f++; + (touchscreen_enable()) ? s++ : f++; + + //display + (display_get_brightness_state(DISPLAY_STATE_NORMAL, &brightness)) ? s++ : f++; + (display_get_brightness_state(DISPLAY_STATE_SCREEN_DIM, &brightness)) ? s++ : f++; + (display_get_max_brightness_state(DISPLAY_STATE_NORMAL, &brightness)) ? s++ : f++; + (display_get_max_brightness_state(DISPLAY_STATE_SCREEN_DIM, &brightness)) ? s++ : f++; + (display_set_brightness_state(DISPLAY_STATE_NORMAL, 100)) ? s++ : f++; + (display_set_brightness_state(DISPLAY_STATE_SCREEN_DIM, 1)) ? s++ : f++; + (display_change_state_by_reason(DISPLAY_STATE_SCREEN_OFF, PALM_STR, 0, __cb)) ? s++ : f++; + + //led + (multi_led_get_number()) ? s++ : f++; + (multi_led_control(blue)) ? s++ : f++; + + //battery + (battery_get_info_direct(&info)) ? s++ : f++; + + if (NULL != success) *success = s; + if (NULL != fail) *fail = f; +} + +static void internal_api_init(void *data) +{ + int success = 0; + int fail = 0; + + _I("start test"); + + internal_api_test_all(&success, &fail); + + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); +} + +static void internal_api_exit(void *data) +{ + _I("end test"); +} + +static int internal_api_unit(int argc, char **argv) +{ + if (argc < 4) { + int success = 0; + int fail = 0; + + _I("start test"); + internal_api_test_all(&success, &fail); + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); + } else { + _E("Unknown test case!!!"); + } + + return 0; +} + +static const struct test_ops internal_api_test_ops = { + .priority = TEST_PRIORITY_NORMAL, + .name = "internal-api", + .init = internal_api_init, + .exit = internal_api_exit, + .unit = internal_api_unit, +}; + +TEST_OPS_REGISTER(&internal_api_test_ops) |