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_xml_chart_with_attrs(void)17 void test_xml_chart_with_attrs(void)
18 {
19     lv_obj_t * scr = lv_screen_active();
20 
21     const char * chart_attrs[] = {
22         "width", "200",
23         "height", "100",
24         "type", "bar",
25         "point_count", "8",
26         NULL, NULL,
27     };
28 
29     lv_obj_t * chart = lv_xml_create(scr, "lv_chart", chart_attrs);
30     lv_obj_center(chart);
31 
32     const char * primary_y_axis_attrs[] = {
33         "axis", "primary_y",
34         "range", "0 40",
35         NULL, NULL,
36     };
37     lv_xml_create(chart, "lv_chart-axis", primary_y_axis_attrs);
38 
39     const char * series_1_axis_attrs[] = {
40         "axis", "primary_y",
41         "color", "0xff0000",
42         "values", "10 20 30 10 20 30",
43         NULL, NULL,
44     };
45 
46     lv_chart_series_t * ser1 = lv_xml_create(chart, "lv_chart-series", series_1_axis_attrs);
47 
48     const char * series_2_axis_attrs[] = {
49         "axis", "secondary_y",
50         "color", "0x00ff00",
51         "values", "90 80",
52         NULL, NULL,
53     };
54 
55     lv_chart_series_t * ser2 = lv_xml_create(chart, "lv_chart-series", series_2_axis_attrs);
56 
57     const char * secondary_y_axis_attrs[] = {
58         "axis", "secondary_y",
59         "range", "70 90",
60         NULL, NULL,
61     };
62     lv_xml_create(chart, "lv_chart-axis", secondary_y_axis_attrs);
63 
64     lv_chart_set_next_value(chart, ser1, 40);
65     lv_chart_set_next_value(chart, ser2, 70);
66 
67 
68     TEST_ASSERT_EQUAL_SCREENSHOT("xml/lv_chart.png");
69 }
70 
71 #endif
72