test(bar): add unit tests (#2845)

* test(bar) Add test for docummented default attributes

* test(bar) Update test for docummented default attributes

* test(bar): Indicator width tracks value

* test(bar) Calculate bar indicator width based on its style

Take padding, max value and bar value into consideraion

* test(bar) Indicator area gets smaller when increasing padding in LV_PART_MAIN style

* test(bar) Start value changes only when in range mode

* docs(bar): Add missing MODE to symbols

* test(bar) Start value should be smaller than current value

* test(bar): Test current value truncation to max and min value

* bar: Check bar mode in lv_bar_set_start_value

bar start_value can be changed only when bar is in LV_BAR_MODE_RANGE mode.
Return early when it's not.

* test(bar): Fix width calculation test

* bar: Initialize indic_area in constructor

* test(bar): Refactor indicator coordinate update test

* test(bar): Indicator negative value in symmetrical mode

* test(bar): Fix base direction

* test(bar): Indicator coord test for RTL base dir
This commit is contained in:
Carlos Diaz
2022-01-22 09:17:13 -06:00
committed by GitHub
parent 1f9d3892a3
commit 0b68840cd9
3 changed files with 264 additions and 3 deletions

View File

@@ -107,6 +107,10 @@ void lv_bar_set_start_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim
lv_bar_t * bar = (lv_bar_t *)obj;
if(bar->mode != LV_BAR_MODE_RANGE) {
return;
}
value = LV_CLAMP(bar->min_value, value, bar->max_value);
value = value > bar->cur_value ? bar->cur_value : value; /*Can't be greater than the right value*/
@@ -211,7 +215,11 @@ static void lv_bar_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
bar->max_value = 100;
bar->start_value = 0;
bar->cur_value = 0;
bar->mode = LV_BAR_MODE_NORMAL;
bar->indic_area.x1 = 0;
bar->indic_area.x2 = 0;
bar->indic_area.y1 = 0;
bar->indic_area.y2 = 0;
bar->mode = LV_BAR_MODE_NORMAL;
lv_bar_init_anim(obj, &bar->cur_value_anim);
lv_bar_init_anim(obj, &bar->start_value_anim);