summaryrefslogtreecommitdiff
path: root/src/libs/lvgl/tests/lv_test_core
diff options
context:
space:
mode:
authorJean-François Milants <jf@codingfield.com>2021-02-23 20:21:29 (GMT)
committerJean-François Milants <jf@codingfield.com>2021-02-23 20:21:29 (GMT)
commitb11b20b0ac5c0adfbd1397cf42c322c873a736a8 (patch)
tree0bcb047f3e9d5c41c6d79b4dac6cbcdd3929136b /src/libs/lvgl/tests/lv_test_core
parentf864330d355172046fab0923fd9015ec52884f00 (diff)
Remove LVGL folder (it's now a submodule)
Diffstat (limited to 'src/libs/lvgl/tests/lv_test_core')
-rw-r--r--src/libs/lvgl/tests/lv_test_core/lv_test_core.c56
-rw-r--r--src/libs/lvgl/tests/lv_test_core/lv_test_core.h38
-rw-r--r--src/libs/lvgl/tests/lv_test_core/lv_test_font_loader.c223
-rw-r--r--src/libs/lvgl/tests/lv_test_core/lv_test_font_loader.h38
-rw-r--r--src/libs/lvgl/tests/lv_test_core/lv_test_obj.c88
-rw-r--r--src/libs/lvgl/tests/lv_test_core/lv_test_obj.h38
-rw-r--r--src/libs/lvgl/tests/lv_test_core/lv_test_style.c624
-rw-r--r--src/libs/lvgl/tests/lv_test_core/lv_test_style.h38
8 files changed, 1143 insertions, 0 deletions
diff --git a/src/libs/lvgl/tests/lv_test_core/lv_test_core.c b/src/libs/lvgl/tests/lv_test_core/lv_test_core.c
new file mode 100644
index 0000000..d500211
--- /dev/null
+++ b/src/libs/lvgl/tests/lv_test_core/lv_test_core.c
@@ -0,0 +1,56 @@
+/**
+ * @file lv_test_core.c
+ *
+ */
+
+/*********************
+ * INCLUDES
+ *********************/
+#include "../lv_test_assert.h"
+
+#if LV_BUILD_TEST
+#include "lv_test_core.h"
+#include "lv_test_obj.h"
+#include "lv_test_style.h"
+#include "lv_test_font_loader.h"
+
+/*********************
+ * DEFINES
+ *********************/
+
+/**********************
+ * TYPEDEFS
+ **********************/
+
+/**********************
+ * STATIC PROTOTYPES
+ **********************/
+
+/**********************
+ * STATIC VARIABLES
+ **********************/
+
+/**********************
+ * MACROS
+ **********************/
+
+/**********************
+ * GLOBAL FUNCTIONS
+ **********************/
+
+void lv_test_core(void)
+{
+ lv_test_print("");
+ lv_test_print("*******************");
+ lv_test_print("Start lv_core tests");
+ lv_test_print("*******************");
+
+ lv_test_obj();
+ lv_test_style();
+ lv_test_font_loader();
+}
+
+/**********************
+ * STATIC FUNCTIONS
+ **********************/
+#endif
diff --git a/src/libs/lvgl/tests/lv_test_core/lv_test_core.h b/src/libs/lvgl/tests/lv_test_core/lv_test_core.h
new file mode 100644
index 0000000..239b018
--- /dev/null
+++ b/src/libs/lvgl/tests/lv_test_core/lv_test_core.h
@@ -0,0 +1,38 @@
+/**
+ * @file lv_test_core.h
+ *
+ */
+
+#ifndef LV_TEST_CORE_H
+#define LV_TEST_CORE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*********************
+ * INCLUDES
+ *********************/
+
+/*********************
+ * DEFINES
+ *********************/
+
+/**********************
+ * TYPEDEFS
+ **********************/
+
+/**********************
+ * GLOBAL PROTOTYPES
+ **********************/
+void lv_test_core(void);
+
+/**********************
+ * MACROS
+ **********************/
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*LV_TEST_CORE_H*/
diff --git a/src/libs/lvgl/tests/lv_test_core/lv_test_font_loader.c b/src/libs/lvgl/tests/lv_test_core/lv_test_font_loader.c
new file mode 100644
index 0000000..16d7544
--- /dev/null
+++ b/src/libs/lvgl/tests/lv_test_core/lv_test_font_loader.c
@@ -0,0 +1,223 @@
+/**
+ * @file lv_test_font_loader.c
+ *
+ */
+
+/*********************
+ * INCLUDES
+ *********************/
+
+#include "../../lvgl.h"
+#if LV_BUILD_TEST
+#include "../lv_test_assert.h"
+#include "../src/lv_font/lv_font_fmt_txt.h"
+#include "../src/lv_font/lv_font.h"
+#include "../src/lv_font/lv_font_loader.h"
+
+#include "lv_test_font_loader.h"
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpedantic"
+
+/*********************
+ * DEFINES
+ *********************/
+
+/**********************
+ * TYPEDEFS
+ **********************/
+
+/**********************
+ * STATIC PROTOTYPES
+ **********************/
+
+#if LV_USE_FILESYSTEM
+static int compare_fonts(lv_font_t * f1, lv_font_t * f2);
+#endif
+
+/**********************
+ * STATIC VARIABLES
+ **********************/
+
+/**********************
+ * MACROS
+ **********************/
+
+/**********************
+ * GLOBAL FUNCTIONS
+ **********************/
+
+extern lv_font_t font_1;
+extern lv_font_t font_2;
+extern lv_font_t font_3;
+
+void lv_test_font_loader(void)
+{
+#if LV_USE_FILESYSTEM
+ lv_test_print("");
+ lv_test_print("===================");
+ lv_test_print("Start lv_font tests");
+ lv_test_print("===================");
+
+ lv_font_t * font_1_bin = lv_font_load("f:font_1.fnt");
+ lv_font_t * font_2_bin = lv_font_load("f:font_2.fnt");
+ lv_font_t * font_3_bin = lv_font_load("f:font_3.fnt");
+
+ compare_fonts(&font_1, font_1_bin);
+ compare_fonts(&font_2, font_2_bin);
+ compare_fonts(&font_3, font_3_bin);
+
+ lv_font_free(font_1_bin);
+ lv_font_free(font_2_bin);
+ lv_font_free(font_3_bin);
+#else
+ lv_test_print("SKIP: font load test because it requires LV_USE_FILESYSTEM 1 and LV_FONT_FMT_TXT_LARGE 0");
+#endif
+}
+
+#if LV_USE_FILESYSTEM
+static int compare_fonts(lv_font_t * f1, lv_font_t * f2)
+{
+ lv_test_assert_true(f1 != NULL && f2 != NULL, "font not null");
+
+ lv_test_assert_ptr_eq(f1->get_glyph_dsc, f2->get_glyph_dsc, "glyph_dsc");
+ lv_test_assert_ptr_eq(f1->get_glyph_bitmap, f2->get_glyph_bitmap, "glyph_bitmap");
+ lv_test_assert_int_eq(f1->line_height, f2->line_height, "line_height");
+ lv_test_assert_int_eq(f1->base_line, f2->base_line, "base_line");
+#if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0)
+ lv_test_assert_int_eq(f1->subpx, f2->subpx, "subpx");
+#endif
+ lv_font_fmt_txt_dsc_t * dsc1 = (lv_font_fmt_txt_dsc_t *) f1->dsc;
+ lv_font_fmt_txt_dsc_t * dsc2 = (lv_font_fmt_txt_dsc_t *) f2->dsc;
+
+ lv_test_assert_int_eq(dsc1->kern_scale, dsc2->kern_scale, "kern_scale");
+ lv_test_assert_int_eq(dsc1->cmap_num, dsc2->cmap_num, "cmap_num");
+ lv_test_assert_int_eq(dsc1->bpp, dsc2->bpp, "bpp");
+ lv_test_assert_int_eq(dsc1->kern_classes, dsc2->kern_classes, "kern_classes");
+ lv_test_assert_int_eq(dsc1->bitmap_format, dsc2->bitmap_format, "bitmap_format");
+
+ // cmaps
+ int total_glyphs = 0;
+ for(int i = 0; i < dsc1->cmap_num; ++i) {
+ lv_font_fmt_txt_cmap_t * cmaps1 = (lv_font_fmt_txt_cmap_t *) &dsc1->cmaps[i];
+ lv_font_fmt_txt_cmap_t * cmaps2 = (lv_font_fmt_txt_cmap_t *) &dsc2->cmaps[i];
+
+ lv_test_assert_int_eq(cmaps1->range_start, cmaps2->range_start, "range_start");
+ lv_test_assert_int_eq(cmaps1->range_length, cmaps2->range_length, "range_length");
+ lv_test_assert_int_eq(cmaps1->glyph_id_start, cmaps2->glyph_id_start, "glyph_id_start");
+ lv_test_assert_int_eq(cmaps1->type, cmaps2->type, "type");
+ lv_test_assert_int_eq(cmaps1->list_length, cmaps2->list_length, "list_length");
+
+ if(cmaps1->unicode_list != NULL && cmaps2->unicode_list != NULL) {
+ lv_test_assert_true(cmaps1->unicode_list && cmaps2->unicode_list, "unicode_list");
+
+ lv_test_assert_array_eq(
+ (uint8_t *) cmaps1->unicode_list,
+ (uint8_t *) cmaps2->unicode_list,
+ sizeof(uint16_t) * cmaps1->list_length,
+ "unicode_list");
+ total_glyphs += cmaps1->list_length;
+ }
+ else {
+ total_glyphs += cmaps1->range_length;
+ lv_test_assert_ptr_eq(cmaps1->unicode_list, cmaps2->unicode_list, "unicode_list");
+ }
+
+ if(cmaps1->glyph_id_ofs_list != NULL && cmaps2->glyph_id_ofs_list != NULL) {
+ uint8_t * ids1 = (uint8_t *) cmaps1->glyph_id_ofs_list;
+ uint8_t * ids2 = (uint8_t *) cmaps2->glyph_id_ofs_list;
+
+ lv_test_assert_array_eq(ids1, ids2, cmaps1->list_length, "glyph_id_ofs_list");
+ }
+ else {
+ lv_test_assert_ptr_eq(cmaps1->glyph_id_ofs_list, cmaps2->glyph_id_ofs_list, "glyph_id_ofs_list");
+ }
+ }
+
+ // kern_dsc
+ if (dsc1->kern_classes == 1 && dsc2->kern_classes == 1) {
+ lv_font_fmt_txt_kern_classes_t * kern1 = (lv_font_fmt_txt_kern_classes_t *) dsc1->kern_dsc;
+ lv_font_fmt_txt_kern_classes_t * kern2 = (lv_font_fmt_txt_kern_classes_t *) dsc2->kern_dsc;
+ if (kern1 != NULL && kern2 != NULL) {
+ lv_test_assert_int_eq(kern1->right_class_cnt, kern2->right_class_cnt, "right_class_cnt");
+ lv_test_assert_int_eq(kern1->left_class_cnt, kern2->left_class_cnt, "left_class_cnt");
+
+ lv_test_assert_array_eq(
+ (uint8_t *) kern1->left_class_mapping,
+ (uint8_t *) kern2->left_class_mapping,
+ kern1->left_class_cnt,
+ "left_class_mapping");
+
+ lv_test_assert_array_eq(
+ (uint8_t *) kern1->right_class_mapping,
+ (uint8_t *) kern2->right_class_mapping,
+ kern1->right_class_cnt,
+ "right_class_mapping");
+
+ lv_test_assert_array_eq(
+ (uint8_t *) kern1->class_pair_values,
+ (uint8_t *) kern2->class_pair_values,
+ kern1->right_class_cnt * kern1->left_class_cnt,
+ "class_pair_values");
+ }
+ else {
+ lv_test_assert_ptr_eq(kern1, kern2, "kern");
+ }
+ }
+ else if (dsc1->kern_classes == 0 && dsc2->kern_classes == 0) {
+ lv_font_fmt_txt_kern_pair_t * kern1 = (lv_font_fmt_txt_kern_pair_t *) dsc1->kern_dsc;
+ lv_font_fmt_txt_kern_pair_t * kern2 = (lv_font_fmt_txt_kern_pair_t *) dsc2->kern_dsc;
+ if (kern1 != NULL && kern2 != NULL) {
+ lv_test_assert_int_eq(kern1->glyph_ids_size, kern2->glyph_ids_size, "glyph_ids_size");
+ lv_test_assert_int_eq(kern1->pair_cnt, kern2->pair_cnt, "pair_cnt");
+
+ int ids_size;
+
+ if (kern1->glyph_ids_size == 0) {
+ ids_size = sizeof(int8_t) * 2 * kern1->pair_cnt;
+ }
+ else {
+ ids_size = sizeof(int16_t) * 2 * kern1->pair_cnt;
+ }
+
+ lv_test_assert_array_eq(kern1->glyph_ids, kern2->glyph_ids, ids_size, "glyph_ids");
+ lv_test_assert_array_eq(
+ (uint8_t * ) kern1->values,
+ (uint8_t * ) kern2->values,
+ kern1->pair_cnt,
+ "glyph_values");
+ }
+ }
+
+ lv_font_fmt_txt_glyph_dsc_t * glyph_dsc1 = (lv_font_fmt_txt_glyph_dsc_t *) dsc1->glyph_dsc;
+ lv_font_fmt_txt_glyph_dsc_t * glyph_dsc2 = (lv_font_fmt_txt_glyph_dsc_t *) dsc2->glyph_dsc;
+
+ for(int i = 0; i < total_glyphs; ++i) {
+ if (i < total_glyphs - 1) {
+ int size1 = glyph_dsc1[i+1].bitmap_index - glyph_dsc1[i].bitmap_index;
+
+ if (size1 > 0) {
+ lv_test_assert_array_eq(
+ dsc1->glyph_bitmap + glyph_dsc1[i].bitmap_index,
+ dsc2->glyph_bitmap + glyph_dsc2[i].bitmap_index,
+ size1 - 1, "glyph_bitmap");
+ }
+ }
+ lv_test_assert_int_eq(glyph_dsc1[i].adv_w, glyph_dsc2[i].adv_w, "adv_w");
+ lv_test_assert_int_eq(glyph_dsc1[i].box_w, glyph_dsc2[i].box_w, "box_w");
+ lv_test_assert_int_eq(glyph_dsc1[i].box_h, glyph_dsc2[i].box_h, "box_h");
+ lv_test_assert_int_eq(glyph_dsc1[i].ofs_x, glyph_dsc2[i].ofs_x, "ofs_x");
+ lv_test_assert_int_eq(glyph_dsc1[i].ofs_y, glyph_dsc2[i].ofs_y, "ofs_y");
+ }
+
+ LV_LOG_INFO("No differences found!");
+ return 0;
+}
+#endif
+
+#pragma GCC diagnostic pop
+/**********************
+ * STATIC FUNCTIONS
+ **********************/
+
+#endif // LV_BUILD_TEST
diff --git a/src/libs/lvgl/tests/lv_test_core/lv_test_font_loader.h b/src/libs/lvgl/tests/lv_test_core/lv_test_font_loader.h
new file mode 100644
index 0000000..25aebc0
--- /dev/null
+++ b/src/libs/lvgl/tests/lv_test_core/lv_test_font_loader.h
@@ -0,0 +1,38 @@
+/**
+ * @file lv_test_font_loader.h
+ *
+ */
+
+#ifndef LV_TEST_FONT_LOADER_H
+#define LV_TEST_FONT_LOADER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*********************
+ * INCLUDES
+ *********************/
+
+/*********************
+ * DEFINES
+ *********************/
+
+/**********************
+ * TYPEDEFS
+ **********************/
+
+/**********************
+ * GLOBAL PROTOTYPES
+ **********************/
+void lv_test_font_loader(void);
+
+/**********************
+ * MACROS
+ **********************/
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*LV_TEST_FONT_LOADER_H*/
diff --git a/src/libs/lvgl/tests/lv_test_core/lv_test_obj.c b/src/libs/lvgl/tests/lv_test_core/lv_test_obj.c
new file mode 100644
index 0000000..e4708a1
--- /dev/null
+++ b/src/libs/lvgl/tests/lv_test_core/lv_test_obj.c
@@ -0,0 +1,88 @@
+/**
+ * @file lv_test_obj.c
+ *
+ */
+
+/*********************
+ * INCLUDES
+ *********************/
+#include "../../lvgl.h"
+#include "../lv_test_assert.h"
+#include "lv_test_obj.h"
+
+#if LV_BUILD_TEST
+
+/*********************
+ * DEFINES
+ *********************/
+
+/**********************
+ * TYPEDEFS
+ **********************/
+
+/**********************
+ * STATIC PROTOTYPES
+ **********************/
+static void create_delete_change_parent(void);
+
+/**********************
+ * STATIC VARIABLES
+ **********************/
+
+/**********************
+ * MACROS
+ **********************/
+
+/**********************
+ * GLOBAL FUNCTIONS
+ **********************/
+
+void lv_test_obj(void)
+{
+ lv_test_print("");
+ lv_test_print("==================");
+ lv_test_print("Start lv_obj tests");
+ lv_test_print("==================");
+
+ create_delete_change_parent();
+}
+
+/**********************
+ * STATIC FUNCTIONS
+ **********************/
+
+static void create_delete_change_parent(void)
+{
+
+ lv_test_print("");
+ lv_test_print("Create, delete, change parent of a simple object:");
+ lv_test_print("-------------------------------------------------");
+
+ lv_test_print("Create an object on the default screen");
+ lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count before creation");
+
+ lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL);
+ lv_test_assert_int_eq(1, lv_obj_count_children(lv_scr_act()), "Screen's children count after creation");
+ lv_test_assert_int_eq(0, lv_obj_count_children(obj), "New object's children count after creation");
+
+ lv_test_print("Delete the created object");
+ lv_obj_del(obj);
+ obj = NULL;
+ lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count after delete");
+
+ lv_test_print("Create two objects");
+ lv_obj_t * obj_parent = lv_obj_create(lv_scr_act(), NULL);
+ lv_obj_t * obj_child = lv_obj_create(lv_scr_act(), NULL);
+ lv_test_assert_int_eq(2, lv_obj_count_children(lv_scr_act()), "Screen's children count after creation");
+
+ lv_test_print("Change the parent of the second object to the first");
+ lv_obj_set_parent(obj_child, obj_parent);
+ lv_test_assert_int_eq(1, lv_obj_count_children(lv_scr_act()), "Screen's children count after parent change");
+ lv_test_assert_int_eq(1, lv_obj_count_children(obj_parent), "Parent object's children count after parent change");
+ lv_test_assert_int_eq(0, lv_obj_count_children(obj_child), "Child object's children count after parent change");
+
+ lv_test_print("Remove the parent object");
+ lv_obj_del(obj_parent);
+ lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count after delete");
+}
+#endif
diff --git a/src/libs/lvgl/tests/lv_test_core/lv_test_obj.h b/src/libs/lvgl/tests/lv_test_core/lv_test_obj.h
new file mode 100644
index 0000000..60c2297
--- /dev/null
+++ b/src/libs/lvgl/tests/lv_test_core/lv_test_obj.h
@@ -0,0 +1,38 @@
+/**
+ * @file lv_test_obj.h
+ *
+ */
+
+#ifndef LV_TEST_OBJ_H
+#define LV_TEST_OBJ_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*********************
+ * INCLUDES
+ *********************/
+
+/*********************
+ * DEFINES
+ *********************/
+
+/**********************
+ * TYPEDEFS
+ **********************/
+
+/**********************
+ * GLOBAL PROTOTYPES
+ **********************/
+void lv_test_obj(void);
+
+/**********************
+ * MACROS
+ **********************/
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*LV_TEST_OBJ_H*/
diff --git a/src/libs/lvgl/tests/lv_test_core/lv_test_style.c b/src/libs/lvgl/tests/lv_test_core/lv_test_style.c
new file mode 100644
index 0000000..f0ddf7b
--- /dev/null
+++ b/src/libs/lvgl/tests/lv_test_core/lv_test_style.c
@@ -0,0 +1,624 @@
+/**
+ * @file lv_test_style.c
+ *
+ */
+
+/*********************
+ * INCLUDES
+ *********************/
+#include "../../lvgl.h"
+#include "../lv_test_assert.h"
+#include "lv_test_style.h"
+
+#if LV_BUILD_TEST
+
+/*********************
+ * DEFINES
+ *********************/
+
+/**********************
+ * TYPEDEFS
+ **********************/
+
+/**********************
+ * STATIC PROTOTYPES
+ **********************/
+static void empty_style(void);
+static void add_remove_read_prop(void);
+static void cascade(void);
+static void copy(void);
+static void states(void);
+static void mem_leak(void);
+
+/**********************
+ * STATIC VARIABLES
+ **********************/
+
+/**********************
+ * MACROS
+ **********************/
+
+/**********************
+ * GLOBAL FUNCTIONS
+ **********************/
+
+void lv_test_style(void)
+{
+ lv_test_print("");
+ lv_test_print("====================");
+ lv_test_print("Start lv_style tests");
+ lv_test_print("====================");
+
+ empty_style();
+ add_remove_read_prop();
+ cascade();
+ copy();
+ states();
+ mem_leak();
+}
+
+/**********************
+ * STATIC FUNCTIONS
+ **********************/
+
+static void empty_style(void)
+{
+ lv_test_print("");
+ lv_test_print("Test empty styles:");
+ lv_test_print("-----------------");
+
+ lv_style_list_t style_list;
+ lv_style_list_init(&style_list);
+
+ lv_res_t found;
+ lv_style_int_t value;
+ lv_opa_t opa;
+ const void * ptr;
+ lv_color_t color;
+
+ lv_test_print("Get a properties from an empty style");
+
+ found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
+ lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'int' property");
+
+ found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa);
+ lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'opa' property");
+
+ found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
+ lv_test_assert_int_eq(LV_RES_INV, found, "Get a 'ptr' property");
+
+ found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
+ lv_test_assert_int_eq(LV_RES_INV, found, "Get a 'color' property");
+}
+
+static void add_remove_read_prop(void)
+{
+ lv_test_print("");
+ lv_test_print("Add, remove and read properties:");
+ lv_test_print("--------------------------------");
+
+ lv_style_list_t style_list;
+ lv_style_list_init(&style_list);
+
+ lv_style_t style;
+ lv_style_init(&style);
+
+ _lv_style_list_add_style(&style_list, &style);
+
+ lv_res_t found;
+ lv_style_int_t value;
+ lv_opa_t opa;
+ const void * ptr;
+ lv_color_t color;
+
+ lv_test_print("Add an empty style and read properties");
+
+ found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
+ lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'int' property");
+
+ found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa);
+ lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'opa' property");
+
+ found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
+ lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'ptr' property");
+
+ found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
+ lv_test_assert_int_eq(LV_RES_INV, found, "Get a non existing 'color' property");
+
+ lv_test_print("Set properties and read back the values");
+ _lv_style_set_int(&style, LV_STYLE_TEXT_LINE_SPACE, 5);
+ _lv_style_set_opa(&style, LV_STYLE_BG_OPA, LV_OPA_50);
+ _lv_style_set_ptr(&style, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL);
+ _lv_style_set_color(&style, LV_STYLE_BG_COLOR, LV_COLOR_RED);
+
+ found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'int' property");
+ lv_test_assert_int_eq(5, value, "Get the value of an 'int' property");
+
+ found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'opa' property");
+ lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'opa' property");
+
+ found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'ptr' property");
+ lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL, ptr, "Get the value of a 'ptr' property");
+
+ found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an existing 'color' property");
+ lv_test_assert_color_eq(LV_COLOR_RED, color, "Get the value of a 'color' property");
+
+ lv_test_print("Reset the style");
+ lv_style_reset(&style);
+ found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
+ lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'int' property from a reseted style");
+
+ found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa);
+ lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'opa' property from a reseted style");
+
+ found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
+ lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'ptr' property from a reseted style");
+
+ found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
+ lv_test_assert_int_eq(LV_RES_INV, found, "Get an 'color' property from a reseted style");
+
+ /*Clean-up*/
+ _lv_style_list_reset(&style_list);
+}
+
+static void cascade(void)
+{
+ lv_test_print("");
+ lv_test_print("Cascade style styles:");
+ lv_test_print("----------------------");
+
+ lv_style_list_t style_list;
+ lv_style_list_init(&style_list);
+
+ lv_style_t style_first;
+ lv_style_init(&style_first);
+ _lv_style_list_add_style(&style_list, &style_first);
+
+ lv_style_t style_second;
+ lv_style_init(&style_second);
+ _lv_style_list_add_style(&style_list, &style_second);
+
+ lv_res_t found;
+ lv_style_int_t value;
+ lv_opa_t opa;
+ const void * ptr;
+ lv_color_t color;
+
+ lv_test_print("Read properties set only in the firstly added style");
+
+ _lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE, 5);
+ _lv_style_set_opa(&style_first, LV_STYLE_BG_OPA, LV_OPA_50);
+ _lv_style_set_ptr(&style_first, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL);
+ _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR, LV_COLOR_RED);
+
+ found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property");
+ lv_test_assert_int_eq(5, value, "Get the value of an 'int' property");
+
+ found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property");
+ lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'opa' property");
+
+ found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'ptr' property");
+ lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL, ptr, "Get the value of a 'ptr' property");
+
+ found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'color' property");
+ lv_test_assert_color_eq(LV_COLOR_RED, color, "Get the value of a 'color' property");
+
+ lv_test_print("Overwrite the properties from the second style");
+
+ _lv_style_set_int(&style_second, LV_STYLE_TEXT_LINE_SPACE, 10);
+ _lv_style_set_opa(&style_second, LV_STYLE_BG_OPA, LV_OPA_60);
+ _lv_style_set_ptr(&style_second, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 1);
+ _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR, LV_COLOR_BLUE);
+
+ found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'int' property");
+ lv_test_assert_int_eq(10, value, "Get the value of an overwritten 'int' property");
+
+ found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'opa' property");
+ lv_test_assert_int_eq(LV_OPA_60, opa, "Get the value of an overwritten 'opa' property");
+
+ found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'ptr' property");
+ lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL + 1, ptr, "Get the value of an overwritten 'ptr' property");
+
+ found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an overwritten 'color' property");
+ lv_test_assert_color_eq(LV_COLOR_BLUE, color, "Get the value of an overwritten 'color' property");
+
+ lv_test_print("Overwrite the properties with the local style");
+ _lv_style_list_set_local_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, 20);
+ _lv_style_list_set_local_opa(&style_list, LV_STYLE_BG_OPA, LV_OPA_70);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT, LV_THEME_DEFAULT_FONT_NORMAL + 2);
+ _lv_style_list_set_local_color(&style_list, LV_STYLE_BG_COLOR, LV_COLOR_LIME);
+
+ found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'int' property");
+ lv_test_assert_int_eq(20, value, "Get the value of a local 'int' property");
+
+ found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA, &opa);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'opa' property");
+ lv_test_assert_int_eq(LV_OPA_70, opa, "Get the value of a local 'opa' property");
+
+ found = _lv_style_list_get_ptr(&style_list, LV_STYLE_TEXT_FONT, &ptr);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'ptr' property");
+ lv_test_assert_ptr_eq(LV_THEME_DEFAULT_FONT_NORMAL + 2, ptr, "Get the value of a local'ptr' property");
+
+ found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get a local 'color' property");
+ lv_test_assert_color_eq(LV_COLOR_LIME, color, "Get the value of a local'color' property");
+
+ /*Clean-up*/
+ _lv_style_list_reset(&style_list);
+}
+
+static void copy(void)
+{
+ lv_test_print("");
+ lv_test_print("Copy styles and style lists");
+ lv_test_print("---------------------------");
+
+ lv_test_print("Copy a style");
+ lv_style_t style_src;
+ lv_style_init(&style_src);
+ _lv_style_set_int(&style_src, LV_STYLE_TEXT_LINE_SPACE, 5);
+
+ lv_style_t style_dest;
+ lv_style_init(&style_dest);
+ lv_style_copy(&style_dest, &style_src);
+
+ int16_t weight;
+ lv_style_int_t value;
+
+ weight = _lv_style_get_int(&style_dest, LV_STYLE_TEXT_LINE_SPACE, &value);
+ lv_test_assert_int_eq(0, weight, "Get a copied property from a style");
+ lv_test_assert_int_eq(5, value, "Get the value of a copied from a property");
+
+ lv_test_print("Copy a style list");
+ lv_style_list_t list_src;
+ lv_style_list_init(&list_src);
+ _lv_style_list_add_style(&list_src, &style_src);
+ _lv_style_list_set_local_int(&list_src, LV_STYLE_LINE_DASH_WIDTH, 20);
+
+ lv_style_list_t list_dest;
+ lv_style_list_init(&list_dest);
+ lv_style_list_copy(&list_dest, &list_src);
+
+ lv_res_t found;
+ found = _lv_style_list_get_int(&list_dest, LV_STYLE_TEXT_LINE_SPACE, &value);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get a copied property from a list");
+ lv_test_assert_int_eq(5, value, "Get the value of a copied property from a list");
+ found = _lv_style_list_get_int(&list_dest, LV_STYLE_LINE_DASH_WIDTH, &value);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get a copied local property from a list");
+ lv_test_assert_int_eq(20, value, "Get the value of a copied local property from a list");
+
+ /*Clean up*/
+ _lv_style_list_reset(&list_dest);
+ _lv_style_list_reset(&list_src);
+
+ lv_style_reset(&style_dest);
+ lv_style_reset(&style_src);
+}
+
+static void states(void)
+{
+ lv_test_print("");
+ lv_test_print("Test style states:");
+ lv_test_print("------------------");
+
+ lv_style_list_t style_list;
+ lv_style_list_init(&style_list);
+
+ lv_style_t style_first;
+ lv_style_init(&style_first);
+ _lv_style_list_add_style(&style_list, &style_first);
+
+ lv_style_t style_second;
+ lv_style_init(&style_second);
+ _lv_style_list_add_style(&style_list, &style_second);
+
+ lv_test_print("Test state precedence in 1 style");
+ _lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE, 5);
+ _lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, 6);
+ _lv_style_set_int(&style_first, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, 7);
+
+ lv_res_t found;
+ lv_style_int_t value;
+
+ found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE, &value);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in normal state");
+ lv_test_assert_int_eq(5, value, "Get the value of an 'int' property in normal state");
+
+ found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, &value);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in checked state");
+ lv_test_assert_int_eq(6, value, "Get the value of an 'int' in checked state");
+
+ found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, &value);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in pressed state");
+ lv_test_assert_int_eq(7, value, "Get the value of an 'int' in pressed state");
+
+ found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_HOVERED) << LV_STYLE_STATE_POS, &value);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in hover (unspecified) state");
+ lv_test_assert_int_eq(5, value, "Get the value of an 'int' in hover (unspecified) state");
+
+ found = _lv_style_list_get_int(&style_list, LV_STYLE_TEXT_LINE_SPACE | (LV_STATE_CHECKED | LV_STATE_PRESSED | LV_STATE_HOVERED) << LV_STYLE_STATE_POS, &value);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'int' property in checked pressed hovered state");
+ lv_test_assert_int_eq(7, value, "Get the value of an 'int' in checked pressed hovered state");
+
+ lv_test_print("Test state precedence in 1 style with combined states");
+ _lv_style_set_opa(&style_first, LV_STYLE_BG_OPA, LV_OPA_50);
+ _lv_style_set_opa(&style_first, LV_STYLE_BG_OPA | (LV_STATE_CHECKED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_OPA_60);
+
+ lv_opa_t opa;
+ found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA , &opa);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property in normal state");
+ lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'int' in normal state");
+
+ found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, &opa);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property in checked (unspecified) state");
+ lv_test_assert_int_eq(LV_OPA_50, opa, "Get the value of an 'int' in checked (unspecified) state");
+
+ found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA | (LV_STATE_CHECKED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, &opa);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property in checked pressed state");
+ lv_test_assert_int_eq(LV_OPA_60, opa, "Get the value of an 'int' in checked pressed state");
+
+ found = _lv_style_list_get_opa(&style_list, LV_STYLE_BG_OPA | (LV_STATE_CHECKED | LV_STATE_PRESSED | LV_STATE_HOVERED) << LV_STYLE_STATE_POS, &opa);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get an 'opa' property in checked pressed hovered state");
+ lv_test_assert_int_eq(LV_OPA_60, opa, "Get the value of an 'int' in checked pressed hovered state");
+
+ lv_test_print("Test state precedence in 2 styles");
+ _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR, LV_COLOR_YELLOW);
+ _lv_style_set_color(&style_first, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED) << LV_STYLE_STATE_POS, LV_COLOR_RED);
+ _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, LV_COLOR_LIME);
+ _lv_style_set_color(&style_second, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_COLOR_BLUE);
+
+ lv_color_t color;
+
+ found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR, &color);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in normal state");
+ lv_test_assert_color_eq(LV_COLOR_YELLOW, color, "Get the value of a 'color' property in normal state");
+
+ found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED) << LV_STYLE_STATE_POS, &color);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in hovered state");
+ lv_test_assert_color_eq(LV_COLOR_RED, color, "Get the value of a 'color' in hovered state");
+
+ found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_CHECKED) << LV_STYLE_STATE_POS, &color);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in checked state");
+ lv_test_assert_color_eq(LV_COLOR_LIME, color, "Get the value of a 'color' in checked state");
+
+ found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_HOVERED | LV_STATE_PRESSED) << LV_STYLE_STATE_POS, &color);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in hover pressed state");
+ lv_test_assert_color_eq(LV_COLOR_BLUE, color, "Get the value of a 'color' in hover pressed state");
+
+ found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, &color);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in edit (unspecified) state");
+ lv_test_assert_color_eq(LV_COLOR_YELLOW, color, "Get the value of a 'color' in edit (unspecified) state");
+
+ found = _lv_style_list_get_color(&style_list, LV_STYLE_BG_COLOR | (LV_STATE_CHECKED | LV_STATE_EDITED) << LV_STYLE_STATE_POS, &color);
+ lv_test_assert_int_eq(LV_RES_OK, found, "Get a 'color' property in checked edit state");
+ lv_test_assert_color_eq(LV_COLOR_LIME, color, "Get the value of a 'color' in checked edit state");
+
+ /*Clean-up*/
+ _lv_style_list_reset(&style_list);
+}
+
+static void mem_leak(void)
+{
+
+ lv_test_print("");
+ lv_test_print("Test style set, add, remove memory leak");
+ lv_test_print("----------------------------------------");
+
+ lv_mem_monitor_t mon_start;
+ lv_mem_monitor_t mon_end;
+
+ lv_style_list_t style_list;
+ lv_style_list_init(&style_list);
+
+ lv_style_t style1;
+ lv_style_init(&style1);
+
+ lv_style_t style2;
+ lv_style_init(&style2);
+
+ lv_style_t style3;
+ lv_style_init(&style3);
+
+ uint32_t i;
+
+ lv_test_print("Set style properties");
+ lv_mem_monitor(&mon_start);
+ for(i = 0; i < 100; i++) {
+ _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, LV_COLOR_RED);
+
+ _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_RED);
+ _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, LV_COLOR_BLUE);
+ _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_BLUE);
+ _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED | LV_STATE_FOCUSED) << LV_STYLE_STATE_POS, LV_COLOR_GREEN);
+
+ _lv_style_set_color(&style3, LV_STYLE_BG_COLOR, LV_COLOR_RED);
+
+ _lv_style_set_color(&style3, LV_STYLE_IMAGE_RECOLOR, LV_COLOR_RED);
+
+ lv_style_reset(&style1);
+ lv_style_reset(&style2);
+ lv_style_reset(&style3);
+
+ }
+
+ lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check");
+ lv_mem_defrag();
+ lv_mem_monitor(&mon_end);
+ lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak");
+
+ lv_test_print("Use local style");
+ lv_mem_monitor(&mon_start);
+ for(i = 0; i < 100; i++) {
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL);
+
+ _lv_style_list_reset(&style_list);
+
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
+
+ _lv_style_list_reset(&style_list);
+ }
+
+ _lv_style_list_reset(&style_list);
+ lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check");
+ lv_mem_defrag();
+ lv_mem_monitor(&mon_end);
+ lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak");
+
+ lv_test_print("Add styles");
+ lv_mem_monitor(&mon_start);
+ for(i = 0; i < 100; i++) {
+ _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED);
+ _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, LV_COLOR_RED);
+ _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_RED);
+
+ _lv_style_list_add_style(&style_list, &style1);
+ _lv_style_list_remove_style(&style_list, &style1);
+
+ _lv_style_list_add_style(&style_list, &style2);
+ _lv_style_list_add_style(&style_list, &style3);
+
+ _lv_style_list_remove_style(&style_list, &style2);
+ _lv_style_list_add_style(&style_list, &style1);
+
+ _lv_style_list_reset(&style_list);
+ lv_style_reset(&style1);
+ lv_style_reset(&style2);
+ lv_style_reset(&style3);
+ }
+
+ lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check");
+ lv_mem_defrag();
+ lv_mem_monitor(&mon_end);
+ lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak");
+
+ lv_test_print("Add styles and use local style");
+ lv_mem_monitor(&mon_start);
+ for(i = 0; i < 100; i++) {
+ _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED);
+ _lv_style_set_color(&style2, LV_STYLE_LINE_COLOR, LV_COLOR_RED);
+ _lv_style_set_color(&style3, LV_STYLE_LINE_COLOR, LV_COLOR_RED);
+
+ if(i % 2 == 0) _lv_style_list_set_local_color(&style_list, LV_STYLE_LINE_COLOR, LV_COLOR_RED);
+
+ _lv_style_list_add_style(&style_list, &style1);
+ _lv_style_list_remove_style(&style_list, &style1);
+
+ _lv_style_list_add_style(&style_list, &style2);
+ _lv_style_list_add_style(&style_list, &style3);
+
+ _lv_style_list_remove_style(&style_list, &style2);
+ _lv_style_list_add_style(&style_list, &style1);
+
+ if(i % 2 != 0) _lv_style_list_set_local_color(&style_list, LV_STYLE_LINE_COLOR, LV_COLOR_RED);
+
+ _lv_style_list_reset(&style_list);
+ lv_style_reset(&style1);
+ lv_style_reset(&style2);
+ lv_style_reset(&style3);
+ }
+
+ lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check");
+ lv_mem_defrag();
+ lv_mem_monitor(&mon_end);
+ lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak");
+
+ lv_test_print("Complex test");
+
+ lv_mem_monitor(&mon_start);
+
+ for(i = 0; i < 100; i++) {
+ if(i % 2 == 0) {
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
+ }
+
+ _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_RED);
+ _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED) << LV_STYLE_STATE_POS, LV_COLOR_BLUE);
+ _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR, LV_COLOR_BLUE);
+ _lv_style_set_color(&style1, LV_STYLE_LINE_COLOR | (LV_STATE_EDITED | LV_STATE_FOCUSED) << LV_STYLE_STATE_POS, LV_COLOR_GREEN);
+
+ _lv_style_list_add_style(&style_list, &style1);
+
+ if(i % 4 == 0) {
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
+ }
+
+ _lv_style_list_remove_style(&style_list, &style1);
+
+ _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_10);
+ _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_20);
+ _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_30);
+ _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_40);
+ _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_50);
+ _lv_style_set_opa(&style2, LV_STYLE_TEXT_OPA, LV_OPA_60);
+
+ _lv_style_list_add_style(&style_list, &style2);
+
+ if(i % 8 == 0) {
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_CLOSE);
+ }
+
+ _lv_style_list_add_style(&style_list, &style2);
+ _lv_style_list_add_style(&style_list, &style2);
+ _lv_style_list_add_style(&style_list, &style2);
+ _lv_style_list_add_style(&style_list, &style2);
+ _lv_style_list_remove_style(&style_list, &style2);
+
+ _lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 10);
+ _lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 20);
+ _lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 11);
+ _lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 21);
+ _lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 12);
+ _lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 22);
+ _lv_style_set_int(&style3, LV_STYLE_PAD_LEFT, 12);
+ _lv_style_set_int(&style3, LV_STYLE_PAD_RIGHT, 23);
+
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, LV_THEME_DEFAULT_FONT_NORMAL);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_TEXT_FONT | (LV_STATE_PRESSED) << LV_STYLE_STATE_POS, NULL);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
+ _lv_style_list_set_local_ptr(&style_list, LV_STYLE_PATTERN_IMAGE, LV_SYMBOL_OK);
+
+ _lv_style_list_add_style(&style_list, &style3);
+ _lv_style_list_add_style(&style_list, &style2);
+ _lv_style_list_add_style(&style_list, &style1);
+
+ _lv_style_list_reset(&style_list);
+ lv_style_reset(&style1);
+ lv_style_reset(&style2);
+ lv_style_reset(&style3);
+
+ }
+
+ _lv_style_list_reset(&style_list);
+ lv_style_reset(&style1);
+ lv_style_reset(&style2);
+ lv_style_reset(&style3);
+
+ lv_test_assert_int_eq(LV_RES_OK, lv_mem_test(), "Memory integrity check");
+ lv_mem_defrag();
+ lv_mem_monitor(&mon_end);
+ lv_test_assert_int_lt(sizeof(void*) * 8, mon_start.free_size - mon_end.free_size, "Style memory leak");
+}
+#endif
diff --git a/src/libs/lvgl/tests/lv_test_core/lv_test_style.h b/src/libs/lvgl/tests/lv_test_core/lv_test_style.h
new file mode 100644
index 0000000..4011246
--- /dev/null
+++ b/src/libs/lvgl/tests/lv_test_core/lv_test_style.h
@@ -0,0 +1,38 @@
+/**
+ * @file lv_test_style.h
+ *
+ */
+
+#ifndef LV_TEST_STYLE_H
+#define LV_TEST_STYLE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*********************
+ * INCLUDES
+ *********************/
+
+/*********************
+ * DEFINES
+ *********************/
+
+/**********************
+ * TYPEDEFS
+ **********************/
+
+/**********************
+ * GLOBAL PROTOTYPES
+ **********************/
+void lv_test_style(void);
+
+/**********************
+ * MACROS
+ **********************/
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*LV_TEST_STYLE_H*/