1 #if LV_BUILD_TEST
2 #include "../lvgl.h"
3
4 #include "unity/unity.h"
5
setUp(void)6 void setUp(void)
7 {
8 /* Function run before every test */
9 }
10
tearDown(void)11 void tearDown(void)
12 {
13 /* Function run after every test */
14 lv_obj_clean(lv_screen_active());
15 }
16
test_with_attrs(const char * name)17 static void test_with_attrs(const char * name)
18 {
19 lv_obj_t * scr = lv_screen_active();
20
21 lv_obj_set_flex_flow(scr, LV_FLEX_FLOW_COLUMN);
22 lv_obj_set_flex_align(scr, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
23
24 lv_xml_create(scr, name, NULL);
25
26 const char * attrs_1[] = {
27 "value", "30",
28 "width", "100",
29 NULL, NULL,
30 };
31
32 lv_xml_create(scr, name, attrs_1);
33
34 const char * attrs_2[] = {
35 "range_min", "-100",
36 "range_max", "100",
37 "mode", "symmetrical",
38 "value", "50",
39 NULL, NULL,
40 };
41
42 lv_xml_create(scr, name, attrs_2);
43
44 const char * attrs_3[] = {
45 "orientation", "vertical",
46 "height", "80",
47 "width", "30",
48 "value", "40",
49 NULL, NULL,
50 };
51
52 lv_xml_create(scr, name, attrs_3);
53
54
55 TEST_ASSERT_EQUAL_SCREENSHOT("xml/lv_slider.png");
56 }
57
test_xml_slider_widget(void)58 void test_xml_slider_widget(void)
59 {
60 test_with_attrs("lv_slider");
61 }
62
test_xml_slider_component(void)63 void test_xml_slider_component(void)
64 {
65 const char * xml = "<component>"
66 "<view extends=\"lv_slider\">"
67 "</view>"
68 "</component>";
69
70 lv_xml_component_register_from_data("slider_test", xml);
71
72 test_with_attrs("slider_test");
73 }
74
75 #endif
76