fix(xml): add the missing parsing of min/max subject limits (#8971)
Arduino Lint / lint (push) Has been cancelled
Build Examples with C++ Compiler / build-examples (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_NORMAL_8BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_SDL - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build ESP IDF ESP32S3 (push) Has been cancelled
C/C++ CI / Run tests with 32bit build (push) Has been cancelled
C/C++ CI / Run tests with 64bit build (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify that lv_conf_internal.h matches repository state / verify-conf-internal (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Compare file templates with file names / template-check (push) Has been cancelled
Build docs / build-and-deploy (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
Install LVGL using CMake / build-examples (push) Has been cancelled
Check Makefile / Build using Makefile (push) Has been cancelled
Check Makefile for UEFI / Build using Makefile for UEFI (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/benchmark_results_comment/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/filter_docker_logs/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/serialize_results/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 32b - lv_conf_perf32b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 64b - lv_conf_perf64b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Save PR Number (push) Has been cancelled
Hardware Performance Test / Hardware Performance Benchmark (push) Has been cancelled
Hardware Performance Test / HW Benchmark - Save PR Number (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_32B - Ubuntu (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_64B - Ubuntu (push) Has been cancelled
Port repo release update / run-release-branch-updater (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
Gabor Kiss-Vamosi
2025-09-29 19:46:58 +02:00
committed by GitHub
parent f04cdf7d72
commit 664aecf32f
2 changed files with 57 additions and 2 deletions
+12 -2
View File
@@ -486,10 +486,20 @@ static void process_subject_element(lv_xml_parser_state_t * state, const char *
}
lv_subject_t * subject = lv_zalloc(sizeof(lv_subject_t));
const char * min_value_str = lv_xml_get_value_of(attrs, "min_value");
const char * max_value_str = lv_xml_get_value_of(attrs, "max_value");
if(lv_streq(type, "int")) lv_subject_init_int(subject, lv_xml_atoi(value));
if(lv_streq(type, "int")) {
lv_subject_init_int(subject, lv_xml_atoi(value));
if(min_value_str) lv_subject_set_min_value_int(subject, lv_xml_atoi(min_value_str));
if(max_value_str) lv_subject_set_max_value_int(subject, lv_xml_atoi(max_value_str));
}
#if LV_USE_FLOAT
else if(lv_streq(type, "float")) lv_subject_init_float(subject, lv_xml_atof(value));
else if(lv_streq(type, "float")) {
lv_subject_init_float(subject, lv_xml_atof(value));
if(min_value_str) lv_subject_set_min_value_float(subject, lv_xml_atof(min_value_str));
if(max_value_str) lv_subject_set_max_value_float(subject, lv_xml_atof(max_value_str));
}
#endif
else if(lv_streq(type, "color")) lv_subject_init_color(subject, lv_xml_to_color(value));
else if(lv_streq(type, "string")) {
@@ -0,0 +1,45 @@
#if LV_BUILD_TEST
#include "../lvgl.h"
#include "unity/unity.h"
void setUp(void)
{
/* Function run before every test */
}
void tearDown(void)
{
/* Function run after every test */
lv_obj_clean(lv_screen_active());
}
void test_xml_subject_int(void)
{
const char * xml = "<globals>"
" <subjects>"
" <int name=\"s1\" value=\"10\"/>"
" <int name=\"s2\" value=\"20\" min_value=\"10\" max_value=\"30\"/>"
" </subjects>"
"</globals>";
lv_xml_component_register_from_data("globals", xml);
lv_subject_t * s1 = lv_xml_get_subject(NULL, "s1");
lv_subject_t * s2 = lv_xml_get_subject(NULL, "s2");
TEST_ASSERT_EQUAL_INT32(10, lv_subject_get_int(s1));
TEST_ASSERT_EQUAL_INT32(20, lv_subject_get_int(s2));
lv_subject_set_int(s1, 35);
lv_subject_set_int(s2, 35);
TEST_ASSERT_EQUAL_INT32(35, lv_subject_get_int(s1));
TEST_ASSERT_EQUAL_INT32(30, lv_subject_get_int(s2));
lv_subject_set_int(s1, 5);
lv_subject_set_int(s2, 5);
TEST_ASSERT_EQUAL_INT32(5, lv_subject_get_int(s1));
TEST_ASSERT_EQUAL_INT32(10, lv_subject_get_int(s2));
}
#endif