fix(warning): fix shadown variable warning
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
1
tests/src/test_cases/cache/test_cache.c
vendored
1
tests/src/test_cases/cache/test_cache.c
vendored
@@ -34,6 +34,7 @@ static lv_cache_compare_res_t compare_cb(const test_data * lhs, const test_data
|
||||
|
||||
static void free_cb(test_data * node, void * user_data)
|
||||
{
|
||||
LV_UNUSED(user_data);
|
||||
lv_free(node->data);
|
||||
}
|
||||
|
||||
|
||||
@@ -234,6 +234,7 @@ static void draw_lines(lv_layer_t * layer)
|
||||
|
||||
static void canvas_draw(const char * name, void (*draw_cb)(lv_layer_t *))
|
||||
{
|
||||
LV_UNUSED(name);
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
uint32_t stride = 640 * 4 + 128; /*Test non-default stride*/
|
||||
lv_draw_buf_t * draw_buf = lv_draw_buf_create(640, 480, LV_COLOR_FORMAT_ARGB8888, stride);
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
|
||||
#include "lv_test_indev.h"
|
||||
|
||||
static lv_obj_t * active_screen = NULL;
|
||||
static lv_obj_t * bar = NULL;
|
||||
static lv_obj_t * g_active_screen = NULL;
|
||||
static lv_obj_t * g_bar = NULL;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
active_screen = lv_screen_active();
|
||||
bar = lv_bar_create(active_screen);
|
||||
g_active_screen = lv_screen_active();
|
||||
g_bar = lv_bar_create(g_active_screen);
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
@@ -20,9 +20,9 @@ void tearDown(void)
|
||||
|
||||
void test_bar_should_have_valid_default_attributes(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL(0, lv_bar_get_min_value(bar));
|
||||
TEST_ASSERT_EQUAL(100, lv_bar_get_max_value(bar));
|
||||
TEST_ASSERT_EQUAL(LV_BAR_MODE_NORMAL, lv_bar_get_mode(bar));
|
||||
TEST_ASSERT_EQUAL(0, lv_bar_get_min_value(g_bar));
|
||||
TEST_ASSERT_EQUAL(100, lv_bar_get_max_value(g_bar));
|
||||
TEST_ASSERT_EQUAL(LV_BAR_MODE_NORMAL, lv_bar_get_mode(g_bar));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -43,7 +43,7 @@ void test_bar_should_have_valid_default_attributes(void)
|
||||
*/
|
||||
void test_bar_should_update_indicator_right_coordinate_based_on_bar_value(void)
|
||||
{
|
||||
lv_bar_t * bar_ptr = (lv_bar_t *) bar;
|
||||
lv_bar_t * bar_ptr = (lv_bar_t *) g_bar;
|
||||
|
||||
static lv_style_t bar_style;
|
||||
|
||||
@@ -56,12 +56,12 @@ void test_bar_should_update_indicator_right_coordinate_based_on_bar_value(void)
|
||||
lv_style_set_pad_all(&bar_style, style_padding);
|
||||
|
||||
/* Setup new style */
|
||||
lv_obj_remove_style_all(bar);
|
||||
lv_obj_add_style(bar, &bar_style, LV_PART_MAIN);
|
||||
lv_obj_remove_style_all(g_bar);
|
||||
lv_obj_add_style(g_bar, &bar_style, LV_PART_MAIN);
|
||||
|
||||
/* Set properties */
|
||||
lv_obj_set_size(bar, bar_width, bar_height);
|
||||
lv_bar_set_value(bar, bar_value, LV_ANIM_OFF);
|
||||
lv_obj_set_size(g_bar, bar_width, bar_height);
|
||||
lv_bar_set_value(g_bar, bar_value, LV_ANIM_OFF);
|
||||
|
||||
/* FIXME: Remove wait */
|
||||
lv_test_indev_wait(50);
|
||||
@@ -69,8 +69,8 @@ void test_bar_should_update_indicator_right_coordinate_based_on_bar_value(void)
|
||||
int32_t actual_coord = lv_area_get_width(&bar_ptr->indic_area);
|
||||
|
||||
/* Calculate bar indicator right coordinate, using rule of 3 */
|
||||
int32_t bar_max_value = lv_bar_get_max_value(bar);
|
||||
int32_t indicator_part_width = lv_obj_get_content_width(bar);
|
||||
int32_t bar_max_value = lv_bar_get_max_value(g_bar);
|
||||
int32_t indicator_part_width = lv_obj_get_content_width(g_bar);
|
||||
|
||||
int32_t expected_coord = (bar_value * indicator_part_width) / bar_max_value;
|
||||
/* 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)
|
||||
*/
|
||||
void test_bar_rtl_should_update_indicator_left_coordinate_based_on_bar_value(void)
|
||||
{
|
||||
lv_bar_t * bar_ptr = (lv_bar_t *) bar;
|
||||
lv_bar_t * bar_ptr = (lv_bar_t *) g_bar;
|
||||
|
||||
static lv_style_t bar_style;
|
||||
|
||||
@@ -109,13 +109,13 @@ void test_bar_rtl_should_update_indicator_left_coordinate_based_on_bar_value(voi
|
||||
lv_style_set_pad_all(&bar_style, style_padding);
|
||||
|
||||
/* Setup new style */
|
||||
lv_obj_remove_style_all(bar);
|
||||
lv_obj_add_style(bar, &bar_style, LV_PART_MAIN);
|
||||
lv_obj_remove_style_all(g_bar);
|
||||
lv_obj_add_style(g_bar, &bar_style, LV_PART_MAIN);
|
||||
|
||||
/* Set properties */
|
||||
lv_obj_set_size(bar, bar_width, bar_height);
|
||||
lv_bar_set_value(bar, bar_value, LV_ANIM_OFF);
|
||||
lv_obj_set_style_base_dir(bar, LV_BASE_DIR_RTL, 0);
|
||||
lv_obj_set_size(g_bar, bar_width, bar_height);
|
||||
lv_bar_set_value(g_bar, bar_value, LV_ANIM_OFF);
|
||||
lv_obj_set_style_base_dir(g_bar, LV_BASE_DIR_RTL, 0);
|
||||
|
||||
/* FIXME: Remove wait */
|
||||
lv_test_indev_wait(50);
|
||||
@@ -123,9 +123,9 @@ void test_bar_rtl_should_update_indicator_left_coordinate_based_on_bar_value(voi
|
||||
int32_t actual_coord = bar_ptr->indic_area.x1;
|
||||
|
||||
/* Calculate current indicator width */
|
||||
int32_t bar_max_value = lv_bar_get_max_value(bar);
|
||||
int32_t indicator_part_width = lv_obj_get_content_width(bar);
|
||||
int32_t right_padding = lv_obj_get_style_pad_right(bar, LV_PART_MAIN);
|
||||
int32_t bar_max_value = lv_bar_get_max_value(g_bar);
|
||||
int32_t indicator_part_width = lv_obj_get_content_width(g_bar);
|
||||
int32_t right_padding = lv_obj_get_style_pad_right(g_bar, LV_PART_MAIN);
|
||||
int32_t indicator_width = (bar_value * indicator_part_width) / bar_max_value;
|
||||
|
||||
int32_t expected_coord = (bar_width - right_padding) - indicator_width;
|
||||
@@ -206,7 +206,7 @@ void test_bar_normal(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 *) g_bar;
|
||||
|
||||
const int32_t style_padding = 10u;
|
||||
static lv_style_t bar_style;
|
||||
@@ -216,7 +216,7 @@ void test_bar_indicator_area_should_get_smaller_when_padding_is_increased(void)
|
||||
int32_t original_height = 0u;
|
||||
int32_t original_width = 0u;
|
||||
|
||||
lv_bar_set_value(bar, 50, LV_ANIM_OFF);
|
||||
lv_bar_set_value(g_bar, 50, LV_ANIM_OFF);
|
||||
lv_test_indev_wait(50);
|
||||
|
||||
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)
|
||||
/* Setup new padding */
|
||||
lv_style_init(&bar_style);
|
||||
lv_style_set_pad_all(&bar_style, style_padding);
|
||||
lv_obj_set_size(bar, 100, 50);
|
||||
lv_obj_set_size(g_bar, 100, 50);
|
||||
|
||||
/* Apply new style */
|
||||
lv_obj_remove_style_all(bar);
|
||||
lv_obj_add_style(bar, &bar_style, LV_PART_MAIN);
|
||||
lv_obj_remove_style_all(g_bar);
|
||||
lv_obj_add_style(g_bar, &bar_style, LV_PART_MAIN);
|
||||
|
||||
/* Notify LVGL of style change */
|
||||
lv_obj_report_style_change(&bar_style);
|
||||
@@ -246,45 +246,45 @@ void test_bar_start_value_should_only_change_when_in_range_mode(void)
|
||||
{
|
||||
int32_t new_start_value = 20u;
|
||||
|
||||
lv_bar_set_value(bar, 90, LV_ANIM_OFF);
|
||||
lv_bar_set_start_value(bar, new_start_value, LV_ANIM_OFF);
|
||||
lv_bar_set_value(g_bar, 90, LV_ANIM_OFF);
|
||||
lv_bar_set_start_value(g_bar, new_start_value, LV_ANIM_OFF);
|
||||
|
||||
/* Start value shouldn't be updated when not in RANGE mode */
|
||||
TEST_ASSERT_EQUAL_INT32(0u, lv_bar_get_start_value(bar));
|
||||
TEST_ASSERT_EQUAL_INT32(0u, lv_bar_get_start_value(g_bar));
|
||||
|
||||
/* Set bar in RANGE mode so we can edit the start value */
|
||||
lv_bar_set_mode(bar, LV_BAR_MODE_RANGE);
|
||||
lv_bar_set_start_value(bar, new_start_value, LV_ANIM_OFF);
|
||||
lv_bar_set_mode(g_bar, LV_BAR_MODE_RANGE);
|
||||
lv_bar_set_start_value(g_bar, new_start_value, LV_ANIM_OFF);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT32(new_start_value, lv_bar_get_start_value(bar));
|
||||
TEST_ASSERT_EQUAL_INT32(new_start_value, lv_bar_get_start_value(g_bar));
|
||||
}
|
||||
|
||||
void test_bar_start_value_should_be_smaller_than_current_value_in_range_mode(void)
|
||||
{
|
||||
/* Set bar in RANGE mode so we can edit the start value */
|
||||
lv_bar_set_mode(bar, LV_BAR_MODE_RANGE);
|
||||
lv_bar_set_value(bar, 50, LV_ANIM_OFF);
|
||||
lv_bar_set_start_value(bar, 100u, LV_ANIM_OFF);
|
||||
lv_bar_set_mode(g_bar, LV_BAR_MODE_RANGE);
|
||||
lv_bar_set_value(g_bar, 50, LV_ANIM_OFF);
|
||||
lv_bar_set_start_value(g_bar, 100u, LV_ANIM_OFF);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT32(lv_bar_get_value(bar), lv_bar_get_start_value(bar));
|
||||
TEST_ASSERT_EQUAL_INT32(lv_bar_get_value(g_bar), lv_bar_get_start_value(g_bar));
|
||||
}
|
||||
|
||||
void test_bar_current_value_should_be_truncated_to_max_value_when_exceeds_it(void)
|
||||
{
|
||||
int32_t max_value = lv_bar_get_max_value(bar);
|
||||
int32_t max_value = lv_bar_get_max_value(g_bar);
|
||||
int32_t new_value = max_value + 1u;
|
||||
|
||||
lv_bar_set_value(bar, new_value, LV_ANIM_OFF);
|
||||
TEST_ASSERT_EQUAL_INT32(max_value, lv_bar_get_value(bar));
|
||||
lv_bar_set_value(g_bar, new_value, LV_ANIM_OFF);
|
||||
TEST_ASSERT_EQUAL_INT32(max_value, lv_bar_get_value(g_bar));
|
||||
}
|
||||
|
||||
void test_bar_current_value_should_be_truncated_to_min_value_when_it_is_below_it(void)
|
||||
{
|
||||
int32_t min_value = lv_bar_get_min_value(bar);
|
||||
int32_t min_value = lv_bar_get_min_value(g_bar);
|
||||
int32_t new_value = min_value - 1u;
|
||||
|
||||
lv_bar_set_value(bar, new_value, LV_ANIM_OFF);
|
||||
TEST_ASSERT_EQUAL_INT32(min_value, lv_bar_get_value(bar));
|
||||
lv_bar_set_value(g_bar, new_value, LV_ANIM_OFF);
|
||||
TEST_ASSERT_EQUAL_INT32(min_value, lv_bar_get_value(g_bar));
|
||||
}
|
||||
|
||||
/** 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
|
||||
*/
|
||||
void test_bar_indicator_should_be_drawn_towards_the_min_range_side_after_setting_a_more_negative_value(void)
|
||||
{
|
||||
lv_bar_t * bar_ptr = (lv_bar_t *) bar;
|
||||
lv_bar_t * bar_ptr = (lv_bar_t *) g_bar;
|
||||
|
||||
/* Setup bar properties */
|
||||
lv_obj_set_size(bar, 100, 50);
|
||||
lv_bar_set_mode(bar, LV_BAR_MODE_SYMMETRICAL);
|
||||
lv_bar_set_range(bar, -100, 100);
|
||||
lv_obj_set_size(g_bar, 100, 50);
|
||||
lv_bar_set_mode(g_bar, LV_BAR_MODE_SYMMETRICAL);
|
||||
lv_bar_set_range(g_bar, -100, 100);
|
||||
|
||||
/* Set bar value to 1, so it gets drawn at the middle of the bar */
|
||||
lv_bar_set_value(bar, 1, LV_ANIM_OFF);
|
||||
lv_bar_set_value(g_bar, 1, LV_ANIM_OFF);
|
||||
lv_test_indev_wait(50);
|
||||
|
||||
int32_t original_pos = bar_ptr->indic_area.x1;
|
||||
|
||||
/* Set bar to a more negative value */
|
||||
lv_bar_set_value(bar, -50, LV_ANIM_OFF);
|
||||
lv_bar_set_value(g_bar, -50, LV_ANIM_OFF);
|
||||
lv_test_indev_wait(50);
|
||||
|
||||
int32_t final_pos = bar_ptr->indic_area.x1;
|
||||
|
||||
@@ -22,23 +22,23 @@ void test_calendar_event_key_down_gui(void);
|
||||
void test_calendar_get_pressed_date_null(void);
|
||||
void test_calendar_get_btnmatrix(void);
|
||||
|
||||
static lv_obj_t * active_screen = NULL;
|
||||
static lv_obj_t * calendar = NULL;
|
||||
static lv_obj_t * g_active_screen = NULL;
|
||||
static lv_obj_t * g_calendar = NULL;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
active_screen = lv_screen_active();
|
||||
calendar = lv_calendar_create(active_screen);
|
||||
g_active_screen = lv_screen_active();
|
||||
g_calendar = lv_calendar_create(g_active_screen);
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
lv_obj_clean(active_screen);
|
||||
lv_obj_clean(g_active_screen);
|
||||
}
|
||||
|
||||
void test_calendar_creation_successful(void)
|
||||
{
|
||||
TEST_ASSERT_NOT_NULL(calendar);
|
||||
TEST_ASSERT_NOT_NULL(g_calendar);
|
||||
}
|
||||
|
||||
void test_calendar_set_today_date(void)
|
||||
@@ -49,9 +49,9 @@ void test_calendar_set_today_date(void)
|
||||
today.month = 9;
|
||||
today.day = 21;
|
||||
|
||||
lv_calendar_set_today_date(calendar, today.year, today.month, today.day);
|
||||
lv_calendar_set_today_date(g_calendar, today.year, today.month, today.day);
|
||||
|
||||
const lv_calendar_date_t * date_after_test = lv_calendar_get_today_date(calendar);
|
||||
const lv_calendar_date_t * date_after_test = lv_calendar_get_today_date(g_calendar);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT16(today.year, date_after_test->year);
|
||||
TEST_ASSERT_EQUAL_INT16(today.month, date_after_test->month);
|
||||
@@ -66,15 +66,15 @@ void test_calendar_set_today_date_gui(void)
|
||||
today.month = 9;
|
||||
today.day = 21;
|
||||
|
||||
lv_calendar_set_today_date(calendar, today.year, today.month, today.day);
|
||||
lv_calendar_set_showed_date(calendar, 2022, 9);
|
||||
lv_calendar_set_today_date(g_calendar, today.year, today.month, today.day);
|
||||
lv_calendar_set_showed_date(g_calendar, 2022, 9);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/calendar_01.png");
|
||||
}
|
||||
|
||||
void test_calendar_set_showed_date_gui(void)
|
||||
{
|
||||
lv_calendar_set_showed_date(calendar, 2022, 9);
|
||||
lv_calendar_set_showed_date(g_calendar, 2022, 9);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/calendar_02.png");
|
||||
}
|
||||
@@ -95,9 +95,9 @@ void test_calendar_set_highlighted_dates(void)
|
||||
highlighted_days[2].month = 2;
|
||||
highlighted_days[2].day = 22;
|
||||
|
||||
lv_calendar_set_highlighted_dates(calendar, highlighted_days, 3);
|
||||
lv_calendar_set_highlighted_dates(g_calendar, highlighted_days, 3);
|
||||
|
||||
const lv_calendar_date_t * highlighted_days_after_test = lv_calendar_get_highlighted_dates(calendar);
|
||||
const lv_calendar_date_t * highlighted_days_after_test = lv_calendar_get_highlighted_dates(g_calendar);
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
TEST_ASSERT_EQUAL_INT16(highlighted_days[i].year, highlighted_days_after_test[i].year);
|
||||
@@ -122,9 +122,9 @@ void test_calendar_set_highlighted_dates_gui(void)
|
||||
highlighted_days[2].month = 2;
|
||||
highlighted_days[2].day = 22;
|
||||
|
||||
lv_calendar_set_highlighted_dates(calendar, highlighted_days, 3);
|
||||
lv_calendar_set_highlighted_dates(g_calendar, highlighted_days, 3);
|
||||
|
||||
lv_calendar_set_showed_date(calendar, 2022, 2);
|
||||
lv_calendar_set_showed_date(g_calendar, 2022, 2);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/calendar_03.png");
|
||||
}
|
||||
@@ -133,9 +133,9 @@ void test_calendar_set_day_names_gui(void)
|
||||
{
|
||||
static const char * day_names[7] = {"Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa"};
|
||||
|
||||
lv_calendar_set_day_names(calendar, day_names);
|
||||
lv_calendar_set_day_names(g_calendar, day_names);
|
||||
|
||||
lv_calendar_set_showed_date(calendar, 2022, 9);
|
||||
lv_calendar_set_showed_date(g_calendar, 2022, 9);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/calendar_04.png");
|
||||
}
|
||||
@@ -156,25 +156,25 @@ void test_calendar_get_highlighted_dates_num(void)
|
||||
highlighted_days[2].month = 2;
|
||||
highlighted_days[2].day = 22;
|
||||
|
||||
lv_calendar_set_highlighted_dates(calendar, highlighted_days, 3);
|
||||
lv_calendar_set_highlighted_dates(g_calendar, highlighted_days, 3);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT16(3, lv_calendar_get_highlighted_dates_num(calendar));
|
||||
TEST_ASSERT_EQUAL_INT16(3, lv_calendar_get_highlighted_dates_num(g_calendar));
|
||||
}
|
||||
|
||||
void test_calendar_header_dropdown_create_gui(void)
|
||||
{
|
||||
lv_calendar_header_dropdown_create(calendar);
|
||||
lv_calendar_header_dropdown_create(g_calendar);
|
||||
|
||||
lv_calendar_set_showed_date(calendar, 2022, 9);
|
||||
lv_calendar_set_showed_date(g_calendar, 2022, 9);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/calendar_05.png");
|
||||
}
|
||||
|
||||
void test_calendar_header_arrow_create_gui(void)
|
||||
{
|
||||
lv_calendar_header_arrow_create(calendar);
|
||||
lv_calendar_header_arrow_create(g_calendar);
|
||||
|
||||
lv_calendar_set_showed_date(calendar, 2022, 10); // Use October to avoid month name sliding
|
||||
lv_calendar_set_showed_date(g_calendar, 2022, 10); // Use October to avoid month name sliding
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/calendar_06.png");
|
||||
}
|
||||
@@ -183,27 +183,27 @@ void test_calendar_event_key_down_gui(void)
|
||||
{
|
||||
uint32_t key = LV_KEY_DOWN;
|
||||
|
||||
lv_calendar_set_showed_date(calendar, 2022, 9);
|
||||
lv_calendar_set_showed_date(g_calendar, 2022, 9);
|
||||
|
||||
lv_obj_send_event(calendar, LV_EVENT_KEY, (void *) &key);
|
||||
lv_obj_send_event(g_calendar, LV_EVENT_KEY, (void *) &key);
|
||||
|
||||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/calendar_07.png");
|
||||
}
|
||||
|
||||
void test_calendar_get_pressed_date_null(void)
|
||||
{
|
||||
lv_calendar_set_showed_date(calendar, 2022, 9);
|
||||
lv_calendar_set_showed_date(g_calendar, 2022, 9);
|
||||
|
||||
lv_calendar_date_t pressed_date;
|
||||
|
||||
lv_result_t result = lv_calendar_get_pressed_date(calendar, &pressed_date);
|
||||
lv_result_t result = lv_calendar_get_pressed_date(g_calendar, &pressed_date);
|
||||
|
||||
TEST_ASSERT_EQUAL(result, LV_RESULT_INVALID);
|
||||
}
|
||||
|
||||
void test_calendar_get_btnmatrix(void)
|
||||
{
|
||||
lv_obj_t * btnm = lv_calendar_get_btnmatrix(calendar);
|
||||
lv_obj_t * btnm = lv_calendar_get_btnmatrix(g_calendar);
|
||||
|
||||
TEST_ASSERT_NOT_NULL(btnm);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user