diff --git a/tests/ref_imgs/bar_1.png b/tests/ref_imgs/bar_1.png new file mode 100644 index 000000000..15103b7ca Binary files /dev/null and b/tests/ref_imgs/bar_1.png differ diff --git a/tests/src/test_cases/test_bar.c b/tests/src/test_cases/test_bar.c index 14eacbe04..423d7b47e 100644 --- a/tests/src/test_cases/test_bar.c +++ b/tests/src/test_cases/test_bar.c @@ -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); } +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) { lv_bar_t * bar_ptr = (lv_bar_t *) bar;