ci(bar): add screenshot test (#4503)

Signed-off-by: wangxuedong <wangxuedong@xiaomi.com>
This commit is contained in:
xaowang96
2023-08-31 16:19:26 +08:00
committed by GitHub
parent 5c984b4a53
commit d7289962f1
2 changed files with 72 additions and 0 deletions

BIN
tests/ref_imgs/bar_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@@ -136,6 +136,78 @@ void test_bar_rtl_should_update_indicator_left_coordinate_based_on_bar_value(voi
TEST_ASSERT_EQUAL_INT32(expected_coord, actual_coord); TEST_ASSERT_EQUAL_INT32(expected_coord, actual_coord);
} }
void test_bar_normal(void)
{
lv_coord_t w = 300;
lv_coord_t h = 40;
lv_coord_t h_gap = 20;
lv_coord_t w_gap = 20;
lv_coord_t y = h_gap;
lv_coord_t x = w_gap;
lv_color_t bg_color = lv_color_black();
lv_color_t indic_color = lv_color_hex(0x0000FF);
lv_obj_t * screen = lv_obj_create(lv_scr_act());
lv_obj_remove_style_all(screen);
lv_obj_set_size(screen, 800, 480);
lv_obj_center(screen);
lv_obj_set_style_bg_color(screen, lv_color_white(), 0);
lv_obj_set_style_bg_opa(screen, LV_OPA_100, 0);
lv_obj_set_style_pad_all(screen, 0, 0);
lv_obj_t * test_bar = lv_bar_create(screen);
lv_obj_set_style_radius(test_bar, 100, 0);
lv_obj_set_style_radius(test_bar, 100, LV_PART_MAIN);
lv_obj_set_style_bg_opa(test_bar, LV_OPA_30, LV_PART_MAIN);
lv_obj_set_style_bg_color(test_bar, bg_color, LV_PART_MAIN);
lv_obj_set_style_bg_color(test_bar, indic_color, LV_PART_INDICATOR);
lv_bar_set_range(test_bar, 0, 100);
lv_bar_set_value(test_bar, 30, LV_ANIM_OFF);
lv_obj_set_size(test_bar, w, h);
lv_obj_align(test_bar, LV_ALIGN_TOP_LEFT, x, y);
y += h + h_gap;
test_bar = lv_bar_create(screen);
lv_obj_set_style_radius(test_bar, 100, 0);
lv_obj_set_style_radius(test_bar, 100, LV_PART_MAIN);
lv_obj_set_style_bg_opa(test_bar, LV_OPA_30, LV_PART_MAIN);
lv_obj_set_style_bg_color(test_bar, bg_color, LV_PART_MAIN);
lv_obj_set_style_bg_color(test_bar, indic_color, LV_PART_INDICATOR);
lv_bar_set_range(test_bar, 0, 100);
lv_bar_set_value(test_bar, 30, LV_ANIM_OFF);
lv_obj_set_size(test_bar, w, h);
lv_obj_align(test_bar, LV_ALIGN_TOP_LEFT, x, y);
lv_obj_set_style_base_dir(test_bar, LV_BASE_DIR_RTL, 0);
y += h + h_gap;
x = 150;
test_bar = lv_bar_create(screen);
lv_obj_set_style_radius(test_bar, 100, 0);
lv_obj_set_style_radius(test_bar, 100, LV_PART_MAIN);
lv_obj_set_style_bg_opa(test_bar, LV_OPA_30, LV_PART_MAIN);
lv_obj_set_style_bg_color(test_bar, bg_color, LV_PART_MAIN);
lv_obj_set_style_bg_color(test_bar, indic_color, LV_PART_INDICATOR);
lv_bar_set_range(test_bar, 0, 100);
lv_bar_set_value(test_bar, 30, LV_ANIM_OFF);
lv_obj_set_size(test_bar, h, w);
lv_obj_align(test_bar, LV_ALIGN_TOP_LEFT, x, y);
x += h + w_gap;
test_bar = lv_bar_create(screen);
lv_obj_set_style_radius(test_bar, 100, 0);
lv_obj_set_style_radius(test_bar, 100, LV_PART_MAIN);
lv_obj_set_style_bg_opa(test_bar, LV_OPA_30, LV_PART_MAIN);
lv_obj_set_style_bg_color(test_bar, bg_color, LV_PART_MAIN);
lv_obj_set_style_bg_color(test_bar, indic_color, LV_PART_INDICATOR);
lv_bar_set_range(test_bar, 0, 100);
lv_bar_set_value(test_bar, 30, LV_ANIM_OFF);
lv_obj_set_size(test_bar, h, w);
lv_obj_set_style_base_dir(test_bar, LV_BASE_DIR_RTL, 0);
lv_obj_align(test_bar, LV_ALIGN_TOP_LEFT, x, y);
TEST_ASSERT_EQUAL_SCREENSHOT("bar_1.png");
}
void test_bar_indicator_area_should_get_smaller_when_padding_is_increased(void) void test_bar_indicator_area_should_get_smaller_when_padding_is_increased(void)
{ {
lv_bar_t * bar_ptr = (lv_bar_t *) bar; lv_bar_t * bar_ptr = (lv_bar_t *) bar;