mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-22 07:02:05 +08:00
feat(xml): add subject and global/local scoping support
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<globals>
|
||||
<config name="mylib" help="This is my great component library"/>
|
||||
|
||||
<consts>
|
||||
<int name="global_int" value="30"/>
|
||||
</consts>
|
||||
|
||||
<styles>
|
||||
<style name="global_red" bg_color="0xf00" radius="global_small_unit" pad_all="12px"/>
|
||||
</styles>
|
||||
|
||||
<subjects>
|
||||
<int name="global_subject" value="22"/>
|
||||
</subjects>
|
||||
</globals>
|
||||
@@ -0,0 +1,23 @@
|
||||
<component>
|
||||
<consts>
|
||||
<int name="local_int" value="15"/>
|
||||
<color name="local_blue" value="0x0000ff"/>
|
||||
</consts>
|
||||
|
||||
<styles>
|
||||
<style name="local_style" bg_color="#local_blue" border_color="#global_red" border_width="5"/>
|
||||
</styles>
|
||||
|
||||
<subjects>
|
||||
<int name="local_subject" value="10"/>
|
||||
</subjects>
|
||||
|
||||
|
||||
<view extends="lv_obj" width="480" height="300" flex_flow="column">
|
||||
<lv_label bind_text="global_subject"/>
|
||||
<lv_slider bind_value="global_subject" range_max="#global_int"/>
|
||||
|
||||
<lv_label bind_text="local_subject" style_margin_top="32px"/>
|
||||
<lv_slider bind_value="local_subject" range_max="#local_int"/>
|
||||
</view>
|
||||
</component>
|
||||
@@ -27,7 +27,7 @@ static void count_event_cb(lv_event_t * e)
|
||||
void test_xml_event_call_function_attr(void)
|
||||
{
|
||||
|
||||
lv_xml_register_event_cb("count_cb", count_event_cb);
|
||||
lv_xml_register_event_cb(NULL, "count_cb", count_event_cb);
|
||||
|
||||
lv_obj_t * scr = lv_screen_active();
|
||||
|
||||
@@ -80,7 +80,7 @@ void test_xml_event_call_function_component(void)
|
||||
"</component>"
|
||||
};
|
||||
|
||||
lv_xml_register_event_cb("count_cb", count_event_cb);
|
||||
lv_xml_register_event_cb(NULL, "count_cb", count_event_cb);
|
||||
lv_xml_component_register_from_data("my_button", xml);
|
||||
lv_xml_create(lv_screen_active(), "my_button", NULL);
|
||||
|
||||
|
||||
@@ -272,11 +272,11 @@ void test_xml_image_and_font(void)
|
||||
/*Monstserrat fonts are registered by LVGL */
|
||||
LV_IMAGE_DECLARE(img_render_lvgl_logo_l8);
|
||||
LV_IMAGE_DECLARE(img_render_lvgl_logo_rgb565);
|
||||
lv_xml_register_image("test_img1", &img_render_lvgl_logo_l8);
|
||||
lv_xml_register_image("test_img2", &img_render_lvgl_logo_rgb565);
|
||||
lv_xml_register_image(NULL, "test_img1", &img_render_lvgl_logo_l8);
|
||||
lv_xml_register_image(NULL, "test_img2", &img_render_lvgl_logo_rgb565);
|
||||
|
||||
lv_xml_register_font("lv_montserrat_16", &lv_font_montserrat_16);
|
||||
lv_xml_register_font("lv_montserrat_18", &lv_font_montserrat_18);
|
||||
lv_xml_register_font(NULL, "lv_montserrat_16", &lv_font_montserrat_16);
|
||||
lv_xml_register_font(NULL, "lv_montserrat_18", &lv_font_montserrat_18);
|
||||
|
||||
lv_xml_component_register_from_data("btn", btn_xml);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ void tearDown(void)
|
||||
void test_xml_image_with_attrs(void)
|
||||
{
|
||||
LV_IMAGE_DECLARE(test_img_lvgl_logo_png);
|
||||
lv_xml_register_image("logo", &test_img_lvgl_logo_png);
|
||||
lv_xml_register_image(NULL, "logo", &test_img_lvgl_logo_png);
|
||||
lv_obj_t * scr = lv_screen_active();
|
||||
|
||||
const char * image1_attrs[] = {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#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_label_with_attrs(void)
|
||||
{
|
||||
lv_obj_t * scr = lv_screen_active();
|
||||
|
||||
const char * textarea1_attrs[] = {
|
||||
"text", "This is the text with ellipses added automatically",
|
||||
"long_mode", "dots",
|
||||
"width", "100",
|
||||
"height", "40",
|
||||
"align", "center",
|
||||
"style_bg_opa", "50%",
|
||||
"style_bg_color", "0xf00",
|
||||
NULL, NULL,
|
||||
};
|
||||
|
||||
lv_xml_create(scr, "lv_label", textarea1_attrs);
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("xml/lv_label.png");
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
#if LV_BUILD_TEST || 1
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
@@ -16,7 +16,7 @@ void tearDown(void)
|
||||
|
||||
void test_xml_view2_from_xml(void)
|
||||
{
|
||||
lv_xml_register_font("lv_montserrat_30", &lv_font_montserrat_30);
|
||||
lv_xml_register_font(NULL, "lv_montserrat_30", &lv_font_montserrat_30);
|
||||
lv_xml_component_register_from_file("A:src/test_assets/xml/view2.xml");
|
||||
|
||||
lv_xml_create(lv_screen_active(), "view2", NULL);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#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_view3_scoping(void)
|
||||
{
|
||||
lv_xml_component_register_from_file("A:src/test_assets/xml/globals.xml");
|
||||
lv_xml_component_register_from_file("A:src/test_assets/xml/view3.xml");
|
||||
|
||||
lv_xml_create(lv_screen_active(), "view3", NULL);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("xml/view3.png");
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user