mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-22 23:37:43 +08:00
fix(test): read indev events in lv_test_wait and lv_test_fast_forward (#9947)
Co-authored-by: Vandra-Meyer Ákos <akos@lvgl.io>
This commit is contained in:
committed by
GitHub
parent
d3a12eb690
commit
b34a41f254
@@ -43,6 +43,10 @@ void lv_test_wait(uint32_t ms)
|
||||
lv_timer_handler();
|
||||
ms--;
|
||||
}
|
||||
|
||||
lv_indev_read(lv_test_indev_get_indev(LV_INDEV_TYPE_POINTER));
|
||||
lv_indev_read(lv_test_indev_get_indev(LV_INDEV_TYPE_ENCODER));
|
||||
lv_indev_read(lv_test_indev_get_indev(LV_INDEV_TYPE_KEYPAD));
|
||||
lv_refr_now(NULL);
|
||||
}
|
||||
|
||||
@@ -50,6 +54,9 @@ void lv_test_fast_forward(uint32_t ms)
|
||||
{
|
||||
lv_tick_inc(ms);
|
||||
lv_timer_handler();
|
||||
lv_indev_read(lv_test_indev_get_indev(LV_INDEV_TYPE_POINTER));
|
||||
lv_indev_read(lv_test_indev_get_indev(LV_INDEV_TYPE_ENCODER));
|
||||
lv_indev_read(lv_test_indev_get_indev(LV_INDEV_TYPE_KEYPAD));
|
||||
lv_refr_now(NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
|
||||
#include "unity/unity.h"
|
||||
|
||||
static size_t timer_click_event_count = 0;
|
||||
static size_t timer_click_timer_cb_count = 0;
|
||||
|
||||
static void timer_click_event_cb(lv_event_t * e)
|
||||
{
|
||||
LV_UNUSED(e);
|
||||
timer_click_event_count++;
|
||||
}
|
||||
|
||||
static void timer_click_at_cb(lv_timer_t * t)
|
||||
{
|
||||
lv_timer_delete(t);
|
||||
timer_click_timer_cb_count++;
|
||||
lv_test_mouse_click_at(70, 70);
|
||||
}
|
||||
|
||||
static void create_timer_click_screen_case(lv_obj_t ** source_screen, lv_obj_t ** target_screen)
|
||||
{
|
||||
*source_screen = lv_obj_create(NULL);
|
||||
*target_screen = lv_obj_create(NULL);
|
||||
|
||||
lv_obj_t * btn = lv_button_create(*source_screen);
|
||||
lv_obj_set_pos(btn, 20, 20);
|
||||
lv_obj_set_size(btn, 100, 100);
|
||||
lv_obj_add_event_cb(btn, timer_click_event_cb, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_add_screen_load_event(btn, LV_EVENT_CLICKED, *target_screen, LV_SCREEN_LOAD_ANIM_NONE, 0, 0);
|
||||
|
||||
lv_screen_load(*source_screen);
|
||||
lv_timer_create(timer_click_at_cb, 1, NULL);
|
||||
}
|
||||
|
||||
void test_mouse_click_at_from_timer_loads_screen(void)
|
||||
{
|
||||
timer_click_event_count = 0;
|
||||
timer_click_timer_cb_count = 0;
|
||||
|
||||
lv_obj_t * source_screen = NULL;
|
||||
lv_obj_t * target_screen = NULL;
|
||||
create_timer_click_screen_case(&source_screen, &target_screen);
|
||||
|
||||
lv_test_wait(200);
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT32(1, timer_click_timer_cb_count);
|
||||
TEST_ASSERT_EQUAL_UINT32(1, timer_click_event_count);
|
||||
TEST_ASSERT_EQUAL(target_screen, lv_screen_active());
|
||||
}
|
||||
|
||||
void test_mouse_click_at_from_timer_loads_screen_fast_forward(void)
|
||||
{
|
||||
timer_click_event_count = 0;
|
||||
timer_click_timer_cb_count = 0;
|
||||
|
||||
lv_obj_t * source_screen = NULL;
|
||||
lv_obj_t * target_screen = NULL;
|
||||
create_timer_click_screen_case(&source_screen, &target_screen);
|
||||
|
||||
lv_test_fast_forward(200);
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT32(1, timer_click_timer_cb_count);
|
||||
TEST_ASSERT_EQUAL_UINT32(1, timer_click_event_count);
|
||||
TEST_ASSERT_EQUAL(target_screen, lv_screen_active());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user