mirror of
https://github.com/lvgl/lvgl.git
synced 2026-09-26 09:24:07 +08:00
tests(api): move test cases that break API contract to its own folder
This commit is contained in:
@@ -238,6 +238,7 @@ lvgl_add_test_folder(test_cases/libs)
|
||||
lvgl_add_test_folder(test_cases/refr)
|
||||
lvgl_add_test_folder(test_cases/widgets)
|
||||
|
||||
lvgl_add_test_folder_if(NOT CONFIG_LV_CHECK_ARG_ASSERT_ON_FAIL test_cases/public_api)
|
||||
lvgl_get_test_files(TEST_CASE_FILES)
|
||||
|
||||
file(GLOB_RECURSE TEST_HELPERS_FILES src/test_helpers/*.c)
|
||||
|
||||
@@ -68,6 +68,8 @@ GitHub's CI automatically runs these tests on pushes and pull requests to `maste
|
||||
## Directory structure
|
||||
- `src` Source files of the tests
|
||||
- `test_cases` The written tests,
|
||||
- `public_api` Tests that call a public function with an argument it is
|
||||
documented to reject, see below,
|
||||
- `test_cases_perf` The performance tests,
|
||||
- `test_runners` Generated automatically from the files in `test_cases`.
|
||||
- other miscellaneous files and folders
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# CONFIG_LV_CHECK_ARG_ASSERT_ON_FAIL is not set
|
||||
@@ -87,6 +87,17 @@ test_options = {
|
||||
"run_tests",
|
||||
],
|
||||
},
|
||||
"OPTIONS_TEST_PUBLIC_API": {
|
||||
"description": "Public API argument checks, system heap, 32 bit color depth",
|
||||
"defconfigs": [
|
||||
"full",
|
||||
"depth_32",
|
||||
HOST,
|
||||
"sys_heap",
|
||||
"run_tests",
|
||||
"public_api",
|
||||
],
|
||||
},
|
||||
"OPTIONS_TEST_VG_LITE": {
|
||||
"description": "VG-Lite simulator with full config, 32 bit color depth",
|
||||
"defconfigs": ["full", "depth_32", HOST, "sys_heap", "run_tests", "vg_lite"],
|
||||
|
||||
@@ -435,32 +435,6 @@ void test_barcode_regeneration_encodes_the_data_once(void)
|
||||
|
||||
#endif /*LV_USE_LOG && LV_LOG_LEVEL <= LV_LOG_LEVEL_INFO*/
|
||||
|
||||
void test_barcode_update_rejects_invalid_data(void)
|
||||
{
|
||||
lv_obj_t * barcode = lv_barcode_create(active_screen);
|
||||
TEST_ASSERT_NOT_NULL(barcode);
|
||||
lv_obj_set_height(barcode, 50);
|
||||
|
||||
#if LV_USE_CHECK_ARG
|
||||
/*Without the argument check the data is dereferenced, so only assert this when it is on*/
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_barcode_update(barcode, NULL));
|
||||
TEST_ASSERT_FALSE(lv_barcode_is_render_valid(barcode));
|
||||
#endif
|
||||
|
||||
/*Nothing to encode*/
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_barcode_update(barcode, ""));
|
||||
TEST_ASSERT_FALSE(lv_barcode_is_render_valid(barcode));
|
||||
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_barcode_update(barcode, "https://lvgl.io"));
|
||||
TEST_ASSERT_TRUE(lv_barcode_is_render_valid(barcode));
|
||||
|
||||
/*Emptying forgets the data, so a property change cannot bring the old barcode back*/
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_barcode_update(barcode, ""));
|
||||
TEST_ASSERT_FALSE(lv_barcode_is_render_valid(barcode));
|
||||
lv_barcode_set_scale(barcode, 2);
|
||||
TEST_ASSERT_FALSE(lv_barcode_is_render_valid(barcode));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void setUp(void)
|
||||
|
||||
@@ -121,59 +121,6 @@ void test_bin_decoder_bin_file(void)
|
||||
{
|
||||
bin_decoder("A:src/test_files/binimages/cogwheel.ARGB8888.bin", "libs/cogwheel.ARGB8888.png");
|
||||
}
|
||||
void test_bin_decoder_image_dsc_error_handling(void)
|
||||
{
|
||||
lv_image_dsc_t * image_dsc = get_image_dsc();
|
||||
|
||||
/* Valid image */
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid magic */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->header.magic = 0;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid NULL data */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->data = NULL;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid data_size */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->data_size = 0;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid stride */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->header.stride = 0;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid color format */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->header.cf = LV_COLOR_FORMAT_UNKNOWN;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid image size */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->header.w++;
|
||||
image_dsc->header.h++;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid unaligned data */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->data = image_dsc->data + 1;
|
||||
image_dsc->header.h = 1;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid flags */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->header.flags = (LV_IMAGE_FLAGS_ALLOCATED | LV_IMAGE_FLAGS_PREMULTIPLIED);
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test NULL image */
|
||||
bin_decoder(NULL, "libs/bin_decoder_empty_image.png");
|
||||
}
|
||||
|
||||
void test_bin_decoder_flush_cache(void)
|
||||
{
|
||||
#if LV_BIN_DECODER_RAM_LOAD == 1
|
||||
@@ -223,114 +170,6 @@ void test_bin_decoder_flush_cache(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_bin_decoder_decoder_dsc_error_handling(void)
|
||||
{
|
||||
lv_image_decoder_dsc_t * decoder_dsc = get_image_decoder_dsc();
|
||||
|
||||
/* Test info invalid file extension */
|
||||
decoder_dsc->src = "test_image.png";
|
||||
lv_result_t result = lv_bin_decoder_info(NULL, decoder_dsc, NULL);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
/* Test info file read error */
|
||||
decoder_dsc->src = "non_existing.bin";
|
||||
result = lv_bin_decoder_info(NULL, decoder_dsc, NULL);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
/* Test info unknown src type */
|
||||
decoder_dsc->src = "A:src/test_files/binimages/cogwheel.ARGB8888.bin";
|
||||
decoder_dsc->src_type = LV_IMAGE_SRC_UNKNOWN;
|
||||
result = lv_bin_decoder_info(NULL, decoder_dsc, NULL);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
/* Test open invalid file extension */
|
||||
decoder_dsc = get_image_decoder_dsc();
|
||||
decoder_dsc->src = "test_image.png";
|
||||
result = lv_bin_decoder_open(NULL, decoder_dsc);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
/* Test open file failure */
|
||||
decoder_dsc->src = "non_existing.bin";
|
||||
result = lv_bin_decoder_open(NULL, decoder_dsc);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
/* Test open variable image with NULL data */
|
||||
lv_image_dsc_t * image_dsc = get_image_dsc();
|
||||
image_dsc->data = NULL;
|
||||
decoder_dsc = get_image_decoder_dsc();
|
||||
decoder_dsc->src = image_dsc;
|
||||
decoder_dsc->src_type = LV_IMAGE_SRC_VARIABLE;
|
||||
result = lv_bin_decoder_open(NULL, decoder_dsc);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
/* Test open decompress image with LV_BIN_DECODER_RAM_LOAD == 0 */
|
||||
#if LV_BIN_DECODER_RAM_LOAD == 0
|
||||
image_dsc = get_image_dsc();
|
||||
decoder_dsc = get_image_decoder_dsc();
|
||||
decoder_dsc->src = image_dsc;
|
||||
decoder_dsc->src_type = LV_IMAGE_SRC_VARIABLE;
|
||||
decoder_dsc->header.flags = LV_IMAGE_FLAGS_COMPRESSED;
|
||||
result = lv_bin_decoder_open(NULL, decoder_dsc);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
#endif
|
||||
|
||||
/* Test open with user_flags handling */
|
||||
image_dsc = get_image_dsc();
|
||||
decoder_dsc = get_image_decoder_dsc();
|
||||
decoder_dsc->src = image_dsc;
|
||||
decoder_dsc->src_type = LV_IMAGE_SRC_VARIABLE;
|
||||
decoder_dsc->header.flags = LV_IMAGE_FLAGS_USER_MASK;
|
||||
result = lv_bin_decoder_open(NULL, decoder_dsc);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, result);
|
||||
|
||||
lv_bin_decoder_close(decoder_dsc->decoder, decoder_dsc);
|
||||
}
|
||||
|
||||
void test_bin_decoder_get_area_outside_image(void)
|
||||
{
|
||||
const char * src = "A:src/test_files/binimages/cogwheel.RGB565.bin";
|
||||
lv_image_cache_drop(src);
|
||||
|
||||
const lv_image_decoder_args_t args = { .no_cache = true };
|
||||
lv_image_decoder_dsc_t dsc;
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_image_decoder_open(&dsc, src, &args));
|
||||
|
||||
int32_t w = dsc.header.w;
|
||||
int32_t h = dsc.header.h;
|
||||
|
||||
/*A transformed image is drawn on a larger area than the image itself. Such an area
|
||||
*cannot be decoded line by line, so it must be rejected instead of reading out of bounds.*/
|
||||
const lv_area_t outside[] = {
|
||||
{-1, 0, w - 1, 0},
|
||||
{0, -1, w - 1, 0},
|
||||
{0, 0, w, 0},
|
||||
{0, 0, w - 1, h},
|
||||
{-4, -4, w + 3, h + 3},
|
||||
};
|
||||
|
||||
for(uint32_t i = 0; i < sizeof(outside) / sizeof(outside[0]); i++) {
|
||||
lv_area_t decoded_area = {LV_COORD_MIN, LV_COORD_MIN, LV_COORD_MIN, LV_COORD_MIN};
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_image_decoder_get_area(&dsc, &outside[i], &decoded_area));
|
||||
}
|
||||
|
||||
/*The full image is a valid area*/
|
||||
const lv_area_t inside = {0, 0, w - 1, h - 1};
|
||||
lv_area_t decoded_area = {LV_COORD_MIN, LV_COORD_MIN, LV_COORD_MIN, LV_COORD_MIN};
|
||||
lv_result_t res = lv_image_decoder_get_area(&dsc, &inside, &decoded_area);
|
||||
#if LV_BIN_DECODER_RAM_LOAD == 0
|
||||
/*Read line by line*/
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, res);
|
||||
TEST_ASSERT_EQUAL(0, decoded_area.y1);
|
||||
TEST_ASSERT_EQUAL(0, decoded_area.y2);
|
||||
TEST_ASSERT_EQUAL(0, decoded_area.x1);
|
||||
TEST_ASSERT_EQUAL(w - 1, decoded_area.x2);
|
||||
#else
|
||||
LV_UNUSED(res); /*The whole image was decoded on open, no need to read it here*/
|
||||
#endif
|
||||
|
||||
lv_image_decoder_close(&dsc);
|
||||
}
|
||||
|
||||
static void render_transformed_image(const void * src)
|
||||
{
|
||||
lv_image_cache_drop(src);
|
||||
|
||||
@@ -91,8 +91,6 @@ static void test_freetype_with_render_mode(lv_freetype_font_render_mode_t render
|
||||
font_path_error = lv_freetype_font_create("", render_mode, 24, LV_FREETYPE_FONT_STYLE_NORMAL);
|
||||
TEST_ASSERT_NULL(font_path_error);
|
||||
|
||||
font_path_error = lv_freetype_font_create(NULL, render_mode, 24, LV_FREETYPE_FONT_STYLE_NORMAL);
|
||||
TEST_ASSERT_NULL(font_path_error);
|
||||
|
||||
lv_font_t * font_size_error = lv_freetype_font_create("./src/test_files/fonts/noto/NotoSansSC-Regular.ttf",
|
||||
render_mode,
|
||||
|
||||
@@ -136,11 +136,6 @@ void test_gstreamer_invalid_source(void)
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_gstreamer_set_src(player, LV_GSTREAMER_FACTORY_TEST_VIDEO, NULL, NULL));
|
||||
}
|
||||
|
||||
void test_gstreamer_stream_state_of_invalid_event(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL(LV_GSTREAMER_STREAM_STATE_INVALID, lv_gstreamer_get_stream_state(NULL));
|
||||
}
|
||||
|
||||
void test_gstreamer_missing_file(void)
|
||||
{
|
||||
lv_obj_t * player = create_player();
|
||||
@@ -282,7 +277,6 @@ void setUp(void) { }
|
||||
void tearDown(void) { }
|
||||
void test_gstreamer_without_source(void) { }
|
||||
void test_gstreamer_invalid_source(void) { }
|
||||
void test_gstreamer_stream_state_of_invalid_event(void) { }
|
||||
void test_gstreamer_missing_file(void) { }
|
||||
void test_gstreamer_videotestsrc(void) { }
|
||||
void test_gstreamer_file_playback(void) { }
|
||||
|
||||
@@ -412,44 +412,6 @@ void test_qrcode_canvas_too_small_is_reported(void)
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_qrcode_update(qr, "https://lvgl.io", 15));
|
||||
}
|
||||
|
||||
void test_qrcode_set_data_ignores_null(void)
|
||||
{
|
||||
lv_obj_t * qr = lv_qrcode_create(active_screen);
|
||||
TEST_ASSERT_NOT_NULL(qr);
|
||||
lv_qrcode_set_size(qr, 150);
|
||||
lv_qrcode_set_data(qr, "https://lvgl.io");
|
||||
TEST_ASSERT_TRUE(lv_qrcode_is_render_valid(qr));
|
||||
|
||||
/*A NULL string is a no-op, not a crash, and leaves the stored payload alone.
|
||||
*The guard is unconditional because lv_strlen() would dereference it even when
|
||||
*argument checks are compiled out.*/
|
||||
lv_qrcode_set_data(qr, NULL);
|
||||
TEST_ASSERT_TRUE(lv_qrcode_is_render_valid(qr));
|
||||
TEST_ASSERT_EQUAL(15, ((lv_qrcode_t *)qr)->data_len);
|
||||
}
|
||||
|
||||
void test_qrcode_update_rejects_invalid_arguments(void)
|
||||
{
|
||||
/*The bound is enforced by LV_CHECK_ARG, which compiles to nothing when disabled.
|
||||
*The guard is inside the function because the Unity runner generator ignores
|
||||
*preprocessor directives and would reference a non-existent symbol otherwise.*/
|
||||
#if LV_USE_CHECK_ARG
|
||||
lv_obj_t * qr = lv_qrcode_create(active_screen);
|
||||
TEST_ASSERT_NOT_NULL(qr);
|
||||
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_qrcode_update(qr, NULL, 4));
|
||||
|
||||
/*More bytes than any QR code can hold is rejected before anything is stored*/
|
||||
static char over_len[qrcodegen_BUFFER_LEN_MAX + 1];
|
||||
lv_memset(over_len, 'a', sizeof(over_len));
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_qrcode_update(qr, over_len, qrcodegen_BUFFER_LEN_MAX + 1));
|
||||
|
||||
/*A previously set payload survives a rejected call*/
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_qrcode_update(qr, "https://lvgl.io", 15));
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_qrcode_update(qr, over_len, qrcodegen_BUFFER_LEN_MAX + 1));
|
||||
#endif /*LV_USE_CHECK_ARG*/
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void setUp(void)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
#include "../../lvgl_private.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
#if LV_USE_BARCODE
|
||||
|
||||
static lv_obj_t * active_screen = NULL;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
active_screen = lv_screen_active();
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_obj_clean(active_screen);
|
||||
}
|
||||
|
||||
void test_barcode_update_rejects_invalid_data(void)
|
||||
{
|
||||
lv_obj_t * barcode = lv_barcode_create(active_screen);
|
||||
TEST_ASSERT_NOT_NULL(barcode);
|
||||
lv_obj_set_height(barcode, 50);
|
||||
|
||||
#if LV_USE_CHECK_ARG
|
||||
/*Without the argument check the data is dereferenced, so only assert this when it is on*/
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_barcode_update(barcode, NULL));
|
||||
TEST_ASSERT_FALSE(lv_barcode_is_render_valid(barcode));
|
||||
#endif
|
||||
|
||||
/*Nothing to encode*/
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_barcode_update(barcode, ""));
|
||||
TEST_ASSERT_FALSE(lv_barcode_is_render_valid(barcode));
|
||||
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_barcode_update(barcode, "https://lvgl.io"));
|
||||
TEST_ASSERT_TRUE(lv_barcode_is_render_valid(barcode));
|
||||
|
||||
/*Emptying forgets the data, so a property change cannot bring the old barcode back*/
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_barcode_update(barcode, ""));
|
||||
TEST_ASSERT_FALSE(lv_barcode_is_render_valid(barcode));
|
||||
lv_barcode_set_scale(barcode, 2);
|
||||
TEST_ASSERT_FALSE(lv_barcode_is_render_valid(barcode));
|
||||
}
|
||||
|
||||
#else /*LV_USE_BARCODE*/
|
||||
|
||||
void setUp(void) { }
|
||||
void tearDown(void) { }
|
||||
void test_barcode_update_rejects_invalid_data(void) { }
|
||||
|
||||
#endif /*LV_USE_BARCODE*/
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,235 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
#include "../../lvgl_private.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_obj_clean(lv_screen_active());
|
||||
}
|
||||
|
||||
static void create_image(const void * src)
|
||||
{
|
||||
lv_obj_t * img = lv_image_create(lv_screen_active());
|
||||
lv_image_set_src(img, src);
|
||||
lv_obj_center(img);
|
||||
}
|
||||
|
||||
/* Render `src` repeatedly and compare against `screenshot`. A descriptor the
|
||||
* decoder rejects has to render as the empty image, without leaking. */
|
||||
static void bin_decoder(const void * src, const char * screenshot)
|
||||
{
|
||||
lv_image_cache_drop(src);
|
||||
create_image(src);
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT(screenshot);
|
||||
lv_obj_clean(lv_screen_active());
|
||||
|
||||
size_t mem_before = lv_test_get_free_mem();
|
||||
for(uint32_t i = 0; i < 20; i++) {
|
||||
lv_obj_clean(lv_screen_active());
|
||||
create_image(src);
|
||||
|
||||
lv_obj_invalidate(lv_screen_active());
|
||||
lv_refr_now(NULL);
|
||||
}
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT(screenshot);
|
||||
lv_obj_clean(lv_screen_active());
|
||||
TEST_ASSERT_MEM_LEAK_LESS_THAN(mem_before, 0);
|
||||
}
|
||||
|
||||
/* A freshly valid descriptor that every case below corrupts in one way */
|
||||
static lv_image_dsc_t * get_image_dsc(void)
|
||||
{
|
||||
#define IMAGE_WIDTH 32
|
||||
#define IMAGE_HEIGHT 2
|
||||
static LV_ATTRIBUTE_MEM_ALIGN uint8_t image_map[IMAGE_WIDTH * IMAGE_HEIGHT * sizeof(lv_color32_t)] = { 0 };
|
||||
static lv_image_dsc_t image_dsc = { 0 };
|
||||
|
||||
image_dsc.header.magic = LV_IMAGE_HEADER_MAGIC,
|
||||
image_dsc.header.cf = LV_COLOR_FORMAT_ARGB8888;
|
||||
image_dsc.header.w = IMAGE_WIDTH;
|
||||
image_dsc.header.h = IMAGE_HEIGHT;
|
||||
image_dsc.header.stride = IMAGE_WIDTH * sizeof(lv_color32_t);
|
||||
image_dsc.header.flags = 0;
|
||||
image_dsc.data_size = sizeof(image_map);
|
||||
image_dsc.data = image_map;
|
||||
|
||||
return &image_dsc;
|
||||
}
|
||||
|
||||
static lv_image_decoder_dsc_t * get_image_decoder_dsc(void)
|
||||
{
|
||||
static lv_image_decoder_dsc_t decoder_dsc = { 0 };
|
||||
decoder_dsc.src_type = LV_IMAGE_SRC_FILE;
|
||||
decoder_dsc.src = NULL;
|
||||
decoder_dsc.header.flags = 0;
|
||||
return &decoder_dsc;
|
||||
}
|
||||
|
||||
void test_bin_decoder_image_dsc_error_handling(void)
|
||||
{
|
||||
lv_image_dsc_t * image_dsc = get_image_dsc();
|
||||
|
||||
/* Valid image */
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid magic */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->header.magic = 0;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid NULL data */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->data = NULL;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid data_size */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->data_size = 0;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid stride */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->header.stride = 0;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid color format */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->header.cf = LV_COLOR_FORMAT_UNKNOWN;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid image size */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->header.w++;
|
||||
image_dsc->header.h++;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid unaligned data */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->data = image_dsc->data + 1;
|
||||
image_dsc->header.h = 1;
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test invalid flags */
|
||||
image_dsc = get_image_dsc();
|
||||
image_dsc->header.flags = (LV_IMAGE_FLAGS_ALLOCATED | LV_IMAGE_FLAGS_PREMULTIPLIED);
|
||||
bin_decoder(image_dsc, "libs/bin_decoder_empty_image.png");
|
||||
|
||||
/* Test NULL image */
|
||||
bin_decoder(NULL, "libs/bin_decoder_empty_image.png");
|
||||
}
|
||||
|
||||
void test_bin_decoder_decoder_dsc_error_handling(void)
|
||||
{
|
||||
lv_image_decoder_dsc_t * decoder_dsc = get_image_decoder_dsc();
|
||||
|
||||
/* Test info invalid file extension */
|
||||
decoder_dsc->src = "test_image.png";
|
||||
lv_result_t result = lv_bin_decoder_info(NULL, decoder_dsc, NULL);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
/* Test info file read error */
|
||||
decoder_dsc->src = "non_existing.bin";
|
||||
result = lv_bin_decoder_info(NULL, decoder_dsc, NULL);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
/* Test info unknown src type */
|
||||
decoder_dsc->src = "A:src/test_files/binimages/cogwheel.ARGB8888.bin";
|
||||
decoder_dsc->src_type = LV_IMAGE_SRC_UNKNOWN;
|
||||
result = lv_bin_decoder_info(NULL, decoder_dsc, NULL);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
/* Test open invalid file extension */
|
||||
decoder_dsc = get_image_decoder_dsc();
|
||||
decoder_dsc->src = "test_image.png";
|
||||
result = lv_bin_decoder_open(NULL, decoder_dsc);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
/* Test open file failure */
|
||||
decoder_dsc->src = "non_existing.bin";
|
||||
result = lv_bin_decoder_open(NULL, decoder_dsc);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
/* Test open variable image with NULL data */
|
||||
lv_image_dsc_t * image_dsc = get_image_dsc();
|
||||
image_dsc->data = NULL;
|
||||
decoder_dsc = get_image_decoder_dsc();
|
||||
decoder_dsc->src = image_dsc;
|
||||
decoder_dsc->src_type = LV_IMAGE_SRC_VARIABLE;
|
||||
result = lv_bin_decoder_open(NULL, decoder_dsc);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
/* Test open decompress image with LV_BIN_DECODER_RAM_LOAD == 0 */
|
||||
#if LV_BIN_DECODER_RAM_LOAD == 0
|
||||
image_dsc = get_image_dsc();
|
||||
decoder_dsc = get_image_decoder_dsc();
|
||||
decoder_dsc->src = image_dsc;
|
||||
decoder_dsc->src_type = LV_IMAGE_SRC_VARIABLE;
|
||||
decoder_dsc->header.flags = LV_IMAGE_FLAGS_COMPRESSED;
|
||||
result = lv_bin_decoder_open(NULL, decoder_dsc);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
#endif
|
||||
|
||||
/* Test open with user_flags handling */
|
||||
image_dsc = get_image_dsc();
|
||||
decoder_dsc = get_image_decoder_dsc();
|
||||
decoder_dsc->src = image_dsc;
|
||||
decoder_dsc->src_type = LV_IMAGE_SRC_VARIABLE;
|
||||
decoder_dsc->header.flags = LV_IMAGE_FLAGS_USER_MASK;
|
||||
result = lv_bin_decoder_open(NULL, decoder_dsc);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, result);
|
||||
|
||||
lv_bin_decoder_close(decoder_dsc->decoder, decoder_dsc);
|
||||
}
|
||||
|
||||
void test_bin_decoder_get_area_outside_image(void)
|
||||
{
|
||||
const char * src = "A:src/test_files/binimages/cogwheel.RGB565.bin";
|
||||
lv_image_cache_drop(src);
|
||||
|
||||
const lv_image_decoder_args_t args = { .no_cache = true };
|
||||
lv_image_decoder_dsc_t dsc;
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_image_decoder_open(&dsc, src, &args));
|
||||
|
||||
int32_t w = dsc.header.w;
|
||||
int32_t h = dsc.header.h;
|
||||
|
||||
/*A transformed image is drawn on a larger area than the image itself. Such an area
|
||||
*cannot be decoded line by line, so it must be rejected instead of reading out of bounds.*/
|
||||
const lv_area_t outside[] = {
|
||||
{-1, 0, w - 1, 0},
|
||||
{0, -1, w - 1, 0},
|
||||
{0, 0, w, 0},
|
||||
{0, 0, w - 1, h},
|
||||
{-4, -4, w + 3, h + 3},
|
||||
};
|
||||
|
||||
for(uint32_t i = 0; i < sizeof(outside) / sizeof(outside[0]); i++) {
|
||||
lv_area_t decoded_area = {LV_COORD_MIN, LV_COORD_MIN, LV_COORD_MIN, LV_COORD_MIN};
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_image_decoder_get_area(&dsc, &outside[i], &decoded_area));
|
||||
}
|
||||
|
||||
/*The full image is a valid area*/
|
||||
const lv_area_t inside = {0, 0, w - 1, h - 1};
|
||||
lv_area_t decoded_area = {LV_COORD_MIN, LV_COORD_MIN, LV_COORD_MIN, LV_COORD_MIN};
|
||||
lv_result_t res = lv_image_decoder_get_area(&dsc, &inside, &decoded_area);
|
||||
#if LV_BIN_DECODER_RAM_LOAD == 0
|
||||
/*Read line by line*/
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, res);
|
||||
TEST_ASSERT_EQUAL(0, decoded_area.y1);
|
||||
TEST_ASSERT_EQUAL(0, decoded_area.y2);
|
||||
TEST_ASSERT_EQUAL(0, decoded_area.x1);
|
||||
TEST_ASSERT_EQUAL(w - 1, decoded_area.x2);
|
||||
#else
|
||||
LV_UNUSED(res); /*The whole image was decoded on open, no need to read it here*/
|
||||
#endif
|
||||
|
||||
lv_image_decoder_close(&dsc);
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,93 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
#include "../../lvgl_private.h"
|
||||
#include "lv_test_init.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
static lv_obj_t * g_screen_active;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
g_screen_active = lv_screen_active();
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_obj_clean(g_screen_active);
|
||||
}
|
||||
|
||||
static void canvas_draw_buf_reshape(lv_draw_buf_t * draw_buf)
|
||||
{
|
||||
#if LV_USE_DRAW_VG_LITE
|
||||
/* VG-Lite requires automatic stride calculation */
|
||||
lv_draw_buf_t * buf = lv_draw_buf_reshape(draw_buf,
|
||||
draw_buf->header.cf,
|
||||
draw_buf->header.w,
|
||||
draw_buf->header.h,
|
||||
LV_STRIDE_AUTO);
|
||||
TEST_ASSERT(buf == draw_buf);
|
||||
#else
|
||||
LV_UNUSED(draw_buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*A draw buffer that was never initialised has no handlers to draw with*/
|
||||
void test_canvas_args_uninitialized_draw_buf(void)
|
||||
{
|
||||
lv_obj_t * canvas = lv_canvas_create(g_screen_active);
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(draw_buf, 100, 100, LV_COLOR_FORMAT_DEFAULT);
|
||||
|
||||
lv_canvas_set_draw_buf(canvas, &draw_buf);
|
||||
TEST_ASSERT_NULL(lv_canvas_get_draw_buf(canvas));
|
||||
TEST_ASSERT_NULL(lv_canvas_get_image(canvas));
|
||||
TEST_ASSERT_NULL(lv_canvas_get_buf(canvas));
|
||||
}
|
||||
|
||||
void test_canvas_empty_draw_buf(void)
|
||||
{
|
||||
lv_obj_t * canvas = lv_canvas_create(g_screen_active);
|
||||
|
||||
TEST_ASSERT_NULL(lv_canvas_get_draw_buf(canvas));
|
||||
TEST_ASSERT_NULL(lv_canvas_get_image(canvas));
|
||||
TEST_ASSERT_NULL(lv_canvas_get_buf(canvas));
|
||||
lv_layer_t layer;
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(src_buf, 10, 10, LV_COLOR_FORMAT_ARGB8888);
|
||||
LV_DRAW_BUF_INIT_STATIC(src_buf);
|
||||
canvas_draw_buf_reshape(&src_buf);
|
||||
|
||||
lv_canvas_copy_buf(canvas, NULL, &src_buf, NULL);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex(0xFFFFFF), LV_OPA_COVER);
|
||||
lv_canvas_init_layer(canvas, &layer);
|
||||
lv_canvas_set_px(canvas, 0, 0, lv_color_hex(0x000000), LV_OPA_COVER);
|
||||
|
||||
lv_color32_t src_px = lv_color_to_32(lv_color_hex(0x000000), LV_OPA_0);
|
||||
lv_color32_t dst_px = lv_canvas_get_px(canvas, 0, 0);
|
||||
TEST_ASSERT_TRUE(lv_color32_eq(src_px, dst_px));
|
||||
|
||||
lv_canvas_set_palette(canvas, 0, src_px);
|
||||
lv_canvas_finish_layer(canvas, &layer);
|
||||
}
|
||||
|
||||
void test_canvas_out_of_area(void)
|
||||
{
|
||||
lv_obj_t * canvas = lv_canvas_create(g_screen_active);
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(draw_buf, 10, 10, LV_COLOR_FORMAT_ARGB8888);
|
||||
LV_DRAW_BUF_INIT_STATIC(draw_buf);
|
||||
canvas_draw_buf_reshape(&draw_buf);
|
||||
lv_canvas_set_draw_buf(canvas, &draw_buf);
|
||||
|
||||
lv_color_t test_color = lv_color_hex(0x1234);
|
||||
|
||||
lv_canvas_set_px(canvas, -1, -1, test_color, LV_OPA_0);
|
||||
lv_color32_t px = lv_canvas_get_px(canvas, -1, -1);
|
||||
TEST_ASSERT_EQUAL_UINT8(0x00, px.red);
|
||||
TEST_ASSERT_EQUAL_UINT8(0x00, px.green);
|
||||
TEST_ASSERT_EQUAL_UINT8(0x00, px.blue);
|
||||
TEST_ASSERT_EQUAL_UINT8(0x00, px.alpha);
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,71 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
static lv_display_t * disp_def;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
disp_def = lv_display_get_default();
|
||||
lv_display_set_default(NULL);
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_display_set_default(disp_def);
|
||||
lv_obj_clean(lv_screen_active());
|
||||
}
|
||||
|
||||
void test_display_args_resolution_without_default_display(void)
|
||||
{
|
||||
lv_display_set_resolution(lv_display_get_default(), 2, 3);
|
||||
lv_display_set_physical_resolution(lv_display_get_default(), 4, 5);
|
||||
lv_display_set_offset(lv_display_get_default(), 6, 7);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT32(0, lv_display_get_horizontal_resolution(lv_display_get_default()));
|
||||
TEST_ASSERT_EQUAL_INT32(0, lv_display_get_vertical_resolution(lv_display_get_default()));
|
||||
TEST_ASSERT_EQUAL_INT32(0, lv_display_get_original_horizontal_resolution(lv_display_get_default()));
|
||||
TEST_ASSERT_EQUAL_INT32(0, lv_display_get_original_vertical_resolution(lv_display_get_default()));
|
||||
TEST_ASSERT_EQUAL_INT32(0, lv_display_get_physical_horizontal_resolution(lv_display_get_default()));
|
||||
TEST_ASSERT_EQUAL_INT32(0, lv_display_get_physical_vertical_resolution(lv_display_get_default()));
|
||||
TEST_ASSERT_EQUAL_INT32(0, lv_display_get_offset_x(lv_display_get_default()));
|
||||
TEST_ASSERT_EQUAL_INT32(0, lv_display_get_offset_y(lv_display_get_default()));
|
||||
TEST_ASSERT_EQUAL(LV_DISPLAY_ROTATION_0, lv_display_get_rotation(lv_display_get_default()));
|
||||
}
|
||||
|
||||
void test_display_args_dpi_tile_cnt_antialiasing_without_default_display(void)
|
||||
{
|
||||
lv_display_set_dpi(lv_display_get_default(), 200);
|
||||
TEST_ASSERT_EQUAL_INT32(LV_DPI_DEF, lv_display_get_dpi(lv_display_get_default()));
|
||||
|
||||
lv_display_set_antialiasing(lv_display_get_default(), false);
|
||||
TEST_ASSERT_FALSE(lv_display_get_antialiasing(lv_display_get_default()));
|
||||
lv_display_set_antialiasing(lv_display_get_default(), true);
|
||||
TEST_ASSERT_FALSE(lv_display_get_antialiasing(lv_display_get_default()));
|
||||
|
||||
lv_display_set_tile_cnt(lv_display_get_default(), 20);
|
||||
TEST_ASSERT_EQUAL_INT32(0, lv_display_get_tile_cnt(lv_display_get_default()));
|
||||
}
|
||||
|
||||
void test_display_args_layers_without_default_display(void)
|
||||
{
|
||||
TEST_ASSERT_NULL(lv_display_get_screen_active(lv_display_get_default()));
|
||||
TEST_ASSERT_NULL(lv_display_get_screen_prev(lv_display_get_default()));
|
||||
TEST_ASSERT_NULL(lv_display_get_layer_top(lv_display_get_default()));
|
||||
TEST_ASSERT_NULL(lv_display_get_layer_sys(lv_display_get_default()));
|
||||
TEST_ASSERT_NULL(lv_display_get_layer_bottom(lv_display_get_default()));
|
||||
}
|
||||
|
||||
void test_display_args_activity_without_default_display(void)
|
||||
{
|
||||
/*Triggering activity on nothing must not disturb the display that does exist*/
|
||||
lv_display_trigger_activity(disp_def);
|
||||
lv_tick_inc(1000);
|
||||
|
||||
lv_display_trigger_activity(lv_display_get_default());
|
||||
lv_tick_inc(1000);
|
||||
TEST_ASSERT_EQUAL_UINT32(2000, lv_display_get_inactive_time(disp_def));
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,36 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
static uint32_t call_cnt;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
call_cnt = 0;
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_obj_clean(lv_screen_active());
|
||||
}
|
||||
|
||||
/*Only LV_EVENT_INVALIDATE_AREA carries an area, every other code reports none*/
|
||||
static void cb_invalidated_area_wrong_code(lv_event_t * e)
|
||||
{
|
||||
call_cnt++;
|
||||
TEST_ASSERT_NULL(lv_event_get_invalidated_area(e));
|
||||
}
|
||||
|
||||
void test_display_event_args_invalidated_area_of_wrong_event_code(void)
|
||||
{
|
||||
lv_display_t * disp = lv_display_get_default();
|
||||
lv_display_add_event_cb(disp, cb_invalidated_area_wrong_code, LV_EVENT_REFR_START, NULL);
|
||||
|
||||
lv_display_send_event(disp, LV_EVENT_REFR_START, NULL);
|
||||
TEST_ASSERT_EQUAL_UINT32(1, call_cnt);
|
||||
|
||||
lv_display_remove_event_cb_with_user_data(disp, cb_invalidated_area_wrong_code, NULL);
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,24 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*A coordinate outside the buffer has no address to report*/
|
||||
void test_draw_buf_args_goto_xy_out_of_range(void)
|
||||
{
|
||||
LV_DRAW_BUF_DEFINE_STATIC(draw_buf, 100, 100, LV_COLOR_FORMAT_RGB565);
|
||||
LV_DRAW_BUF_INIT_STATIC(draw_buf);
|
||||
|
||||
TEST_ASSERT_NULL(lv_draw_buf_goto_xy(&draw_buf, 100, 100));
|
||||
TEST_ASSERT_NULL(lv_draw_buf_goto_xy(&draw_buf, -10, -10));
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,30 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
#include "../../lvgl_private.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_obj_clean(lv_screen_active());
|
||||
}
|
||||
|
||||
/*A NULL callback is nothing to call, so it is not added to the list*/
|
||||
void test_event_args_add_event_cb_null_callback(void)
|
||||
{
|
||||
lv_obj_t * obj = lv_obj_create(lv_screen_active());
|
||||
uint32_t before = lv_obj_get_event_count(obj);
|
||||
|
||||
lv_obj_add_event_cb(obj, NULL, LV_EVENT_ALL, NULL);
|
||||
TEST_ASSERT_EQUAL_UINT32(before, lv_obj_get_event_count(obj));
|
||||
|
||||
/*Sending an event still works with the rejected callback absent*/
|
||||
lv_obj_send_event(obj, LV_EVENT_CLICKED, NULL);
|
||||
TEST_PASS();
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,31 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
#if LV_USE_FREETYPE
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
void test_freetype_args_font_create_null_pathname(void)
|
||||
{
|
||||
TEST_ASSERT_NULL(lv_freetype_font_create(NULL, LV_FREETYPE_FONT_RENDER_MODE_BITMAP, 24,
|
||||
LV_FREETYPE_FONT_STYLE_NORMAL));
|
||||
TEST_ASSERT_NULL(lv_freetype_font_create(NULL, LV_FREETYPE_FONT_RENDER_MODE_OUTLINE, 24,
|
||||
LV_FREETYPE_FONT_STYLE_NORMAL));
|
||||
}
|
||||
|
||||
#else /*LV_USE_FREETYPE*/
|
||||
|
||||
void setUp(void) { }
|
||||
void tearDown(void) { }
|
||||
void test_freetype_args_font_create_null_pathname(void) { }
|
||||
|
||||
#endif /*LV_USE_FREETYPE*/
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,51 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
void test_fs_args_open_null_path(void)
|
||||
{
|
||||
lv_fs_file_t f;
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_INV_PARAM, lv_fs_open(&f, NULL, LV_FS_MODE_RD));
|
||||
}
|
||||
|
||||
void test_fs_args_path_get_size_null_path(void)
|
||||
{
|
||||
uint32_t size;
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_INV_PARAM, lv_fs_path_get_size(NULL, &size));
|
||||
}
|
||||
|
||||
void test_fs_args_dir_open_null_path(void)
|
||||
{
|
||||
lv_fs_dir_t dir;
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_INV_PARAM, lv_fs_dir_open(&dir, NULL));
|
||||
}
|
||||
|
||||
void test_fs_args_dir_read_invalid_handle(void)
|
||||
{
|
||||
char filename[256];
|
||||
lv_fs_dir_t invalid_dir = {0};
|
||||
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_INV_PARAM, lv_fs_dir_read(&invalid_dir, filename, sizeof(filename)));
|
||||
TEST_ASSERT_EQUAL_CHAR('\0', filename[0]);
|
||||
}
|
||||
|
||||
void test_fs_args_dir_read_zero_length_buffer(void)
|
||||
{
|
||||
char filename[256];
|
||||
lv_fs_dir_t dir;
|
||||
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_OK, lv_fs_dir_open(&dir, "A:src/test_files"));
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_INV_PARAM, lv_fs_dir_read(&dir, filename, 0));
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_OK, lv_fs_dir_close(&dir));
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,28 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
#if LV_USE_GSTREAMER
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
void test_gstreamer_stream_state_of_invalid_event(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL(LV_GSTREAMER_STREAM_STATE_INVALID, lv_gstreamer_get_stream_state(NULL));
|
||||
}
|
||||
|
||||
#else /*LV_USE_GSTREAMER*/
|
||||
|
||||
void setUp(void) { }
|
||||
void tearDown(void) { }
|
||||
void test_gstreamer_stream_state_of_invalid_event(void) { }
|
||||
|
||||
#endif /*LV_USE_GSTREAMER*/
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,25 @@
|
||||
#if LV_BUILD_TEST
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
#if LV_USE_ST7796
|
||||
/*ST7796 has no gamma curve support, so the setter is a no-op even with a
|
||||
*display; with a NULL one there is nothing to reject either*/
|
||||
void test_lcd_args_st7796_set_gamma_curve_null_display(void)
|
||||
{
|
||||
lv_st7796_set_gamma_curve(NULL, 0);
|
||||
TEST_PASS();
|
||||
}
|
||||
#else
|
||||
void test_lcd_args_st7796_set_gamma_curve_null_display(void) { }
|
||||
#endif /*LV_USE_ST7796*/
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,36 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
static lv_ll_t test_ll;
|
||||
|
||||
#define NODE_SIZE sizeof(int32_t)
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
lv_ll_init(&test_ll, NODE_SIZE);
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_ll_clear(&test_ll);
|
||||
}
|
||||
|
||||
void test_ll_args_is_empty_null_list(void)
|
||||
{
|
||||
TEST_ASSERT_TRUE(lv_ll_is_empty(NULL));
|
||||
}
|
||||
|
||||
void test_ll_args_null_list_handling(void)
|
||||
{
|
||||
TEST_ASSERT_NULL(lv_ll_ins_prev(NULL, NULL));
|
||||
TEST_ASSERT_NULL(lv_ll_ins_prev(&test_ll, NULL));
|
||||
|
||||
lv_ll_remove(NULL, NULL);
|
||||
|
||||
TEST_ASSERT_NULL(lv_ll_get_head(NULL));
|
||||
TEST_ASSERT_NULL(lv_ll_get_tail(NULL));
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,34 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
void test_mem_add_pool_size_limits(void)
|
||||
{
|
||||
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
|
||||
const size_t overhead = lv_tlsf_pool_overhead();
|
||||
const size_t block_max = lv_tlsf_block_size_max();
|
||||
uint32_t mem = lv_test_get_free_mem();
|
||||
|
||||
void * pool_mem = malloc(overhead + block_max);
|
||||
TEST_ASSERT_NOT_NULL(pool_mem);
|
||||
|
||||
/* A pool of exactly block_size_max would index sl_bitmap out of bounds */
|
||||
TEST_ASSERT_NULL(lv_mem_add_pool(pool_mem, overhead + block_max));
|
||||
TEST_ASSERT_NULL(lv_mem_add_pool(pool_mem, SIZE_MAX));
|
||||
TEST_ASSERT_NULL(lv_mem_add_pool(pool_mem, overhead + lv_tlsf_block_size_min() - 1));
|
||||
TEST_ASSERT_NULL(lv_mem_add_pool(pool_mem, 0));
|
||||
|
||||
/* One word less is the largest pool the range check accepts */
|
||||
lv_mem_pool_t pool = lv_mem_add_pool(pool_mem, overhead + block_max - lv_tlsf_align_size());
|
||||
TEST_ASSERT_NOT_NULL(pool);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_mem_test());
|
||||
|
||||
lv_mem_remove_pool(pool);
|
||||
free(pool_mem);
|
||||
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_mem_test());
|
||||
TEST_ASSERT_MEM_LEAK_LESS_THAN(mem, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,256 @@
|
||||
#if LV_BUILD_TEST == 1
|
||||
#include "../../lvgl_private.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
static uint32_t observer_called = 0;
|
||||
|
||||
/* Subjects are owned by LVGL, so every case registers the ones it creates here
|
||||
* and tearDown() deletes them. */
|
||||
static lv_subject_t * subjects[16] = {NULL};
|
||||
|
||||
static lv_subject_t * subject_create(lv_subject_type_t type)
|
||||
{
|
||||
for(size_t i = 0; i < LV_ARRAYLEN(subjects); ++i) {
|
||||
if(subjects[i] == NULL) {
|
||||
subjects[i] = lv_subject_create(type);
|
||||
TEST_ASSERT_NOT_NULL(subjects[i]);
|
||||
return subjects[i];
|
||||
}
|
||||
}
|
||||
TEST_FAIL_MESSAGE("subject pool exhausted");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void observer_int(lv_observer_t * observer, lv_subject_t * subject)
|
||||
{
|
||||
LV_UNUSED(observer);
|
||||
LV_UNUSED(subject);
|
||||
observer_called++;
|
||||
}
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
observer_called = 0;
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_obj_clean(lv_screen_active());
|
||||
|
||||
/* Group Subjects first: deleting a group dereferences its elements, so the
|
||||
* elements have to outlive it. */
|
||||
for(size_t i = 0; i < LV_ARRAYLEN(subjects); ++i) {
|
||||
if(subjects[i] && subjects[i]->type == LV_SUBJECT_TYPE_GROUP) {
|
||||
lv_subject_delete(subjects[i]);
|
||||
subjects[i] = NULL;
|
||||
}
|
||||
}
|
||||
for(size_t i = 0; i < LV_ARRAYLEN(subjects); ++i) {
|
||||
lv_subject_delete(subjects[i]);
|
||||
subjects[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*A setter for the wrong type leaves the value and the observers alone*/
|
||||
void test_observer_args_int_setters_of_other_types_are_ignored(void)
|
||||
{
|
||||
lv_subject_t * subject = subject_create(LV_SUBJECT_TYPE_INT);
|
||||
lv_subject_set_int(subject, 15);
|
||||
lv_subject_add_observer(subject, observer_int, NULL);
|
||||
observer_called = 0;
|
||||
|
||||
lv_subject_set_pointer(subject, NULL);
|
||||
lv_subject_set_color(subject, lv_color_black());
|
||||
lv_subject_set_string(subject, "hello");
|
||||
|
||||
TEST_ASSERT_EQUAL(15, lv_subject_get_int(subject));
|
||||
TEST_ASSERT_EQUAL(0, observer_called);
|
||||
}
|
||||
|
||||
void test_observer_args_float_setters_of_other_types_are_ignored(void)
|
||||
{
|
||||
lv_subject_t * subject = subject_create(LV_SUBJECT_TYPE_FLOAT);
|
||||
lv_subject_set_float(subject, 15.75f);
|
||||
lv_subject_add_observer(subject, observer_int, NULL);
|
||||
observer_called = 0;
|
||||
|
||||
lv_subject_set_pointer(subject, NULL);
|
||||
lv_subject_set_color(subject, lv_color_black());
|
||||
lv_subject_set_string(subject, "hello");
|
||||
|
||||
TEST_ASSERT_EQUAL_FLOAT(15.75, lv_subject_get_float(subject));
|
||||
TEST_ASSERT_EQUAL(0, observer_called);
|
||||
}
|
||||
|
||||
void test_observer_args_string_setters_of_other_types_are_ignored(void)
|
||||
{
|
||||
static char buf_current[32];
|
||||
static char buf_previous[32];
|
||||
lv_subject_t * subject = subject_create(LV_SUBJECT_TYPE_STRING);
|
||||
lv_subject_set_string_buffer_static(subject, buf_current, buf_previous, sizeof(buf_current));
|
||||
lv_subject_set_string(subject, "a");
|
||||
lv_subject_add_observer(subject, observer_int, NULL);
|
||||
observer_called = 0;
|
||||
|
||||
lv_subject_set_pointer(subject, NULL);
|
||||
lv_subject_set_color(subject, lv_color_black());
|
||||
lv_subject_set_int(subject, 10);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("a", lv_subject_get_string(subject));
|
||||
TEST_ASSERT_EQUAL(0, observer_called);
|
||||
}
|
||||
|
||||
void test_observer_args_color_setters_of_other_types_are_ignored(void)
|
||||
{
|
||||
lv_subject_t * subject = subject_create(LV_SUBJECT_TYPE_COLOR);
|
||||
lv_subject_set_color(subject, lv_color_hex3(0xabc));
|
||||
lv_subject_add_observer(subject, observer_int, NULL);
|
||||
observer_called = 0;
|
||||
|
||||
lv_subject_set_pointer(subject, NULL);
|
||||
lv_subject_set_int(subject, 10);
|
||||
lv_subject_set_string(subject, "hello");
|
||||
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_hex3(0xabc), lv_subject_get_color(subject));
|
||||
TEST_ASSERT_EQUAL(0, observer_called);
|
||||
}
|
||||
|
||||
void test_observer_args_pointer_setters_of_other_types_are_ignored(void)
|
||||
{
|
||||
static const int a[] = {1, 2, 3};
|
||||
lv_subject_t * subject = subject_create(LV_SUBJECT_TYPE_POINTER);
|
||||
lv_subject_set_pointer(subject, (void *)&a[2]);
|
||||
lv_subject_add_observer(subject, observer_int, NULL);
|
||||
observer_called = 0;
|
||||
|
||||
lv_subject_set_int(subject, 10);
|
||||
lv_subject_set_color(subject, lv_color_black());
|
||||
lv_subject_set_string(subject, "hello");
|
||||
|
||||
TEST_ASSERT_EQUAL_PTR(&a[2], lv_subject_get_pointer(subject));
|
||||
TEST_ASSERT_EQUAL(0, observer_called);
|
||||
}
|
||||
|
||||
/*An index past the end of the group reports no element*/
|
||||
void test_observer_args_group_element_out_of_range(void)
|
||||
{
|
||||
static lv_subject_t * list[2];
|
||||
for(uint32_t i = 0; i < LV_ARRAYLEN(list); i++) {
|
||||
list[i] = subject_create(LV_SUBJECT_TYPE_INT);
|
||||
lv_subject_set_int(list[i], (int32_t)i + 1);
|
||||
}
|
||||
|
||||
lv_subject_t * group_subject = subject_create(LV_SUBJECT_TYPE_GROUP);
|
||||
lv_subject_set_group_list_static(group_subject, list, 2);
|
||||
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, lv_subject_get_group_element(group_subject, 2));
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, lv_subject_get_group_element(group_subject, 1000));
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, lv_subject_get_group_element(group_subject, -1));
|
||||
}
|
||||
|
||||
/*A subject that was never initialised has no type to observe*/
|
||||
void test_observer_args_add_observer_to_uninitialized_subject(void)
|
||||
{
|
||||
static lv_subject_t uninitialized_subject;
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, lv_subject_add_observer(&uninitialized_subject, observer_int, NULL));
|
||||
}
|
||||
|
||||
/*lv_obj_bind_checked() only accepts an int subject*/
|
||||
void test_observer_args_bind_checked_to_non_int_subject(void)
|
||||
{
|
||||
lv_obj_t * obj = lv_button_create(lv_screen_active());
|
||||
lv_obj_set_checkable(obj, true);
|
||||
|
||||
lv_subject_t * subject_wrong = subject_create(LV_SUBJECT_TYPE_POINTER);
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, lv_obj_bind_checked(obj, subject_wrong));
|
||||
}
|
||||
|
||||
/*A string setter on a pointer subject changes nothing, so a bound label stays put*/
|
||||
void test_observer_args_set_string_to_pointer_subject_is_ignored(void)
|
||||
{
|
||||
lv_obj_t * obj = lv_label_create(lv_screen_active());
|
||||
lv_subject_t * subject_pointer = subject_create(LV_SUBJECT_TYPE_POINTER);
|
||||
lv_subject_set_pointer(subject_pointer, "HELLO");
|
||||
lv_label_bind_text(obj, subject_pointer, NULL);
|
||||
TEST_ASSERT_EQUAL_STRING("HELLO", lv_label_get_text(obj));
|
||||
|
||||
lv_subject_set_string(subject_pointer, "NOTHING");
|
||||
TEST_ASSERT_EQUAL_STRING("HELLO", lv_label_get_text(obj));
|
||||
}
|
||||
|
||||
void test_observer_obj_bind_bool_invalid(void)
|
||||
{
|
||||
lv_obj_t * obj = lv_obj_create(lv_screen_active());
|
||||
|
||||
lv_subject_t * subject = subject_create(LV_SUBJECT_TYPE_INT);
|
||||
lv_subject_set_int(subject, 0);
|
||||
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, lv_obj_bind_bool(NULL, subject, lv_obj_set_hidden));
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, lv_obj_bind_bool(obj, NULL, lv_obj_set_hidden));
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, lv_obj_bind_bool(obj, subject, NULL));
|
||||
|
||||
lv_obj_delete(obj);
|
||||
}
|
||||
|
||||
void test_observer_obj_flag_invalid_subject(void)
|
||||
{
|
||||
LV_DEPRECATIONS_IGNORE_BEGIN
|
||||
typedef lv_observer_t * (*lv_obj_bind_flag_fn)(
|
||||
lv_obj_t *, lv_subject_t *, lv_obj_flag_t, int32_t);
|
||||
static const lv_obj_bind_flag_fn fns[] = {
|
||||
lv_obj_bind_flag_if_eq, lv_obj_bind_flag_if_not_eq,
|
||||
lv_obj_bind_flag_if_ge, lv_obj_bind_flag_if_gt,
|
||||
lv_obj_bind_flag_if_lt, lv_obj_bind_flag_if_le,
|
||||
};
|
||||
LV_DEPRECATIONS_IGNORE_END
|
||||
|
||||
lv_obj_t * obj = lv_obj_create(lv_screen_active());
|
||||
|
||||
|
||||
/* Can only bind to int */
|
||||
lv_subject_t * invalid[4];
|
||||
invalid[0] = subject_create(LV_SUBJECT_TYPE_POINTER);
|
||||
invalid[1] = subject_create(LV_SUBJECT_TYPE_STRING);
|
||||
invalid[2] = subject_create(LV_SUBJECT_TYPE_COLOR);
|
||||
invalid[3] = subject_create(LV_SUBJECT_TYPE_GROUP);
|
||||
|
||||
for(size_t i = 0; i < LV_ARRAYLEN(fns); ++i) {
|
||||
for(size_t j = 0; j < LV_ARRAYLEN(invalid); ++j) {
|
||||
TEST_ASSERT_EQUAL_PTR(NULL,
|
||||
fns[i](obj, invalid[j],
|
||||
LV_OBJ_FLAG_HIDDEN, 5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_observer_obj_state_invalid_subject(void)
|
||||
{
|
||||
LV_DEPRECATIONS_IGNORE_BEGIN
|
||||
typedef lv_observer_t * (*lv_obj_bind_state_fn)(
|
||||
lv_obj_t *, lv_subject_t *, lv_state_t, int32_t);
|
||||
|
||||
static const lv_obj_bind_state_fn fns[] = {
|
||||
lv_obj_bind_state_if_eq, lv_obj_bind_state_if_not_eq,
|
||||
lv_obj_bind_state_if_ge, lv_obj_bind_state_if_gt,
|
||||
lv_obj_bind_state_if_lt, lv_obj_bind_state_if_le,
|
||||
};
|
||||
lv_obj_t * obj = lv_obj_create(lv_screen_active());
|
||||
|
||||
/* Can only bind to int */
|
||||
lv_subject_t * invalid[4];
|
||||
invalid[0] = subject_create(LV_SUBJECT_TYPE_POINTER);
|
||||
invalid[1] = subject_create(LV_SUBJECT_TYPE_STRING);
|
||||
invalid[2] = subject_create(LV_SUBJECT_TYPE_COLOR);
|
||||
invalid[3] = subject_create(LV_SUBJECT_TYPE_GROUP);
|
||||
|
||||
for(size_t i = 0; i < LV_ARRAYLEN(fns); ++i) {
|
||||
for(size_t j = 0; j < LV_ARRAYLEN(invalid); ++j) {
|
||||
TEST_ASSERT_EQUAL_PTR(
|
||||
NULL, fns[i](obj, invalid[j], 0, 5));
|
||||
}
|
||||
}
|
||||
LV_DEPRECATIONS_IGNORE_END
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,64 @@
|
||||
#if LV_BUILD_TEST
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* Test lv_palette_main with invalid palette */
|
||||
void test_palette_main_invalid(void)
|
||||
{
|
||||
lv_color_t color = lv_palette_main(LV_PALETTE_LAST);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
|
||||
color = lv_palette_main(LV_PALETTE_NONE);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
}
|
||||
|
||||
/* Test lv_palette_main with out-of-range palette index */
|
||||
void test_palette_main_out_of_range(void)
|
||||
{
|
||||
lv_color_t color = lv_palette_main(LV_PALETTE_LAST + 1);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
}
|
||||
|
||||
/* Test lv_palette_lighten with invalid levels */
|
||||
void test_palette_lighten_invalid(void)
|
||||
{
|
||||
lv_color_t color = lv_palette_lighten(LV_PALETTE_RED, 0);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
|
||||
color = lv_palette_lighten(LV_PALETTE_RED, 6);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
}
|
||||
|
||||
/* Test lv_palette_lighten with out-of-range palette index */
|
||||
void test_palette_lighten_out_of_range(void)
|
||||
{
|
||||
lv_color_t color = lv_palette_lighten(LV_PALETTE_LAST + 1, 1);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
}
|
||||
|
||||
/* Test lv_palette_darken with invalid levels */
|
||||
void test_palette_darken_invalid(void)
|
||||
{
|
||||
lv_color_t color = lv_palette_darken(LV_PALETTE_RED, 0);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
|
||||
color = lv_palette_darken(LV_PALETTE_RED, 5);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
}
|
||||
|
||||
/* Test lv_palette_darken with out-of-range palette index */
|
||||
void test_palette_darken_out_of_range(void)
|
||||
{
|
||||
lv_color_t color = lv_palette_darken(LV_PALETTE_LAST + 1, 1);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,67 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../../lvgl_private.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
#if LV_USE_QRCODE
|
||||
#include "../../../src/libs/qrcode/qrcodegen.h"
|
||||
|
||||
static lv_obj_t * active_screen = NULL;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
active_screen = lv_screen_active();
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_obj_clean(active_screen);
|
||||
}
|
||||
|
||||
void test_qrcode_set_data_ignores_null(void)
|
||||
{
|
||||
lv_obj_t * qr = lv_qrcode_create(active_screen);
|
||||
TEST_ASSERT_NOT_NULL(qr);
|
||||
lv_qrcode_set_size(qr, 150);
|
||||
lv_qrcode_set_data(qr, "https://lvgl.io");
|
||||
TEST_ASSERT_TRUE(lv_qrcode_is_render_valid(qr));
|
||||
|
||||
/*A NULL string is a no-op, not a crash, and leaves the stored payload alone.
|
||||
*The guard is unconditional because lv_strlen() would dereference it even when
|
||||
*argument checks are compiled out.*/
|
||||
lv_qrcode_set_data(qr, NULL);
|
||||
TEST_ASSERT_TRUE(lv_qrcode_is_render_valid(qr));
|
||||
TEST_ASSERT_EQUAL(15, ((lv_qrcode_t *)qr)->data_len);
|
||||
}
|
||||
|
||||
void test_qrcode_update_rejects_invalid_arguments(void)
|
||||
{
|
||||
/*The bound is enforced by LV_CHECK_ARG, which compiles to nothing when disabled.
|
||||
*The guard is inside the function because the Unity runner generator ignores
|
||||
*preprocessor directives and would reference a non-existent symbol otherwise.*/
|
||||
#if LV_USE_CHECK_ARG
|
||||
lv_obj_t * qr = lv_qrcode_create(active_screen);
|
||||
TEST_ASSERT_NOT_NULL(qr);
|
||||
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_qrcode_update(qr, NULL, 4));
|
||||
|
||||
/*More bytes than any QR code can hold is rejected before anything is stored*/
|
||||
static char over_len[qrcodegen_BUFFER_LEN_MAX + 1];
|
||||
lv_memset(over_len, 'a', sizeof(over_len));
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_qrcode_update(qr, over_len, qrcodegen_BUFFER_LEN_MAX + 1));
|
||||
|
||||
/*A previously set payload survives a rejected call*/
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_qrcode_update(qr, "https://lvgl.io", 15));
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_qrcode_update(qr, over_len, qrcodegen_BUFFER_LEN_MAX + 1));
|
||||
#endif /*LV_USE_CHECK_ARG*/
|
||||
}
|
||||
|
||||
#else /*LV_USE_QRCODE*/
|
||||
|
||||
void setUp(void) { }
|
||||
void tearDown(void) { }
|
||||
void test_qrcode_set_data_ignores_null(void) { }
|
||||
void test_qrcode_update_rejects_invalid_arguments(void) { }
|
||||
|
||||
#endif /*LV_USE_QRCODE*/
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,33 @@
|
||||
#if LV_BUILD_TEST
|
||||
|
||||
#include "refr/lv_test_refr.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
refr_ctx_reset();
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
refr_disp_delete();
|
||||
}
|
||||
|
||||
void test_refr_top_obj_invalid_arguments(void)
|
||||
{
|
||||
refr_disp_create(64, 64, LV_COLOR_FORMAT_XRGB8888, LV_DISPLAY_RENDER_MODE_DIRECT, 1, 64);
|
||||
lv_area_t area = {0, 0, 9, 9};
|
||||
TEST_ASSERT_NULL(lv_refr_get_top_obj(NULL, refr_screen()));
|
||||
TEST_ASSERT_NULL(lv_refr_get_top_obj(&area, NULL));
|
||||
}
|
||||
|
||||
void test_refr_obj_redraw_invalid_arguments(void)
|
||||
{
|
||||
refr_disp_create(64, 64, LV_COLOR_FORMAT_XRGB8888, LV_DISPLAY_RENDER_MODE_DIRECT, 1, 64);
|
||||
lv_layer_t layer;
|
||||
lv_obj_redraw(NULL, refr_screen());
|
||||
lv_obj_redraw(&layer, NULL);
|
||||
lv_obj_refr(NULL, refr_screen());
|
||||
lv_obj_refr(&layer, NULL);
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,31 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl_private.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_obj_clean(lv_screen_active());
|
||||
}
|
||||
|
||||
void test_snapshot_reshape_draw_buf_invalid_params(void)
|
||||
{
|
||||
lv_obj_t * obj = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(obj, 50, 40);
|
||||
|
||||
/* Create initial draw buffer */
|
||||
lv_draw_buf_t * draw_buf = lv_draw_buf_create(50, 40, LV_COLOR_FORMAT_ARGB8888, LV_STRIDE_AUTO);
|
||||
TEST_ASSERT_NOT_NULL(draw_buf);
|
||||
|
||||
/* Only test NULL buffer, not NULL object (function asserts obj != NULL internally) */
|
||||
lv_result_t result = lv_snapshot_reshape_draw_buf(obj, NULL);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
lv_draw_buf_destroy(draw_buf);
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,51 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
#include "../../lvgl_private.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
static lv_obj_t * spangroup = NULL;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
spangroup = lv_spangroup_create(NULL);
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_obj_delete(spangroup);
|
||||
spangroup = NULL;
|
||||
lv_obj_clean(lv_screen_active());
|
||||
}
|
||||
|
||||
void test_spangroup_new_span_with_null_parameter_returns_null_object(void)
|
||||
{
|
||||
lv_span_t * span = lv_spangroup_add_span(NULL);
|
||||
|
||||
TEST_ASSERT(NULL == span);
|
||||
TEST_ASSERT_EQUAL_INT(0, lv_spangroup_get_span_count(spangroup));
|
||||
}
|
||||
|
||||
void test_span_set_text_with_bad_parameter_no_action_performed(void)
|
||||
{
|
||||
const char * test_text = "Test Text";
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
|
||||
lv_span_set_text(span, test_text);
|
||||
lv_span_set_text(span, NULL);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING(span->txt, test_text);
|
||||
}
|
||||
|
||||
void test_span_set_text_static_with_bad_parameter_no_action_performed(void)
|
||||
{
|
||||
const char * test_text = "Test Text";
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
|
||||
lv_span_set_text_static(span, test_text);
|
||||
lv_span_set_text_static(span, NULL);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING(span->txt, test_text);
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,23 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
}
|
||||
|
||||
void test_theme_args_set_user_data_null_theme(void)
|
||||
{
|
||||
int dummy = 42;
|
||||
|
||||
/*No theme to store it on, so the call is a no-op rather than a crash*/
|
||||
lv_theme_set_user_data(NULL, &dummy);
|
||||
TEST_PASS();
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -0,0 +1,60 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
lv_translation_deinit();
|
||||
lv_translation_init();
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_obj_clean(lv_screen_active());
|
||||
}
|
||||
|
||||
static const char * const languages[] = {"en", "de", "es", NULL};
|
||||
static const char * const tags[] = {"tiger", "lion", NULL};
|
||||
static const char * const translations[] = {
|
||||
"The Tiger", "Der Tiger", "El Tigre",
|
||||
"The Lion", "Der Löwe", "El León",
|
||||
};
|
||||
|
||||
/* A static pack rejects every mutation, it is built from constant data */
|
||||
static lv_translation_pack_t * add_animals_pack(void)
|
||||
{
|
||||
return lv_translation_add_static(languages, tags, translations);
|
||||
}
|
||||
|
||||
void test_static_pack_rejects_add_tag(void)
|
||||
{
|
||||
lv_translation_pack_t * pack = add_animals_pack();
|
||||
TEST_ASSERT_NULL(lv_translation_add_tag(pack, "zebra"));
|
||||
}
|
||||
|
||||
void test_static_pack_rejects_set_tag_translation(void)
|
||||
{
|
||||
lv_translation_pack_t * static_pack = add_animals_pack();
|
||||
|
||||
/* A valid tag descriptor is needed, borrow one from a dynamic pack */
|
||||
lv_translation_pack_t * dynamic_pack = lv_translation_add_dynamic();
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_translation_add_language(dynamic_pack, "en"));
|
||||
lv_translation_tag_dsc_t * tag = lv_translation_add_tag(dynamic_pack, "cat");
|
||||
TEST_ASSERT_NOT_NULL(tag);
|
||||
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_translation_set_tag_translation(static_pack, tag, 0, "The Cat"));
|
||||
}
|
||||
|
||||
void test_set_tag_translation_rejects_out_of_range_language(void)
|
||||
{
|
||||
lv_translation_pack_t * pack = lv_translation_add_dynamic();
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_translation_add_language(pack, "en"));
|
||||
|
||||
lv_translation_tag_dsc_t * tag = lv_translation_add_tag(pack, "cat");
|
||||
TEST_ASSERT_NOT_NULL(tag);
|
||||
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_translation_set_tag_translation(pack, tag, 1, "Die Katze"));
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
@@ -190,14 +190,4 @@ void test_refr_display_deleted_in_refr_start(void)
|
||||
TEST_ASSERT_NULL(refr_ctx.disp);
|
||||
}
|
||||
|
||||
void test_refr_obj_redraw_invalid_arguments(void)
|
||||
{
|
||||
refr_disp_create(64, 64, LV_COLOR_FORMAT_XRGB8888, LV_DISPLAY_RENDER_MODE_DIRECT, 1, 64);
|
||||
lv_layer_t layer;
|
||||
lv_obj_redraw(NULL, refr_screen());
|
||||
lv_obj_redraw(&layer, NULL);
|
||||
lv_obj_refr(NULL, refr_screen());
|
||||
lv_obj_refr(&layer, NULL);
|
||||
}
|
||||
|
||||
#endif /*LV_BUILD_TEST*/
|
||||
|
||||
@@ -15,14 +15,6 @@ void tearDown(void)
|
||||
refr_disp_delete();
|
||||
}
|
||||
|
||||
void test_refr_top_obj_invalid_arguments(void)
|
||||
{
|
||||
refr_disp_create(64, 64, LV_COLOR_FORMAT_XRGB8888, LV_DISPLAY_RENDER_MODE_DIRECT, 1, 64);
|
||||
lv_area_t area = {0, 0, 9, 9};
|
||||
TEST_ASSERT_NULL(lv_refr_get_top_obj(NULL, refr_screen()));
|
||||
TEST_ASSERT_NULL(lv_refr_get_top_obj(&area, NULL));
|
||||
}
|
||||
|
||||
void test_refr_top_obj_finds_the_covering_object(void)
|
||||
{
|
||||
refr_disp_create(64, 64, LV_COLOR_FORMAT_XRGB8888, LV_DISPLAY_RENDER_MODE_DIRECT, 1, 64);
|
||||
|
||||
@@ -15,7 +15,9 @@ void setUp(void)
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
#if LV_DRAW_TRANSFORM_USE_MATRIX
|
||||
lv_display_set_matrix_rotation(lv_display_get_default(), false);
|
||||
#endif
|
||||
lv_obj_clean(lv_screen_active());
|
||||
lv_obj_clean(lv_layer_top());
|
||||
lv_obj_clean(lv_layer_sys());
|
||||
@@ -395,13 +397,6 @@ void test_display_resolution(void)
|
||||
lv_display_set_offset(lv_display_get_default(), 1, 2);
|
||||
test_display_resolution_full_rotation(disp, 32, 48, 24, 32, 1, 2);
|
||||
|
||||
/* Test NULL default display, should not affect the display */
|
||||
lv_display_set_default(NULL);
|
||||
lv_display_set_resolution(lv_display_get_default(), 2, 3);
|
||||
lv_display_set_physical_resolution(lv_display_get_default(), 4, 5);
|
||||
lv_display_set_offset(lv_display_get_default(), 6, 7);
|
||||
test_display_resolution_full_rotation(disp, 32, 48, 24, 32, 1, 2);
|
||||
test_display_resolution_full_rotation(lv_display_get_default(), 0, 0, 0, 0, 0, 0);
|
||||
|
||||
/* Restore default display */
|
||||
lv_display_set_default(disp_def);
|
||||
@@ -450,16 +445,6 @@ void test_display_dpi_tile_cnt_antialiasing(void)
|
||||
lv_display_set_tile_cnt(lv_display_get_default(), 20);
|
||||
TEST_ASSERT_EQUAL_INT32(20, lv_display_get_tile_cnt(lv_display_get_default()));
|
||||
|
||||
/* Test NULL default display, should not affect the display */
|
||||
lv_display_set_default(NULL);
|
||||
lv_display_set_dpi(lv_display_get_default(), 200);
|
||||
TEST_ASSERT_EQUAL_INT32(LV_DPI_DEF, lv_display_get_dpi(lv_display_get_default()));
|
||||
lv_display_set_antialiasing(lv_display_get_default(), false);
|
||||
TEST_ASSERT_FALSE(lv_display_get_antialiasing(lv_display_get_default()));
|
||||
lv_display_set_antialiasing(lv_display_get_default(), true);
|
||||
TEST_ASSERT_FALSE(lv_display_get_antialiasing(lv_display_get_default()));
|
||||
lv_display_set_tile_cnt(lv_display_get_default(), 20);
|
||||
TEST_ASSERT_EQUAL_INT32(0, lv_display_get_tile_cnt(lv_display_get_default()));
|
||||
|
||||
/* Restore default display */
|
||||
lv_display_set_default(disp_def);
|
||||
@@ -554,12 +539,6 @@ void test_display_layers(void)
|
||||
TEST_ASSERT_NOT_NULL(lv_display_get_layer_sys(lv_display_get_default()));
|
||||
TEST_ASSERT_NOT_NULL(lv_display_get_layer_bottom(lv_display_get_default()));
|
||||
|
||||
lv_display_set_default(NULL);
|
||||
TEST_ASSERT_NULL(lv_display_get_screen_active(lv_display_get_default()));
|
||||
TEST_ASSERT_NULL(lv_display_get_screen_prev(lv_display_get_default()));
|
||||
TEST_ASSERT_NULL(lv_display_get_layer_top(lv_display_get_default()));
|
||||
TEST_ASSERT_NULL(lv_display_get_layer_sys(lv_display_get_default()));
|
||||
TEST_ASSERT_NULL(lv_display_get_layer_bottom(lv_display_get_default()));
|
||||
|
||||
lv_display_set_default(disp_def);
|
||||
}
|
||||
@@ -576,11 +555,6 @@ void test_display_active_time(void)
|
||||
lv_tick_inc(1000);
|
||||
TEST_ASSERT_EQUAL_UINT32(1000, lv_display_get_inactive_time(lv_display_get_default()));
|
||||
|
||||
/* Test NULL default display, should not affect the display */
|
||||
lv_display_set_default(NULL);
|
||||
lv_display_trigger_activity(lv_display_get_default());
|
||||
lv_tick_inc(1000);
|
||||
TEST_ASSERT_EQUAL_UINT32(2000, lv_display_get_inactive_time(lv_display_get_default()));
|
||||
|
||||
lv_display_set_default(disp_def);
|
||||
}
|
||||
|
||||
@@ -345,25 +345,16 @@ static void cb_check_invalidated_area(lv_event_t * e)
|
||||
last_param = area;
|
||||
}
|
||||
|
||||
static void cb_invalidated_area_wrong_code(lv_event_t * e)
|
||||
{
|
||||
call_cnt++;
|
||||
TEST_ASSERT_NULL(lv_event_get_invalidated_area(e));
|
||||
}
|
||||
|
||||
void test_display_event_get_invalidated_area(void)
|
||||
{
|
||||
lv_area_t area = { 1, 2, 3, 4 };
|
||||
|
||||
lv_display_add_event_cb(test_disp, cb_check_invalidated_area, LV_EVENT_INVALIDATE_AREA, NULL);
|
||||
lv_display_add_event_cb(test_disp, cb_invalidated_area_wrong_code, LV_EVENT_REFR_START, NULL);
|
||||
|
||||
lv_display_send_event(test_disp, LV_EVENT_INVALIDATE_AREA, &area);
|
||||
TEST_ASSERT_EQUAL_UINT32(1, call_cnt);
|
||||
TEST_ASSERT_EQUAL_PTR(&area, last_param);
|
||||
|
||||
lv_display_send_event(test_disp, LV_EVENT_REFR_START, NULL);
|
||||
TEST_ASSERT_EQUAL_UINT32(2, call_cnt);
|
||||
}
|
||||
|
||||
/* The handler of LV_EVENT_INVALIDATE_AREA may enlarge the area, and the
|
||||
|
||||
@@ -189,10 +189,6 @@ void test_draw_buf_xy_access(void)
|
||||
|
||||
uint8_t * ret = lv_draw_buf_goto_xy(&draw_buf, 50, 50);
|
||||
TEST_ASSERT_NOT_NULL(ret);
|
||||
ret = lv_draw_buf_goto_xy(&draw_buf, 100, 100);
|
||||
TEST_ASSERT_NULL(ret);
|
||||
ret = lv_draw_buf_goto_xy(&draw_buf, -10, -10);
|
||||
TEST_ASSERT_NULL(ret);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,11 @@ void test_event_object_deletion(void)
|
||||
lv_obj_send_event(obj, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
}
|
||||
|
||||
static void event_noop_cb(lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(e);
|
||||
}
|
||||
|
||||
/* Add and then remove event should not memory leak */
|
||||
void test_event_should_not_memory_lean(void)
|
||||
{
|
||||
@@ -33,7 +38,7 @@ void test_event_should_not_memory_lean(void)
|
||||
size_t initial_free_size = monitor.free_size;
|
||||
|
||||
for(int i = 0; i < 10; i++) {
|
||||
lv_obj_add_event_cb(obj, NULL, LV_EVENT_ALL, NULL);
|
||||
lv_obj_add_event_cb(obj, event_noop_cb, LV_EVENT_ALL, NULL);
|
||||
}
|
||||
|
||||
lv_obj_delete(obj);
|
||||
@@ -137,7 +142,6 @@ void test_event_delete_obj_in_recursive_event_call(void)
|
||||
lv_obj_t * obj = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(obj, 200, 100);
|
||||
lv_obj_add_event_cb(obj, event_click_to_delete_cb, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_add_event_cb(obj, NULL, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_add_event_cb(obj, event_click_to_delete_cb, LV_EVENT_CLICKED, NULL);
|
||||
lv_test_mouse_click_at(30, 30);
|
||||
}
|
||||
|
||||
@@ -296,8 +296,7 @@ void test_fs_open(void)
|
||||
/*'T' has cache*/
|
||||
lv_fs_file_t fa;
|
||||
lv_fs_res_t res;
|
||||
res = lv_fs_open(&fa, NULL, LV_FS_MODE_RD);
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_INV_PARAM, res);
|
||||
|
||||
|
||||
lv_test_fs_set_ready(false);
|
||||
res = lv_fs_open(&fa, "T:src/test_files/readtest.txt", LV_FS_MODE_RD);
|
||||
@@ -408,9 +407,6 @@ void test_fs_path_get_size(void)
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_OK, res);
|
||||
TEST_ASSERT_EQUAL_UINT32(expected_size, size);
|
||||
|
||||
/* Test error cases */
|
||||
res = lv_fs_path_get_size(NULL, &size);
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_INV_PARAM, res);
|
||||
|
||||
/* Test with non-existent file */
|
||||
res = lv_fs_path_get_size("A:src/test_files/nonexistent.txt", &size);
|
||||
@@ -455,9 +451,6 @@ void test_fs_dir_open(void)
|
||||
lv_fs_res_t res;
|
||||
lv_fs_dir_t dir;
|
||||
|
||||
/* Test with NULL path */
|
||||
res = lv_fs_dir_open(&dir, NULL);
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_INV_PARAM, res);
|
||||
|
||||
/* Test with drive 'A' (has cache) */
|
||||
res = lv_fs_dir_open(&dir, "A:src/test_files");
|
||||
@@ -490,18 +483,6 @@ void test_fs_dir_read(void)
|
||||
lv_fs_dir_t dir;
|
||||
char filename[256];
|
||||
|
||||
/* Test with invalid directory handle */
|
||||
lv_fs_dir_t invalid_dir = {0};
|
||||
res = lv_fs_dir_read(&invalid_dir, filename, sizeof(filename));
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_INV_PARAM, res);
|
||||
TEST_ASSERT_EQUAL_CHAR('\0', filename[0]);
|
||||
|
||||
/* Test with zero buffer length */
|
||||
res = lv_fs_dir_open(&dir, "A:src/test_files");
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_OK, res);
|
||||
res = lv_fs_dir_read(&dir, filename, 0);
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_INV_PARAM, res);
|
||||
TEST_ASSERT_EQUAL(LV_FS_RES_OK, lv_fs_dir_close(&dir));
|
||||
|
||||
/* Test normal directory reading with drive 'A' */
|
||||
res = lv_fs_dir_open(&dir, "A:src/test_files");
|
||||
|
||||
@@ -212,8 +212,6 @@ void test_lcd_st7796(void)
|
||||
test_lcd_generic_mipi(lv_st7796_create, lv_st7796_set_gap, lv_st7796_set_invert, NULL,
|
||||
lv_st7796_send_cmd_list);
|
||||
|
||||
/* NOTE: lv_st7796_set_gamma_curve is not supported, the setting should have no effect */
|
||||
lv_st7796_set_gamma_curve(NULL, 0);
|
||||
}
|
||||
|
||||
void test_lcd_ili9341(void)
|
||||
|
||||
@@ -158,7 +158,6 @@ void test_ll_get_len(void)
|
||||
|
||||
void test_ll_is_empty(void)
|
||||
{
|
||||
TEST_ASSERT_TRUE(lv_ll_is_empty(NULL));
|
||||
TEST_ASSERT_TRUE(lv_ll_is_empty(&test_ll));
|
||||
|
||||
lv_ll_ins_head(&test_ll);
|
||||
@@ -315,15 +314,4 @@ void test_ll_get_len_empty_list(void)
|
||||
TEST_ASSERT_EQUAL(0, lv_ll_get_len(&test_ll));
|
||||
}
|
||||
|
||||
void test_ll_nullptr_handling(void)
|
||||
{
|
||||
TEST_ASSERT_NULL(lv_ll_ins_prev(NULL, NULL));
|
||||
TEST_ASSERT_NULL(lv_ll_ins_prev(&test_ll, NULL));
|
||||
|
||||
lv_ll_remove(NULL, NULL);
|
||||
|
||||
TEST_ASSERT_NULL(lv_ll_get_head(NULL));
|
||||
TEST_ASSERT_NULL(lv_ll_get_tail(NULL));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -168,35 +168,6 @@ void test_realloc_size_overflow(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_mem_add_pool_size_limits(void)
|
||||
{
|
||||
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
|
||||
const size_t overhead = lv_tlsf_pool_overhead();
|
||||
const size_t block_max = lv_tlsf_block_size_max();
|
||||
uint32_t mem = lv_test_get_free_mem();
|
||||
|
||||
void * pool_mem = malloc(overhead + block_max);
|
||||
TEST_ASSERT_NOT_NULL(pool_mem);
|
||||
|
||||
/* A pool of exactly block_size_max would index sl_bitmap out of bounds */
|
||||
TEST_ASSERT_NULL(lv_mem_add_pool(pool_mem, overhead + block_max));
|
||||
TEST_ASSERT_NULL(lv_mem_add_pool(pool_mem, SIZE_MAX));
|
||||
TEST_ASSERT_NULL(lv_mem_add_pool(pool_mem, overhead + lv_tlsf_block_size_min() - 1));
|
||||
TEST_ASSERT_NULL(lv_mem_add_pool(pool_mem, 0));
|
||||
|
||||
/* One word less is the largest pool the range check accepts */
|
||||
lv_mem_pool_t pool = lv_mem_add_pool(pool_mem, overhead + block_max - lv_tlsf_align_size());
|
||||
TEST_ASSERT_NOT_NULL(pool);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_mem_test());
|
||||
|
||||
lv_mem_remove_pool(pool);
|
||||
free(pool_mem);
|
||||
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_mem_test());
|
||||
TEST_ASSERT_MEM_LEAK_LESS_THAN(mem, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_mem_test(void)
|
||||
{
|
||||
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
|
||||
|
||||
@@ -107,10 +107,6 @@ void test_observer_add_remove(void)
|
||||
lv_subject_deinit(&subject);
|
||||
LV_DEPRECATIONS_IGNORE_END
|
||||
|
||||
static lv_subject_t uninitialized_subject;
|
||||
lv_observer_t * observer = lv_subject_add_observer(&uninitialized_subject, observer_int,
|
||||
NULL);
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, observer); /*The observer must be NULL*/
|
||||
}
|
||||
|
||||
void test_object_observer_add_remove(void)
|
||||
@@ -232,21 +228,6 @@ void test_observer_int(void)
|
||||
TEST_ASSERT_EQUAL(15, lv_subject_get_previous_int(subject));
|
||||
TEST_ASSERT_EQUAL(3, observer_called);
|
||||
|
||||
/*Ignore incorrect types*/
|
||||
lv_subject_set_pointer(subject, NULL);
|
||||
TEST_ASSERT_EQUAL(15, lv_subject_get_int(subject));
|
||||
TEST_ASSERT_EQUAL(15, lv_subject_get_previous_int(subject));
|
||||
TEST_ASSERT_EQUAL(3, observer_called);
|
||||
|
||||
lv_subject_set_color(subject, lv_color_black());
|
||||
TEST_ASSERT_EQUAL(15, lv_subject_get_int(subject));
|
||||
TEST_ASSERT_EQUAL(15, lv_subject_get_previous_int(subject));
|
||||
TEST_ASSERT_EQUAL(3, observer_called);
|
||||
|
||||
lv_subject_set_string(subject, "hello");
|
||||
TEST_ASSERT_EQUAL(15, lv_subject_get_int(subject));
|
||||
TEST_ASSERT_EQUAL(15, lv_subject_get_previous_int(subject));
|
||||
TEST_ASSERT_EQUAL(3, observer_called);
|
||||
|
||||
lv_observer_delete(basic_observer);
|
||||
}
|
||||
@@ -279,21 +260,6 @@ void test_observer_float(void)
|
||||
TEST_ASSERT_EQUAL_FLOAT(15.75, lv_subject_get_previous_float(subject));
|
||||
TEST_ASSERT_EQUAL(3, observer_called);
|
||||
|
||||
/*Ignore incorrect types*/
|
||||
lv_subject_set_pointer(subject, NULL);
|
||||
TEST_ASSERT_EQUAL_FLOAT(15.75, lv_subject_get_float(subject));
|
||||
TEST_ASSERT_EQUAL_FLOAT(15.75, lv_subject_get_previous_float(subject));
|
||||
TEST_ASSERT_EQUAL(3, observer_called);
|
||||
|
||||
lv_subject_set_color(subject, lv_color_black());
|
||||
TEST_ASSERT_EQUAL_FLOAT(15.75, lv_subject_get_float(subject));
|
||||
TEST_ASSERT_EQUAL_FLOAT(15.75, lv_subject_get_previous_float(subject));
|
||||
TEST_ASSERT_EQUAL(3, observer_called);
|
||||
|
||||
lv_subject_set_string(subject, "hello");
|
||||
TEST_ASSERT_EQUAL_FLOAT(15.75, lv_subject_get_float(subject));
|
||||
TEST_ASSERT_EQUAL_FLOAT(15.75, lv_subject_get_previous_float(subject));
|
||||
TEST_ASSERT_EQUAL(3, observer_called);
|
||||
|
||||
lv_observer_delete(basic_observer);
|
||||
}
|
||||
@@ -375,24 +341,6 @@ void test_observer_string(void)
|
||||
lv_subject_get_previous_string(subject));
|
||||
TEST_ASSERT_EQUAL(7, observer_called);
|
||||
|
||||
/*Ignore incorrect types*/
|
||||
lv_subject_set_pointer(subject, NULL);
|
||||
TEST_ASSERT_EQUAL_STRING("a", lv_subject_get_string(subject));
|
||||
TEST_ASSERT_EQUAL_STRING("text to be clipped to 32 chars.",
|
||||
lv_subject_get_previous_string(subject));
|
||||
TEST_ASSERT_EQUAL(7, observer_called);
|
||||
|
||||
lv_subject_set_color(subject, lv_color_black());
|
||||
TEST_ASSERT_EQUAL_STRING("a", lv_subject_get_string(subject));
|
||||
TEST_ASSERT_EQUAL_STRING("text to be clipped to 32 chars.",
|
||||
lv_subject_get_previous_string(subject));
|
||||
TEST_ASSERT_EQUAL(7, observer_called);
|
||||
|
||||
lv_subject_set_int(subject, 10);
|
||||
TEST_ASSERT_EQUAL_STRING("a", lv_subject_get_string(subject));
|
||||
TEST_ASSERT_EQUAL_STRING("text to be clipped to 32 chars.",
|
||||
lv_subject_get_previous_string(subject));
|
||||
TEST_ASSERT_EQUAL(7, observer_called);
|
||||
lv_observer_delete(basic_observer);
|
||||
}
|
||||
|
||||
@@ -431,21 +379,6 @@ void test_observer_pointer(void)
|
||||
TEST_ASSERT_EQUAL_PTR(&a[2], lv_subject_get_previous_pointer(subject));
|
||||
TEST_ASSERT_EQUAL(4, observer_called);
|
||||
|
||||
/*Ignore incorrect types*/
|
||||
lv_subject_set_int(subject, 10);
|
||||
TEST_ASSERT_EQUAL_PTR(&a[2], lv_subject_get_pointer(subject));
|
||||
TEST_ASSERT_EQUAL_PTR(&a[2], lv_subject_get_previous_pointer(subject));
|
||||
TEST_ASSERT_EQUAL(4, observer_called);
|
||||
|
||||
lv_subject_set_color(subject, lv_color_black());
|
||||
TEST_ASSERT_EQUAL_PTR(&a[2], lv_subject_get_pointer(subject));
|
||||
TEST_ASSERT_EQUAL_PTR(&a[2], lv_subject_get_previous_pointer(subject));
|
||||
TEST_ASSERT_EQUAL(4, observer_called);
|
||||
|
||||
lv_subject_set_string(subject, "hello");
|
||||
TEST_ASSERT_EQUAL_PTR(&a[2], lv_subject_get_pointer(subject));
|
||||
TEST_ASSERT_EQUAL_PTR(&a[2], lv_subject_get_previous_pointer(subject));
|
||||
TEST_ASSERT_EQUAL(4, observer_called);
|
||||
lv_observer_delete(basic_observer);
|
||||
}
|
||||
|
||||
@@ -485,24 +418,6 @@ void test_observer_color(void)
|
||||
lv_subject_get_previous_color(subject));
|
||||
TEST_ASSERT_EQUAL(3, observer_called);
|
||||
|
||||
/*Ignore incorrect types*/
|
||||
lv_subject_set_pointer(subject, NULL);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_hex3(0xabc),
|
||||
lv_subject_get_color(subject));
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_hex3(0xabc),
|
||||
lv_subject_get_previous_color(subject));
|
||||
|
||||
lv_subject_set_int(subject, 10);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_hex3(0xabc),
|
||||
lv_subject_get_color(subject));
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_hex3(0xabc),
|
||||
lv_subject_get_previous_color(subject));
|
||||
|
||||
lv_subject_set_string(subject, "hello");
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_hex3(0xabc),
|
||||
lv_subject_get_color(subject));
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_hex3(0xabc),
|
||||
lv_subject_get_previous_color(subject));
|
||||
lv_observer_delete(basic_observer);
|
||||
}
|
||||
|
||||
@@ -538,10 +453,6 @@ void test_observer_group(void)
|
||||
lv_subject_get_group_element(group_subject, 0));
|
||||
TEST_ASSERT_EQUAL_PTR(list[1],
|
||||
lv_subject_get_group_element(group_subject, 1));
|
||||
TEST_ASSERT_EQUAL_PTR(NULL,
|
||||
lv_subject_get_group_element(group_subject, 2));
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, lv_subject_get_group_element(group_subject,
|
||||
1000));
|
||||
|
||||
group_observer_called = 0;
|
||||
lv_subject_add_observer(group_subject, group_observer_cb, NULL);
|
||||
@@ -591,36 +502,6 @@ void test_observer_group_deinit_unsubscribes_from_elements(void)
|
||||
TEST_ASSERT_EQUAL(0, group_observer_called);
|
||||
}
|
||||
|
||||
void test_observer_obj_flag_invalid_subject(void)
|
||||
{
|
||||
LV_DEPRECATIONS_IGNORE_BEGIN
|
||||
typedef lv_observer_t * (*lv_obj_bind_flag_fn)(
|
||||
lv_obj_t *, lv_subject_t *, lv_obj_flag_t, int32_t);
|
||||
static const lv_obj_bind_flag_fn fns[] = {
|
||||
lv_obj_bind_flag_if_eq, lv_obj_bind_flag_if_not_eq,
|
||||
lv_obj_bind_flag_if_ge, lv_obj_bind_flag_if_gt,
|
||||
lv_obj_bind_flag_if_lt, lv_obj_bind_flag_if_le,
|
||||
};
|
||||
LV_DEPRECATIONS_IGNORE_END
|
||||
|
||||
lv_obj_t * obj = lv_obj_create(lv_screen_active());
|
||||
|
||||
|
||||
/* Can only bind to int */
|
||||
lv_subject_t * invalid[4];
|
||||
invalid[0] = subject_create(LV_SUBJECT_TYPE_POINTER);
|
||||
invalid[1] = subject_create(LV_SUBJECT_TYPE_STRING);
|
||||
invalid[2] = subject_create(LV_SUBJECT_TYPE_COLOR);
|
||||
invalid[3] = subject_create(LV_SUBJECT_TYPE_GROUP);
|
||||
|
||||
for(size_t i = 0; i < LV_ARRAYLEN(fns); ++i) {
|
||||
for(size_t j = 0; j < LV_ARRAYLEN(invalid); ++j) {
|
||||
TEST_ASSERT_EQUAL_PTR(NULL,
|
||||
fns[i](obj, invalid[j],
|
||||
LV_OBJ_FLAG_HIDDEN, 5));
|
||||
}
|
||||
}
|
||||
}
|
||||
void test_observer_obj_flag_eq(void)
|
||||
{
|
||||
LV_DEPRECATIONS_IGNORE_BEGIN
|
||||
@@ -740,35 +621,6 @@ void test_observer_obj_flag_lt(void)
|
||||
LV_DEPRECATIONS_IGNORE_END
|
||||
}
|
||||
|
||||
void test_observer_obj_state_invalid_subject(void)
|
||||
{
|
||||
LV_DEPRECATIONS_IGNORE_BEGIN
|
||||
typedef lv_observer_t * (*lv_obj_bind_state_fn)(
|
||||
lv_obj_t *, lv_subject_t *, lv_state_t, int32_t);
|
||||
|
||||
static const lv_obj_bind_state_fn fns[] = {
|
||||
lv_obj_bind_state_if_eq, lv_obj_bind_state_if_not_eq,
|
||||
lv_obj_bind_state_if_ge, lv_obj_bind_state_if_gt,
|
||||
lv_obj_bind_state_if_lt, lv_obj_bind_state_if_le,
|
||||
};
|
||||
lv_obj_t * obj = lv_obj_create(lv_screen_active());
|
||||
|
||||
/* Can only bind to int */
|
||||
lv_subject_t * invalid[4];
|
||||
invalid[0] = subject_create(LV_SUBJECT_TYPE_POINTER);
|
||||
invalid[1] = subject_create(LV_SUBJECT_TYPE_STRING);
|
||||
invalid[2] = subject_create(LV_SUBJECT_TYPE_COLOR);
|
||||
invalid[3] = subject_create(LV_SUBJECT_TYPE_GROUP);
|
||||
|
||||
for(size_t i = 0; i < LV_ARRAYLEN(fns); ++i) {
|
||||
for(size_t j = 0; j < LV_ARRAYLEN(invalid); ++j) {
|
||||
TEST_ASSERT_EQUAL_PTR(
|
||||
NULL, fns[i](obj, invalid[j], 0, 5));
|
||||
}
|
||||
}
|
||||
LV_DEPRECATIONS_IGNORE_END
|
||||
}
|
||||
|
||||
void test_observer_obj_state_eq(void)
|
||||
{
|
||||
LV_DEPRECATIONS_IGNORE_BEGIN
|
||||
@@ -915,20 +767,6 @@ void test_observer_obj_bind_bool_flag(void)
|
||||
lv_obj_delete(obj);
|
||||
}
|
||||
|
||||
void test_observer_obj_bind_bool_invalid(void)
|
||||
{
|
||||
lv_obj_t * obj = lv_obj_create(lv_screen_active());
|
||||
|
||||
lv_subject_t * subject = subject_create(LV_SUBJECT_TYPE_INT);
|
||||
lv_subject_set_int(subject, 0);
|
||||
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, lv_obj_bind_bool(NULL, subject, lv_obj_set_hidden));
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, lv_obj_bind_bool(obj, NULL, lv_obj_set_hidden));
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, lv_obj_bind_bool(obj, subject, NULL));
|
||||
|
||||
lv_obj_delete(obj);
|
||||
}
|
||||
|
||||
/* The remaining lv_obj_bind_<type>() functions just forward the subject's value
|
||||
* to the setter; these tests confirm the value arrives on subscribe and update. */
|
||||
static int32_t captured_int;
|
||||
@@ -1086,10 +924,6 @@ void test_observer_button_checked(void)
|
||||
lv_obj_set_checkable(obj, true);
|
||||
lv_obj_update_layout(obj);
|
||||
|
||||
/*Can bind only to int*/
|
||||
lv_subject_t * subject_wrong = subject_create(LV_SUBJECT_TYPE_POINTER);
|
||||
lv_observer_t * observer = lv_obj_bind_checked(obj, subject_wrong);
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, observer);
|
||||
|
||||
lv_subject_t * subject = subject_create(LV_SUBJECT_TYPE_INT);
|
||||
lv_subject_set_int(subject, 1);
|
||||
@@ -1163,7 +997,7 @@ void test_observer_label_text_normal(void)
|
||||
|
||||
/*Remove the label from the subject*/
|
||||
lv_obj_remove_from_subject(obj, subject_pointer);
|
||||
lv_subject_set_string(subject_pointer, "NOTHING");
|
||||
lv_subject_set_pointer(subject_pointer, "NOTHING");
|
||||
TEST_ASSERT_EQUAL_STRING("WORLD", lv_label_get_text(obj));
|
||||
}
|
||||
|
||||
@@ -1219,7 +1053,7 @@ void test_observer_label_text_formatted(void)
|
||||
|
||||
/*Remove the label from the subject*/
|
||||
lv_obj_remove_from_subject(obj, subject_pointer);
|
||||
lv_subject_set_string(subject_pointer, "NOTHING");
|
||||
lv_subject_set_pointer(subject_pointer, "pointer: NOTHING");
|
||||
TEST_ASSERT_EQUAL_STRING("pointer: WORLD", lv_label_get_text(obj));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,16 +22,6 @@ void test_palette_main_all_colors(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Test lv_palette_main with invalid palette */
|
||||
void test_palette_main_invalid(void)
|
||||
{
|
||||
lv_color_t color = lv_palette_main(LV_PALETTE_LAST);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
|
||||
color = lv_palette_main(LV_PALETTE_NONE);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
}
|
||||
|
||||
/* Test lv_palette_lighten with all levels */
|
||||
void test_palette_lighten_all_levels(void)
|
||||
{
|
||||
@@ -43,16 +33,6 @@ void test_palette_lighten_all_levels(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Test lv_palette_lighten with invalid levels */
|
||||
void test_palette_lighten_invalid(void)
|
||||
{
|
||||
lv_color_t color = lv_palette_lighten(LV_PALETTE_RED, 0);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
|
||||
color = lv_palette_lighten(LV_PALETTE_RED, 6);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
}
|
||||
|
||||
/* Test lv_palette_darken with all levels */
|
||||
void test_palette_darken_all_levels(void)
|
||||
{
|
||||
@@ -64,16 +44,6 @@ void test_palette_darken_all_levels(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Test lv_palette_darken with invalid levels */
|
||||
void test_palette_darken_invalid(void)
|
||||
{
|
||||
lv_color_t color = lv_palette_darken(LV_PALETTE_RED, 0);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
|
||||
color = lv_palette_darken(LV_PALETTE_RED, 5);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
}
|
||||
|
||||
/* Test specific color values */
|
||||
void test_palette_specific_values(void)
|
||||
{
|
||||
@@ -86,25 +56,4 @@ void test_palette_specific_values(void)
|
||||
TEST_ASSERT_EQUAL_HEX32(0x81D4FA, lv_color_to_int(light_blue));
|
||||
}
|
||||
|
||||
/* Test lv_palette_main with out-of-range palette index */
|
||||
void test_palette_main_out_of_range(void)
|
||||
{
|
||||
lv_color_t color = lv_palette_main(LV_PALETTE_LAST + 1);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
}
|
||||
|
||||
/* Test lv_palette_lighten with out-of-range palette index */
|
||||
void test_palette_lighten_out_of_range(void)
|
||||
{
|
||||
lv_color_t color = lv_palette_lighten(LV_PALETTE_LAST + 1, 1);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
}
|
||||
|
||||
/* Test lv_palette_darken with out-of-range palette index */
|
||||
void test_palette_darken_out_of_range(void)
|
||||
{
|
||||
lv_color_t color = lv_palette_darken(LV_PALETTE_LAST + 1, 1);
|
||||
TEST_ASSERT_EQUAL_COLOR(lv_color_black(), color);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -314,22 +314,6 @@ void test_snapshot_reshape_draw_buf_zero_size_object(void)
|
||||
lv_draw_buf_destroy(draw_buf);
|
||||
}
|
||||
|
||||
void test_snapshot_reshape_draw_buf_invalid_params(void)
|
||||
{
|
||||
lv_obj_t * obj = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(obj, 50, 40);
|
||||
|
||||
/* Create initial draw buffer */
|
||||
lv_draw_buf_t * draw_buf = lv_draw_buf_create(50, 40, LV_COLOR_FORMAT_ARGB8888, LV_STRIDE_AUTO);
|
||||
TEST_ASSERT_NOT_NULL(draw_buf);
|
||||
|
||||
/* Only test NULL buffer, not NULL object (function asserts obj != NULL internally) */
|
||||
lv_result_t result = lv_snapshot_reshape_draw_buf(obj, NULL);
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, result);
|
||||
|
||||
lv_draw_buf_destroy(draw_buf);
|
||||
}
|
||||
|
||||
void test_snapshot_reshape_draw_buf_reshape_failure(void)
|
||||
{
|
||||
lv_obj_t * obj = lv_obj_create(lv_screen_active());
|
||||
|
||||
@@ -258,8 +258,6 @@ void test_theme_user_data(void)
|
||||
lv_theme_set_user_data(&theme, NULL);
|
||||
TEST_ASSERT_EQUAL_PTR(NULL, theme.user_data);
|
||||
|
||||
// NULL theme must not crash
|
||||
lv_theme_set_user_data(NULL, &dummy);
|
||||
|
||||
// A non NULL value can be retrieved
|
||||
lv_theme_set_user_data(&theme, &dummy);
|
||||
|
||||
@@ -181,25 +181,6 @@ void test_static_pack_rejects_add_language(void)
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_translation_add_language(pack, "fr"));
|
||||
}
|
||||
|
||||
void test_static_pack_rejects_add_tag(void)
|
||||
{
|
||||
lv_translation_pack_t * pack = add_animals_pack();
|
||||
TEST_ASSERT_NULL(lv_translation_add_tag(pack, "zebra"));
|
||||
}
|
||||
|
||||
void test_static_pack_rejects_set_tag_translation(void)
|
||||
{
|
||||
lv_translation_pack_t * static_pack = add_animals_pack();
|
||||
|
||||
/* A valid tag descriptor is needed, borrow one from a dynamic pack */
|
||||
lv_translation_pack_t * dynamic_pack = lv_translation_add_dynamic();
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_translation_add_language(dynamic_pack, "en"));
|
||||
lv_translation_tag_dsc_t * tag = lv_translation_add_tag(dynamic_pack, "cat");
|
||||
TEST_ASSERT_NOT_NULL(tag);
|
||||
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_translation_set_tag_translation(static_pack, tag, 0, "The Cat"));
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* DYNAMIC PACKS
|
||||
@@ -245,17 +226,6 @@ void test_set_tag_translation_overwrites_the_previous_one(void)
|
||||
TEST_ASSERT_EQUAL_STRING("The Kitten", lv_tr("cat"));
|
||||
}
|
||||
|
||||
void test_set_tag_translation_rejects_out_of_range_language(void)
|
||||
{
|
||||
lv_translation_pack_t * pack = lv_translation_add_dynamic();
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_OK, lv_translation_add_language(pack, "en"));
|
||||
|
||||
lv_translation_tag_dsc_t * tag = lv_translation_add_tag(pack, "cat");
|
||||
TEST_ASSERT_NOT_NULL(tag);
|
||||
|
||||
TEST_ASSERT_EQUAL(LV_RESULT_INVALID, lv_translation_set_tag_translation(pack, tag, 1, "Die Katze"));
|
||||
}
|
||||
|
||||
void test_deinit_releases_dynamic_packs(void)
|
||||
{
|
||||
add_animals_pack_dynamic();
|
||||
|
||||
@@ -48,11 +48,6 @@ void test_canvas_functions_invalidate(void)
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(draw_buf, 100, 100, LV_COLOR_FORMAT_DEFAULT);
|
||||
|
||||
/* test uninitialized draw buffer, it should fail.*/
|
||||
lv_canvas_set_draw_buf(canvas, &draw_buf);
|
||||
TEST_ASSERT_NULL(lv_canvas_get_draw_buf(canvas));
|
||||
TEST_ASSERT_NULL(lv_canvas_get_image(canvas));
|
||||
TEST_ASSERT_NULL(lv_canvas_get_buf(canvas));
|
||||
|
||||
LV_DRAW_BUF_INIT_STATIC(draw_buf);
|
||||
canvas_draw_buf_reshape(&draw_buf);
|
||||
@@ -713,51 +708,6 @@ void test_canvas_copy_buffer_partial(void)
|
||||
}
|
||||
}
|
||||
|
||||
void test_canvas_empty_draw_buf(void)
|
||||
{
|
||||
lv_obj_t * canvas = lv_canvas_create(g_screen_active);
|
||||
|
||||
TEST_ASSERT_NULL(lv_canvas_get_draw_buf(canvas));
|
||||
TEST_ASSERT_NULL(lv_canvas_get_image(canvas));
|
||||
TEST_ASSERT_NULL(lv_canvas_get_buf(canvas));
|
||||
lv_layer_t layer;
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(src_buf, 10, 10, LV_COLOR_FORMAT_ARGB8888);
|
||||
LV_DRAW_BUF_INIT_STATIC(src_buf);
|
||||
canvas_draw_buf_reshape(&src_buf);
|
||||
|
||||
lv_canvas_copy_buf(canvas, NULL, &src_buf, NULL);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex(0xFFFFFF), LV_OPA_COVER);
|
||||
lv_canvas_init_layer(canvas, &layer);
|
||||
lv_canvas_set_px(canvas, 0, 0, lv_color_hex(0x000000), LV_OPA_COVER);
|
||||
|
||||
lv_color32_t src_px = lv_color_to_32(lv_color_hex(0x000000), LV_OPA_0);
|
||||
lv_color32_t dst_px = lv_canvas_get_px(canvas, 0, 0);
|
||||
TEST_ASSERT_TRUE(lv_color32_eq(src_px, dst_px));
|
||||
|
||||
lv_canvas_set_palette(canvas, 0, src_px);
|
||||
lv_canvas_finish_layer(canvas, &layer);
|
||||
}
|
||||
|
||||
void test_canvas_out_of_area(void)
|
||||
{
|
||||
lv_obj_t * canvas = lv_canvas_create(g_screen_active);
|
||||
|
||||
LV_DRAW_BUF_DEFINE_STATIC(draw_buf, 10, 10, LV_COLOR_FORMAT_ARGB8888);
|
||||
LV_DRAW_BUF_INIT_STATIC(draw_buf);
|
||||
canvas_draw_buf_reshape(&draw_buf);
|
||||
lv_canvas_set_draw_buf(canvas, &draw_buf);
|
||||
|
||||
lv_color_t test_color = lv_color_hex(0x1234);
|
||||
|
||||
lv_canvas_set_px(canvas, -1, -1, test_color, LV_OPA_0);
|
||||
lv_color32_t px = lv_canvas_get_px(canvas, -1, -1);
|
||||
TEST_ASSERT_EQUAL_UINT8(0x00, px.red);
|
||||
TEST_ASSERT_EQUAL_UINT8(0x00, px.green);
|
||||
TEST_ASSERT_EQUAL_UINT8(0x00, px.blue);
|
||||
TEST_ASSERT_EQUAL_UINT8(0x00, px.alpha);
|
||||
}
|
||||
|
||||
void test_line_bigger_than_display_resolution(void)
|
||||
{
|
||||
int32_t hor_res = lv_display_get_horizontal_resolution(lv_display_get_default());
|
||||
|
||||
@@ -31,14 +31,6 @@ void test_spangroup_create_returns_not_null_object(void)
|
||||
TEST_ASSERT(NULL != obj);
|
||||
}
|
||||
|
||||
void test_spangroup_new_span_with_null_parameter_returns_null_object(void)
|
||||
{
|
||||
lv_span_t * span = lv_spangroup_add_span(NULL);
|
||||
|
||||
TEST_ASSERT(NULL == span);
|
||||
TEST_ASSERT_EQUAL_INT(0, lv_spangroup_get_span_count(spangroup));
|
||||
}
|
||||
|
||||
void test_spangroup_new_span_with_valid_parameter_returns_not_null_object(void)
|
||||
{
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
@@ -66,17 +58,6 @@ void test_span_set_text(void)
|
||||
TEST_ASSERT_EQUAL_STRING(span->txt, test_text);
|
||||
}
|
||||
|
||||
void test_span_set_text_with_bad_parameter_no_action_performed(void)
|
||||
{
|
||||
const char * test_text = "Test Text";
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
|
||||
lv_span_set_text(span, test_text);
|
||||
lv_span_set_text(span, NULL);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING(span->txt, test_text);
|
||||
}
|
||||
|
||||
void test_span_set_text_with_previous_test_overwrites(void)
|
||||
{
|
||||
const char * old_test_text = "Old Test Text";
|
||||
@@ -99,17 +80,6 @@ void test_span_set_text_static(void)
|
||||
TEST_ASSERT_EQUAL_STRING(span->txt, test_text);
|
||||
}
|
||||
|
||||
void test_span_set_text_static_with_bad_parameter_no_action_performed(void)
|
||||
{
|
||||
const char * test_text = "Test Text";
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
|
||||
lv_span_set_text_static(span, test_text);
|
||||
lv_span_set_text_static(span, NULL);
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING(span->txt, test_text);
|
||||
}
|
||||
|
||||
void test_span_set_text_static_with_previous_text_overwrites(void)
|
||||
{
|
||||
const char * old_test_text = "Old Test Text";
|
||||
|
||||
@@ -136,9 +136,6 @@ void test_table_should_wrap_long_texts(void)
|
||||
|
||||
static void draw_part_event_cb(lv_event_t * e)
|
||||
{
|
||||
/* Test lv_event_get_invalidated_area error handling. */
|
||||
TEST_ASSERT_NULL(lv_event_get_invalidated_area(e));
|
||||
|
||||
lv_draw_task_t * draw_task = lv_event_get_draw_task(e);
|
||||
lv_draw_dsc_base_t * base_dsc = draw_task->draw_dsc;
|
||||
/*If the cells are drawn...*/
|
||||
|
||||
Reference in New Issue
Block a user