feat(test): make LVGL's test utilities public

This commit is contained in:
Gabor Kiss-Vamosi
2025-02-13 01:03:27 +01:00
parent aff9ad3b4a
commit 8d04466c68
118 changed files with 1189 additions and 516 deletions

View File

@@ -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

View File

@@ -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();
<create and delete items>
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);
<scroll emulation>
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 ``<image_name>_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
***

View File

@@ -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

1
lvgl.h
View File

@@ -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"

View File

@@ -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

View File

@@ -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

45
src/others/test/lv_test.h Normal file
View File

@@ -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*/

View File

@@ -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 <stdlib.h>
/*********************
* 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*/

View File

@@ -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*/

View File

@@ -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*/

View File

@@ -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*/

View File

@@ -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*/

View File

@@ -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*/

View File

@@ -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*/

View File

@@ -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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include "unity.h"
#define PNG_DEBUG 3
#include <png.h>
@@ -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");

View File

@@ -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 `<image_name>_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 (`<image_name>_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*/

View File

@@ -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}
)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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*/

View File

@@ -1,135 +0,0 @@
#include "../../src/indev/lv_indev_private.h"
#if LV_BUILD_TEST
#include "../lvgl.h"
#include <stdio.h>
#include <stdlib.h>
#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

View File

@@ -1,52 +0,0 @@
#ifndef LV_TEST_INDEV_H
#define LV_TEST_INDEV_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#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*/

View File

@@ -1,6 +1,5 @@
#if LV_BUILD_TEST
#include "lv_test_init.h"
#include "lv_test_indev.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
@@ -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) {

View File

@@ -2,7 +2,7 @@
#include "../lvgl.h"
#include "../../lvgl_private.h"
#include "lv_test_helpers.h"
#include "unity/unity.h"

View File

@@ -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);

View File

@@ -1,6 +1,6 @@
#if LV_BUILD_TEST
#include "../lvgl.h"
#include "lv_test_helpers.h"
#include <string.h>
#include "unity/unity.h"

View File

@@ -1,7 +1,7 @@
#if LV_BUILD_TEST
#include "../lvgl.h"
#include "../../lvgl_private.h"
#include "lv_test_helpers.h"
#include "unity/unity.h"

View File

@@ -3,7 +3,7 @@
#include "../../lvgl_private.h"
#include "unity/unity.h"
#include "lv_test_helpers.h"
void setUp(void)
{

View File

@@ -3,7 +3,7 @@
#include "../../lvgl_private.h"
#include "unity/unity.h"
#include "lv_test_helpers.h"
void setUp(void)
{

View File

@@ -3,7 +3,7 @@
#include "../../lvgl_private.h"
#include "unity/unity.h"
#include "lv_test_helpers.h"
void setUp(void)
{

View File

@@ -3,7 +3,7 @@
#include "../../lvgl_private.h"
#include "unity/unity.h"
#include "lv_test_helpers.h"
void setUp(void)
{

View File

@@ -3,7 +3,7 @@
#include "../../lvgl_private.h"
#include "unity/unity.h"
#include "lv_test_helpers.h"
void setUp(void)
{

View File

@@ -3,7 +3,7 @@
#include "../../lvgl_private.h"
#include "unity/unity.h"
#include "lv_test_helpers.h"
void setUp(void)
{

View File

@@ -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);

View File

@@ -4,7 +4,7 @@
#include "../../lvgl_private.h"
#include "unity/unity.h"
#include "lv_test_helpers.h"
static lv_anim_timeline_t * anim_timeline;

View File

@@ -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");
}

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -3,7 +3,7 @@
#include "../../lvgl_private.h"
#include "unity/unity.h"
#include "lv_test_helpers.h"
void setUp(void)
{

View File

@@ -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)
{

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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();

View File

@@ -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);
}

Some files were not shown because too many files have changed in this diff Show More