feat(xml): add support scale, span, roller and bar
Also add some backward compatible API changes
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 36 KiB |
BIN
tests/ref_imgs/xml/lv_bar.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
tests/ref_imgs/xml/lv_roller.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
tests/ref_imgs/xml/lv_scale.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
tests/ref_imgs/xml/lv_spangroup.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
BIN
tests/ref_imgs_vg_lite/xml/lv_bar.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
tests/ref_imgs_vg_lite/xml/lv_roller.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
tests/ref_imgs_vg_lite/xml/lv_scale.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
tests/ref_imgs_vg_lite/xml/lv_spangroup.png
Normal file
|
After Width: | Height: | Size: 8.5 KiB |
@@ -117,10 +117,10 @@ void test_scale_render_example_2(void)
|
||||
|
||||
lv_scale_section_t * section = lv_scale_add_section(scale);
|
||||
/* Configure section styles */
|
||||
lv_scale_section_set_range(section, 75, 100);
|
||||
lv_scale_section_set_style(section, LV_PART_INDICATOR, §ion_label_style);
|
||||
lv_scale_section_set_style(section, LV_PART_ITEMS, §ion_minor_tick_style);
|
||||
lv_scale_section_set_style(section, LV_PART_MAIN, §ion_main_line_style);
|
||||
lv_scale_set_section_range(scale, section, 75, 100);
|
||||
lv_scale_set_section_style_indicator(scale, section, §ion_label_style);
|
||||
lv_scale_set_section_style_items(scale, section, §ion_minor_tick_style);
|
||||
lv_scale_set_section_style_main(scale, section, §ion_main_line_style);
|
||||
|
||||
lv_obj_set_style_bg_color(scale, lv_palette_main(LV_PALETTE_BLUE_GREY), 0);
|
||||
lv_obj_set_style_bg_opa(scale, LV_OPA_50, 0);
|
||||
@@ -234,10 +234,10 @@ void test_scale_render_example_4(void)
|
||||
|
||||
/* Configure section styles */
|
||||
lv_scale_section_t * section = lv_scale_add_section(scale);
|
||||
lv_scale_section_set_range(section, 75, 100);
|
||||
lv_scale_section_set_style(section, LV_PART_INDICATOR, §ion_label_style);
|
||||
lv_scale_section_set_style(section, LV_PART_ITEMS, §ion_minor_tick_style);
|
||||
lv_scale_section_set_style(section, LV_PART_MAIN, §ion_main_line_style);
|
||||
lv_scale_set_section_range(scale, section, 75, 100);
|
||||
lv_scale_set_section_style_indicator(scale, section, §ion_label_style);
|
||||
lv_scale_set_section_style_items(scale, section, §ion_minor_tick_style);
|
||||
lv_scale_set_section_style_main(scale, section, §ion_main_line_style);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/scale_4.png");
|
||||
}
|
||||
@@ -321,16 +321,16 @@ void test_scale_set_style(void)
|
||||
|
||||
/* Configure section styles */
|
||||
lv_scale_section_t * section = lv_scale_add_section(scale);
|
||||
lv_scale_section_set_range(section, 75, 100);
|
||||
lv_scale_set_section_range(scale, section, 75, 100);
|
||||
|
||||
lv_scale_section_set_style(section, LV_PART_MAIN, §ion_main_line_style);
|
||||
lv_scale_set_section_style_main(scale, section, §ion_main_line_style);
|
||||
TEST_ASSERT_NOT_NULL(section->main_style);
|
||||
TEST_ASSERT_NULL(section->indicator_style);
|
||||
TEST_ASSERT_NULL(section->items_style);
|
||||
|
||||
TEST_ASSERT_EQUAL(section->main_style, §ion_main_line_style);
|
||||
|
||||
lv_scale_section_set_style(section, LV_PART_INDICATOR, §ion_label_style);
|
||||
lv_scale_set_section_style_indicator(scale, section, §ion_label_style);
|
||||
TEST_ASSERT_NOT_NULL(section->main_style);
|
||||
TEST_ASSERT_NOT_NULL(section->indicator_style);
|
||||
TEST_ASSERT_NULL(section->items_style);
|
||||
@@ -338,7 +338,7 @@ void test_scale_set_style(void)
|
||||
TEST_ASSERT_EQUAL(section->main_style, §ion_main_line_style);
|
||||
TEST_ASSERT_EQUAL(section->indicator_style, §ion_label_style);
|
||||
|
||||
lv_scale_section_set_style(section, LV_PART_ITEMS, §ion_minor_tick_style);
|
||||
lv_scale_set_section_style_items(scale, section, §ion_minor_tick_style);
|
||||
TEST_ASSERT_NOT_NULL(section->main_style);
|
||||
TEST_ASSERT_NOT_NULL(section->indicator_style);
|
||||
TEST_ASSERT_NOT_NULL(section->items_style);
|
||||
@@ -346,22 +346,6 @@ void test_scale_set_style(void)
|
||||
TEST_ASSERT_EQUAL(section->main_style, §ion_main_line_style);
|
||||
TEST_ASSERT_EQUAL(section->indicator_style, §ion_label_style);
|
||||
TEST_ASSERT_EQUAL(section->items_style, §ion_minor_tick_style);
|
||||
|
||||
/* Invalid part */
|
||||
lv_scale_section_set_style(section, LV_PART_CURSOR, §ion_minor_tick_style);
|
||||
TEST_ASSERT_NOT_NULL(section->main_style);
|
||||
TEST_ASSERT_NOT_NULL(section->indicator_style);
|
||||
TEST_ASSERT_NOT_NULL(section->items_style);
|
||||
|
||||
TEST_ASSERT_EQUAL(section->main_style, §ion_main_line_style);
|
||||
TEST_ASSERT_EQUAL(section->indicator_style, §ion_label_style);
|
||||
TEST_ASSERT_EQUAL(section->items_style, §ion_minor_tick_style);
|
||||
|
||||
/* NULL section */
|
||||
lv_scale_section_t * null_section = NULL;
|
||||
|
||||
lv_scale_section_set_range(null_section, 75, 100);
|
||||
lv_scale_section_set_style(null_section, LV_PART_MAIN, §ion_main_line_style);
|
||||
}
|
||||
|
||||
/* The scale internally counts the number of custom labels until it finds the NULL sentinel */
|
||||
|
||||
@@ -150,7 +150,7 @@ void test_slider_normal_mode_should_leave_edit_mode_if_released(void)
|
||||
void test_ranged_mode_adjust_with_encoder(void)
|
||||
{
|
||||
lv_slider_set_value(sliderRangeMode, 90, LV_ANIM_OFF);
|
||||
lv_slider_set_left_value(sliderRangeMode, 10, LV_ANIM_OFF);
|
||||
lv_slider_set_start_value(sliderRangeMode, 10, LV_ANIM_OFF);
|
||||
|
||||
/* Setup group and encoder indev */
|
||||
lv_group_add_obj(g, sliderRangeMode);
|
||||
|
||||
@@ -33,7 +33,7 @@ void test_spangroup_create_returns_not_null_object(void)
|
||||
|
||||
void test_spangroup_new_span_with_null_parameter_returns_null_object(void)
|
||||
{
|
||||
lv_span_t * span = lv_spangroup_new_span(NULL);
|
||||
lv_span_t * span = lv_spangroup_add_span(NULL);
|
||||
|
||||
TEST_ASSERT(NULL == span);
|
||||
TEST_ASSERT_EQUAL_INT(0, lv_spangroup_get_span_count(spangroup));
|
||||
@@ -41,7 +41,7 @@ void test_spangroup_new_span_with_null_parameter_returns_null_object(void)
|
||||
|
||||
void test_spangroup_new_span_with_valid_parameter_returns_not_null_object(void)
|
||||
{
|
||||
lv_span_t * span = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
|
||||
TEST_ASSERT(NULL != span);
|
||||
TEST_ASSERT_EQUAL_INT(1, lv_spangroup_get_span_count(spangroup));
|
||||
@@ -49,7 +49,7 @@ void test_spangroup_new_span_with_valid_parameter_returns_not_null_object(void)
|
||||
|
||||
void test_spangroup_delete_span_span_is_null(void)
|
||||
{
|
||||
lv_span_t * span = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
|
||||
lv_spangroup_delete_span(spangroup, span);
|
||||
|
||||
@@ -59,7 +59,7 @@ void test_spangroup_delete_span_span_is_null(void)
|
||||
void test_span_set_text(void)
|
||||
{
|
||||
const char * test_text = "Test Text";
|
||||
lv_span_t * span = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
|
||||
lv_span_set_text(span, test_text);
|
||||
|
||||
@@ -69,7 +69,7 @@ void test_span_set_text(void)
|
||||
void test_span_set_text_with_bad_parameter_no_action_performed(void)
|
||||
{
|
||||
const char * test_text = "Test Text";
|
||||
lv_span_t * span = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
|
||||
lv_span_set_text(span, test_text);
|
||||
lv_span_set_text(span, NULL);
|
||||
@@ -81,7 +81,7 @@ void test_span_set_text_with_previous_test_overwrites(void)
|
||||
{
|
||||
const char * old_test_text = "Old Test Text";
|
||||
const char * new_test_text = "New Test Text and it is longer";
|
||||
lv_span_t * span = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
|
||||
lv_span_set_text(span, old_test_text);
|
||||
lv_span_set_text(span, new_test_text);
|
||||
@@ -92,7 +92,7 @@ void test_span_set_text_with_previous_test_overwrites(void)
|
||||
void test_span_set_text_static(void)
|
||||
{
|
||||
const char * test_text = "Test Text";
|
||||
lv_span_t * span = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
|
||||
lv_span_set_text_static(span, test_text);
|
||||
|
||||
@@ -102,7 +102,7 @@ void test_span_set_text_static(void)
|
||||
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_new_span(spangroup);
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
|
||||
lv_span_set_text_static(span, test_text);
|
||||
lv_span_set_text_static(span, NULL);
|
||||
@@ -114,7 +114,7 @@ void test_span_set_text_static_with_previous_text_overwrites(void)
|
||||
{
|
||||
const char * old_test_text = "Old Test Text";
|
||||
const char * new_test_text = "New Test Text and it is longer";
|
||||
lv_span_t * span = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
lv_span_set_text_static(span, old_test_text);
|
||||
lv_span_set_text_static(span, new_test_text);
|
||||
|
||||
@@ -205,7 +205,7 @@ void test_spangroup_get_max_line_h(void)
|
||||
|
||||
TEST_ASSERT_EQUAL(0, (uint32_t)max_line);
|
||||
|
||||
(void)lv_spangroup_new_span(spangroup);
|
||||
(void)lv_spangroup_add_span(spangroup);
|
||||
max_line = lv_spangroup_get_max_line_height(spangroup);
|
||||
|
||||
// TODO: find out why this magic numberdd
|
||||
@@ -218,12 +218,12 @@ void test_spangroup_draw(void)
|
||||
spangroup = lv_spangroup_create(active_screen);
|
||||
lv_spangroup_set_mode(spangroup, LV_SPAN_MODE_BREAK);
|
||||
lv_obj_set_width(spangroup, 100);
|
||||
lv_span_t * span_1 = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span_1 = lv_spangroup_add_span(spangroup);
|
||||
lv_span_set_text(span_1, "This text is over 100 pixels width");
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/span_01.png");
|
||||
|
||||
lv_span_t * span_2 = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span_2 = lv_spangroup_add_span(spangroup);
|
||||
lv_span_set_text(span_2, "This text is also over 100 pixels width");
|
||||
lv_style_set_text_decor(&span_2->style, LV_TEXT_DECOR_STRIKETHROUGH);
|
||||
|
||||
@@ -246,8 +246,8 @@ void test_spangroup_get_child(void)
|
||||
{
|
||||
const int32_t span_1_idx = 0;
|
||||
const int32_t span_2_idx = 1;
|
||||
lv_span_t * span_1 = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span_2 = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span_1 = lv_spangroup_add_span(spangroup);
|
||||
lv_span_t * span_2 = lv_spangroup_add_span(spangroup);
|
||||
|
||||
TEST_ASSERT_EQUAL_PTR(span_2, lv_spangroup_get_child(spangroup, span_2_idx));
|
||||
TEST_ASSERT_EQUAL_PTR(span_1, lv_spangroup_get_child(spangroup, span_1_idx));
|
||||
@@ -255,8 +255,8 @@ void test_spangroup_get_child(void)
|
||||
|
||||
void test_spangroup_get_child_count(void)
|
||||
{
|
||||
(void)lv_spangroup_new_span(spangroup);
|
||||
(void)lv_spangroup_new_span(spangroup);
|
||||
(void)lv_spangroup_add_span(spangroup);
|
||||
(void)lv_spangroup_add_span(spangroup);
|
||||
|
||||
const uint32_t cnt = lv_spangroup_get_span_count(spangroup);
|
||||
|
||||
@@ -270,7 +270,7 @@ void test_spangroup_get_expand_width(void)
|
||||
active_screen = lv_screen_active();
|
||||
|
||||
spangroup = lv_spangroup_create(active_screen);
|
||||
lv_span_t * span = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span = lv_spangroup_add_span(spangroup);
|
||||
lv_span_set_text(span, "This text is over 100 pixels width");
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(experimental_size,
|
||||
@@ -286,26 +286,26 @@ void test_spangroup_newlines(void)
|
||||
spangroup = lv_spangroup_create(active_screen);
|
||||
lv_obj_set_size(spangroup, LV_PCT(100), LV_PCT(100));
|
||||
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "Lorem\n");
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "ipsum");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "Lorem\n");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "ipsum");
|
||||
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "\n\n");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "\n\n");
|
||||
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "dolor");
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "");
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "\nsit");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "dolor");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "\nsit");
|
||||
|
||||
/* carriage return is treated as equivalent to line feed */
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "\r");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "\r");
|
||||
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "amet,\n consectetur");
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), " adipiscing");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "amet,\n consectetur");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), " adipiscing");
|
||||
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "\n");
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "\n");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "");
|
||||
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "\relit, sed\n");
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "do eiusmod");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "\relit, sed\n");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "do eiusmod");
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/span_06.png");
|
||||
}
|
||||
@@ -331,15 +331,15 @@ void test_spangroup_chinese_break_line(void)
|
||||
lv_obj_set_style_border_width(spangroup, 2, 0);
|
||||
lv_obj_set_width(spangroup, 250);
|
||||
|
||||
lv_span_t * span1 = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span1 = lv_spangroup_add_span(spangroup);
|
||||
lv_span_set_text(span1, "八百标兵奔北坡");
|
||||
lv_span_t * span2 = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span2 = lv_spangroup_add_span(spangroup);
|
||||
lv_span_set_text(span2, "炮兵并排北边跑");
|
||||
lv_style_set_text_color(&span2->style, lv_palette_main(LV_PALETTE_RED));
|
||||
lv_span_t * span3 = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span3 = lv_spangroup_add_span(spangroup);
|
||||
lv_span_set_text(span3, "中英文测试。The quick brown fox jumps over a lazy dog. ");
|
||||
lv_style_set_text_color(&span3->style, lv_palette_main(LV_PALETTE_BLUE));
|
||||
lv_span_t * span4 = lv_spangroup_new_span(spangroup);
|
||||
lv_span_t * span4 = lv_spangroup_add_span(spangroup);
|
||||
lv_span_set_text(span4, "abcdefghijklmn中英文测试");
|
||||
lv_style_set_text_color(&span4->style, lv_palette_main(LV_PALETTE_GREEN));
|
||||
|
||||
@@ -365,12 +365,12 @@ void test_spangroup_style_text_letter_space(void)
|
||||
lv_obj_set_style_outline_width(spangroup, 1, 0);
|
||||
lv_obj_set_style_text_letter_space(spangroup, 20, 0);
|
||||
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "A");
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "B");
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "C");
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "D");
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "E");
|
||||
lv_span_set_text(lv_spangroup_new_span(spangroup), "F");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "A");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "B");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "C");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "D");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "E");
|
||||
lv_span_set_text(lv_spangroup_add_span(spangroup), "F");
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/span_08.png");
|
||||
}
|
||||
@@ -393,33 +393,33 @@ void test_spangroup_get_span_coords(void)
|
||||
lv_obj_set_style_pad_all(spangroup, 20, LV_PART_MAIN);
|
||||
|
||||
/* Create spans and set their properties */
|
||||
spans[0] = lv_spangroup_new_span(spangroup);
|
||||
spans[0] = lv_spangroup_add_span(spangroup);
|
||||
lv_span_set_text(spans[0], "China is a beautiful country.");
|
||||
lv_style_set_text_color(lv_span_get_style(spans[0]), lv_palette_main(LV_PALETTE_RED));
|
||||
lv_style_set_text_decor(lv_span_get_style(spans[0]), LV_TEXT_DECOR_UNDERLINE);
|
||||
lv_style_set_text_opa(lv_span_get_style(spans[0]), LV_OPA_50);
|
||||
|
||||
spans[1] = lv_spangroup_new_span(spangroup);
|
||||
spans[1] = lv_spangroup_add_span(spangroup);
|
||||
lv_span_set_text_static(spans[1], "good good study, day day up.");
|
||||
lv_style_set_text_font(lv_span_get_style(spans[1]), &lv_font_montserrat_24);
|
||||
lv_style_set_text_color(lv_span_get_style(spans[1]), lv_palette_main(LV_PALETTE_GREEN));
|
||||
|
||||
spans[2] = lv_spangroup_new_span(spangroup);
|
||||
spans[2] = lv_spangroup_add_span(spangroup);
|
||||
lv_span_set_text_static(spans[2], "LVGL is an open-source graphics library.");
|
||||
lv_style_set_text_color(lv_span_get_style(spans[2]), lv_palette_main(LV_PALETTE_BLUE));
|
||||
|
||||
spans[3] = lv_spangroup_new_span(spangroup);
|
||||
spans[3] = lv_spangroup_add_span(spangroup);
|
||||
lv_span_set_text_static(spans[3], "the boy no name.");
|
||||
lv_style_set_text_color(lv_span_get_style(spans[3]), lv_palette_main(LV_PALETTE_GREEN));
|
||||
lv_style_set_text_font(lv_span_get_style(spans[3]), &lv_font_montserrat_20);
|
||||
lv_style_set_text_decor(lv_span_get_style(spans[3]), LV_TEXT_DECOR_UNDERLINE);
|
||||
|
||||
spans[4] = lv_spangroup_new_span(spangroup);
|
||||
spans[4] = lv_spangroup_add_span(spangroup);
|
||||
lv_span_set_text(spans[4], "I have a dream that hope to come true.");
|
||||
lv_style_set_text_decor(lv_span_get_style(spans[4]), LV_TEXT_DECOR_STRIKETHROUGH);
|
||||
|
||||
/* Refresh the span group mode and update layout */
|
||||
lv_spangroup_refr_mode(spangroup);
|
||||
lv_spangroup_refresh(spangroup);
|
||||
lv_obj_update_layout(spangroup);
|
||||
|
||||
/* Define expected coordinates for testing */
|
||||
|
||||
74
tests/src/test_cases/xml/test_xml_bar.c
Normal file
@@ -0,0 +1,74 @@
|
||||
#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());
|
||||
}
|
||||
|
||||
static void test_with_attrs(const char * name)
|
||||
{
|
||||
lv_obj_t * scr = lv_screen_active();
|
||||
|
||||
lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
lv_xml_create(scr, name, NULL);
|
||||
|
||||
const char * attrs_1[] = {
|
||||
"value", "30",
|
||||
"width", "100",
|
||||
NULL, NULL,
|
||||
};
|
||||
|
||||
lv_xml_create(scr, name, attrs_1);
|
||||
|
||||
const char * attrs_2[] = {
|
||||
"range", "-100 100",
|
||||
"mode", "symmetrical",
|
||||
"value", "50",
|
||||
NULL, NULL,
|
||||
};
|
||||
|
||||
lv_xml_create(scr, name, attrs_2);
|
||||
|
||||
const char * attrs_3[] = {
|
||||
"orientation", "vertical",
|
||||
"height", "80",
|
||||
"width", "30",
|
||||
"value", "40",
|
||||
NULL, NULL,
|
||||
};
|
||||
|
||||
lv_xml_create(scr, name, attrs_3);
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("xml/lv_bar.png");
|
||||
}
|
||||
|
||||
void test_xml_bar_widget(void)
|
||||
{
|
||||
test_with_attrs("lv_bar");
|
||||
}
|
||||
|
||||
void test_xml_bar_component(void)
|
||||
{
|
||||
const char * xml = "<component>"
|
||||
"<view extends=\"lv_bar\">"
|
||||
"</view>"
|
||||
"</component>";
|
||||
|
||||
lv_xml_component_register_from_data("bar_test", xml);
|
||||
|
||||
test_with_attrs("bar_test");
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
@@ -23,6 +24,8 @@ void test_xml_chart_with_attrs(void)
|
||||
"height", "100",
|
||||
"type", "bar",
|
||||
"point_count", "8",
|
||||
"style_length:indicator", "10",
|
||||
"style_transform_rotation:indicator", "300",
|
||||
NULL, NULL,
|
||||
};
|
||||
|
||||
|
||||
36
tests/src/test_cases/xml/test_xml_roller.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#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_roller_with_attrs(void)
|
||||
{
|
||||
|
||||
lv_obj_t * scr = lv_screen_active();
|
||||
|
||||
const char * roller_attrs[] = {
|
||||
"width", "200",
|
||||
"options", "'a\nb\nc\nd\ne' infinite",
|
||||
"selected", "2 true",
|
||||
"visible_line_count", "3",
|
||||
NULL, NULL,
|
||||
};
|
||||
|
||||
lv_obj_t * roller = lv_xml_create(scr, "lv_roller", roller_attrs);
|
||||
lv_obj_center(roller);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("xml/lv_roller.png");
|
||||
}
|
||||
|
||||
#endif
|
||||
53
tests/src/test_cases/xml/test_xml_scale.c
Normal file
@@ -0,0 +1,53 @@
|
||||
#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_scale_with_attrs(void)
|
||||
{
|
||||
lv_obj_t * scr = lv_screen_active();
|
||||
|
||||
const char * scale_attrs[] = {
|
||||
"width", "120",
|
||||
"height", "120",
|
||||
"mode", "round_outer",
|
||||
"range", "0 150",
|
||||
"total_tick_count", "16",
|
||||
"major_tick_every", "3",
|
||||
"style_length:indicator", "10",
|
||||
"style_transform_rotation:indicator", "300",
|
||||
NULL, NULL,
|
||||
};
|
||||
|
||||
lv_obj_t * scale = lv_xml_create(scr, "lv_scale", scale_attrs);
|
||||
lv_obj_center(scale);
|
||||
|
||||
const char * section_attrs[] = {
|
||||
"range", "10 80",
|
||||
NULL, NULL,
|
||||
};
|
||||
|
||||
lv_scale_section_t * section = lv_xml_create(scale, "lv_scale-section", section_attrs);
|
||||
|
||||
static lv_style_t style;
|
||||
lv_style_init(&style);
|
||||
lv_style_set_text_color(&style, lv_color_hex(0xff0000));
|
||||
lv_style_set_line_color(&style, lv_color_hex(0x00ff00));
|
||||
lv_style_set_line_width(&style, 4);
|
||||
lv_scale_set_section_style_indicator(scale, section, &style);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("xml/lv_scale.png");
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -32,8 +32,7 @@ static void test_with_attrs(const char * name)
|
||||
lv_xml_create(scr, name, attrs_1);
|
||||
|
||||
const char * attrs_2[] = {
|
||||
"range_min", "-100",
|
||||
"range_max", "100",
|
||||
"range", "-100 100",
|
||||
"mode", "symmetrical",
|
||||
"value", "50",
|
||||
NULL, NULL,
|
||||
|
||||
67
tests/src/test_cases/xml/test_xml_spangroup.c
Normal file
@@ -0,0 +1,67 @@
|
||||
#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_spangroup_with_attrs(void)
|
||||
{
|
||||
|
||||
lv_obj_t * scr = lv_screen_active();
|
||||
|
||||
const char * spangroup_attrs[] = {
|
||||
"width", "300",
|
||||
"indent", "40",
|
||||
"max_lines", "3",
|
||||
"overflow", "ellipsis",
|
||||
"style_text_align", "center",
|
||||
"style_bg_opa", "20%",
|
||||
"style_bg_color", "#ffff00",
|
||||
NULL, NULL,
|
||||
};
|
||||
|
||||
lv_obj_t * spangroup = lv_xml_create(scr, "lv_spangroup", spangroup_attrs);
|
||||
lv_obj_center(spangroup);
|
||||
|
||||
const char * span1_attrs[] = {
|
||||
"text", "This is a red text as a span!",
|
||||
NULL, NULL,
|
||||
};
|
||||
|
||||
lv_span_t * span1 = lv_xml_create(spangroup, "lv_spangroup-span", span1_attrs);
|
||||
|
||||
static lv_style_t style1;
|
||||
lv_style_init(&style1);
|
||||
lv_style_set_text_color(&style1, lv_color_hex(0xff0000));
|
||||
lv_style_set_text_letter_space(&style1, 5);
|
||||
|
||||
lv_spangroup_set_span_style(spangroup, span1, &style1);
|
||||
|
||||
const char * span2_attrs[] = {
|
||||
"text", "And this a large blue!",
|
||||
NULL, NULL,
|
||||
};
|
||||
|
||||
lv_span_t * span2 = lv_xml_create(spangroup, "lv_spangroup-span", span2_attrs);
|
||||
|
||||
static lv_style_t style2;
|
||||
lv_style_init(&style2);
|
||||
lv_style_set_text_color(&style2, lv_color_hex(0x0000ff));
|
||||
lv_style_set_text_font(&style2, &lv_font_montserrat_48);
|
||||
|
||||
lv_spangroup_set_span_style(spangroup, span2, &style2);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("xml/lv_spangroup.png");
|
||||
}
|
||||
|
||||
#endif
|
||||