diff --git a/tests/lib/gui/lvgl/CMakeLists.txt b/tests/lib/gui/lvgl/CMakeLists.txt new file mode 100644 index 00000000000..5021ec80e2b --- /dev/null +++ b/tests/lib/gui/lvgl/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.13.1) +include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) +project(lvgl) + +FILE(GLOB app_sources src/*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/tests/lib/gui/lvgl/prj.conf b/tests/lib/gui/lvgl/prj.conf new file mode 100644 index 00000000000..379baffde09 --- /dev/null +++ b/tests/lib/gui/lvgl/prj.conf @@ -0,0 +1,81 @@ +CONFIG_ZTEST=y + +CONFIG_DISPLAY=y +CONFIG_SDL_DISPLAY=n +CONFIG_DUMMY_DISPLAY=y +CONFIG_DUMMY_DISPLAY_DEV_NAME="DISPLAY" + +CONFIG_LOG=y + +CONFIG_FLASH=y +CONFIG_FILE_SYSTEM=y +CONFIG_FILE_SYSTEM_NFFS=y +CONFIG_FS_NFFS_FLASH_DEV_NAME="flash_ctrl" + +CONFIG_LVGL=y +# Make sure that the rendering task is always executed if we call +# lv_task_handler by setting the refresh period to zero +CONFIG_LVGL_SCREEN_REFRESH_PERIOD=0 +CONFIG_LVGL_COLOR_SCREEN_TRANSP=y +CONFIG_LVGL_ANTIALIAS=y +CONFIG_LVGL_ANIMATION=y +CONFIG_LVGL_SHADOW=y +CONFIG_LVGL_GROUP=y +CONFIG_LVGL_GPU=y +CONFIG_LVGL_IMG_CF_INDEXED=y +CONFIG_LVGL_IMG_CF_ALPHA=y +CONFIG_LVGL_FILESYSTEM=y +CONFIG_LVGL_DOUBLE_VDB=y +CONFIG_LVGL_OBJ_REALIGN=y +CONFIG_LVGL_OBJ_LABEL=y +CONFIG_LVGL_OBJ_LABEL_TEXT_SEL=y +CONFIG_LVGL_OBJ_LABEL_LONG_TXT_HINT=y +CONFIG_LVGL_OBJ_IMAGE=y +CONFIG_LVGL_OBJ_LINE=y +CONFIG_LVGL_OBJ_ARC=y +CONFIG_LVGL_OBJ_CONTAINER=y +CONFIG_LVGL_OBJ_PAGE=y +CONFIG_LVGL_OBJ_WINDOW=y +CONFIG_LVGL_OBJ_TAB_VIEW=y +CONFIG_LVGL_OBJ_TILE_VIEW=y +CONFIG_LVGL_OBJ_CALENDAR=y +CONFIG_LVGL_OBJ_PRELOAD=y +CONFIG_LVGL_OBJ_PRELOAD_DEF_ANIMATION_SPIN_ARC=y +CONFIG_LVGL_OBJ_PRELOAD_DEF_ANIMATION_FILL=y +CONFIG_LVGL_OBJ_CANVAS=y +CONFIG_LVGL_OBJ_BAR=y +CONFIG_LVGL_OBJ_LINE_METER=y +CONFIG_LVGL_OBJ_GAUGE=y +CONFIG_LVGL_OBJ_CHART=y +CONFIG_LVGL_OBJ_TABLE=y +CONFIG_LVGL_OBJ_LED=y +CONFIG_LVGL_OBJ_MSG_BOX=y +CONFIG_LVGL_OBJ_TEXT_AREA=y +CONFIG_LVGL_OBJ_SPINBOX=y +CONFIG_LVGL_OBJ_BUTTON=y +CONFIG_LVGL_OBJ_BUTTON_INK_EFFECT=y +CONFIG_LVGL_OBJ_IMG_BUTTON=y +CONFIG_LVGL_OBJ_IMG_BUTTON_TILED=y +CONFIG_LVGL_OBJ_BUTTON_MATRIX=y +CONFIG_LVGL_OBJ_KEYBOARD=y +CONFIG_LVGL_OBJ_CHECK_BOX=y +CONFIG_LVGL_OBJ_LIST=y +CONFIG_LVGL_OBJ_DROP_DOWN_LIST=y +CONFIG_LVGL_OBJ_ROLLER=y +CONFIG_LVGL_OBJ_SLIDER=y +CONFIG_LVGL_OBJ_SWITCH=y +CONFIG_LVGL_THEMES=y +CONFIG_LVGL_THEME_LIVE_UPDATE=y +CONFIG_LVGL_THEME_DEFAULT=y +CONFIG_LVGL_THEME_ALIEN=y +CONFIG_LVGL_THEME_NIGHT=y +CONFIG_LVGL_THEME_MONO=y +CONFIG_LVGL_THEME_MATERIAL=y +CONFIG_LVGL_THEME_ZEN=y +CONFIG_LVGL_THEME_NEMO=y + +CONFIG_LVGL_BUILD_IN_FONT_ROBOTO_12=y +CONFIG_LVGL_BUILD_IN_FONT_ROBOTO_16=y +CONFIG_LVGL_BUILD_IN_FONT_ROBOTO_22=y +CONFIG_LVGL_BUILD_IN_FONT_ROBOTO_28=y +CONFIG_LVGL_BUILD_IN_FONT_UNSCII_8=y diff --git a/tests/lib/gui/lvgl/src/img.c b/tests/lib/gui/lvgl/src/img.c new file mode 100644 index 00000000000..2f86eab8da1 --- /dev/null +++ b/tests/lib/gui/lvgl/src/img.c @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2019 Jan Van Winkel + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include "img.h" + +static const u8_t img_data[] = { + 0x00, 0x00, 0x00, 0x00, /* Index color 0 */ + 0x00, 0xff, 0x00, 0x00, /* Index color 1 */ + +/* 0 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, +/* 10 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, +/* 20 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, +/* 30 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, +/* 40 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, +/* 50 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, +/* 60 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, +/* 70 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, +/* 80 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, +/* 90 */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +/* 96 */ +}; + +static lv_img_dsc_t img_dsc = { + .header.always_zero = 0, + .header.w = 96, + .header.h = 96, + .data_size = sizeof(img_data), + .header.cf = LV_IMG_CF_INDEXED_1BIT, + .data = img_data, +}; + + +const lv_img_dsc_t *get_lvgl_img(void) +{ + return &img_dsc; +} + diff --git a/tests/lib/gui/lvgl/src/img.h b/tests/lib/gui/lvgl/src/img.h new file mode 100644 index 00000000000..17097725ae6 --- /dev/null +++ b/tests/lib/gui/lvgl/src/img.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2019 Jan Van Winkel + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_TEST_LIB_GUI_LVGL_IMG_H_ +#define ZEPHYR_TEST_LIB_GUI_LVGL_IMG_H_ + +#include + + +const lv_img_dsc_t *get_lvgl_img(void); + +#endif /* ZEPHYR_TEST_LIB_GUI_LVGL_IMG_H_ */ diff --git a/tests/lib/gui/lvgl/src/main.c b/tests/lib/gui/lvgl/src/main.c new file mode 100644 index 00000000000..df96717570b --- /dev/null +++ b/tests/lib/gui/lvgl/src/main.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2019 Jan Van Winkel + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "img.h" + +#include +#include +#include +#include +#include + +#include + +#define IMG_FILE_PATH "/mnt/img.bin" + +static struct nffs_flash_desc flash_desc; + +static struct fs_mount_t mnt = { + .type = FS_NFFS, + .mnt_point = "/mnt", + .fs_data = &flash_desc, +}; + +void test_get_default_screen(void) +{ + zassert_not_null(lv_scr_act(), "No default screen"); +} + +void test_add_delete_screen(void) +{ + lv_obj_t *default_screen = lv_scr_act(); + + zassert_not_null(default_screen, "No default screen"); + + lv_obj_t *new_screen = lv_obj_create(NULL, NULL); + + zassert_not_null(new_screen, "Failed to create new screen"); + + lv_scr_load(new_screen); + + lv_task_handler(); + + lv_obj_t *act_screen = lv_scr_act(); + + zassert_equal_ptr(act_screen, new_screen, "New screen not active"); + + lv_obj_del(new_screen); + + lv_scr_load(default_screen); + + lv_task_handler(); + + act_screen = lv_scr_act(); + zassert_equal_ptr(act_screen, default_screen, + "Default screen not active"); + +} +void test_add_img(void) +{ + lv_obj_t *img = lv_img_create(lv_scr_act(), NULL); + + zassert_not_null(img, "Failed to create image"); + + lv_img_set_src(img, IMG_FILE_PATH); + lv_obj_align(img, NULL, LV_ALIGN_CENTER, 0, 0); + + lv_task_handler(); +} + + +void setup_fs(void) +{ + struct device *flash_dev; + struct fs_file_t img; + struct fs_dirent info; + int ret; + const lv_img_dsc_t *c_img = get_lvgl_img(); + + flash_dev = device_get_binding(CONFIG_FS_NFFS_FLASH_DEV_NAME); + if (flash_dev == NULL) { + TC_PRINT("Could not get flash device \"%s\"\n", + CONFIG_FS_NFFS_FLASH_DEV_NAME); + ztest_test_fail(); + } + mnt.storage_dev = flash_dev; + ret = fs_mount(&mnt); + if (ret < 0) { + TC_PRINT("Failed to mount file system: %d\n", ret); + ztest_test_fail(); + return; + } + + ret = fs_stat(IMG_FILE_PATH, &info); + if ((ret == 0) && (info.type == FS_DIR_ENTRY_FILE)) { + return; + } + + ret = fs_open(&img, IMG_FILE_PATH); + if (ret < 0) { + TC_PRINT("Failed to open image file: %d\n", ret); + ztest_test_fail(); + return; + } + + ret = fs_write(&img, &c_img->header, sizeof(lv_img_header_t)); + if (ret < 0) { + TC_PRINT("Failed to write image file header: %d\n", ret); + ztest_test_fail(); + return; + } + + ret = fs_write(&img, &c_img->data, c_img->data_size); + if (ret < 0) { + TC_PRINT("Failed to write image file data: %d\n", ret); + ztest_test_fail(); + return; + } + + ret = fs_close(&img); + if (ret < 0) { + TC_PRINT("Failed to close image file: %d\n", ret); + ztest_test_fail(); + return; + } +} + +void teardown_fs(void) +{ +} + +void test_main(void) +{ + + ztest_test_suite(lvgl_screen, ztest_unit_test(test_get_default_screen), + ztest_unit_test(test_add_delete_screen)); + ztest_test_suite(lvgl_fs, ztest_user_unit_test_setup_teardown( + test_add_img, setup_fs, teardown_fs)); + + ztest_run_test_suite(lvgl_screen); + ztest_run_test_suite(lvgl_fs); +} + diff --git a/tests/lib/gui/lvgl/testcase.yaml b/tests/lib/gui/lvgl/testcase.yaml new file mode 100644 index 00000000000..1e4e8477207 --- /dev/null +++ b/tests/lib/gui/lvgl/testcase.yaml @@ -0,0 +1,48 @@ +tests: + libraries.gui.lvgl: + tags: display gui + platform_whitelist: native_posix + libraries.gui.lvgl.dynamic.heap.libc: + tags: display gui + platform_whitelist: native_posix + extra_configs: + - CONFIG_NEWLIB_LIBC=y + - CONFIG_LVGL_BUFFER_ALLOC_DYNAMIC=y + - CONFIG_LVGL_MEM_POOL_HEAP_LIB_C=y + libraries.gui.lvgl.dynamic.pool.user: + tags: display gui + platform_whitelist: native_posix + extra_configs: + - CONFIG_LVGL_BUFFER_ALLOC_DYNAMIC=y + - CONFIG_LVGL_MEM_POOL_USER=y + - CONFIG_LVGL_MEM_POOL_NUMBER_BLOCKS=3 + - CONFIG_LVGL_MEM_POOL_MAX_SIZE=32768 + libraries.gui.lvgl.dynamic.pool.kernel: + tags: display gui + platform_whitelist: native_posix + extra_configs: + - CONFIG_LVGL_BUFFER_ALLOC_DYNAMIC=y + - CONFIG_LVGL_MEM_POOL_KERNEL=y + - CONFIG_LVGL_MEM_POOL_NUMBER_BLOCKS=3 + - CONFIG_LVGL_MEM_POOL_MAX_SIZE=32768 + libraries.gui.lvgl.16bit: + tags: display gui + platform_whitelist: native_posix + extra_configs: + - CONFIG_LVGL_COLOR_DEPTH_16=y + libraries.gui.lvgl.8bit: + tags: display gui + platform_whitelist: native_posix + extra_configs: + - CONFIG_LVGL_COLOR_DEPTH_8=y + libraries.gui.lvgl.mono: + tags: display gui + platform_whitelist: native_posix + extra_configs: + - CONFIG_LVGL_COLOR_DEPTH_1=y + libraries.gui.lvgl.16bit.swap: + tags: display gui + platform_whitelist: native_posix + extra_configs: + - CONFIG_LVGL_COLOR_DEPTH_16=y + - CONFIG_LVGL_COLOR_16_SWAP=y