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_tabview_with_attrs(void)17 void test_xml_tabview_with_attrs(void)
18 {
19 lv_obj_t * scr = lv_screen_active();
20
21 const char * tabview_attrs[] = {
22 "width", "300",
23 "height", "250",
24 "tab_bar_position", "bottom",
25 "active", "1",
26 NULL, NULL,
27 };
28
29 lv_obj_t * tabview = lv_xml_create(scr, "lv_tabview", tabview_attrs);
30 lv_obj_center(tabview);
31
32 const char * tabbar_attrs[] = {
33 "style_pad_left", "100",
34 "height", "100",
35 NULL, NULL,
36 };
37 lv_obj_t * tabbar = lv_xml_create(tabview, "lv_tabview-tab_bar", tabbar_attrs);
38
39 const char * tabbar_label_attrs[] = {
40 "ignore_layout", "true",
41 "text", "Hello\ntabview!",
42 "x", "-90",
43 "style_text_align", "right",
44 "align", "left_mid",
45 NULL, NULL,
46 };
47 lv_xml_create(tabbar, "lv_label", tabbar_label_attrs);
48
49
50 const char * tab1_attrs[] = {
51 "text", "Tab1",
52 NULL, NULL,
53 };
54 lv_obj_t * tab1 = lv_xml_create(tabview, "lv_tabview-tab", tab1_attrs);
55
56 lv_obj_t * label1 = lv_label_create(tab1);
57 lv_label_set_text(label1, "This is the first tab");
58
59 const char * tab2_attrs[] = {
60 "text", "Tab2",
61 NULL, NULL,
62 };
63 lv_obj_t * tab2 = lv_xml_create(tabview, "lv_tabview-tab", tab2_attrs);
64
65 lv_obj_t * label2 = lv_label_create(tab2);
66 lv_label_set_text(label2, "This is the second tab");
67
68
69 TEST_ASSERT_EQUAL_SCREENSHOT("xml/lv_tabview.png");
70 }
71
72 #endif
73