diff --git a/Kconfig b/Kconfig index 51eabf11c..4220be262 100644 --- a/Kconfig +++ b/Kconfig @@ -1642,6 +1642,11 @@ menu "LVGL configuration" int "Font manager name max length" depends on LV_USE_FONT_MANAGER default 32 + config LV_USE_TEST + bool "Enable emulated input devices, time emulation, and screenshot compares." + config LV_USE_TEST_SCREENSHOT_COMPARE + bool "Enable `lv_test_screenshot_compare`. Requires libpng and a few MB of extra RAM." + depends on LV_USE_TEST config LV_USE_XML bool "Enable loading XML UIs runtime" config LVGL_VERSION_MAJOR diff --git a/docs/details/other-components/test.rst b/docs/details/other-components/test.rst new file mode 100644 index 000000000..403f2c427 --- /dev/null +++ b/docs/details/other-components/test.rst @@ -0,0 +1,156 @@ +.. _test: + +==== +Test +==== + +Overview +******** + +The Test module provides functions to emulate clicks, key presses, encoder turns, time passing, and +compare the UI with reference images. + +These functions can be easily used in any test framework (such as Unity, GoogleTest, etc.), and +assertions can be performed to check if, for example: + +- A widget's value is different from the expected value after emulating user inputs. +- The values are incorrect after some time has passed. +- The screen's content is different from the reference image. +- Some event functions are not triggered. +- Etc. + +Note that it is assumed the tests are performed on a desktop or server environment, +where there are no memory constraints. + +Usage +***** + +The Test module can be enabled by ``LV_USE_TEST``, and it consists of the following components: + +- Helpers +- Display emulation +- Input device emulation +- Screenshot comparison + +Helpers +------- + +Time +^^^^ + +To emulate elapsed time, two functions can be used: + +1. :cpp:expr:`lv_test_wait(ms)`: Emulates that ``ms`` milliseconds have elapsed, but it also calls ``lv_timer_handler`` after each millisecond. + This is useful to check if events (e.g., long press, long press repeat) and timers were triggered correctly over time. +2. :cpp:expr:`lv_test_fast_forward(ms)`: Jumps ``ms`` milliseconds ahead and calls ``lv_timer_handler`` only once at the end. + +:cpp:expr:`lv_refr_now(NULL)` is called at the end of both functions to ensure that animations and +widget coordinates are recalculated. + +:cpp:expr:`lv_refr_now(NULL)` can also be called manually to force LVGL to refresh the emulated display. + +Memory Usage +^^^^^^^^^^^^ + +If ``LV_USE_STDLIB_MALLOC`` is set to ``LV_STDLIB_BUILTIN``, memory usage and memory leaks can be monitored. + +.. code-block:: c + + size_t mem1 = lv_test_get_free_mem(); + + size_t mem2 = lv_test_get_free_mem(); + if(mem1 != mem2) fail(); + +It might make sense to create and delete items in a loop many times and add a small tolerance +to the memory leakage test. This might be needed due to potential memory fragmentation. Empirically, +a tolerance of 32 bytes is recommended. + +.. code-block:: c + + if(LV_ABS((int64_t)mem2 - (int64_t)mem1) > 32) fail(); + +Display Emulation +----------------- + +By calling :cpp:expr:`lv_test_display_create(hor_res, ver_res)`, a dummy display can be created. + +It functions like any other normal display, but its content exists only in memory. + +When creating this display, the horizontal and vertical resolutions must be passed. Internally, +a framebuffer will be allocated for this size, and ``XRGB8888`` color format will be set. + +The resolution and color format can be changed at any time by calling :cpp:expr:`lv_display_set_resolution` and +:cpp:expr:`lv_display_set_color_format`. + +Input Device Emulation +---------------------- + +By calling :cpp:expr:`lv_test_indev_create_all`, three test input devices will be created: + +1. A pointer (for touch or mouse) +2. A keypad +3. An encoder + +For example, this is how a scroll gesture can be emulated: + +.. code-block:: c + + lv_test_mouse_move_to(20, 30); + lv_test_mouse_press(); + lv_test_wait(20); + lv_test_mouse_move_by(0, 100); + lv_test_wait(20); + lv_test_mouse_release(); + lv_test_wait(20); + +It is recommended to add :cpp:expr:`lv_test_wait` after user actions to ensure that +the new state and coordinates are read and applied from the input device. + +After that, the user can check if the given widget was really scrolled +by getting the Y coordinate of a child. + +.. code-block:: c + + int32_t y_start = lv_obj_get_y(child); + + int32_t y_end = lv_obj_get_y(child); + if(y_start + 100 != y_end) fail(); + +Please refer to ``lv_test_indev.h`` for the list of supported input device emulation functions. + +Screenshot Comparison +--------------------- + +:cpp:expr:`bool lv_test_screenshot_compare(const char * fn_ref)` is a useful function +to compare the content of the emulated display with reference PNG images. + +The screenshot comparison uses `libpng`, so it needs to be linked to LVGL when this feature is required. +To avoid making the entire Test module dependent on `libpng`, screenshot comparison can be individually enabled by +``LV_USE_TEST_SCREENSHOT_COMPARE``. + +This function works in a practical way: + +- If the folder(s) referenced in ``fn_ref`` do not exist, they will be created automatically. +- If the reference image is not found, it will be created automatically from the rendered screen. +- If the comparison fails, an ``_err.png`` file will be created with the rendered content next to the reference image. +- If the comparison fails, the X and Y coordinates of the first divergent pixel, along with the actual and expected colors, will also be printed. + +The reference PNG images should have a **32-bit color format** and match the display size. + +The test display's content will be converted to ``XRGB8888`` to simplify comparison with the reference images. +The conversion is supported from the following formats (i.e., the test display should have a color +format from any of these): + +- :cpp:expr:`LV_COLOR_FORMAT_XRGB8888` +- :cpp:expr:`LV_COLOR_FORMAT_ARGB8888` +- :cpp:expr:`LV_COLOR_FORMAT_RGB888` +- :cpp:expr:`LV_COLOR_FORMAT_RGB565` +- :cpp:expr:`LV_COLOR_FORMAT_L8` +- :cpp:expr:`LV_COLOR_FORMAT_AL88` +- :cpp:expr:`LV_COLOR_FORMAT_I1` + +To read and decode PNG images and to store the converted rendered image, a few MBs of RAM are dynamically allocated using the standard ``malloc`` +(not :cpp:expr:`lv_malloc`). + +API +*** diff --git a/lv_conf_template.h b/lv_conf_template.h index 43abdf3b2..c5880b719 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -1121,6 +1121,15 @@ #endif +/** Enable emulated input devices, time emulation, and screenshot compares. */ +#define LV_USE_TEST 0 +#if LV_USE_TEST + +/** Enable `lv_test_screenshot_compare`. + * Requires libpng and a few MB of extra RAM. */ +#define LV_USE_TEST_SCREENSHOT_COMPARE 0 +#endif /*LV_USE_TEST*/ + /** Enable loading XML UIs runtime */ #define LV_USE_XML 0 diff --git a/lvgl.h b/lvgl.h index 73051e1ad..6ee7e7379 100644 --- a/lvgl.h +++ b/lvgl.h @@ -96,6 +96,7 @@ extern "C" { #include "src/others/font_manager/lv_font_manager.h" #include "src/others/xml/lv_xml.h" #include "src/others/xml/lv_xml_component.h" +#include "src/others/test/lv_test.h" #include "src/libs/barcode/lv_barcode.h" #include "src/libs/bin_decoder/lv_bin_decoder.h" diff --git a/src/core/lv_global.h b/src/core/lv_global.h index a9356ba29..4515c01c9 100644 --- a/src/core/lv_global.h +++ b/src/core/lv_global.h @@ -53,6 +53,7 @@ extern "C" { #include "../draw/sw/lv_draw_sw_mask_private.h" #include "../stdlib/builtin/lv_tlsf_private.h" #include "../others/sysmon/lv_sysmon_private.h" +#include "../others/test/lv_test_private.h" #include "../layouts/lv_layout_private.h" /********************* @@ -223,6 +224,10 @@ typedef struct _lv_global_t { uint32_t objid_count; #endif +#if LV_USE_TEST + lv_test_state_t test_state; +#endif + #if LV_USE_NUTTX struct _lv_nuttx_ctx_t * nuttx_ctx; #endif diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index 481052242..d70a33f20 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -3550,6 +3550,27 @@ #endif +/** Enable emulated input devices, time emulation, and screenshot compares. */ +#ifndef LV_USE_TEST + #ifdef CONFIG_LV_USE_TEST + #define LV_USE_TEST CONFIG_LV_USE_TEST + #else + #define LV_USE_TEST 0 + #endif +#endif +#if LV_USE_TEST + +/** Enable `lv_test_screenshot_compare`. + * Requires libpng and a few MB of extra RAM. */ +#ifndef LV_USE_TEST_SCREENSHOT_COMPARE + #ifdef CONFIG_LV_USE_TEST_SCREENSHOT_COMPARE + #define LV_USE_TEST_SCREENSHOT_COMPARE CONFIG_LV_USE_TEST_SCREENSHOT_COMPARE + #else + #define LV_USE_TEST_SCREENSHOT_COMPARE 0 + #endif +#endif +#endif /*LV_USE_TEST*/ + /** Enable loading XML UIs runtime */ #ifndef LV_USE_XML #ifdef CONFIG_LV_USE_XML diff --git a/src/others/test/lv_test.h b/src/others/test/lv_test.h new file mode 100644 index 000000000..b22c1636e --- /dev/null +++ b/src/others/test/lv_test.h @@ -0,0 +1,45 @@ +/** + * @file lv_test.h + * + */ + +#ifndef LV_TEST_H +#define LV_TEST_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "../../lv_conf_internal.h" +#if LV_USE_TEST + +/********************* + * DEFINES + *********************/ +#include "lv_test_indev.h" +#include "lv_test_display.h" +#include "lv_test_helpers.h" +#include "lv_test_screenshot_compare.h" + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/********************** + * MACROS + **********************/ + +#endif /*LV_USE TEST*/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*LV_TEST_H*/ diff --git a/src/others/test/lv_test_display.c b/src/others/test/lv_test_display.c new file mode 100644 index 000000000..f3aa892f6 --- /dev/null +++ b/src/others/test/lv_test_display.c @@ -0,0 +1,108 @@ +/** + * @file lv_test_display.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include "lv_test_display.h" +#if LV_USE_TEST + +#include "../../core/lv_global.h" +#include "../../lvgl_private.h" +#include + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ +static void dummy_flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * color_p); + +static void buf_changed_event_cb(lv_event_t * e); +static void delete_event_cb(lv_event_t * e); + +/********************** + * STATIC VARIABLES + **********************/ + +/********************** + * MACROS + **********************/ +#define _state LV_GLOBAL_DEFAULT()->test_state + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +lv_display_t * lv_test_display_create(int32_t hor_res, int32_t ver_res) +{ + + lv_display_t * disp = lv_display_create(hor_res, ver_res); + lv_display_set_color_format(disp, LV_COLOR_FORMAT_XRGB8888); + + size_t buf_size = 4 * (hor_res + LV_DRAW_BUF_STRIDE_ALIGN - 1) * ver_res + LV_DRAW_BUF_ALIGN; + uint8_t * buf = malloc(buf_size); + LV_ASSERT_MALLOC(buf); + + lv_draw_buf_init(&_state.draw_buf, hor_res, ver_res, LV_COLOR_FORMAT_XRGB8888, LV_STRIDE_AUTO, lv_draw_buf_align(buf, + LV_COLOR_FORMAT_XRGB8888), buf_size); + _state.draw_buf.unaligned_data = buf; + lv_display_set_draw_buffers(disp, &_state.draw_buf, NULL); + lv_display_set_render_mode(disp, LV_DISPLAY_RENDER_MODE_DIRECT); + + lv_display_set_flush_cb(disp, dummy_flush_cb); + + lv_display_add_event_cb(disp, buf_changed_event_cb, LV_EVENT_COLOR_FORMAT_CHANGED, NULL); + lv_display_add_event_cb(disp, buf_changed_event_cb, LV_EVENT_RESOLUTION_CHANGED, NULL); + lv_display_add_event_cb(disp, delete_event_cb, LV_EVENT_DELETE, NULL); + + return disp; +} + +/********************** + * STATIC FUNCTIONS + **********************/ + +static void buf_changed_event_cb(lv_event_t * e) +{ + lv_display_t * disp = lv_event_get_target(e); + lv_color_format_t cf = lv_display_get_color_format(disp); + int32_t hor_res = lv_display_get_horizontal_resolution(disp); + int32_t ver_res = lv_display_get_vertical_resolution(disp); + + free(_state.draw_buf.unaligned_data); + + size_t buf_size = 4 * (hor_res + LV_DRAW_BUF_STRIDE_ALIGN - 1) * ver_res + LV_DRAW_BUF_ALIGN; + uint8_t * buf = malloc(buf_size); + LV_ASSERT_MALLOC(buf); + + lv_draw_buf_init(&_state.draw_buf, hor_res, ver_res, cf, LV_STRIDE_AUTO, lv_draw_buf_align(buf, cf), buf_size); + _state.draw_buf.unaligned_data = buf; + lv_display_set_draw_buffers(disp, &_state.draw_buf, NULL); +} + +static void delete_event_cb(lv_event_t * e) +{ + LV_UNUSED(e); + lv_display_t * disp = lv_event_get_target(e); + lv_draw_buf_t * draw_buf = lv_display_get_buf_active(disp); + free(draw_buf->unaligned_data); + +} + +static void dummy_flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * color_p) +{ + LV_UNUSED(area); + LV_UNUSED(color_p); + lv_display_flush_ready(disp); +} + +#endif /*LV_USE_TEST*/ diff --git a/src/others/test/lv_test_display.h b/src/others/test/lv_test_display.h new file mode 100644 index 000000000..ea39da2da --- /dev/null +++ b/src/others/test/lv_test_display.h @@ -0,0 +1,55 @@ +/** + * @file lv_test_display.h + * + */ + +#ifndef LV_TEST_DISPLAY_H +#define LV_TEST_DISPLAY_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "../../lv_conf_internal.h" +#if LV_USE_TEST + +#include "../../misc/lv_types.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/*** + * Create a dummy display for for the tests + * @param hor_res the maximal horizontal resolution + * @param ver_res the maximal vertical resolution + * @return the created display + * + * @note The resolution can be changed to any smaller values later + * using `lv_display_set_resolution` + * The color format can be freely changed later using `lv_display_set_color_format` + */ +lv_display_t * lv_test_display_create(int32_t hor_res, int32_t ver_res); + +/********************** + * MACROS + **********************/ + +#endif /*LV_USE_TEST*/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*LV_TEST_DISPLAY_H*/ diff --git a/src/others/test/lv_test_helpers.c b/src/others/test/lv_test_helpers.c new file mode 100644 index 000000000..cbaadca7d --- /dev/null +++ b/src/others/test/lv_test_helpers.c @@ -0,0 +1,60 @@ +/** + * @file lv_test_helpers.c + * + */ + +/********************* + * INCLUDES + *********************/ + +#include "lv_test_helpers.h" + +#if LV_USE_TEST +#include "../../lvgl.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ + +/********************** + * STATIC VARIABLES + **********************/ + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +void lv_test_wait(uint32_t ms) +{ + while(ms) { + lv_tick_inc(1); + lv_timer_handler(); + ms--; + } + lv_refr_now(NULL); +} + +void lv_test_fast_forward(uint32_t ms) +{ + lv_tick_inc(ms); + lv_timer_handler(); + lv_refr_now(NULL); +} + +/********************** + * STATIC FUNCTIONS + **********************/ + +#endif /*LV_USE_TEST*/ diff --git a/src/others/test/lv_test_helpers.h b/src/others/test/lv_test_helpers.h new file mode 100644 index 000000000..0c9048b8d --- /dev/null +++ b/src/others/test/lv_test_helpers.h @@ -0,0 +1,80 @@ +/** + * @file lv_test_helpers.h + * + */ + +#ifndef LV_TEST_HELPERS_H +#define LV_TEST_HELPERS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ + +#include "../../lv_conf_internal.h" +#if LV_USE_TEST + +#include "../../misc/lv_types.h" +#include "../../stdlib/lv_mem.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/** + * Emulate a delay. It's not real delay, but it tricks LVGL to think that the + * required time has been elapsed. + * `lv_timer_handler` is called after each millisecond, meaning all the events + * will be fired inside this function. + * At the end the animations and display will be also updated. + * @param ms the number of milliseconds to pass + */ +void lv_test_wait(uint32_t ms); + +/** + * Emulates some time passing. + * Update the animations and the display only once at the end. + * @param ms the number of milliseconds to pass + */ +void lv_test_fast_forward(uint32_t ms); + +#if LV_USE_STDLIB_MALLOC != LV_STDLIB_BUILTIN +/* Skip checking heap as we don't have the info available */ +#define LV_HEAP_CHECK(x) do {} while(0) +/* Pick a non-zero value */ +#define lv_test_get_free_mem() (65536) +#else +#define LV_HEAP_CHECK(x) x + +static inline size_t lv_test_get_free_mem(void) +{ + lv_mem_monitor_t m1; + lv_mem_monitor(&m1); + return m1.free_size; +} +#endif /* LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN */ + +/********************** + * MACROS + **********************/ + +#define LV_TEST_WIDTH_TO_STRIDE(w, px_size) ((((w) * (px_size) + (LV_DRAW_BUF_STRIDE_ALIGN - 1)) / LV_DRAW_BUF_STRIDE_ALIGN) * LV_DRAW_BUF_STRIDE_ALIGN) + +#endif /*LV_USE_TEST*/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*LV_TEST_HELPERS_H*/ diff --git a/src/others/test/lv_test_indev.c b/src/others/test/lv_test_indev.c new file mode 100644 index 000000000..11bdb14b2 --- /dev/null +++ b/src/others/test/lv_test_indev.c @@ -0,0 +1,194 @@ +/** + * @file lv_test_indev.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include "lv_test.h" +#if LV_USE_TEST + +#include "../../core/lv_global.h" +#include "../../lvgl_private.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ +static void lv_test_mouse_read_cb(lv_indev_t * indev, lv_indev_data_t * data); +static void lv_test_keypad_read_cb(lv_indev_t * indev, lv_indev_data_t * data); +static void lv_test_encoder_read_cb(lv_indev_t * indev, lv_indev_data_t * data); + +/********************** + * STATIC VARIABLES + **********************/ + +/********************** + * MACROS + **********************/ +#define _state LV_GLOBAL_DEFAULT()->test_state + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +void lv_test_indev_create_all(void) +{ + _state.mouse_indev = lv_indev_create(); + lv_indev_set_type(_state.mouse_indev, LV_INDEV_TYPE_POINTER); + lv_indev_set_read_cb(_state.mouse_indev, lv_test_mouse_read_cb); + + _state.keypad_indev = lv_indev_create(); + lv_indev_set_type(_state.keypad_indev, LV_INDEV_TYPE_KEYPAD); + lv_indev_set_read_cb(_state.keypad_indev, lv_test_keypad_read_cb); + + _state.encoder_indev = lv_indev_create(); + lv_indev_set_type(_state.encoder_indev, LV_INDEV_TYPE_ENCODER); + lv_indev_set_read_cb(_state.encoder_indev, lv_test_encoder_read_cb); +} + +lv_indev_t * lv_test_indev_get_indev(lv_indev_type_t type) +{ + switch(type) { + case LV_INDEV_TYPE_POINTER: + return _state.mouse_indev; + case LV_INDEV_TYPE_KEYPAD: + return _state.keypad_indev; + case LV_INDEV_TYPE_ENCODER: + return _state.encoder_indev; + default: + return NULL; + + } +} + +void lv_test_mouse_move_to(int32_t x, int32_t y) +{ + _state.x_act = x; + _state.y_act = y; +} + + +void lv_test_mouse_move_to_obj(lv_obj_t * obj) +{ + int32_t x = obj->coords.x1 + lv_obj_get_width(obj) / 2; + int32_t y = obj->coords.y1 + lv_obj_get_height(obj) / 2; + lv_test_mouse_move_to(x, y); +} + +void lv_test_mouse_move_by(int32_t x, int32_t y) +{ + _state.x_act += x; + _state.y_act += y; +} + +void lv_test_mouse_press(void) +{ + _state.mouse_pressed = true; +} + +void lv_test_mouse_release(void) +{ + _state.mouse_pressed = false; +} + +void lv_test_mouse_click_at(int32_t x, int32_t y) +{ + lv_test_mouse_release(); + lv_test_wait(50); + lv_test_mouse_move_to(x, y); + lv_test_mouse_press(); + lv_test_wait(50); + lv_test_mouse_release(); + lv_test_wait(50); +} + +void lv_test_key_press(uint32_t k) +{ + _state.key_act = k; + _state.key_pressed = true; +} + +void lv_test_key_release(void) +{ + _state.key_pressed = false; +} + +void lv_test_key_hit(uint32_t k) +{ + lv_test_key_release(); + lv_test_wait(50); + lv_test_key_press(k); + lv_test_wait(50); + lv_test_key_release(); + lv_test_wait(50); +} + +void lv_test_encoder_add_diff(int32_t d) +{ + _state.diff_act += d; +} + +void lv_test_encoder_turn(int32_t d) +{ + _state.diff_act += d; + lv_test_wait(50); +} + +void lv_test_encoder_press(void) +{ + _state.enc_pressed = true; +} + +void lv_test_encoder_release(void) +{ + _state.enc_pressed = false; +} + +void lv_test_encoder_click(void) +{ + lv_test_encoder_release(); + lv_test_wait(50); + lv_test_encoder_press(); + lv_test_wait(50); + lv_test_encoder_release(); + lv_test_wait(50); +} + +/********************** + * STATIC FUNCTIONS + **********************/ + +static void lv_test_mouse_read_cb(lv_indev_t * indev, lv_indev_data_t * data) +{ + LV_UNUSED(indev); + lv_point_set(&data->point, _state.x_act, _state.y_act); + data->state = _state.mouse_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED; +} + + +static void lv_test_keypad_read_cb(lv_indev_t * indev, lv_indev_data_t * data) +{ + LV_UNUSED(indev); + data->key = _state.key_act; + data->state = _state.key_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED; +} + + +static void lv_test_encoder_read_cb(lv_indev_t * indev, lv_indev_data_t * data) +{ + LV_UNUSED(indev); + data->enc_diff = _state.diff_act; + data->state = _state.enc_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED; + _state.diff_act = 0; +} + +#endif /*LV_USE_TEST*/ diff --git a/src/others/test/lv_test_indev.h b/src/others/test/lv_test_indev.h new file mode 100644 index 000000000..7d833fff4 --- /dev/null +++ b/src/others/test/lv_test_indev.h @@ -0,0 +1,166 @@ +/** + * @file lv_test_indev.h + * + */ + +#ifndef LV_TEST_INDEV_H +#define LV_TEST_INDEV_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "../../lv_conf_internal.h" +#if LV_USE_TEST + +#include "../../misc/lv_types.h" +#include "../../indev/lv_indev.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/** + * Create a mouse (pointer), keypad, and encoder indevs. + * They can be controlled via function calls during the test + */ +void lv_test_indev_create_all(void); + +/** + * Get one of the indev created in `lv_test_indev_create_all` + * @param type type of the indev to get + * @return the indev + */ +lv_indev_t * lv_test_indev_get_indev(lv_indev_type_t type); + +/** + * Move the mouse to the given coordinates. + * This function doesn't wait, but just changes the state and returns immediately. + * @param x the target absolute X coordinate + * @param y the target absolute Y coordinate + */ +void lv_test_mouse_move_to(int32_t x, int32_t y); + +/** + * Move the mouse to the center of a widget + * This function doesn't wait, but just changes the state and returns immediately. + * @param obj pointer to an widget + */ +void lv_test_mouse_move_to_obj(lv_obj_t * obj); + +/** + * Move the mouse cursor. Keep the pressed or released state + * This function doesn't wait, but just changes the state and returns immediately. + * @param x the difference in X to move + * @param y the difference in Y to move + */ +void lv_test_mouse_move_by(int32_t x, int32_t y); + +/** + * Make the mouse button pressed. + * This function doesn't wait, but just changes the state and returns immediately. + */ +void lv_test_mouse_press(void); + +/** + * Make the mouse button released. + * This function doesn't wait, but just changes the state and returns immediately. + */ +void lv_test_mouse_release(void); + +/** + * Emulate a click on a given point. + * First set the released state, wait a little, press, wait, and release again. + * The wait time is 50ms. + * Internally `lv_timer_handler` is called, meaning all the events will be fired inside this function. + * @param x the target absolute X coordinate + * @param y the target absolute Y coordinate + */ +void lv_test_mouse_click_at(int32_t x, int32_t y); + +/** + * Emulate a key press. + * This function doesn't wait, but just changes the state and returns immediately. + * @param k the key to press + */ +void lv_test_key_press(uint32_t k); + +/** + * Release the previously press key. + * This function doesn't wait, but just changes the state and returns immediately. + * @param k the key to press + */ +void lv_test_key_release(void); + +/** + * Emulate a key hit. + * First set the released state, wait a little, press, wait, and release again. + * The wait time is 50ms. + * Internally `lv_timer_handler` is called, meaning all the events will be fired inside this function. + * @param k the key to hit + */ +void lv_test_key_hit(uint32_t k); + + +/** + * Emulate encoder rotation, use positive parameter to rotate to the right + * and negative to rotate to the left. + * This function doesn't wait, but just changes the state and returns immediately. + * @param d number of encoder ticks to emulate + */ +void lv_test_encoder_add_diff(int32_t d); + +/** + * Emulate an encoder turn a wait 50ms. Use positive parameter to rotate to the right + * and negative to rotate to the left. + * Internally `lv_timer_handler` is called, meaning all the events will be fired inside this function. + * @param d number of encoder ticks to emulate + */ +void lv_test_encoder_turn(int32_t d); + +/** + * Emulate an encoder press. + * This function doesn't wait, but just changes the state and returns immediately. + */ +void lv_test_encoder_press(void); + +/** + * Emulate an encoder release. + * This function doesn't wait, but just changes the state and returns immediately. + */ +void lv_test_encoder_release(void); + +/** + * Emulate am encoder click. + * First set the released state, wait a little, press, wait, and release again. + * The wait time is 50ms. + * Internally `lv_timer_handler` is called, meaning all the events will be fired inside this function. + */ +void lv_test_encoder_click(void); + +/********************** + * MACROS + **********************/ + +#endif /*LV_USE_TEST*/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*LV_TEST_INDEV_H*/ + + + + diff --git a/src/others/test/lv_test_private.h b/src/others/test/lv_test_private.h new file mode 100644 index 000000000..eebca7109 --- /dev/null +++ b/src/others/test/lv_test_private.h @@ -0,0 +1,61 @@ +/** + * @file lv_test_private.h + * + */ + +#ifndef LV_TEST_PRIVATE_H +#define LV_TEST_PRIVATE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "../../lv_conf_internal.h" +#if LV_USE_TEST + +#include "../../misc/lv_types.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +typedef struct { + lv_indev_t * mouse_indev; + lv_indev_t * keypad_indev; + lv_indev_t * encoder_indev; + + + lv_draw_buf_t draw_buf; + + int32_t x_act; + int32_t y_act; + uint32_t key_act; + int32_t diff_act; + bool mouse_pressed; + bool key_pressed; + bool enc_pressed; +} lv_test_state_t; + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/********************** + * MACROS + **********************/ + +#endif /*LV_USE_TEST*/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + + +#endif /*LV_TEST_PRIVATE_H*/ diff --git a/tests/unity/unity_support.c b/src/others/test/lv_test_screenshot_compare.c similarity index 71% rename from tests/unity/unity_support.c rename to src/others/test/lv_test_screenshot_compare.c index c5da40a48..555292e78 100644 --- a/tests/unity/unity_support.c +++ b/src/others/test/lv_test_screenshot_compare.c @@ -11,14 +11,15 @@ /********************* * INCLUDES *********************/ -#if LV_BUILD_TEST -#include "../lvgl.h" +#include "../../lv_conf_internal.h" +#if LV_USE_TEST && defined(LV_USE_TEST_SCREENSHOT_COMPARE) && LV_USE_TEST_SCREENSHOT_COMPARE + +#include "../../lvgl.h" #include #include #include #include #include -#include "unity.h" #define PNG_DEBUG 3 #include @@ -35,7 +36,7 @@ *********************/ #ifndef REF_IMGS_PATH - #define REF_IMGS_PATH "ref_imgs/" + #define REF_IMGS_PATH "" #endif #ifndef REF_IMG_TOLERANCE @@ -48,6 +49,7 @@ /********************** * TYPEDEFS **********************/ + typedef struct { int width, height; png_byte color_type; @@ -62,7 +64,7 @@ typedef struct { /********************** * STATIC PROTOTYPES **********************/ -static bool screenshot_compare(const char * fn_ref, const char * mode, uint8_t tolerance); +static bool screenshot_compare(const char * fn_ref, uint8_t tolerance); static int read_png_file(png_image_t * p, const char * file_name); static int write_png_file(void * raw_img, uint32_t width, uint32_t height, char * file_name); static void png_release(png_image_t * p); @@ -81,52 +83,16 @@ static void create_folders_if_needed(const char * path) ; * GLOBAL FUNCTIONS **********************/ -bool lv_test_assert_image_eq(const char * fn_ref) +bool lv_test_screenshot_compare(const char * fn_ref) { bool pass; lv_obj_t * scr = lv_screen_active(); lv_obj_invalidate(scr); - pass = screenshot_compare(fn_ref, "full refresh", REF_IMG_TOLERANCE); + pass = screenshot_compare(fn_ref, REF_IMG_TOLERANCE); if(!pass) return false; - //Software has minor rounding errors when not the whole image is updated - //so ignore stripe invalidation for now - // uint32_t i; - // for(i = 0; i < 800; i += 50 ) { - // lv_area_t a; - // a.y1 = 0; - // a.y2 = 479; - // a.x1 = i; - // a.x2 = i + 12; - // lv_obj_invalidate_area(scr, &a); - // - // a.x1 = i + 25; - // a.x2 = i + 32; - // lv_obj_invalidate_area(scr, &a); - // } - // - // pass = screenshot_compare(fn_ref, "vertical stripes", 32); - // if(!pass) return false; - // - // - // for(i = 0; i < 480; i += 40) { - // lv_area_t a; - // a.x1 = 0; - // a.x2 = 799; - // a.y1 = i; - // a.y2 = i + 9; - // lv_obj_invalidate_area(scr, &a); - // - // a.y1 = i + 25; - // a.y2 = i + 32; - // lv_obj_invalidate_area(scr, &a); - // } - // - // pass = screenshot_compare(fn_ref, "horizontal stripes", 32); - // if(!pass) return false; - return true; } @@ -134,16 +100,13 @@ bool lv_test_assert_image_eq(const char * fn_ref) * STATIC FUNCTIONS **********************/ -static uint8_t screen_buf_xrgb8888[800 * 480 * 4]; /** * Compare the content of the frame buffer with a reference image - * @param fn_ref reference image name - * @param mode arbitrary string to tell more about the compare - * @return true: test passed; false: test failed + * @param fn_ref reference image path + * @return true: test passed; false: test failed */ -static bool screenshot_compare(const char * fn_ref, const char * mode, uint8_t tolerance) +static bool screenshot_compare(const char * fn_ref, uint8_t tolerance) { - char fn_ref_full[256]; lv_snprintf(fn_ref_full, sizeof(fn_ref_full), "%s%s", REF_IMGS_PATH, fn_ref); @@ -152,17 +115,19 @@ static bool screenshot_compare(const char * fn_ref, const char * mode, uint8_t t lv_refr_now(NULL); lv_draw_buf_t * draw_buf = lv_display_get_buf_active(NULL); + uint8_t * screen_buf_xrgb8888 = malloc(draw_buf->header.w * draw_buf->header.h * 4); buf_to_xrgb8888(draw_buf, screen_buf_xrgb8888); png_image_t p; int res = read_png_file(&p, fn_ref_full); if(res == ERR_FILE_NOT_FOUND) { - TEST_PRINTF("%s%s", fn_ref_full, " was not found, creating is now from the rendered screen"); - fflush(stderr); - write_png_file(screen_buf_xrgb8888, 800, 480, fn_ref_full); + LV_LOG_ERROR("%s%s", fn_ref_full, " was not found, creating is now from the rendered screen"); + write_png_file(screen_buf_xrgb8888, draw_buf->header.w, draw_buf->header.h, fn_ref_full); + free(screen_buf_xrgb8888); return true; } else if(res == ERR_PNG) { + free(screen_buf_xrgb8888); return false; } @@ -172,7 +137,7 @@ static bool screenshot_compare(const char * fn_ref, const char * mode, uint8_t t bool err = false; int x, y; for(y = 0; y < p.height; y++) { - uint8_t * screen_buf_tmp = screen_buf_xrgb8888 + 800 * 4 * y; + uint8_t * screen_buf_tmp = screen_buf_xrgb8888 + draw_buf->header.w * 4 * y; png_byte * row = p.row_pointers[y]; for(x = 0; x < p.width; x++) { ptr_ref = &(row[x * 3]); @@ -184,15 +149,13 @@ static bool screenshot_compare(const char * fn_ref, const char * mode, uint8_t t uint32_t act_px = (ptr_act[2] << 16) + (ptr_act[1] << 8) + (ptr_act[0] << 0); uint32_t ref_px = 0; memcpy(&ref_px, ptr_ref, 3); - TEST_PRINTF("\nScreenshot compare error\n" - " - File: %s\n" - " - Mode: %s\n" - " - At x:%d, y:%d.\n" - " - Expected: %X\n" - " - Actual: %X\n" - " - Tolerance: %d", - fn_ref_full, mode, x, y, ref_px, act_px, tolerance); - fflush(stderr); + LV_LOG("\nScreenshot compare error\n" + " - File: %s\n" + " - At x:%d, y:%d.\n" + " - Expected: %X\n" + " - Actual: %X\n" + " - Tolerance: %d\n", + fn_ref_full, x, y, ref_px, act_px, tolerance); err = true; break; } @@ -209,12 +172,13 @@ static bool screenshot_compare(const char * fn_ref, const char * mode, uint8_t t char fn_err_full[256]; lv_snprintf(fn_err_full, sizeof(fn_err_full), "%s%s_err.png", REF_IMGS_PATH, fn_ref_no_ext); - write_png_file(screen_buf_xrgb8888, 800, 480, fn_err_full); + write_png_file(screen_buf_xrgb8888, draw_buf->header.w, draw_buf->header.h, fn_err_full); } png_release(&p); fflush(stdout); + free(screen_buf_xrgb8888); return !err; } @@ -226,13 +190,13 @@ static int read_png_file(png_image_t * p, const char * file_name) /*open file and test for it being a png*/ FILE * fp = fopen(file_name, "rb"); if(!fp) { - TEST_PRINTF("[read_png_file %s] could not be opened for reading", file_name); + LV_LOG_ERROR("[read_png_file %s] could not be opened for reading", file_name); return ERR_FILE_NOT_FOUND; } size_t rcnt = fread(header, 1, 8, fp); if(rcnt != 8 || png_sig_cmp((png_const_bytep)header, 0, 8)) { - TEST_PRINTF("[read_png_file %s] not recognized as a PNG file", file_name); + LV_LOG_ERROR("[read_png_file %s] not recognized as a PNG file", file_name); return ERR_PNG; } @@ -240,17 +204,17 @@ static int read_png_file(png_image_t * p, const char * file_name) p->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if(!p->png_ptr) { - TEST_PRINTF("[read_png_file %s] png_create_read_struct failed", file_name); + LV_LOG_ERROR("[read_png_file %s] png_create_read_struct failed", file_name); return ERR_PNG; } p->info_ptr = png_create_info_struct(p->png_ptr); if(!p->info_ptr) { - TEST_PRINTF("[read_png_file %s] png_create_info_struct failed", file_name); + LV_LOG_ERROR("[read_png_file %s] png_create_info_struct failed", file_name); return ERR_PNG; } if(setjmp(png_jmpbuf(p->png_ptr))) { - TEST_PRINTF("[read_png_file %s] Error during init_io", file_name); + LV_LOG_ERROR("[read_png_file %s] Error during init_io", file_name); return ERR_PNG; } png_init_io(p->png_ptr, fp); @@ -268,7 +232,7 @@ static int read_png_file(png_image_t * p, const char * file_name) /*read file*/ if(setjmp(png_jmpbuf(p->png_ptr))) { - TEST_PRINTF("[read_png_file %s] Error during read_image", file_name); + LV_LOG_ERROR("[read_png_file %s] Error during read_image", file_name); return ERR_PNG; } p->row_pointers = (png_bytep *) malloc(sizeof(png_bytep) * p->height); @@ -291,10 +255,7 @@ static int write_png_file(void * raw_img, uint32_t width, uint32_t height, char /* create file */ FILE * fp = fopen(file_name, "wb"); if(!fp) { - printf("###### %s\n", file_name); - fflush(stdout); - TEST_PRINTF("[write_png_file %s] could not be opened for writing", file_name); - TEST_PRINTF("%s", file_name); + LV_LOG_ERROR("[write_png_file %s] could not be opened for writing", file_name); return -1; } @@ -302,18 +263,18 @@ static int write_png_file(void * raw_img, uint32_t width, uint32_t height, char png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if(!png_ptr) { - TEST_PRINTF("[write_png_file %s] png_create_write_struct failed", file_name); + LV_LOG_ERROR("[write_png_file %s] png_create_write_struct failed", file_name); return -1; } info_ptr = png_create_info_struct(png_ptr); if(!info_ptr) { - TEST_PRINTF("[write_png_file %s] png_create_info_struct failed", file_name); + LV_LOG_ERROR("[write_png_file %s] png_create_info_struct failed", file_name); return -1; } if(setjmp(png_jmpbuf(png_ptr))) { - TEST_PRINTF("[write_png_file %s] Error during init_io", file_name); + LV_LOG_ERROR("[write_png_file %s] Error during init_io", file_name); return -1; } @@ -321,7 +282,7 @@ static int write_png_file(void * raw_img, uint32_t width, uint32_t height, char /* write header */ if(setjmp(png_jmpbuf(png_ptr))) { - TEST_PRINTF("[write_png_file %s] Error during writing header", file_name); + LV_LOG_ERROR("[write_png_file %s] Error during writing header", file_name); return -1; } @@ -333,7 +294,7 @@ static int write_png_file(void * raw_img, uint32_t width, uint32_t height, char /* write bytes */ if(setjmp(png_jmpbuf(png_ptr))) { - TEST_PRINTF("[write_png_file %s] Error during writing bytes", file_name); + LV_LOG_ERROR("[write_png_file %s] Error during writing bytes", file_name); return -1; } @@ -352,7 +313,7 @@ static int write_png_file(void * raw_img, uint32_t width, uint32_t height, char /* end write */ if(setjmp(png_jmpbuf(png_ptr))) { - TEST_PRINTF("[write_png_file %s] Error during end of write", file_name); + LV_LOG_ERROR("[write_png_file %s] Error during end of write", file_name); return -1; } png_write_end(png_ptr, NULL); @@ -385,10 +346,10 @@ static void buf_to_xrgb8888(const lv_draw_buf_t * draw_buf, uint8_t * buf_out) if(cf_in == LV_COLOR_FORMAT_RGB565) { uint32_t y; - for(y = 0; y < 480; y++) { + for(y = 0; y < draw_buf->header.h; y++) { uint32_t x; - for(x = 0; x < 800; x++) { + for(x = 0; x < draw_buf->header.w; x++) { const lv_color16_t * c16 = (const lv_color16_t *)&buf_in[x * 2]; buf_out[x * 4 + 3] = 0xff; @@ -398,14 +359,14 @@ static void buf_to_xrgb8888(const lv_draw_buf_t * draw_buf, uint8_t * buf_out) } buf_in += stride; - buf_out += 800 * 4; + buf_out += draw_buf->header.w * 4; } } else if(cf_in == LV_COLOR_FORMAT_ARGB8888 || cf_in == LV_COLOR_FORMAT_XRGB8888) { uint32_t y; - for(y = 0; y < 480; y++) { + for(y = 0; y < draw_buf->header.h; y++) { uint32_t x; - for(x = 0; x < 800; x++) { + for(x = 0; x < draw_buf->header.w; x++) { buf_out[x * 4 + 3] = buf_in[x * 4 + 3]; buf_out[x * 4 + 2] = buf_in[x * 4 + 0]; buf_out[x * 4 + 1] = buf_in[x * 4 + 1]; @@ -413,14 +374,14 @@ static void buf_to_xrgb8888(const lv_draw_buf_t * draw_buf, uint8_t * buf_out) } buf_in += stride; - buf_out += 800 * 4; + buf_out += draw_buf->header.w * 4; } } else if(cf_in == LV_COLOR_FORMAT_RGB888) { uint32_t y; - for(y = 0; y < 480; y++) { + for(y = 0; y < draw_buf->header.h; y++) { uint32_t x; - for(x = 0; x < 800; x++) { + for(x = 0; x < draw_buf->header.w; x++) { buf_out[x * 4 + 3] = 0xff; buf_out[x * 4 + 2] = buf_in[x * 3 + 0]; buf_out[x * 4 + 1] = buf_in[x * 3 + 1]; @@ -428,14 +389,14 @@ static void buf_to_xrgb8888(const lv_draw_buf_t * draw_buf, uint8_t * buf_out) } buf_in += stride; - buf_out += 800 * 4; + buf_out += draw_buf->header.w * 4; } } else if(cf_in == LV_COLOR_FORMAT_L8) { uint32_t y; - for(y = 0; y < 480; y++) { + for(y = 0; y < draw_buf->header.h; y++) { uint32_t x; - for(x = 0; x < 800; x++) { + for(x = 0; x < draw_buf->header.w; x++) { buf_out[x * 4 + 3] = 0xff; buf_out[x * 4 + 2] = buf_in[x]; buf_out[x * 4 + 1] = buf_in[x]; @@ -443,14 +404,14 @@ static void buf_to_xrgb8888(const lv_draw_buf_t * draw_buf, uint8_t * buf_out) } buf_in += stride; - buf_out += 800 * 4; + buf_out += draw_buf->header.w * 4; } } else if(cf_in == LV_COLOR_FORMAT_AL88) { uint32_t y; - for(y = 0; y < 480; y++) { + for(y = 0; y < draw_buf->header.h; y++) { uint32_t x; - for(x = 0; x < 800; x++) { + for(x = 0; x < draw_buf->header.w; x++) { buf_out[x * 4 + 3] = buf_in[x * 2 + 1]; buf_out[x * 4 + 2] = buf_in[x * 2 + 0]; buf_out[x * 4 + 1] = buf_in[x * 2 + 0]; @@ -458,15 +419,16 @@ static void buf_to_xrgb8888(const lv_draw_buf_t * draw_buf, uint8_t * buf_out) } buf_in += stride; - buf_out += 800 * 4; + buf_out += draw_buf->header.w * 4; } } else if(cf_in == LV_COLOR_FORMAT_I1) { + buf_in += 8; uint32_t y; - for(y = 0; y < 480; y++) { + for(y = 0; y < draw_buf->header.h; y++) { uint32_t x; - for(x = 0; x < 800; x++) { - const uint8_t byte = buf_in[x / 8]; + for(x = 0; x < draw_buf->header.w; x++) { + const uint8_t byte = buf_in[x / 8] ; const uint8_t bit_pos = x % 8; const uint8_t pixel = (byte >> (7 - bit_pos)) & 0x01; @@ -477,7 +439,7 @@ static void buf_to_xrgb8888(const lv_draw_buf_t * draw_buf, uint8_t * buf_out) } buf_in += stride; - buf_out += 800 * 4; + buf_out += draw_buf->header.w * 4; } } } @@ -500,7 +462,7 @@ static void create_folders_if_needed(const char * path) int mkdir_retval = mkdir(current_path, 0777); if(mkdir_retval == 0) { - printf("Created folder: %s\n", current_path); + LV_LOG_INFO("Created folder: %s\n", current_path); } else if(errno != EEXIST) { perror("Error creating folder"); diff --git a/src/others/test/lv_test_screenshot_compare.h b/src/others/test/lv_test_screenshot_compare.h new file mode 100644 index 000000000..b962becef --- /dev/null +++ b/src/others/test/lv_test_screenshot_compare.h @@ -0,0 +1,53 @@ +/** + * @file lv_test_screenshot_compare.h + * + */ + +#ifndef LV_TEST_SCREENSHOT_COMPARE_H +#define LV_TEST_SCREENSHOT_COMPARE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "../../lv_conf_internal.h" +#if LV_USE_TEST && defined(LV_USE_TEST_SCREENSHOT_COMPARE) && LV_USE_TEST_SCREENSHOT_COMPARE + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/** + * Compare the current content of the test screen with a reference PNG image + * - If the reference image is not found it will be created automatically from the rendered screen. + * - If the compare fails an `_err.png` file will be created with the rendered content next to the reference image. + * + * It requires libPNG. + * + * @param fn_ref path to the reference image. Will be appended toREF_IMGS_PATH if set. + * @return true: the reference image and the display are the same; false: they are different (`_err.png` is created). + */ +bool lv_test_screenshot_compare(const char * fn_ref); + +/********************** + * MACROS + **********************/ + +#endif /*LV_USE_TEST_SCREENSHOT_COMPARE*/ + +#ifdef __cplusplus +} /*extern "C"*/ +#endif + +#endif /*LV_TEST_SCREENSHOT_COMPARE_H*/ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5744d8ba7..82cac6ebf 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -125,17 +125,20 @@ elseif (OPTIONS_TEST_SYSHEAP) filter_compiler_options (C TEST_LIBS ${SANITIZE_AND_COVERAGE_OPTIONS}) set (LV_CONF_BUILD_DISABLE_EXAMPLES ON) set (ENABLE_TESTS ON) + add_definitions(-DREF_IMGS_PATH="ref_imgs/") elseif (OPTIONS_TEST_DEFHEAP) set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_TEST_DEFHEAP}) filter_compiler_options (C TEST_LIBS ${SANITIZE_AND_COVERAGE_OPTIONS}) set (LV_CONF_BUILD_DISABLE_EXAMPLES ON) set (ENABLE_TESTS ON) + add_definitions(-DREF_IMGS_PATH="ref_imgs/") elseif (OPTIONS_TEST_MEMORYCHECK) # sanitizer is disabled because valgrind uses LD_PRELOAD and the # sanitizer lib needs to load first set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_TEST_SYSHEAP}) set (LV_CONF_BUILD_DISABLE_EXAMPLES ON) set (ENABLE_TESTS ON) + add_definitions(-DREF_IMGS_PATH="ref_imgs/") elseif (OPTIONS_TEST_VG_LITE) set (BUILD_OPTIONS ${LVGL_TEST_OPTIONS_VG_LITE} -DLVGL_CI_USING_SYS_HEAP ${SANITIZE_AND_COVERAGE_OPTIONS}) filter_compiler_options (C TEST_LIBS ${SANITIZE_AND_COVERAGE_OPTIONS}) @@ -276,9 +279,7 @@ file(GLOB_RECURSE TEST_IMAGES_SRC ${LVGL_TEST_DIR}/test_images/*.c) add_library(test_common STATIC - src/lv_test_indev.c src/lv_test_init.c - src/lv_test_helpers.c src/test_assets/test_animimg001.c src/test_assets/test_animimg002.c src/test_assets/test_animimg003.c @@ -311,7 +312,6 @@ add_library(test_common src/test_assets/test_imagebutton_right.c src/test_assets/test_music_button_play.c src/test_assets/test_lottie_approve.c - unity/unity_support.c unity/unity.c ${TEST_IMAGES_SRC} ) diff --git a/tests/ref_imgs/draw/render/i1/demo_render_arc_image_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_arc_image_opa_192.png index 2b5b4b25b..6b6910b9c 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_arc_image_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_arc_image_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_arc_image_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_arc_image_opa_255.png index 6bbcaaee4..94fbf1d23 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_arc_image_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_arc_image_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_arc_normal_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_arc_normal_opa_192.png index 7b95fae38..fe506e2fa 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_arc_normal_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_arc_normal_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_arc_normal_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_arc_normal_opa_255.png index 7b95fae38..fe506e2fa 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_arc_normal_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_arc_normal_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_blend_mode_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_blend_mode_opa_192.png index 37721ec57..5aa167f1c 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_blend_mode_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_blend_mode_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_blend_mode_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_blend_mode_opa_255.png index 8d6eba6a8..847ac8b96 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_blend_mode_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_blend_mode_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_border_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_border_opa_192.png index 7157961b7..8543eb5e6 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_border_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_border_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_border_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_border_opa_255.png index 7157961b7..8543eb5e6 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_border_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_border_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_box_shadow_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_box_shadow_opa_192.png index e03d8878a..10608eab7 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_box_shadow_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_box_shadow_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_box_shadow_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_box_shadow_opa_255.png index f1f5fe2a6..4950b4355 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_box_shadow_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_box_shadow_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_conical_gradient_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_conical_gradient_opa_192.png index 753dac9c8..77e99c0e8 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_conical_gradient_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_conical_gradient_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_conical_gradient_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_conical_gradient_opa_255.png index 4c48e1868..9ea277edf 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_conical_gradient_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_conical_gradient_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_fill_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_fill_opa_192.png index 151f952b6..d4444cac6 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_fill_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_fill_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_fill_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_fill_opa_255.png index 788ae7233..950bd9264 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_fill_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_fill_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_image_normal_1_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_image_normal_1_opa_192.png index da136154c..a6a899bce 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_image_normal_1_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_image_normal_1_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_image_normal_1_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_image_normal_1_opa_255.png index 8af8e3068..ec996dc77 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_image_normal_1_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_image_normal_1_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_image_normal_2_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_image_normal_2_opa_192.png index acd797eb6..822ec6a7a 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_image_normal_2_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_image_normal_2_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_image_normal_2_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_image_normal_2_opa_255.png index 711b5635d..c6200065d 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_image_normal_2_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_image_normal_2_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_1_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_1_opa_192.png index 86f31be36..a902ba043 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_1_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_1_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_1_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_1_opa_255.png index c01ba9587..6d35c3ecf 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_1_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_1_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_2_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_2_opa_192.png index 99d9416b6..eeb3d9252 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_2_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_2_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_2_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_2_opa_255.png index 24c5a50cc..ed1544e09 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_2_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_image_recolor_2_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_layer_normal_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_layer_normal_opa_192.png index 5e26124fb..aa0e410b4 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_layer_normal_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_layer_normal_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_layer_normal_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_layer_normal_opa_255.png index 743e98aa7..46f3f5bbc 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_layer_normal_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_layer_normal_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_line_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_line_opa_192.png index 7b95fae38..fe506e2fa 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_line_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_line_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_line_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_line_opa_255.png index 7b95fae38..fe506e2fa 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_line_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_line_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_linear_gradient_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_linear_gradient_opa_192.png index 75907937d..0f0dcd55c 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_linear_gradient_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_linear_gradient_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_linear_gradient_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_linear_gradient_opa_255.png index 9314b4cd6..42345a5c5 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_linear_gradient_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_linear_gradient_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_radial_gradient_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_radial_gradient_opa_192.png index d5437fd2b..4ac902bbf 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_radial_gradient_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_radial_gradient_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_radial_gradient_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_radial_gradient_opa_255.png index 1bdcb9c66..2b736119b 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_radial_gradient_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_radial_gradient_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_text_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_text_opa_192.png index 913d65a45..ca7497bd6 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_text_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_text_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_text_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_text_opa_255.png index 913d65a45..ca7497bd6 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_text_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_text_opa_255.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_triangle_opa_192.png b/tests/ref_imgs/draw/render/i1/demo_render_triangle_opa_192.png index 26d4fc46b..3b0ba64e4 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_triangle_opa_192.png and b/tests/ref_imgs/draw/render/i1/demo_render_triangle_opa_192.png differ diff --git a/tests/ref_imgs/draw/render/i1/demo_render_triangle_opa_255.png b/tests/ref_imgs/draw/render/i1/demo_render_triangle_opa_255.png index c4d15fed9..a4632874f 100644 Binary files a/tests/ref_imgs/draw/render/i1/demo_render_triangle_opa_255.png and b/tests/ref_imgs/draw/render/i1/demo_render_triangle_opa_255.png differ diff --git a/tests/ref_imgs/widgets/label_scroll_13.png b/tests/ref_imgs/widgets/label_scroll_13.png index f8a2c82fa..afad03aa2 100644 Binary files a/tests/ref_imgs/widgets/label_scroll_13.png and b/tests/ref_imgs/widgets/label_scroll_13.png differ diff --git a/tests/ref_imgs/widgets/label_scroll_14.png b/tests/ref_imgs/widgets/label_scroll_14.png index 9619d5ab2..589c11767 100644 Binary files a/tests/ref_imgs/widgets/label_scroll_14.png and b/tests/ref_imgs/widgets/label_scroll_14.png differ diff --git a/tests/ref_imgs/widgets/label_scroll_15.png b/tests/ref_imgs/widgets/label_scroll_15.png new file mode 100644 index 000000000..118797221 Binary files /dev/null and b/tests/ref_imgs/widgets/label_scroll_15.png differ diff --git a/tests/ref_imgs/widgets/label_scroll_16.png b/tests/ref_imgs/widgets/label_scroll_16.png new file mode 100644 index 000000000..59955799f Binary files /dev/null and b/tests/ref_imgs/widgets/label_scroll_16.png differ diff --git a/tests/ref_imgs/widgets/label_scroll_17.png b/tests/ref_imgs/widgets/label_scroll_17.png new file mode 100644 index 000000000..aa8a9793f Binary files /dev/null and b/tests/ref_imgs/widgets/label_scroll_17.png differ diff --git a/tests/ref_imgs/widgets/label_scroll_18.png b/tests/ref_imgs/widgets/label_scroll_18.png new file mode 100644 index 000000000..67f263929 Binary files /dev/null and b/tests/ref_imgs/widgets/label_scroll_18.png differ diff --git a/tests/ref_imgs/widgets/label_scroll_19.png b/tests/ref_imgs/widgets/label_scroll_19.png new file mode 100644 index 000000000..624699abd Binary files /dev/null and b/tests/ref_imgs/widgets/label_scroll_19.png differ diff --git a/tests/ref_imgs/widgets/obj_flag_overflow_visible_1_1.png b/tests/ref_imgs/widgets/obj_flag_overflow_visible_1_1.png index 085acc749..4d1be5910 100644 Binary files a/tests/ref_imgs/widgets/obj_flag_overflow_visible_1_1.png and b/tests/ref_imgs/widgets/obj_flag_overflow_visible_1_1.png differ diff --git a/tests/ref_imgs/widgets/obj_flag_overflow_visible_1_2.png b/tests/ref_imgs/widgets/obj_flag_overflow_visible_1_2.png index d3a5c8368..983a73cb5 100644 Binary files a/tests/ref_imgs/widgets/obj_flag_overflow_visible_1_2.png and b/tests/ref_imgs/widgets/obj_flag_overflow_visible_1_2.png differ diff --git a/tests/ref_imgs/widgets/obj_flag_overflow_visible_1_3.png b/tests/ref_imgs/widgets/obj_flag_overflow_visible_1_3.png index f74cb9e5d..73680c602 100644 Binary files a/tests/ref_imgs/widgets/obj_flag_overflow_visible_1_3.png and b/tests/ref_imgs/widgets/obj_flag_overflow_visible_1_3.png differ diff --git a/tests/ref_imgs_vg_lite/widgets/label_scroll_13.png b/tests/ref_imgs_vg_lite/widgets/label_scroll_13.png index 02f28a9ac..79a398eb3 100644 Binary files a/tests/ref_imgs_vg_lite/widgets/label_scroll_13.png and b/tests/ref_imgs_vg_lite/widgets/label_scroll_13.png differ diff --git a/tests/ref_imgs_vg_lite/widgets/label_scroll_14.png b/tests/ref_imgs_vg_lite/widgets/label_scroll_14.png index f63e6b164..49ced9ad7 100644 Binary files a/tests/ref_imgs_vg_lite/widgets/label_scroll_14.png and b/tests/ref_imgs_vg_lite/widgets/label_scroll_14.png differ diff --git a/tests/ref_imgs_vg_lite/widgets/label_scroll_15.png b/tests/ref_imgs_vg_lite/widgets/label_scroll_15.png new file mode 100644 index 000000000..37ae6e158 Binary files /dev/null and b/tests/ref_imgs_vg_lite/widgets/label_scroll_15.png differ diff --git a/tests/ref_imgs_vg_lite/widgets/label_scroll_16.png b/tests/ref_imgs_vg_lite/widgets/label_scroll_16.png new file mode 100644 index 000000000..637352c45 Binary files /dev/null and b/tests/ref_imgs_vg_lite/widgets/label_scroll_16.png differ diff --git a/tests/ref_imgs_vg_lite/widgets/label_scroll_17.png b/tests/ref_imgs_vg_lite/widgets/label_scroll_17.png new file mode 100644 index 000000000..3bf17deb6 Binary files /dev/null and b/tests/ref_imgs_vg_lite/widgets/label_scroll_17.png differ diff --git a/tests/ref_imgs_vg_lite/widgets/label_scroll_18.png b/tests/ref_imgs_vg_lite/widgets/label_scroll_18.png new file mode 100644 index 000000000..decf11728 Binary files /dev/null and b/tests/ref_imgs_vg_lite/widgets/label_scroll_18.png differ diff --git a/tests/ref_imgs_vg_lite/widgets/label_scroll_19.png b/tests/ref_imgs_vg_lite/widgets/label_scroll_19.png new file mode 100644 index 000000000..4a21dbe0c Binary files /dev/null and b/tests/ref_imgs_vg_lite/widgets/label_scroll_19.png differ diff --git a/tests/ref_imgs_vg_lite/widgets/obj_flag_overflow_visible_1_1.png b/tests/ref_imgs_vg_lite/widgets/obj_flag_overflow_visible_1_1.png index 1db6cdac6..22b1c35d0 100644 Binary files a/tests/ref_imgs_vg_lite/widgets/obj_flag_overflow_visible_1_1.png and b/tests/ref_imgs_vg_lite/widgets/obj_flag_overflow_visible_1_1.png differ diff --git a/tests/ref_imgs_vg_lite/widgets/obj_flag_overflow_visible_1_2.png b/tests/ref_imgs_vg_lite/widgets/obj_flag_overflow_visible_1_2.png index 66eb2d065..ed0f7e273 100644 Binary files a/tests/ref_imgs_vg_lite/widgets/obj_flag_overflow_visible_1_2.png and b/tests/ref_imgs_vg_lite/widgets/obj_flag_overflow_visible_1_2.png differ diff --git a/tests/ref_imgs_vg_lite/widgets/obj_flag_overflow_visible_1_3.png b/tests/ref_imgs_vg_lite/widgets/obj_flag_overflow_visible_1_3.png index 8d9d6ff2b..27a5890d3 100644 Binary files a/tests/ref_imgs_vg_lite/widgets/obj_flag_overflow_visible_1_3.png and b/tests/ref_imgs_vg_lite/widgets/obj_flag_overflow_visible_1_3.png differ diff --git a/tests/src/lv_test_conf_full.h b/tests/src/lv_test_conf_full.h index f4ece2d15..2d8206cf6 100644 --- a/tests/src/lv_test_conf_full.h +++ b/tests/src/lv_test_conf_full.h @@ -104,6 +104,8 @@ #define LV_PROFILER_INCLUDE "lv_profiler_builtin.h" #define LV_USE_GRIDNAV 1 #define LV_USE_XML 1 +#define LV_USE_TEST 1 +#define LV_USE_TEST_SCREENSHOT_COMPARE 1 #define LV_BUILD_EXAMPLES 1 #define LV_USE_DEMO_WIDGETS 1 diff --git a/tests/src/lv_test_conf_minimal.h b/tests/src/lv_test_conf_minimal.h index 20eb2c35a..c4848a288 100644 --- a/tests/src/lv_test_conf_minimal.h +++ b/tests/src/lv_test_conf_minimal.h @@ -8,6 +8,8 @@ #define LV_USE_ASSERT_MEM_INTEGRITY 0 #define LV_USE_ASSERT_OBJ 0 #define LV_USE_ASSERT_STYLE 0 +#define LV_USE_TEST 1 +#define LV_USE_TEST_SCREENSHOT_COMPARE 1 #define LV_USE_BIDI 0 #define LV_USE_ARABIC_PERSIAN_CHARS 0 diff --git a/tests/src/lv_test_helpers.c b/tests/src/lv_test_helpers.c deleted file mode 100644 index 7362bfd68..000000000 --- a/tests/src/lv_test_helpers.c +++ /dev/null @@ -1,12 +0,0 @@ -#if LV_BUILD_TEST - -#include "lv_test_helpers.h" - -void lv_test_wait(uint32_t ms) -{ - lv_tick_inc(ms); - lv_timer_handler(); - lv_refr_now(NULL); -} - -#endif diff --git a/tests/src/lv_test_helpers.h b/tests/src/lv_test_helpers.h deleted file mode 100644 index 5f155567c..000000000 --- a/tests/src/lv_test_helpers.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef LV_TEST_HELPERS_H -#define LV_TEST_HELPERS_H - -#include "lv_test_conf.h" -#include "../lvgl.h" - -#ifdef LVGL_CI_USING_SYS_HEAP -/* Skip checking heap as we don't have the info available */ -#define LV_HEAP_CHECK(x) do {} while(0) -/* Pick a non-zero value */ -#define lv_test_get_free_mem() (65536) -#else -#define LV_HEAP_CHECK(x) x - -static inline size_t lv_test_get_free_mem(void) -{ - lv_mem_monitor_t m1; - lv_mem_monitor(&m1); - return m1.free_size; -} -#endif /* LVGL_CI_USING_SYS_HEAP */ - -#define CANVAS_WIDTH_TO_STRIDE(w, px_size) ((((w) * (px_size) + (LV_DRAW_BUF_STRIDE_ALIGN - 1)) / LV_DRAW_BUF_STRIDE_ALIGN) * LV_DRAW_BUF_STRIDE_ALIGN) - -void lv_test_wait(uint32_t ms); - -#endif /*LV_TEST_HELPERS_H*/ diff --git a/tests/src/lv_test_indev.c b/tests/src/lv_test_indev.c deleted file mode 100644 index 503660074..000000000 --- a/tests/src/lv_test_indev.c +++ /dev/null @@ -1,135 +0,0 @@ -#include "../../src/indev/lv_indev_private.h" -#if LV_BUILD_TEST -#include "../lvgl.h" -#include -#include - -#include "lv_test_indev.h" -#include "lv_test_init.h" - -static int32_t x_act; -static int32_t y_act; -static uint32_t key_act; -static int32_t diff_act; -static bool mouse_pressed; -static bool key_pressed; -static bool enc_pressed; - -void lv_test_mouse_read_cb(lv_indev_t * indev, lv_indev_data_t * data) -{ - LV_UNUSED(indev); - lv_point_set(&data->point, x_act, y_act); - data->state = mouse_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED; -} - -void lv_test_mouse_move_to(int32_t x, int32_t y) -{ - x_act = x; - y_act = y; -} - -void lv_test_mouse_move_by(int32_t x, int32_t y) -{ - x_act += x; - y_act += y; -} - -void lv_test_mouse_press(void) -{ - mouse_pressed = true; -} - -void lv_test_mouse_release(void) -{ - mouse_pressed = false; -} - -void lv_test_mouse_click_at(int32_t x, int32_t y) -{ - lv_test_mouse_release(); - lv_test_indev_wait(50); - lv_test_mouse_move_to(x, y); - lv_test_mouse_press(); - lv_test_indev_wait(50); - lv_test_mouse_release(); - lv_test_indev_wait(50); -} - -void lv_test_keypad_read_cb(lv_indev_t * indev, lv_indev_data_t * data) -{ - LV_UNUSED(indev); - data->key = key_act; - data->state = key_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED; -} - -void lv_test_key_press(uint32_t k) -{ - key_act = k; - key_pressed = true; -} - -void lv_test_key_release(void) -{ - key_pressed = false; -} - -void lv_test_key_hit(uint32_t k) -{ - lv_test_key_release(); - lv_test_indev_wait(50); - lv_test_key_press(k); - lv_test_mouse_press(); - lv_test_indev_wait(50); - lv_test_key_release(); - lv_test_indev_wait(50); -} - -void lv_test_encoder_read_cb(lv_indev_t * indev, lv_indev_data_t * data) -{ - LV_UNUSED(indev); - data->enc_diff = diff_act; - data->state = enc_pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED; - diff_act = 0; -} - -void lv_test_encoder_add_diff(int32_t d) -{ - diff_act += d; -} - -void lv_test_encoder_turn(int32_t d) -{ - diff_act += d; - lv_test_indev_wait(50); -} - -void lv_test_encoder_press(void) -{ - enc_pressed = true; -} - -void lv_test_encoder_release(void) -{ - enc_pressed = false; -} - -void lv_test_encoder_click(void) -{ - lv_test_encoder_release(); - lv_test_indev_wait(50); - lv_test_encoder_press(); - lv_test_indev_wait(50); - lv_test_encoder_release(); - lv_test_indev_wait(50); -} - -void lv_test_indev_wait(uint32_t ms) -{ - uint32_t t = lv_tick_get(); - while(lv_tick_elaps(t) < ms) { - lv_timer_handler(); - lv_tick_inc(1); - } -} - -#endif diff --git a/tests/src/lv_test_indev.h b/tests/src/lv_test_indev.h deleted file mode 100644 index 6b524d47d..000000000 --- a/tests/src/lv_test_indev.h +++ /dev/null @@ -1,52 +0,0 @@ - -#ifndef LV_TEST_INDEV_H -#define LV_TEST_INDEV_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "../lvgl.h" - -void lv_test_mouse_read_cb(lv_indev_t * indev, lv_indev_data_t * data); - -void lv_test_mouse_move_to(int32_t x, int32_t y); -void lv_test_mouse_move_by(int32_t x, int32_t y); -void lv_test_mouse_press(void); -void lv_test_mouse_release(void); -void lv_test_mouse_click_at(int32_t x, int32_t y); - -void lv_test_keypad_read_cb(lv_indev_t * indev, lv_indev_data_t * data); - -void lv_test_key_press(uint32_t k); -void lv_test_key_release(void); -void lv_test_key_hit(uint32_t k); - -/* encoder read callback */ -void lv_test_encoder_read_cb(lv_indev_t * indev, lv_indev_data_t * data) ; - -/* Simulate encoder rotation, use positive parameter to rotate to the right - * and negative to rotate to the left */ -void lv_test_encoder_add_diff(int32_t d); -/* Same as lv_test_encoder_add_diff but with additional delay */ -void lv_test_encoder_turn(int32_t d); -/* Set encoder to pressed */ -void lv_test_encoder_press(void); -/* Set encoder to released */ -void lv_test_encoder_release(void); -/* Simulate release+press+release (including delays) */ -void lv_test_encoder_click(void); - -/* Simulate delay */ -void lv_test_indev_wait(uint32_t ms); - -extern lv_indev_t * lv_test_mouse_indev; -extern lv_indev_t * lv_test_keypad_indev; -extern lv_indev_t * lv_test_encoder_indev; - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*LV_TEST_INDEV_H*/ diff --git a/tests/src/lv_test_init.c b/tests/src/lv_test_init.c index 9ce34b30c..074447715 100644 --- a/tests/src/lv_test_init.c +++ b/tests/src/lv_test_init.c @@ -1,6 +1,5 @@ #if LV_BUILD_TEST #include "lv_test_init.h" -#include "lv_test_indev.h" #include #include #include @@ -9,15 +8,8 @@ #define HOR_RES 800 #define VER_RES 480 -static void hal_init(void); -static void dummy_flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * color_p); static void test_log_print_cb(lv_log_level_t level, const char * buf); -uint8_t * last_flushed_buf; -lv_indev_t * lv_test_mouse_indev; -lv_indev_t * lv_test_keypad_indev; -lv_indev_t * lv_test_encoder_indev; - void lv_test_init(void) { lv_init(); @@ -29,7 +21,9 @@ void lv_test_init(void) lv_profiler_builtin_set_enable(false); #endif - hal_init(); + lv_test_display_create(HOR_RES, VER_RES); + lv_test_indev_create_all(); + #if LV_USE_SYSMON #if LV_USE_MEM_MONITOR lv_sysmon_hide_memory(NULL); @@ -45,47 +39,6 @@ void lv_test_deinit(void) lv_mem_deinit(); } -static void color_format_changled_event_cb(lv_event_t * e) -{ - lv_display_t * disp = lv_event_get_target(e); - lv_color_format_t cf = lv_display_get_color_format(disp); - lv_draw_buf_t * draw_buf = lv_display_get_buf_active(NULL); - - lv_display_set_buffers(disp, lv_draw_buf_align(draw_buf->unaligned_data, cf), NULL, draw_buf->data_size, - LV_DISPLAY_RENDER_MODE_DIRECT); - -} - -static void hal_init(void) -{ - - static lv_color32_t test_fb[(HOR_RES + LV_DRAW_BUF_STRIDE_ALIGN - 1) * VER_RES + LV_DRAW_BUF_ALIGN]; - lv_display_t * disp = lv_display_create(HOR_RES, VER_RES); - lv_display_set_buffers(disp, lv_draw_buf_align(test_fb, LV_COLOR_FORMAT_ARGB8888), NULL, HOR_RES * VER_RES * 4, - LV_DISPLAY_RENDER_MODE_DIRECT); - lv_display_set_flush_cb(disp, dummy_flush_cb); - lv_display_add_event_cb(disp, color_format_changled_event_cb, LV_EVENT_COLOR_FORMAT_CHANGED, NULL); - lv_test_mouse_indev = lv_indev_create(); - lv_indev_set_type(lv_test_mouse_indev, LV_INDEV_TYPE_POINTER); - lv_indev_set_read_cb(lv_test_mouse_indev, lv_test_mouse_read_cb); - - lv_test_keypad_indev = lv_indev_create(); - lv_indev_set_type(lv_test_keypad_indev, LV_INDEV_TYPE_KEYPAD); - lv_indev_set_read_cb(lv_test_keypad_indev, lv_test_keypad_read_cb); - - lv_test_encoder_indev = lv_indev_create(); - lv_indev_set_type(lv_test_encoder_indev, LV_INDEV_TYPE_ENCODER); - lv_indev_set_read_cb(lv_test_encoder_indev, lv_test_encoder_read_cb); -} - -static void dummy_flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * color_p) -{ - LV_UNUSED(area); - LV_UNUSED(color_p); - last_flushed_buf = color_p; - lv_display_flush_ready(disp); -} - static void test_log_print_cb(lv_log_level_t level, const char * buf) { if(level < LV_LOG_LEVEL_WARN) { diff --git a/tests/src/test_cases/cache/test_cache.c b/tests/src/test_cases/cache/test_cache.c index ce181bf7e..baade8b76 100644 --- a/tests/src/test_cases/cache/test_cache.c +++ b/tests/src/test_cases/cache/test_cache.c @@ -2,7 +2,7 @@ #include "../lvgl.h" #include "../../lvgl_private.h" -#include "lv_test_helpers.h" + #include "unity/unity.h" diff --git a/tests/src/test_cases/draw/test_draw_blend.c b/tests/src/test_cases/draw/test_draw_blend.c index ce2e5536e..87784e017 100644 --- a/tests/src/test_cases/draw/test_draw_blend.c +++ b/tests/src/test_cases/draw/test_draw_blend.c @@ -1,7 +1,7 @@ #if LV_BUILD_TEST #include "../lvgl.h" #include "../../lvgl_private.h" -#include "lv_test_helpers.h" + #include "unity/unity.h" @@ -123,9 +123,9 @@ static void canvas_draw(const char * name, lv_color_format_t large_render_cf) { lv_obj_clean(lv_screen_active()); - static LV_ATTRIBUTE_MEM_ALIGN uint8_t canvas_buf[CANVAS_WIDTH_TO_STRIDE(180, 4) * 180 + LV_DRAW_BUF_ALIGN]; + static LV_ATTRIBUTE_MEM_ALIGN uint8_t canvas_buf[LV_TEST_WIDTH_TO_STRIDE(180, 4) * 180 + LV_DRAW_BUF_ALIGN]; - static uint8_t canvas2_buf[CANVAS_WIDTH_TO_STRIDE(768, 4) * 390 + LV_DRAW_BUF_ALIGN]; + static uint8_t canvas2_buf[LV_TEST_WIDTH_TO_STRIDE(768, 4) * 390 + LV_DRAW_BUF_ALIGN]; lv_obj_t * canvas2 = lv_canvas_create(lv_screen_active()); lv_canvas_set_buffer(canvas2, lv_draw_buf_align(canvas2_buf, large_render_cf), 768, 390, large_render_cf); lv_canvas_fill_bg(canvas2, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 2), LV_OPA_COVER); diff --git a/tests/src/test_cases/draw/test_draw_svg.c b/tests/src/test_cases/draw/test_draw_svg.c index 501cbbefb..d106df181 100644 --- a/tests/src/test_cases/draw/test_draw_svg.c +++ b/tests/src/test_cases/draw/test_draw_svg.c @@ -1,6 +1,6 @@ #if LV_BUILD_TEST #include "../lvgl.h" -#include "lv_test_helpers.h" + #include #include "unity/unity.h" diff --git a/tests/src/test_cases/draw/test_draw_vector.c b/tests/src/test_cases/draw/test_draw_vector.c index 279158522..f1fa2815b 100644 --- a/tests/src/test_cases/draw/test_draw_vector.c +++ b/tests/src/test_cases/draw/test_draw_vector.c @@ -1,7 +1,7 @@ #if LV_BUILD_TEST #include "../lvgl.h" #include "../../lvgl_private.h" -#include "lv_test_helpers.h" + #include "unity/unity.h" diff --git a/tests/src/test_cases/libs/test_bmp.c b/tests/src/test_cases/libs/test_bmp.c index 6230647d6..fdd4ca050 100644 --- a/tests/src/test_cases/libs/test_bmp.c +++ b/tests/src/test_cases/libs/test_bmp.c @@ -3,7 +3,7 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_helpers.h" + void setUp(void) { diff --git a/tests/src/test_cases/libs/test_libjpeg_turbo.c b/tests/src/test_cases/libs/test_libjpeg_turbo.c index b084de569..248b8de43 100644 --- a/tests/src/test_cases/libs/test_libjpeg_turbo.c +++ b/tests/src/test_cases/libs/test_libjpeg_turbo.c @@ -3,7 +3,7 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_helpers.h" + void setUp(void) { diff --git a/tests/src/test_cases/libs/test_libpng.c b/tests/src/test_cases/libs/test_libpng.c index 4db9b80c5..bf88047f2 100644 --- a/tests/src/test_cases/libs/test_libpng.c +++ b/tests/src/test_cases/libs/test_libpng.c @@ -3,7 +3,7 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_helpers.h" + void setUp(void) { diff --git a/tests/src/test_cases/libs/test_lodepng.c b/tests/src/test_cases/libs/test_lodepng.c index aae78f309..4c975edb9 100644 --- a/tests/src/test_cases/libs/test_lodepng.c +++ b/tests/src/test_cases/libs/test_lodepng.c @@ -3,7 +3,7 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_helpers.h" + void setUp(void) { diff --git a/tests/src/test_cases/libs/test_memmove.c b/tests/src/test_cases/libs/test_memmove.c index cb28a5b73..b8e45c080 100644 --- a/tests/src/test_cases/libs/test_memmove.c +++ b/tests/src/test_cases/libs/test_memmove.c @@ -3,7 +3,7 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_helpers.h" + void setUp(void) { diff --git a/tests/src/test_cases/libs/test_tjpgd.c b/tests/src/test_cases/libs/test_tjpgd.c index 2ee8422d3..0d0b5fdd9 100644 --- a/tests/src/test_cases/libs/test_tjpgd.c +++ b/tests/src/test_cases/libs/test_tjpgd.c @@ -3,7 +3,7 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_helpers.h" + void setUp(void) { diff --git a/tests/src/test_cases/test_anim.c b/tests/src/test_cases/test_anim.c index 2e3e98329..00446d1d2 100644 --- a/tests/src/test_cases/test_anim.c +++ b/tests/src/test_cases/test_anim.c @@ -3,7 +3,7 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_helpers.h" + void setUp(void) { @@ -134,7 +134,6 @@ void test_anim_pause_for(void) lv_anim_t * animation = lv_anim_start(&a); lv_anim_pause_for(animation, 20); - lv_test_wait(40); TEST_ASSERT_EQUAL(19, var); diff --git a/tests/src/test_cases/test_anim_timeline.c b/tests/src/test_cases/test_anim_timeline.c index 993aa4c89..8f6f06e7b 100644 --- a/tests/src/test_cases/test_anim_timeline.c +++ b/tests/src/test_cases/test_anim_timeline.c @@ -4,7 +4,7 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_helpers.h" + static lv_anim_timeline_t * anim_timeline; diff --git a/tests/src/test_cases/test_bindings.c b/tests/src/test_cases/test_bindings.c index 4a46fe753..746dc1640 100644 --- a/tests/src/test_cases/test_bindings.c +++ b/tests/src/test_cases/test_bindings.c @@ -3,8 +3,6 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_indev.h" -#include "lv_test_helpers.h" static void create_ui(void); static void chart_type_observer_cb(lv_observer_t * observer, lv_subject_t * subject); @@ -28,7 +26,7 @@ void test_binding(void) create_ui(); /*Wait for the animation*/ - lv_test_indev_wait(500); + lv_test_wait(500); TEST_ASSERT_EQUAL_SCREENSHOT("binding.png"); } diff --git a/tests/src/test_cases/test_click.c b/tests/src/test_cases/test_click.c index 9cff59774..b81d299a1 100644 --- a/tests/src/test_cases/test_click.c +++ b/tests/src/test_cases/test_click.c @@ -1,6 +1,5 @@ #if LV_BUILD_TEST #include "../lvgl.h" -#include "../lv_test_indev.h" #include "unity/unity.h" void setUp(void) @@ -136,7 +135,7 @@ void test_click(void) /*Resetting the click streak due to time.*/ lv_memzero(&counts, sizeof(counts)); - lv_test_indev_wait(1000); + lv_test_wait(1000); lv_test_mouse_click_at(12, 14); TEST_ASSERT_EQUAL_UINT32(1, counts.num_clicked); TEST_ASSERT_EQUAL_UINT32(1, counts.num_short_clicked); @@ -149,9 +148,9 @@ void test_click(void) /*Long press does not continue (or start) click streak.*/ lv_memzero(&counts, sizeof(counts)); lv_test_mouse_press(); - lv_test_indev_wait(1000); + lv_test_wait(1000); lv_test_mouse_release(); - lv_test_indev_wait(50); + lv_test_wait(50); TEST_ASSERT_EQUAL_UINT32(1, counts.num_clicked); TEST_ASSERT_EQUAL_UINT32(0, counts.num_short_clicked); TEST_ASSERT_EQUAL_UINT32(0, counts.num_single_clicked); diff --git a/tests/src/test_cases/test_demo_stress.c b/tests/src/test_cases/test_demo_stress.c index 56ee06744..823bb45c9 100644 --- a/tests/src/test_cases/test_demo_stress.c +++ b/tests/src/test_cases/test_demo_stress.c @@ -5,9 +5,6 @@ #include "unity/unity.h" -#include "lv_test_helpers.h" -#include "lv_test_indev.h" - static void loop_through_stress_test(void) { #if LV_USE_DEMO_STRESS diff --git a/tests/src/test_cases/test_demo_widgets.c b/tests/src/test_cases/test_demo_widgets.c index b9c5e55e3..37e606801 100644 --- a/tests/src/test_cases/test_demo_widgets.c +++ b/tests/src/test_cases/test_demo_widgets.c @@ -5,9 +5,6 @@ #include "unity/unity.h" -#include "lv_test_helpers.h" -#include "lv_test_indev.h" - void test_demo_widgets(void) { #if LV_USE_DEMO_WIDGETS diff --git a/tests/src/test_cases/test_draw_buf_stride.c b/tests/src/test_cases/test_draw_buf_stride.c index a3ec51e37..d0e6186df 100644 --- a/tests/src/test_cases/test_draw_buf_stride.c +++ b/tests/src/test_cases/test_draw_buf_stride.c @@ -3,7 +3,7 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_helpers.h" + void setUp(void) { diff --git a/tests/src/test_cases/test_event.c b/tests/src/test_cases/test_event.c index 3f0dd3407..8aef1f017 100644 --- a/tests/src/test_cases/test_event.c +++ b/tests/src/test_cases/test_event.c @@ -3,7 +3,6 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_indev.h" static void event_object_deletion_cb(const lv_obj_class_t * cls, lv_event_t * e) { diff --git a/tests/src/test_cases/test_gridnav.c b/tests/src/test_cases/test_gridnav.c index 014a74772..9e27733e8 100644 --- a/tests/src/test_cases/test_gridnav.c +++ b/tests/src/test_cases/test_gridnav.c @@ -2,7 +2,6 @@ #include "../lvgl.h" #include "unity/unity.h" -#include "lv_test_indev.h" static lv_obj_t * g_screen; static lv_group_t * g_group; @@ -40,7 +39,7 @@ static void gridnav_one_axis_move_only(uint32_t key_grid_axis_next, lv_gridnav_ctrl_t gridnav_ctrl, lv_flex_flow_t flex_flow) { - lv_indev_set_group(lv_test_keypad_indev, g_group); + lv_indev_set_group(lv_test_indev_get_indev(LV_INDEV_TYPE_KEYPAD), g_group); lv_obj_t * cont = lv_obj_create(g_screen); lv_obj_set_flex_flow(cont, flex_flow); diff --git a/tests/src/test_cases/test_hover.c b/tests/src/test_cases/test_hover.c index 66cbcfb0c..899977ac5 100644 --- a/tests/src/test_cases/test_hover.c +++ b/tests/src/test_cases/test_hover.c @@ -1,6 +1,5 @@ #if LV_BUILD_TEST #include "../lvgl.h" -#include "../lv_test_indev.h" #include "unity/unity.h" #define TEST_HOVER_COUNTS 20 @@ -46,7 +45,7 @@ static void test_move_mouse(lv_point_t * point, uint8_t size) for(uint8_t j = 0; j < TEST_HOVER_COUNTS; j++) { for(uint8_t i = 0; i < size; i++) { lv_test_mouse_move_to(p[i].x, p[i].y); - lv_test_indev_wait(50); + lv_test_wait(50); } } } @@ -86,10 +85,10 @@ void test_hover_delete(void) lv_obj_set_size(btn, 200, 100); lv_test_mouse_move_to(i * 10, 50); - lv_test_indev_wait(50); + lv_test_wait(50); lv_obj_delete(btn); /*No crash while deleting the hovered button*/ - lv_test_indev_wait(50); + lv_test_wait(50); } } diff --git a/tests/src/test_cases/test_indev_reset.c b/tests/src/test_cases/test_indev_reset.c index 610872de6..ef07f521d 100644 --- a/tests/src/test_cases/test_indev_reset.c +++ b/tests/src/test_cases/test_indev_reset.c @@ -1,6 +1,5 @@ #if LV_BUILD_TEST #include "../lvgl.h" -#include "../lv_test_indev.h" #include "unity/unity.h" static uint32_t indev_reset_count = 0; @@ -43,15 +42,15 @@ void test_indev_wait_release(void) lv_test_mouse_move_to(200, 200); lv_test_mouse_press(); - lv_test_indev_wait(50); + lv_test_wait(50); lv_test_mouse_move_by(-20, 0); lv_test_mouse_press(); - lv_test_indev_wait(50); + lv_test_wait(50); lv_test_mouse_move_by(-20, 0); lv_test_mouse_press(); - lv_test_indev_wait(50); + lv_test_wait(50); lv_test_mouse_release(); diff --git a/tests/src/test_cases/test_indev_wait_release.c b/tests/src/test_cases/test_indev_wait_release.c index 116f4fb9b..a573cb91d 100644 --- a/tests/src/test_cases/test_indev_wait_release.c +++ b/tests/src/test_cases/test_indev_wait_release.c @@ -1,6 +1,5 @@ #if LV_BUILD_TEST #include "../lvgl.h" -#include "../lv_test_indev.h" #include "unity/unity.h" void setUp(void) @@ -40,18 +39,18 @@ void test_indev_wait_release(void) lv_obj_add_event_cb(btn, event_cb, LV_EVENT_ALL, &pressed_count); lv_test_mouse_release(); - lv_test_indev_wait(50); + lv_test_wait(50); lv_test_mouse_move_to(50, 50); lv_test_mouse_press(); - lv_test_indev_wait(50); + lv_test_wait(50); lv_test_mouse_release(); - lv_test_indev_wait(50); + lv_test_wait(50); lv_test_mouse_press(); - lv_test_indev_wait(50); + lv_test_wait(50); lv_test_mouse_release(); - lv_test_indev_wait(50); + lv_test_wait(50); TEST_ASSERT_EQUAL_UINT32(2, pressed_count); } diff --git a/tests/src/test_cases/test_observer.c b/tests/src/test_cases/test_observer.c index a25c54a7f..ebbf0e0d4 100644 --- a/tests/src/test_cases/test_observer.c +++ b/tests/src/test_cases/test_observer.c @@ -3,7 +3,6 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_indev.h" static uint32_t observer_called = 0; @@ -771,11 +770,11 @@ void test_observer_arc_value(void) lv_obj_update_layout(obj); lv_test_mouse_release(); - lv_test_indev_wait(100); + lv_test_wait(100); lv_test_mouse_move_to(65, 10); lv_test_mouse_press(); - lv_test_indev_wait(100); + lv_test_wait(100); lv_test_mouse_release(); TEST_ASSERT_EQUAL(50, lv_arc_get_value(obj)); @@ -797,15 +796,15 @@ void test_observer_slider_value(void) lv_obj_update_layout(obj); lv_test_mouse_release(); - lv_test_indev_wait(100); + lv_test_wait(100); lv_test_mouse_move_to(65, 10); lv_test_mouse_press(); - lv_test_indev_wait(100); + lv_test_wait(100); lv_test_mouse_move_to(75, 10); lv_test_mouse_press(); - lv_test_indev_wait(100); + lv_test_wait(100); lv_test_mouse_release(); TEST_ASSERT_EQUAL(29, lv_slider_get_value(obj)); diff --git a/tests/src/test_cases/widgets/test_animimg.c b/tests/src/test_cases/widgets/test_animimg.c index 9f501288f..f778a3eb8 100644 --- a/tests/src/test_cases/widgets/test_animimg.c +++ b/tests/src/test_cases/widgets/test_animimg.c @@ -3,7 +3,6 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_indev.h" LV_IMAGE_DECLARE(test_animimg001); LV_IMAGE_DECLARE(test_animimg002); diff --git a/tests/src/test_cases/widgets/test_arc.c b/tests/src/test_cases/widgets/test_arc.c index ef82688ab..b4d059b1a 100644 --- a/tests/src/test_cases/widgets/test_arc.c +++ b/tests/src/test_cases/widgets/test_arc.c @@ -3,7 +3,6 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_indev.h" /* This function runs before each test */ void setUp(void); @@ -210,12 +209,12 @@ void test_arc_click_sustained_from_start_to_end_does_not_set_value_to_max(void) /* Click close to start angle */ event_cnt = 0; lv_test_mouse_release(); - lv_test_indev_wait(50); + lv_test_wait(50); lv_test_mouse_move_to(376, 285); lv_test_mouse_press(); - lv_test_indev_wait(500); + lv_test_wait(500); lv_test_mouse_release(); - lv_test_indev_wait(50); + lv_test_wait(50); TEST_ASSERT_EQUAL_UINT32(1, event_cnt); TEST_ASSERT_EQUAL_INT32(lv_arc_get_min_value(arc), lv_arc_get_value(arc)); @@ -224,14 +223,14 @@ void test_arc_click_sustained_from_start_to_end_does_not_set_value_to_max(void) event_cnt = 0; lv_test_mouse_release(); - lv_test_indev_wait(50); + lv_test_wait(50); lv_test_mouse_move_to(376, 285); lv_test_mouse_press(); - lv_test_indev_wait(500); + lv_test_wait(500); lv_test_mouse_move_to(415, 281); - lv_test_indev_wait(500); + lv_test_wait(500); lv_test_mouse_release(); - lv_test_indev_wait(50); + lv_test_wait(50); TEST_ASSERT_EQUAL_UINT32(1, event_cnt); TEST_ASSERT_EQUAL_INT32(lv_arc_get_min_value(arc), lv_arc_get_value(arc)); @@ -269,12 +268,12 @@ void test_two_overlapping_arcs_can_be_interacted_independently(void) // Click on the position of the first arc (center) lv_test_mouse_release(); - lv_test_indev_wait(50); + lv_test_wait(50); lv_test_mouse_move_to(400, 195); lv_test_mouse_press(); - lv_test_indev_wait(500); + lv_test_wait(500); lv_test_mouse_release(); - lv_test_indev_wait(50); + lv_test_wait(50); // Verify that the event callback was called for the first arc TEST_ASSERT_EQUAL_UINT32(0, event_cnt); @@ -282,12 +281,12 @@ void test_two_overlapping_arcs_can_be_interacted_independently(void) // click on the position of the second arc (center) lv_test_mouse_release(); - lv_test_indev_wait(50); + lv_test_wait(50); lv_test_mouse_move_to(400, 285); lv_test_mouse_press(); - lv_test_indev_wait(500); + lv_test_wait(500); lv_test_mouse_release(); - lv_test_indev_wait(50); + lv_test_wait(50); // Verify that the event callback was called for the second arc TEST_ASSERT_EQUAL_UINT32(1, event_cnt); diff --git a/tests/src/test_cases/widgets/test_bar.c b/tests/src/test_cases/widgets/test_bar.c index a6fa8f58f..6256bbcd5 100644 --- a/tests/src/test_cases/widgets/test_bar.c +++ b/tests/src/test_cases/widgets/test_bar.c @@ -4,8 +4,6 @@ #include "unity/unity.h" -#include "lv_test_indev.h" - static lv_obj_t * g_active_screen = NULL; static lv_obj_t * g_bar = NULL; @@ -66,7 +64,7 @@ void test_bar_should_update_indicator_right_coordinate_based_on_bar_value(void) lv_bar_set_value(g_bar, bar_value, LV_ANIM_OFF); /* FIXME: Remove wait */ - lv_test_indev_wait(50); + lv_test_wait(50); int32_t actual_coord = lv_area_get_width(&bar_ptr->indic_area); @@ -120,7 +118,7 @@ void test_bar_rtl_should_update_indicator_left_coordinate_based_on_bar_value(voi lv_obj_set_style_base_dir(g_bar, LV_BASE_DIR_RTL, 0); /* FIXME: Remove wait */ - lv_test_indev_wait(50); + lv_test_wait(50); int32_t actual_coord = bar_ptr->indic_area.x1; @@ -219,7 +217,7 @@ void test_bar_indicator_area_should_get_smaller_when_padding_is_increased(void) int32_t original_width = 0u; lv_bar_set_value(g_bar, 50, LV_ANIM_OFF); - lv_test_indev_wait(50); + lv_test_wait(50); original_width = lv_area_get_width(&bar_ptr->indic_area); original_height = lv_area_get_height(&bar_ptr->indic_area); @@ -235,7 +233,7 @@ void test_bar_indicator_area_should_get_smaller_when_padding_is_increased(void) /* Notify LVGL of style change */ lv_obj_report_style_change(&bar_style); - lv_test_indev_wait(50); + lv_test_wait(50); new_height = lv_area_get_height(&bar_ptr->indic_area); new_width = lv_area_get_width(&bar_ptr->indic_area); @@ -307,13 +305,13 @@ void test_bar_indicator_should_be_drawn_towards_the_min_range_side_after_setting /* Set bar value to 1, so it gets drawn at the middle of the bar */ lv_bar_set_value(g_bar, 1, LV_ANIM_OFF); - lv_test_indev_wait(50); + lv_test_wait(50); int32_t original_pos = bar_ptr->indic_area.x1; /* Set bar to a more negative value */ lv_bar_set_value(g_bar, -50, LV_ANIM_OFF); - lv_test_indev_wait(50); + lv_test_wait(50); int32_t final_pos = bar_ptr->indic_area.x1; diff --git a/tests/src/test_cases/widgets/test_btnmatrix.c b/tests/src/test_cases/widgets/test_btnmatrix.c index dbfb1b9cd..59e508f6c 100644 --- a/tests/src/test_cases/widgets/test_btnmatrix.c +++ b/tests/src/test_cases/widgets/test_btnmatrix.c @@ -1,7 +1,6 @@ #if LV_BUILD_TEST #include "../lvgl.h" #include "../../lvgl_private.h" -#include "lv_test_indev.h" #include "unity/unity.h" static lv_obj_t * active_screen = NULL; @@ -393,7 +392,7 @@ void test_button_matrix_pressing_event_works(void) * This is done to increase code coverage. */ btnmObj->btn_id_sel = 3; /* Send a dummy lv_indev_t object as param to avoid crashing during build. */ - lv_obj_send_event(btnm, LV_EVENT_PRESSING, lv_test_mouse_indev); + lv_obj_send_event(btnm, LV_EVENT_PRESSING, lv_test_indev_get_indev(LV_INDEV_TYPE_POINTER)); TEST_ASSERT_TRUE(event_triggered); } diff --git a/tests/src/test_cases/widgets/test_checkbox.c b/tests/src/test_cases/widgets/test_checkbox.c index cdfeed51f..31d532c76 100644 --- a/tests/src/test_cases/widgets/test_checkbox.c +++ b/tests/src/test_cases/widgets/test_checkbox.c @@ -4,9 +4,6 @@ #include "unity/unity.h" -#include "lv_test_helpers.h" -#include "lv_test_indev.h" - void test_checkbox_creation_successful(void); void test_checkbox_should_call_event_handler_on_click_when_enabled(void); void test_checkbox_should_have_default_text_when_created(void); diff --git a/tests/src/test_cases/widgets/test_dropdown.c b/tests/src/test_cases/widgets/test_dropdown.c index 2dedafebd..9cdbf0f48 100644 --- a/tests/src/test_cases/widgets/test_dropdown.c +++ b/tests/src/test_cases/widgets/test_dropdown.c @@ -1,9 +1,7 @@ #if LV_BUILD_TEST #include "../lvgl.h" #include "../../lvgl_private.h" - #include "unity/unity.h" -#include "lv_test_indev.h" #include void setUp(void) @@ -165,7 +163,7 @@ void test_dropdown_keypad(void) lv_obj_clean(lv_screen_active()); lv_group_t * g = lv_group_create(); - lv_indev_set_group(lv_test_keypad_indev, g); + lv_indev_set_group(lv_test_indev_get_indev(LV_INDEV_TYPE_KEYPAD), g); lv_obj_t * dd1 = lv_dropdown_create(lv_screen_active()); lv_obj_set_pos(dd1, 20, 20); @@ -258,7 +256,7 @@ void test_dropdown_keypad(void) TEST_ASSERT_FALSE(lv_dropdown_is_open(dd1)); TEST_ASSERT_NOT_NULL(lv_dropdown_get_list(dd2)); - lv_indev_set_group(lv_test_keypad_indev, NULL); + lv_indev_set_group(lv_test_indev_get_indev(LV_INDEV_TYPE_KEYPAD), NULL); lv_group_delete(g); } @@ -267,7 +265,7 @@ void test_dropdown_encoder(void) lv_obj_clean(lv_screen_active()); lv_group_t * g = lv_group_create(); - lv_indev_set_group(lv_test_encoder_indev, g); + lv_indev_set_group(lv_test_indev_get_indev(LV_INDEV_TYPE_ENCODER), g); lv_obj_t * dd1 = lv_dropdown_create(lv_screen_active()); lv_obj_set_pos(dd1, 20, 20); @@ -302,9 +300,9 @@ void test_dropdown_encoder(void) lv_test_encoder_click(); lv_test_encoder_turn(2); lv_test_encoder_press(); - lv_test_indev_wait(1000); //Long press + lv_test_wait(1000); //Long press lv_test_encoder_release(); - lv_test_indev_wait(50); + lv_test_wait(50); TEST_ASSERT_FALSE(lv_dropdown_is_open(dd1)); TEST_ASSERT_EQUAL(4, lv_dropdown_get_selected(dd1)); TEST_ASSERT_EQUAL(2, event_cnt); @@ -314,7 +312,7 @@ void test_dropdown_encoder(void) TEST_ASSERT_FALSE(lv_dropdown_is_open(dd1)); TEST_ASSERT_TRUE(lv_dropdown_is_open(dd2)); - lv_indev_set_group(lv_test_encoder_indev, NULL); + lv_indev_set_group(lv_test_indev_get_indev(LV_INDEV_TYPE_ENCODER), NULL); lv_group_delete(g); } diff --git a/tests/src/test_cases/widgets/test_label.c b/tests/src/test_cases/widgets/test_label.c index 4e4acdd33..cfd663f4d 100644 --- a/tests/src/test_cases/widgets/test_label.c +++ b/tests/src/test_cases/widgets/test_label.c @@ -630,11 +630,12 @@ static void scroll_next_step(lv_obj_t * label1, lv_obj_t * label2, const char * { lv_label_set_text(label1, (idx % 2) == 0 ? text1 : text2); lv_label_set_text(label2, (idx % 2) == 0 ? text1 : text2); - lv_test_wait(783); /*Use an odd delay*/ char buf[128]; lv_snprintf(buf, sizeof(buf), "widgets/label_scroll_%d.png", idx); TEST_ASSERT_EQUAL_SCREENSHOT(buf); + + lv_test_wait(783); /*Use an odd delay*/ } void test_label_scroll_mid_update(void) @@ -646,18 +647,18 @@ void test_label_scroll_mid_update(void) lv_obj_t * label1 = lv_label_create(lv_screen_active()); lv_label_set_long_mode(label1, LV_LABEL_LONG_MODE_SCROLL); - lv_label_set_text(label1, text1), - lv_obj_set_width(label1, 150); + lv_label_set_text(label1, text1); + lv_obj_set_width(label1, 150); lv_obj_set_pos(label1, 10, 10); lv_obj_t * label2 = lv_label_create(lv_screen_active()); lv_label_set_long_mode(label2, LV_LABEL_LONG_MODE_SCROLL_CIRCULAR); - lv_label_set_text(label2, text1), - lv_obj_set_width(label2, 150); + lv_label_set_text(label2, text1); + lv_obj_set_width(label2, 150); lv_obj_set_pos(label2, 10, 80); uint32_t i; - for(i = 0; i < 15; i++) { + for(i = 0; i < 20; i++) { scroll_next_step(label1, label2, text1, text2, i); } } diff --git a/tests/src/test_cases/widgets/test_lottie.c b/tests/src/test_cases/widgets/test_lottie.c index 72ce2e312..4c81ffa55 100644 --- a/tests/src/test_cases/widgets/test_lottie.c +++ b/tests/src/test_cases/widgets/test_lottie.c @@ -2,9 +2,9 @@ #include "../lvgl.h" #include "unity/unity.h" -#include "lv_test_helpers.h" -static uint32_t buf[CANVAS_WIDTH_TO_STRIDE(100, 4) * 100 + LV_DRAW_BUF_ALIGN]; + +static uint32_t buf[LV_TEST_WIDTH_TO_STRIDE(100, 4) * 100 + LV_DRAW_BUF_ALIGN]; extern const uint8_t test_lottie_approve[]; extern const size_t test_lottie_approve_size; @@ -36,18 +36,18 @@ void test_lottie_simple(void) TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_1.png"); /*Wait a little*/ - lv_test_wait(200); + lv_test_fast_forward(200); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_2.png"); /*Should be the last frame*/ - lv_test_wait(750); + lv_test_fast_forward(750); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_3.png"); /*Setting a source should reset the animation*/ lv_lottie_set_src_data(lottie, test_lottie_approve, test_lottie_approve_size); /*Should reset automatically*/ - lv_test_wait(200); + lv_test_fast_forward(200); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_2.png"); } @@ -60,24 +60,24 @@ void test_lottie_load_from_file(void) TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_1.png"); /*Wait a little*/ - lv_test_wait(200); + lv_test_fast_forward(200); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_2.png"); /*Should be the last frame*/ - lv_test_wait(750); + lv_test_fast_forward(750); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_3.png"); /*Setting a source should reset the animation*/ lv_lottie_set_src_data(lottie, test_lottie_approve, test_lottie_approve_size); /*Should reset automatically*/ - lv_test_wait(200); + lv_test_fast_forward(200); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_2.png"); } void test_lottie_missing_settings(void) { - uint32_t tmp_buf[CANVAS_WIDTH_TO_STRIDE(100, 4) * 100 + LV_DRAW_BUF_ALIGN]; + uint32_t tmp_buf[LV_TEST_WIDTH_TO_STRIDE(100, 4) * 100 + LV_DRAW_BUF_ALIGN]; lv_obj_t * lottie1 = lv_lottie_create(lv_screen_active()); lv_lottie_set_buffer(lottie1, 100, 100, lv_draw_buf_align(tmp_buf, LV_COLOR_FORMAT_ARGB8888)); @@ -95,7 +95,7 @@ void test_lottie_missing_settings(void) lv_lottie_set_buffer(lottie2, 100, 100, lv_draw_buf_align(buf, LV_COLOR_FORMAT_ARGB8888)); lv_obj_center(lottie2); - lv_test_wait(950); + lv_test_fast_forward(950); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_3.png"); } @@ -107,14 +107,14 @@ void test_lottie_rescale(void) lv_obj_center(lottie); /*Wait a little*/ - lv_test_wait(200); + lv_test_fast_forward(200); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_2.png"); lv_lottie_set_buffer(lottie, 50, 50, lv_draw_buf_align(buf, LV_COLOR_FORMAT_ARGB8888)); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_2_small.png"); /*Should be the last frame*/ - lv_test_wait(750); + lv_test_fast_forward(750); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_3_small.png"); } @@ -126,7 +126,7 @@ void test_lottie_non_uniform_shape(void) lv_lottie_set_src_data(lottie, test_lottie_approve, test_lottie_approve_size); lv_obj_center(lottie); - lv_test_wait(950); + lv_test_fast_forward(950); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_4.png"); } @@ -140,7 +140,7 @@ void test_lottie_memory_leak(void) lv_lottie_set_buffer(lottie, 100, 100, lv_draw_buf_align(buf, LV_COLOR_FORMAT_ARGB8888)); lv_lottie_set_src_data(lottie, test_lottie_approve, test_lottie_approve_size); lv_obj_center(lottie); - lv_test_wait(753 * i); /*Render a random frame*/ + lv_test_fast_forward(753 * i); /*Render a random frame*/ lv_timer_handler(); lv_obj_delete(lottie); } @@ -155,18 +155,18 @@ void test_lottie_no_jump_when_visible_again(void) lv_obj_center(lottie); /*Wait a little*/ - lv_test_wait(200); + lv_test_fast_forward(200); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_2.png"); lv_obj_add_flag(lottie, LV_OBJ_FLAG_HIDDEN); - lv_test_wait(300); + lv_test_fast_forward(300); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_1.png"); /*Empty screen*/ /*Should be on the same frame*/ lv_obj_clear_flag(lottie, LV_OBJ_FLAG_HIDDEN); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_2.png"); - lv_test_wait(750); + lv_test_fast_forward(750); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/lottie_3.png"); } diff --git a/tests/src/test_cases/widgets/test_msgbox.c b/tests/src/test_cases/widgets/test_msgbox.c index a2f42339c..fe9157ed0 100644 --- a/tests/src/test_cases/widgets/test_msgbox.c +++ b/tests/src/test_cases/widgets/test_msgbox.c @@ -3,7 +3,6 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_indev.h" /* This function runs before each test */ void setUp(void); diff --git a/tests/src/test_cases/widgets/test_obj_flags.c b/tests/src/test_cases/widgets/test_obj_flags.c index 88f6d7846..fc5a0624a 100644 --- a/tests/src/test_cases/widgets/test_obj_flags.c +++ b/tests/src/test_cases/widgets/test_obj_flags.c @@ -3,7 +3,6 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_indev.h" void setUp(void) { diff --git a/tests/src/test_cases/widgets/test_roller.c b/tests/src/test_cases/widgets/test_roller.c index 956ec9813..089a82bf6 100644 --- a/tests/src/test_cases/widgets/test_roller.c +++ b/tests/src/test_cases/widgets/test_roller.c @@ -3,7 +3,6 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_indev.h" #include #define OPTION_BUFFER_SZ (20U) @@ -32,13 +31,13 @@ void setUp(void) lv_roller_set_options(roller_mouse, default_roller_options, LV_ROLLER_MODE_NORMAL); g = lv_group_create(); - lv_indev_set_group(lv_test_keypad_indev, g); + lv_indev_set_group(lv_test_indev_get_indev(LV_INDEV_TYPE_KEYPAD), g); encoder_g = lv_group_create(); - lv_indev_set_group(lv_test_encoder_indev, encoder_g); + lv_indev_set_group(lv_test_indev_get_indev(LV_INDEV_TYPE_ENCODER), encoder_g); mouse_g = lv_group_create(); - lv_indev_set_group(lv_test_mouse_indev, mouse_g); + lv_indev_set_group(lv_test_indev_get_indev(LV_INDEV_TYPE_POINTER), mouse_g); lv_group_add_obj(g, roller); lv_group_add_obj(encoder_g, roller_infinite); @@ -149,7 +148,7 @@ void test_roller_keypad_events(void) int16_t expected_index = 1; int16_t actual_index = 0; - lv_test_indev_wait(20); + lv_test_wait(20); return; diff --git a/tests/src/test_cases/widgets/test_slider.c b/tests/src/test_cases/widgets/test_slider.c index 133a93ff1..069c69328 100644 --- a/tests/src/test_cases/widgets/test_slider.c +++ b/tests/src/test_cases/widgets/test_slider.c @@ -3,7 +3,6 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_indev.h" static lv_obj_t * active_screen = NULL; static lv_obj_t * slider = NULL; @@ -25,7 +24,7 @@ void setUp(void) lv_slider_set_mode(sliderSymmetricalMode, LV_SLIDER_MODE_SYMMETRICAL); g = lv_group_create(); - lv_indev_set_group(lv_test_encoder_indev, g); + lv_indev_set_group(lv_test_indev_get_indev(LV_INDEV_TYPE_ENCODER), g); } void tearDown(void) @@ -116,7 +115,7 @@ void test_slider_range_mode_should_not_leave_edit_mode_if_released_with_no_left_ lv_group_set_editing(g, true); lv_test_encoder_release(); - lv_test_indev_wait(50); + lv_test_wait(50); /* Always executed when handling LV_EVENT_RELEASED or * LV_EVENT_PRESS_LOST */ diff --git a/tests/src/test_cases/widgets/test_spinbox.c b/tests/src/test_cases/widgets/test_spinbox.c index c404203e0..55efcba42 100644 --- a/tests/src/test_cases/widgets/test_spinbox.c +++ b/tests/src/test_cases/widgets/test_spinbox.c @@ -3,7 +3,6 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_indev.h" static lv_obj_t * active_screen = NULL; static lv_obj_t * spinbox_negative_min_range = NULL; @@ -27,7 +26,7 @@ void setUp(void) lv_spinbox_set_range(spinbox_zero_min_range, SPINBOX_ZERO_MIN_RANGE_VALUE, SPINBOX_NEGATIVE_MAX_RANGE_VALUE); g = lv_group_create(); - lv_indev_set_group(lv_test_encoder_indev, g); + lv_indev_set_group(lv_test_indev_get_indev(LV_INDEV_TYPE_ENCODER), g); } void tearDown(void) diff --git a/tests/src/test_cases/widgets/test_switch.c b/tests/src/test_cases/widgets/test_switch.c index 8ffa58731..4569fcbc7 100644 --- a/tests/src/test_cases/widgets/test_switch.c +++ b/tests/src/test_cases/widgets/test_switch.c @@ -4,9 +4,6 @@ #include "unity/unity.h" -#include "lv_test_helpers.h" -#include "lv_test_indev.h" - #define SWITCHES_CNT 10 uint8_t value_changed_event_cnt = 0; @@ -75,14 +72,14 @@ void test_switch_animation(void) /* Trigger animation */ mouse_click_on_switch(); /* Wait some time */ - lv_test_indev_wait(50); + lv_test_wait(50); int32_t checked_anim_state = anim_sw->anim_state; TEST_ASSERT_GREATER_THAN(initial_anim_state, checked_anim_state); TEST_ASSERT(lv_obj_has_state(sw, LV_STATE_CHECKED)); mouse_click_on_switch(); - lv_test_indev_wait(50); + lv_test_wait(50); TEST_ASSERT_LESS_THAN(checked_anim_state, anim_sw->anim_state); TEST_ASSERT_FALSE(lv_obj_has_state(sw, LV_STATE_CHECKED)); diff --git a/tests/src/test_cases/widgets/test_tabview.c b/tests/src/test_cases/widgets/test_tabview.c index e31fff1f1..69517b9ea 100644 --- a/tests/src/test_cases/widgets/test_tabview.c +++ b/tests/src/test_cases/widgets/test_tabview.c @@ -3,7 +3,6 @@ #include "../../lvgl_private.h" #include "unity/unity.h" -#include "lv_test_indev.h" void setUp(void); void tearDown(void); diff --git a/tests/src/test_cases/xml/test_xml_event.c b/tests/src/test_cases/xml/test_xml_event.c index cb90ce34a..9c7335c1a 100644 --- a/tests/src/test_cases/xml/test_xml_event.c +++ b/tests/src/test_cases/xml/test_xml_event.c @@ -2,7 +2,6 @@ #include "../lvgl.h" #include "unity/unity.h" -#include "lv_test_indev.h" #include void setUp(void) @@ -65,7 +64,7 @@ void test_xml_event_call_function_attr(void) lv_test_mouse_click_at(30, 20); TEST_ASSERT_EQUAL(3, cnt); - lv_test_indev_wait(100); + lv_test_wait(100); lv_test_mouse_click_at(30, 20); TEST_ASSERT_EQUAL(6, cnt); } @@ -91,7 +90,7 @@ void test_xml_event_call_function_component(void) lv_test_mouse_click_at(30, 10); TEST_ASSERT_EQUAL(3, cnt); - lv_test_indev_wait(100); + lv_test_wait(100); lv_test_mouse_click_at(30, 10); TEST_ASSERT_EQUAL(6, cnt); } diff --git a/tests/unity/unity_support.h b/tests/unity/unity_support.h index 6bd025d9b..daae78c79 100644 --- a/tests/unity/unity_support.h +++ b/tests/unity/unity_support.h @@ -8,10 +8,6 @@ extern "C" { #include #include "../../lvgl.h" -#include "../src/lv_test_helpers.h" - -bool lv_test_assert_image_eq(const char * fn_ref); - #if LV_COLOR_DEPTH != 32 # define TEST_ASSERT_EQUAL_SCREENSHOT(path) TEST_IGNORE_MESSAGE("Requires LV_COLOR_DEPTH 32"); @@ -21,14 +17,14 @@ bool lv_test_assert_image_eq(const char * fn_ref); # define TEST_ASSERT_EQUAL_SCREENSHOT(path) if(LV_HOR_RES != 800 || LV_VER_RES != 480) { \ TEST_IGNORE_MESSAGE("Requires 800x480 resolution"); \ } else { \ - TEST_ASSERT_MESSAGE(lv_test_assert_image_eq(path), path); \ + TEST_ASSERT_MESSAGE(lv_test_screenshot_compare(path), path); \ } # define TEST_ASSERT_EQUAL_SCREENSHOT_MESSAGE(path, msg) if(LV_HOR_RES != 800 || LV_VER_RES != 480) { \ TEST_PRINTF(msg); \ TEST_IGNORE_MESSAGE("Requires 800x480 resolution"); \ } else { \ - TEST_ASSERT_MESSAGE(lv_test_assert_image_eq(path), msg); \ + TEST_ASSERT_MESSAGE(lv_test_screenshot_compare(path), msg); \ } #endif