mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-27 03:25:28 +08:00
test(indev): merge indev testcase (#9071)
Arduino Lint / lint (push) Has been cancelled
Build Examples with C++ Compiler / build-examples (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_NORMAL_8BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_SDL - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build ESP IDF ESP32S3 (push) Has been cancelled
C/C++ CI / Run tests with 32bit build (push) Has been cancelled
C/C++ CI / Run tests with 64bit build (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify that lv_conf_internal.h matches repository state / verify-conf-internal (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Compare file templates with file names / template-check (push) Has been cancelled
Build docs / build-and-deploy (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
Install LVGL using CMake / build-examples (push) Has been cancelled
Check Makefile / Build using Makefile (push) Has been cancelled
Check Makefile for UEFI / Build using Makefile for UEFI (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/benchmark_results_comment/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/filter_docker_logs/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/serialize_results/test.sh) (push) Has been cancelled
Hardware Performance Test / Hardware Performance Benchmark (push) Has been cancelled
Hardware Performance Test / HW Benchmark - Save PR Number (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_32B - Ubuntu (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_64B - Ubuntu (push) Has been cancelled
Port repo release update / run-release-branch-updater (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 32b - lv_conf_perf32b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 64b - lv_conf_perf64b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Save PR Number (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
Arduino Lint / lint (push) Has been cancelled
Build Examples with C++ Compiler / build-examples (push) Has been cancelled
MicroPython CI / Build esp32 port (push) Has been cancelled
MicroPython CI / Build rp2 port (push) Has been cancelled
MicroPython CI / Build stm32 port (push) Has been cancelled
MicroPython CI / Build unix port (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_NORMAL_8BIT - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_SDL - Ubuntu (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_16BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_24BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - cl - Windows (push) Has been cancelled
C/C++ CI / Build OPTIONS_FULL_32BIT - gcc - Windows (push) Has been cancelled
C/C++ CI / Build ESP IDF ESP32S3 (push) Has been cancelled
C/C++ CI / Run tests with 32bit build (push) Has been cancelled
C/C++ CI / Run tests with 64bit build (push) Has been cancelled
BOM Check / bom-check (push) Has been cancelled
Verify that lv_conf_internal.h matches repository state / verify-conf-internal (push) Has been cancelled
Verify the widget property name / verify-property-name (push) Has been cancelled
Verify code formatting / verify-formatting (push) Has been cancelled
Compare file templates with file names / template-check (push) Has been cancelled
Build docs / build-and-deploy (push) Has been cancelled
Test API JSON generator / Test API JSON (push) Has been cancelled
Install LVGL using CMake / build-examples (push) Has been cancelled
Check Makefile / Build using Makefile (push) Has been cancelled
Check Makefile for UEFI / Build using Makefile for UEFI (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/benchmark_results_comment/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/filter_docker_logs/test.sh) (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Script Check (scripts/perf/tests/serialize_results/test.sh) (push) Has been cancelled
Hardware Performance Test / Hardware Performance Benchmark (push) Has been cancelled
Hardware Performance Test / HW Benchmark - Save PR Number (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_32B - Ubuntu (push) Has been cancelled
Performance Tests CI / Perf Tests OPTIONS_TEST_PERF_64B - Ubuntu (push) Has been cancelled
Port repo release update / run-release-branch-updater (push) Has been cancelled
Verify Font License / verify-font-license (push) Has been cancelled
Verify Kconfig / verify-kconfig (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 32b - lv_conf_perf32b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark 64b - lv_conf_perf64b (push) Has been cancelled
Emulated Performance Test / ARM Emulated Benchmark - Save PR Number (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
#include "unity/unity.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
/* Function run before every test */
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
/* Function run after every test */
|
||||
lv_obj_clean(lv_screen_active());
|
||||
}
|
||||
|
||||
static void indev_reset_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * scroll_obj = lv_event_get_target(e);
|
||||
lv_obj_t * act_obj = lv_obj_get_child(scroll_obj, 0);
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
if(code == LV_EVENT_SCROLL && act_obj) {
|
||||
lv_obj_delete(act_obj);
|
||||
}
|
||||
else if(code == LV_EVENT_INDEV_RESET) {
|
||||
uint32_t * indev_reset_count = lv_event_get_user_data(e);
|
||||
(*indev_reset_count)++;
|
||||
}
|
||||
}
|
||||
|
||||
void test_indev_obj_delete_reset(void)
|
||||
{
|
||||
lv_obj_t * scroll_obj = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(scroll_obj, 300, 300);
|
||||
lv_obj_align(scroll_obj, LV_ALIGN_LEFT_MID, 0, 0);
|
||||
|
||||
uint32_t indev_reset_count = 0;
|
||||
lv_obj_add_event_cb(scroll_obj, indev_reset_event_cb, LV_EVENT_ALL, &indev_reset_count);
|
||||
|
||||
lv_obj_t * act_obj = lv_obj_create(scroll_obj);
|
||||
lv_obj_set_size(act_obj, 400, 200);
|
||||
lv_obj_align(act_obj, LV_ALIGN_LEFT_MID, 0, 0);
|
||||
lv_obj_update_layout(scroll_obj);
|
||||
|
||||
lv_test_mouse_move_to(200, 200);
|
||||
lv_test_mouse_press();
|
||||
lv_test_wait(50);
|
||||
|
||||
lv_test_mouse_move_by(-20, 0);
|
||||
lv_test_mouse_press();
|
||||
lv_test_wait(50);
|
||||
|
||||
lv_test_mouse_move_by(-20, 0);
|
||||
lv_test_mouse_press();
|
||||
lv_test_wait(50);
|
||||
|
||||
lv_test_mouse_release();
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT32(1, indev_reset_count);
|
||||
}
|
||||
|
||||
static void indev_wait_release_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
uint32_t * pressed_count = lv_event_get_user_data(e);
|
||||
|
||||
switch(lv_event_get_code(e)) {
|
||||
case LV_EVENT_PRESSED:
|
||||
(*pressed_count)++;
|
||||
lv_indev_wait_release(lv_indev_active());
|
||||
break;
|
||||
case LV_EVENT_PRESS_LOST:
|
||||
lv_indev_reset(lv_indev_active(), obj);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void test_indev_wait_release(void)
|
||||
{
|
||||
uint32_t pressed_count = 0;
|
||||
lv_obj_t * btn = lv_button_create(lv_screen_active());
|
||||
lv_obj_set_size(btn, 100, 100);
|
||||
lv_obj_add_event_cb(btn, indev_wait_release_event_cb, LV_EVENT_ALL, &pressed_count);
|
||||
|
||||
lv_test_mouse_release();
|
||||
lv_test_wait(50);
|
||||
lv_test_mouse_move_to(50, 50);
|
||||
|
||||
lv_test_mouse_press();
|
||||
lv_test_wait(50);
|
||||
lv_test_mouse_release();
|
||||
lv_test_wait(50);
|
||||
|
||||
lv_test_mouse_press();
|
||||
lv_test_wait(50);
|
||||
lv_test_mouse_release();
|
||||
lv_test_wait(50);
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT32(2, pressed_count);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,60 +0,0 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
#include "unity/unity.h"
|
||||
|
||||
static uint32_t indev_reset_count = 0;
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
/* Function run before every test */
|
||||
indev_reset_count = 0;
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
/* Function run after every test */
|
||||
lv_obj_clean(lv_screen_active());
|
||||
}
|
||||
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * scroll_obj = lv_event_get_target(e);
|
||||
lv_obj_t * act_obj = lv_obj_get_child(scroll_obj, 0);
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
if(code == LV_EVENT_SCROLL && act_obj) {
|
||||
lv_obj_delete(act_obj);
|
||||
}
|
||||
else if(code == LV_EVENT_INDEV_RESET) {
|
||||
indev_reset_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
void test_indev_wait_release(void)
|
||||
{
|
||||
lv_obj_t * scroll_obj = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_size(scroll_obj, 300, 300);
|
||||
lv_obj_align(scroll_obj, LV_ALIGN_LEFT_MID, 0, 0);
|
||||
lv_obj_add_event_cb(scroll_obj, event_cb, LV_EVENT_ALL, NULL);
|
||||
|
||||
lv_obj_t * act_obj = lv_obj_create(scroll_obj);
|
||||
lv_obj_set_size(act_obj, 400, 200);
|
||||
lv_obj_align(act_obj, LV_ALIGN_LEFT_MID, 0, 0);
|
||||
|
||||
lv_test_mouse_move_to(200, 200);
|
||||
lv_test_mouse_press();
|
||||
lv_test_wait(50);
|
||||
|
||||
lv_test_mouse_move_by(-20, 0);
|
||||
lv_test_mouse_press();
|
||||
lv_test_wait(50);
|
||||
|
||||
lv_test_mouse_move_by(-20, 0);
|
||||
lv_test_mouse_press();
|
||||
lv_test_wait(50);
|
||||
|
||||
lv_test_mouse_release();
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT32(1, indev_reset_count);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,58 +0,0 @@
|
||||
#if LV_BUILD_TEST
|
||||
#include "../lvgl.h"
|
||||
#include "unity/unity.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
/* Function run before every test */
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
/* Function run after every test */
|
||||
lv_obj_clean(lv_screen_active());
|
||||
}
|
||||
|
||||
static void event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
uint32_t * pressed_count = lv_event_get_user_data(e);
|
||||
|
||||
switch(lv_event_get_code(e)) {
|
||||
case LV_EVENT_PRESSED:
|
||||
(*pressed_count)++;
|
||||
lv_indev_wait_release(lv_indev_active());
|
||||
break;
|
||||
case LV_EVENT_PRESS_LOST:
|
||||
lv_indev_reset(lv_indev_active(), obj);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void test_indev_wait_release(void)
|
||||
{
|
||||
uint32_t pressed_count = 0;
|
||||
lv_obj_t * btn = lv_button_create(lv_screen_active());
|
||||
lv_obj_set_size(btn, 100, 100);
|
||||
lv_obj_add_event_cb(btn, event_cb, LV_EVENT_ALL, &pressed_count);
|
||||
|
||||
lv_test_mouse_release();
|
||||
lv_test_wait(50);
|
||||
lv_test_mouse_move_to(50, 50);
|
||||
|
||||
lv_test_mouse_press();
|
||||
lv_test_wait(50);
|
||||
lv_test_mouse_release();
|
||||
lv_test_wait(50);
|
||||
|
||||
lv_test_mouse_press();
|
||||
lv_test_wait(50);
|
||||
lv_test_mouse_release();
|
||||
lv_test_wait(50);
|
||||
|
||||
TEST_ASSERT_EQUAL_UINT32(2, pressed_count);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user