55
66#include "lv_test_indev.h"
77
8- static lv_obj_t * active_screen = NULL ;
9- static lv_obj_t * bar = NULL ;
8+ static lv_obj_t * g_active_screen = NULL ;
9+ static lv_obj_t * g_bar = NULL ;
1010
1111void setUp (void )
1212{
13- active_screen = lv_screen_active ();
14- bar = lv_bar_create (active_screen );
13+ g_active_screen = lv_screen_active ();
14+ g_bar = lv_bar_create (g_active_screen );
1515}
1616
1717void tearDown (void )
@@ -20,9 +20,9 @@ void tearDown(void)
2020
2121void test_bar_should_have_valid_default_attributes (void )
2222{
23- TEST_ASSERT_EQUAL (0 , lv_bar_get_min_value (bar ));
24- TEST_ASSERT_EQUAL (100 , lv_bar_get_max_value (bar ));
25- TEST_ASSERT_EQUAL (LV_BAR_MODE_NORMAL , lv_bar_get_mode (bar ));
23+ TEST_ASSERT_EQUAL (0 , lv_bar_get_min_value (g_bar ));
24+ TEST_ASSERT_EQUAL (100 , lv_bar_get_max_value (g_bar ));
25+ TEST_ASSERT_EQUAL (LV_BAR_MODE_NORMAL , lv_bar_get_mode (g_bar ));
2626}
2727
2828/*
@@ -43,7 +43,7 @@ void test_bar_should_have_valid_default_attributes(void)
4343 */
4444void test_bar_should_update_indicator_right_coordinate_based_on_bar_value (void )
4545{
46- lv_bar_t * bar_ptr = (lv_bar_t * ) bar ;
46+ lv_bar_t * bar_ptr = (lv_bar_t * ) g_bar ;
4747
4848 static lv_style_t bar_style ;
4949
@@ -56,21 +56,21 @@ void test_bar_should_update_indicator_right_coordinate_based_on_bar_value(void)
5656 lv_style_set_pad_all (& bar_style , style_padding );
5757
5858 /* Setup new style */
59- lv_obj_remove_style_all (bar );
60- lv_obj_add_style (bar , & bar_style , LV_PART_MAIN );
59+ lv_obj_remove_style_all (g_bar );
60+ lv_obj_add_style (g_bar , & bar_style , LV_PART_MAIN );
6161
6262 /* Set properties */
63- lv_obj_set_size (bar , bar_width , bar_height );
64- lv_bar_set_value (bar , bar_value , LV_ANIM_OFF );
63+ lv_obj_set_size (g_bar , bar_width , bar_height );
64+ lv_bar_set_value (g_bar , bar_value , LV_ANIM_OFF );
6565
6666 /* FIXME: Remove wait */
6767 lv_test_indev_wait (50 );
6868
6969 int32_t actual_coord = lv_area_get_width (& bar_ptr -> indic_area );
7070
7171 /* Calculate bar indicator right coordinate, using rule of 3 */
72- int32_t bar_max_value = lv_bar_get_max_value (bar );
73- int32_t indicator_part_width = lv_obj_get_content_width (bar );
72+ int32_t bar_max_value = lv_bar_get_max_value (g_bar );
73+ int32_t indicator_part_width = lv_obj_get_content_width (g_bar );
7474
7575 int32_t expected_coord = (bar_value * indicator_part_width ) / bar_max_value ;
7676 /* NOTE: Add 1 to calculation because the coordinates start at 0 */
@@ -96,7 +96,7 @@ void test_bar_should_update_indicator_right_coordinate_based_on_bar_value(void)
9696 */
9797void test_bar_rtl_should_update_indicator_left_coordinate_based_on_bar_value (void )
9898{
99- lv_bar_t * bar_ptr = (lv_bar_t * ) bar ;
99+ lv_bar_t * bar_ptr = (lv_bar_t * ) g_bar ;
100100
101101 static lv_style_t bar_style ;
102102
@@ -109,23 +109,23 @@ void test_bar_rtl_should_update_indicator_left_coordinate_based_on_bar_value(voi
109109 lv_style_set_pad_all (& bar_style , style_padding );
110110
111111 /* Setup new style */
112- lv_obj_remove_style_all (bar );
113- lv_obj_add_style (bar , & bar_style , LV_PART_MAIN );
112+ lv_obj_remove_style_all (g_bar );
113+ lv_obj_add_style (g_bar , & bar_style , LV_PART_MAIN );
114114
115115 /* Set properties */
116- lv_obj_set_size (bar , bar_width , bar_height );
117- lv_bar_set_value (bar , bar_value , LV_ANIM_OFF );
118- lv_obj_set_style_base_dir (bar , LV_BASE_DIR_RTL , 0 );
116+ lv_obj_set_size (g_bar , bar_width , bar_height );
117+ lv_bar_set_value (g_bar , bar_value , LV_ANIM_OFF );
118+ lv_obj_set_style_base_dir (g_bar , LV_BASE_DIR_RTL , 0 );
119119
120120 /* FIXME: Remove wait */
121121 lv_test_indev_wait (50 );
122122
123123 int32_t actual_coord = bar_ptr -> indic_area .x1 ;
124124
125125 /* Calculate current indicator width */
126- int32_t bar_max_value = lv_bar_get_max_value (bar );
127- int32_t indicator_part_width = lv_obj_get_content_width (bar );
128- int32_t right_padding = lv_obj_get_style_pad_right (bar , LV_PART_MAIN );
126+ int32_t bar_max_value = lv_bar_get_max_value (g_bar );
127+ int32_t indicator_part_width = lv_obj_get_content_width (g_bar );
128+ int32_t right_padding = lv_obj_get_style_pad_right (g_bar , LV_PART_MAIN );
129129 int32_t indicator_width = (bar_value * indicator_part_width ) / bar_max_value ;
130130
131131 int32_t expected_coord = (bar_width - right_padding ) - indicator_width ;
@@ -206,7 +206,7 @@ void test_bar_normal(void)
206206
207207void test_bar_indicator_area_should_get_smaller_when_padding_is_increased (void )
208208{
209- lv_bar_t * bar_ptr = (lv_bar_t * ) bar ;
209+ lv_bar_t * bar_ptr = (lv_bar_t * ) g_bar ;
210210
211211 const int32_t style_padding = 10u ;
212212 static lv_style_t bar_style ;
@@ -216,7 +216,7 @@ void test_bar_indicator_area_should_get_smaller_when_padding_is_increased(void)
216216 int32_t original_height = 0u ;
217217 int32_t original_width = 0u ;
218218
219- lv_bar_set_value (bar , 50 , LV_ANIM_OFF );
219+ lv_bar_set_value (g_bar , 50 , LV_ANIM_OFF );
220220 lv_test_indev_wait (50 );
221221
222222 original_width = lv_area_get_width (& bar_ptr -> indic_area );
@@ -225,11 +225,11 @@ void test_bar_indicator_area_should_get_smaller_when_padding_is_increased(void)
225225 /* Setup new padding */
226226 lv_style_init (& bar_style );
227227 lv_style_set_pad_all (& bar_style , style_padding );
228- lv_obj_set_size (bar , 100 , 50 );
228+ lv_obj_set_size (g_bar , 100 , 50 );
229229
230230 /* Apply new style */
231- lv_obj_remove_style_all (bar );
232- lv_obj_add_style (bar , & bar_style , LV_PART_MAIN );
231+ lv_obj_remove_style_all (g_bar );
232+ lv_obj_add_style (g_bar , & bar_style , LV_PART_MAIN );
233233
234234 /* Notify LVGL of style change */
235235 lv_obj_report_style_change (& bar_style );
@@ -246,45 +246,45 @@ void test_bar_start_value_should_only_change_when_in_range_mode(void)
246246{
247247 int32_t new_start_value = 20u ;
248248
249- lv_bar_set_value (bar , 90 , LV_ANIM_OFF );
250- lv_bar_set_start_value (bar , new_start_value , LV_ANIM_OFF );
249+ lv_bar_set_value (g_bar , 90 , LV_ANIM_OFF );
250+ lv_bar_set_start_value (g_bar , new_start_value , LV_ANIM_OFF );
251251
252252 /* Start value shouldn't be updated when not in RANGE mode */
253- TEST_ASSERT_EQUAL_INT32 (0u , lv_bar_get_start_value (bar ));
253+ TEST_ASSERT_EQUAL_INT32 (0u , lv_bar_get_start_value (g_bar ));
254254
255255 /* Set bar in RANGE mode so we can edit the start value */
256- lv_bar_set_mode (bar , LV_BAR_MODE_RANGE );
257- lv_bar_set_start_value (bar , new_start_value , LV_ANIM_OFF );
256+ lv_bar_set_mode (g_bar , LV_BAR_MODE_RANGE );
257+ lv_bar_set_start_value (g_bar , new_start_value , LV_ANIM_OFF );
258258
259- TEST_ASSERT_EQUAL_INT32 (new_start_value , lv_bar_get_start_value (bar ));
259+ TEST_ASSERT_EQUAL_INT32 (new_start_value , lv_bar_get_start_value (g_bar ));
260260}
261261
262262void test_bar_start_value_should_be_smaller_than_current_value_in_range_mode (void )
263263{
264264 /* Set bar in RANGE mode so we can edit the start value */
265- lv_bar_set_mode (bar , LV_BAR_MODE_RANGE );
266- lv_bar_set_value (bar , 50 , LV_ANIM_OFF );
267- lv_bar_set_start_value (bar , 100u , LV_ANIM_OFF );
265+ lv_bar_set_mode (g_bar , LV_BAR_MODE_RANGE );
266+ lv_bar_set_value (g_bar , 50 , LV_ANIM_OFF );
267+ lv_bar_set_start_value (g_bar , 100u , LV_ANIM_OFF );
268268
269- TEST_ASSERT_EQUAL_INT32 (lv_bar_get_value (bar ), lv_bar_get_start_value (bar ));
269+ TEST_ASSERT_EQUAL_INT32 (lv_bar_get_value (g_bar ), lv_bar_get_start_value (g_bar ));
270270}
271271
272272void test_bar_current_value_should_be_truncated_to_max_value_when_exceeds_it (void )
273273{
274- int32_t max_value = lv_bar_get_max_value (bar );
274+ int32_t max_value = lv_bar_get_max_value (g_bar );
275275 int32_t new_value = max_value + 1u ;
276276
277- lv_bar_set_value (bar , new_value , LV_ANIM_OFF );
278- TEST_ASSERT_EQUAL_INT32 (max_value , lv_bar_get_value (bar ));
277+ lv_bar_set_value (g_bar , new_value , LV_ANIM_OFF );
278+ TEST_ASSERT_EQUAL_INT32 (max_value , lv_bar_get_value (g_bar ));
279279}
280280
281281void test_bar_current_value_should_be_truncated_to_min_value_when_it_is_below_it (void )
282282{
283- int32_t min_value = lv_bar_get_min_value (bar );
283+ int32_t min_value = lv_bar_get_min_value (g_bar );
284284 int32_t new_value = min_value - 1u ;
285285
286- lv_bar_set_value (bar , new_value , LV_ANIM_OFF );
287- TEST_ASSERT_EQUAL_INT32 (min_value , lv_bar_get_value (bar ));
286+ lv_bar_set_value (g_bar , new_value , LV_ANIM_OFF );
287+ TEST_ASSERT_EQUAL_INT32 (min_value , lv_bar_get_value (g_bar ));
288288}
289289
290290/** When in symmetrical mode, the bar indicator has to be drawn towards the min
@@ -296,21 +296,21 @@ void test_bar_current_value_should_be_truncated_to_min_value_when_it_is_below_it
296296 */
297297void test_bar_indicator_should_be_drawn_towards_the_min_range_side_after_setting_a_more_negative_value (void )
298298{
299- lv_bar_t * bar_ptr = (lv_bar_t * ) bar ;
299+ lv_bar_t * bar_ptr = (lv_bar_t * ) g_bar ;
300300
301301 /* Setup bar properties */
302- lv_obj_set_size (bar , 100 , 50 );
303- lv_bar_set_mode (bar , LV_BAR_MODE_SYMMETRICAL );
304- lv_bar_set_range (bar , -100 , 100 );
302+ lv_obj_set_size (g_bar , 100 , 50 );
303+ lv_bar_set_mode (g_bar , LV_BAR_MODE_SYMMETRICAL );
304+ lv_bar_set_range (g_bar , -100 , 100 );
305305
306306 /* Set bar value to 1, so it gets drawn at the middle of the bar */
307- lv_bar_set_value (bar , 1 , LV_ANIM_OFF );
307+ lv_bar_set_value (g_bar , 1 , LV_ANIM_OFF );
308308 lv_test_indev_wait (50 );
309309
310310 int32_t original_pos = bar_ptr -> indic_area .x1 ;
311311
312312 /* Set bar to a more negative value */
313- lv_bar_set_value (bar , -50 , LV_ANIM_OFF );
313+ lv_bar_set_value (g_bar , -50 , LV_ANIM_OFF );
314314 lv_test_indev_wait (50 );
315315
316316 int32_t final_pos = bar_ptr -> indic_area .x1 ;
0 commit comments