Skip to content

Commit

Permalink
test(arc): add test case for adv_hittest
Browse files Browse the repository at this point in the history
  • Loading branch information
kisvegabor committed Oct 19, 2021
1 parent 79ab3d2 commit e83df6f
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/src/test_cases/test_arc.c
Expand Up @@ -2,6 +2,7 @@
#include "../lvgl.h"

#include "unity/unity.h"
#include "lv_test_indev.h"

/* This function runs before each test */
void setUp(void);
Expand All @@ -16,6 +17,9 @@ void test_arc_angles_when_reversed(void);

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);

void setUp(void)
{
Expand Down Expand Up @@ -119,4 +123,45 @@ void test_arc_angles_when_reversed(void)
TEST_ASSERT_EQUAL_INT16(expected_value, lv_arc_get_value(arcBlack));
}

void test_arc_click_area_with_adv_hittest(void)
{
arc = lv_arc_create(lv_scr_act());
lv_obj_set_size(arc, 100, 100);
lv_obj_set_style_arc_width(arc, 10, 0);
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);
TEST_ASSERT_GREATER_THAN(0, event_cnt);

/*No click beyond to the radius + ext_click_area*/
event_cnt = 0;
lv_test_mouse_click_at(106, 50);
TEST_ASSERT_EQUAL_UINT32(0, event_cnt);
}

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

#endif

0 comments on commit e83df6f

Please sign in to comment.