1 #if LV_BUILD_TEST
2 #include "../lvgl.h"
3 #include "../../lvgl_private.h"
4 
5 #include "unity/unity.h"
6 
setUp(void)7 void setUp(void)
8 {
9     /* Function run before every test */
10 }
11 
tearDown(void)12 void tearDown(void)
13 {
14     /* Function run after every test */
15 }
16 
create_panel(int32_t radius,bool transform)17 static lv_obj_t * create_panel(int32_t radius, bool transform)
18 {
19     lv_obj_t * parent = lv_obj_create(lv_screen_active());
20     lv_obj_set_style_pad_all(parent, 3, 0);
21     lv_obj_set_style_radius(parent, radius, 0);
22     lv_obj_set_style_clip_corner(parent, true, 0);
23     lv_obj_set_style_shadow_color(parent, lv_color_hex(0x888888), 0);
24     lv_obj_set_style_shadow_width(parent, 30, 0);
25     lv_obj_set_style_shadow_spread(parent, 10, 0);
26     lv_obj_set_style_outline_color(parent, lv_color_hex(0xff0000), 0);
27     lv_obj_set_style_outline_width(parent, 2, 0);
28     lv_obj_set_style_outline_pad(parent, 5, 0);
29     if(transform) lv_obj_set_style_transform_rotation(parent, 300, 0);
30 
31     lv_obj_t * label = lv_label_create(parent);
32     lv_obj_set_width(label, lv_pct(200));
33     lv_label_set_text(label,
34                       "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus dignissim quam id eros iaculis dapibus. Mauris nisl orci, vulputate sed eleifend a, consectetur et nulla.");
35     lv_obj_set_style_text_font(label, &lv_font_montserrat_24, 0);
36     lv_obj_set_style_bg_color(label, lv_palette_main(LV_PALETTE_RED), 0);
37     lv_obj_set_style_bg_opa(label, LV_OPA_20, 0);
38 
39     lv_obj_update_layout(parent);
40     lv_obj_scroll_by(parent, -15, -15, LV_ANIM_OFF);
41 
42     return parent;
43 }
44 
test_clip_corner_1(void)45 void test_clip_corner_1(void)
46 {
47     lv_obj_set_flex_flow(lv_screen_active(), LV_FLEX_FLOW_ROW_WRAP);
48     lv_obj_set_flex_align(lv_screen_active(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_EVENLY);
49     lv_obj_set_style_pad_column(lv_screen_active(), 40, 0);
50 
51     create_panel(0, false);
52     create_panel(10, false);
53     create_panel(30, false);
54     create_panel(100, false);
55 
56     lv_obj_t * cont = create_panel(0, true);
57     lv_obj_add_flag(cont, LV_OBJ_FLAG_FLEX_IN_NEW_TRACK);
58     create_panel(10, true);
59     create_panel(30, true);
60     create_panel(100, true);
61 
62     TEST_ASSERT_EQUAL_SCREENSHOT("draw/clip_corner_1.png");
63 
64 }
65 
66 #endif
67