Skip to content

Commit

Permalink
chore(test): format test cases (lvgl#3071)
Browse files Browse the repository at this point in the history
  • Loading branch information
C47D authored Feb 3, 2022
1 parent e400a87 commit 2c7760c
Show file tree
Hide file tree
Showing 14 changed files with 501 additions and 474 deletions.
26 changes: 26 additions & 0 deletions scripts/code-format-tests.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--style=kr
--indent=spaces=4
--indent-classes
--indent-switches
--indent-cases
--indent-preproc-block
--indent-preproc-define
--indent-col1-comments
--pad-oper
--unpad-paren
--align-pointer=middle
--align-reference=middle
--convert-tabs
--max-code-length=120
--break-after-logical
--break-closing-braces
--attach-closing-while
--min-conditional-indent=0
--max-continuation-indent=120
--mode=c
--lineend=linux
--recursive
--suffix=none
--preserve-date
--formatted
--exclude=../tests/src/test_cases/_test_template.c
1 change: 1 addition & 0 deletions scripts/code-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
import os

os.system('astyle --options=code-format.cfg "../src/*.c,*.h"')
os.system('astyle --options=code-format-tests.cfg "../tests/src/test_cases/*.c"')
22 changes: 11 additions & 11 deletions tests/src/test_cases/test_arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ void test_arc_should_update_angles_when_changing_to_symmetrical_mode(void);
void test_arc_should_update_angles_when_changing_to_symmetrical_mode_value_more_than_middle_range(void);
void test_arc_angles_when_reversed(void);

static lv_obj_t *active_screen = NULL;
static lv_obj_t *arc = NULL;
static lv_obj_t * active_screen = NULL;
static lv_obj_t * arc = NULL;
static uint32_t event_cnt;

static void dummy_event_cb(lv_event_t * e);
Expand Down Expand Up @@ -109,13 +109,13 @@ void test_arc_angles_when_reversed(void)
uint16_t expected_end_angle = 90;
int16_t expected_value = 40;

lv_obj_t *arcBlack;
lv_obj_t * arcBlack;
arcBlack = lv_arc_create(lv_scr_act());

lv_arc_set_mode(arcBlack, LV_ARC_MODE_REVERSE);

lv_arc_set_bg_angles(arcBlack, 0, 90);

lv_arc_set_value(arcBlack, expected_value);

TEST_ASSERT_EQUAL_UINT16(expected_start_angle, lv_arc_get_angle_start(arcBlack));
Expand All @@ -131,22 +131,22 @@ void test_arc_click_area_with_adv_hittest(void)
lv_obj_add_flag(arc, LV_OBJ_FLAG_ADV_HITTEST);
lv_obj_add_event_cb(arc, dummy_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
lv_obj_set_ext_click_area(arc, 5);

/*No click detected at the middle*/
event_cnt = 0;
lv_test_mouse_click_at(50, 50);
TEST_ASSERT_EQUAL_UINT32(0, event_cnt);

/*No click close to the radius - bg_arc - ext_click_area*/
event_cnt = 0;
lv_test_mouse_click_at(83, 50);
TEST_ASSERT_EQUAL_UINT32(0, event_cnt);

/*Click on the radius - bg_arc - ext_click_area*/
event_cnt = 0;
lv_test_mouse_click_at(86, 50);
TEST_ASSERT_GREATER_THAN(0, event_cnt);

/*Click on the radius + ext_click_area*/
event_cnt = 0;
lv_test_mouse_click_at(104, 50);
Expand All @@ -158,10 +158,10 @@ void test_arc_click_area_with_adv_hittest(void)
TEST_ASSERT_EQUAL_UINT32(0, event_cnt);
}

static void dummy_event_cb(lv_event_t * e)
static void dummy_event_cb(lv_event_t * e)
{
LV_UNUSED(e);
event_cnt++;
LV_UNUSED(e);
event_cnt++;
}

#endif
6 changes: 3 additions & 3 deletions tests/src/test_cases/test_bar.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include "lv_test_indev.h"

static lv_obj_t *active_screen = NULL;
static lv_obj_t *bar = NULL;
static lv_obj_t * active_screen = NULL;
static lv_obj_t * bar = NULL;

void setUp(void)
{
Expand Down Expand Up @@ -67,7 +67,7 @@ void test_bar_should_update_indicator_right_coordinate_based_on_bar_value(void)
lv_test_indev_wait(50);

int32_t actual_coord = lv_area_get_width(&bar_ptr->indic_area);

/* Calculate bar indicator right coordinate, using rule of 3 */
lv_coord_t bar_max_value = lv_bar_get_max_value(bar);
lv_coord_t indicator_part_width = lv_obj_get_content_width(bar);
Expand Down
18 changes: 9 additions & 9 deletions tests/src/test_cases/test_checkbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ void test_checkbox_should_have_default_text_when_created(void);
void test_checkbox_should_return_dinamically_allocated_text(void);
void test_checkbox_should_allocate_memory_for_static_text(void);

static lv_obj_t *active_screen = NULL;
static lv_obj_t *checkbox = NULL;
static lv_obj_t * active_screen = NULL;
static lv_obj_t * checkbox = NULL;

static volatile bool event_called = false;

static void event_handler(lv_event_t *e)
static void event_handler(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);

if (LV_EVENT_VALUE_CHANGED == code) {
if(LV_EVENT_VALUE_CHANGED == code) {
event_called = true;
}
}
Expand All @@ -38,20 +38,20 @@ void test_checkbox_should_call_event_handler_on_click_when_enabled(void)
{
active_screen = lv_scr_act();
checkbox = lv_checkbox_create(active_screen);

lv_obj_add_state(checkbox, LV_STATE_CHECKED);
lv_obj_add_event_cb(checkbox, event_handler, LV_EVENT_ALL, NULL);

lv_test_mouse_click_at(checkbox->coords.x1, checkbox->coords.y1);

TEST_ASSERT_TRUE(event_called);

event_called = false;
}

void test_checkbox_should_have_default_text_when_created(void)
{
const char *default_text = "Check box";
const char * default_text = "Check box";

active_screen = lv_scr_act();
checkbox = lv_checkbox_create(active_screen);
Expand All @@ -62,7 +62,7 @@ void test_checkbox_should_have_default_text_when_created(void)

void test_checkbox_should_return_dinamically_allocated_text(void)
{
const char *message = "Hello World!";
const char * message = "Hello World!";

active_screen = lv_scr_act();
checkbox = lv_checkbox_create(active_screen);
Expand All @@ -76,7 +76,7 @@ void test_checkbox_should_return_dinamically_allocated_text(void)
void test_checkbox_should_allocate_memory_for_static_text(void)
{
uint32_t initial_available_memory = 0;
const char *static_text = "Keep me while you exist";
const char * static_text = "Keep me while you exist";

lv_mem_monitor_t m1;
lv_mem_monitor(&m1);
Expand Down
14 changes: 7 additions & 7 deletions tests/src/test_cases/test_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ void test_config(void);

void test_config(void)
{
TEST_ASSERT_EQUAL(130, LV_DPI_DEF);
TEST_ASSERT_EQUAL(130, lv_disp_get_dpi(NULL));
TEST_ASSERT_EQUAL(800, LV_HOR_RES);
TEST_ASSERT_EQUAL(800, lv_disp_get_hor_res(NULL));
TEST_ASSERT_EQUAL(480, LV_VER_RES);
TEST_ASSERT_EQUAL(480, lv_disp_get_ver_res(NULL));
TEST_ASSERT_EQUAL(32, LV_COLOR_DEPTH);
TEST_ASSERT_EQUAL(130, LV_DPI_DEF);
TEST_ASSERT_EQUAL(130, lv_disp_get_dpi(NULL));
TEST_ASSERT_EQUAL(800, LV_HOR_RES);
TEST_ASSERT_EQUAL(800, lv_disp_get_hor_res(NULL));
TEST_ASSERT_EQUAL(480, LV_VER_RES);
TEST_ASSERT_EQUAL(480, lv_disp_get_ver_res(NULL));
TEST_ASSERT_EQUAL(32, LV_COLOR_DEPTH);
}

#endif
2 changes: 1 addition & 1 deletion tests/src/test_cases/test_demo_stress.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
static void loop_through_stress_test(void)
{
#if LV_USE_DEMO_STRESS
lv_test_indev_wait(LV_DEMO_STRESS_TIME_STEP*33); /* FIXME: remove magic number of states */
lv_test_indev_wait(LV_DEMO_STRESS_TIME_STEP * 33); /* FIXME: remove magic number of states */
#endif
}
void test_demo_stress(void)
Expand Down
Loading

0 comments on commit 2c7760c

Please sign in to comment.