5
5
6
6
#include "lv_test_indev.h"
7
7
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 ;
10
10
11
11
void setUp (void )
12
12
{
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 );
15
15
}
16
16
17
17
void tearDown (void )
@@ -20,9 +20,9 @@ void tearDown(void)
20
20
21
21
void test_bar_should_have_valid_default_attributes (void )
22
22
{
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 ));
26
26
}
27
27
28
28
/*
@@ -43,7 +43,7 @@ void test_bar_should_have_valid_default_attributes(void)
43
43
*/
44
44
void test_bar_should_update_indicator_right_coordinate_based_on_bar_value (void )
45
45
{
46
- lv_bar_t * bar_ptr = (lv_bar_t * ) bar ;
46
+ lv_bar_t * bar_ptr = (lv_bar_t * ) g_bar ;
47
47
48
48
static lv_style_t bar_style ;
49
49
@@ -56,21 +56,21 @@ void test_bar_should_update_indicator_right_coordinate_based_on_bar_value(void)
56
56
lv_style_set_pad_all (& bar_style , style_padding );
57
57
58
58
/* 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 );
61
61
62
62
/* 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 );
65
65
66
66
/* FIXME: Remove wait */
67
67
lv_test_indev_wait (50 );
68
68
69
69
int32_t actual_coord = lv_area_get_width (& bar_ptr -> indic_area );
70
70
71
71
/* 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 );
74
74
75
75
int32_t expected_coord = (bar_value * indicator_part_width ) / bar_max_value ;
76
76
/* 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)
96
96
*/
97
97
void test_bar_rtl_should_update_indicator_left_coordinate_based_on_bar_value (void )
98
98
{
99
- lv_bar_t * bar_ptr = (lv_bar_t * ) bar ;
99
+ lv_bar_t * bar_ptr = (lv_bar_t * ) g_bar ;
100
100
101
101
static lv_style_t bar_style ;
102
102
@@ -109,23 +109,23 @@ void test_bar_rtl_should_update_indicator_left_coordinate_based_on_bar_value(voi
109
109
lv_style_set_pad_all (& bar_style , style_padding );
110
110
111
111
/* 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 );
114
114
115
115
/* 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 );
119
119
120
120
/* FIXME: Remove wait */
121
121
lv_test_indev_wait (50 );
122
122
123
123
int32_t actual_coord = bar_ptr -> indic_area .x1 ;
124
124
125
125
/* 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 );
129
129
int32_t indicator_width = (bar_value * indicator_part_width ) / bar_max_value ;
130
130
131
131
int32_t expected_coord = (bar_width - right_padding ) - indicator_width ;
@@ -206,7 +206,7 @@ void test_bar_normal(void)
206
206
207
207
void test_bar_indicator_area_should_get_smaller_when_padding_is_increased (void )
208
208
{
209
- lv_bar_t * bar_ptr = (lv_bar_t * ) bar ;
209
+ lv_bar_t * bar_ptr = (lv_bar_t * ) g_bar ;
210
210
211
211
const int32_t style_padding = 10u ;
212
212
static lv_style_t bar_style ;
@@ -216,7 +216,7 @@ void test_bar_indicator_area_should_get_smaller_when_padding_is_increased(void)
216
216
int32_t original_height = 0u ;
217
217
int32_t original_width = 0u ;
218
218
219
- lv_bar_set_value (bar , 50 , LV_ANIM_OFF );
219
+ lv_bar_set_value (g_bar , 50 , LV_ANIM_OFF );
220
220
lv_test_indev_wait (50 );
221
221
222
222
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)
225
225
/* Setup new padding */
226
226
lv_style_init (& bar_style );
227
227
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 );
229
229
230
230
/* 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 );
233
233
234
234
/* Notify LVGL of style change */
235
235
lv_obj_report_style_change (& bar_style );
@@ -246,45 +246,45 @@ void test_bar_start_value_should_only_change_when_in_range_mode(void)
246
246
{
247
247
int32_t new_start_value = 20u ;
248
248
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 );
251
251
252
252
/* 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 ));
254
254
255
255
/* 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 );
258
258
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 ));
260
260
}
261
261
262
262
void test_bar_start_value_should_be_smaller_than_current_value_in_range_mode (void )
263
263
{
264
264
/* 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 );
268
268
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 ));
270
270
}
271
271
272
272
void test_bar_current_value_should_be_truncated_to_max_value_when_exceeds_it (void )
273
273
{
274
- int32_t max_value = lv_bar_get_max_value (bar );
274
+ int32_t max_value = lv_bar_get_max_value (g_bar );
275
275
int32_t new_value = max_value + 1u ;
276
276
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 ));
279
279
}
280
280
281
281
void test_bar_current_value_should_be_truncated_to_min_value_when_it_is_below_it (void )
282
282
{
283
- int32_t min_value = lv_bar_get_min_value (bar );
283
+ int32_t min_value = lv_bar_get_min_value (g_bar );
284
284
int32_t new_value = min_value - 1u ;
285
285
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 ));
288
288
}
289
289
290
290
/** 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
296
296
*/
297
297
void test_bar_indicator_should_be_drawn_towards_the_min_range_side_after_setting_a_more_negative_value (void )
298
298
{
299
- lv_bar_t * bar_ptr = (lv_bar_t * ) bar ;
299
+ lv_bar_t * bar_ptr = (lv_bar_t * ) g_bar ;
300
300
301
301
/* 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 );
305
305
306
306
/* 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 );
308
308
lv_test_indev_wait (50 );
309
309
310
310
int32_t original_pos = bar_ptr -> indic_area .x1 ;
311
311
312
312
/* 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 );
314
314
lv_test_indev_wait (50 );
315
315
316
316
int32_t final_pos = bar_ptr -> indic_area .x1 ;
0 commit comments