tests add mosue emulator
This commit is contained in:
@@ -58,7 +58,7 @@ def build_test(defines, test_name):
|
||||
test_file_name = test_name + ".c"
|
||||
test_file_runner_name = test_name + "_Runner.c"
|
||||
test_file_runner_name = test_file_runner_name.replace("/test_cases/", "/test_runners/")
|
||||
csrcs = " EXTRA_CSRCS=\"unity/unity.c unity/unity_support.c src/test_fonts/font_1.c src/test_fonts/font_2.c src/test_fonts/font_3.c \" "
|
||||
csrcs = " EXTRA_CSRCS=\"unity/unity.c unity/unity_support.c src/lv_test_indev.c src/test_fonts/font_1.c src/test_fonts/font_2.c src/test_fonts/font_3.c \" "
|
||||
# -s makes it silence
|
||||
cmd = "make -s -j BIN=test.bin MAINSRC=" + test_file_name + " TEST_SRC=" + test_file_runner_name + csrcs + " LVGL_DIR_NAME=" + lvgldirname + " DEFINES=" + d_all + " OPTIMIZATION=" + optimization
|
||||
|
||||
|
||||
@@ -192,8 +192,6 @@ test = {
|
||||
|
||||
"LV_USE_BIDI": 1,
|
||||
"LV_USE_ARABIC_PERSIAN_CHARS":1,
|
||||
"LV_USE_PERF_MONITOR":1,
|
||||
"LV_USE_MEM_MONITOR":1,
|
||||
|
||||
"LV_LABEL_TEXT_SELECTION":1,
|
||||
|
||||
|
||||
65
tests/src/lv_test_indev.c
Normal file
65
tests/src/lv_test_indev.c
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "../lvgl.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if LV_BUILD_TEST
|
||||
#include <sys/time.h>
|
||||
#include "lv_test_indev.h"
|
||||
#include "lv_test_init.h"
|
||||
|
||||
static lv_coord_t x_act;
|
||||
static lv_coord_t y_act;
|
||||
static bool pressed;
|
||||
|
||||
void lv_test_mouse_read_cb(lv_indev_drv_t * drv, lv_indev_data_t * data)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
data->point.x = x_act;
|
||||
data->point.y = y_act;
|
||||
data->state = pressed ? LV_INDEV_STATE_PRESSED : LV_INDEV_STATE_RELEASED;
|
||||
}
|
||||
|
||||
void lv_test_mouse_move_to(lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
x_act = x;
|
||||
y_act = y;
|
||||
}
|
||||
|
||||
void lv_test_mouse_move_by(lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
x_act += x;
|
||||
y_act += y;
|
||||
}
|
||||
|
||||
void lv_test_mouse_press(void)
|
||||
{
|
||||
pressed = true;
|
||||
}
|
||||
|
||||
void lv_test_mouse_release(void)
|
||||
{
|
||||
pressed = false;
|
||||
}
|
||||
|
||||
void lv_test_mouse_click_at(lv_coord_t x, lv_coord_t y)
|
||||
{
|
||||
lv_test_mouse_release();
|
||||
lv_test_mouse_wait(50);
|
||||
lv_test_mouse_move_to(x, y);
|
||||
lv_test_mouse_press();
|
||||
lv_test_mouse_wait(50);
|
||||
lv_test_mouse_release();
|
||||
lv_test_mouse_wait(50);
|
||||
}
|
||||
|
||||
void lv_test_mouse_wait(uint32_t ms)
|
||||
{
|
||||
uint32_t t = lv_tick_get();
|
||||
while(lv_tick_elaps(t) < ms) {
|
||||
lv_timer_handler();
|
||||
lv_tick_inc(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
26
tests/src/lv_test_indev.h
Normal file
26
tests/src/lv_test_indev.h
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
#ifndef LV_TEST_INDEV_H
|
||||
#define LV_TEST_INDEV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../lvgl.h"
|
||||
|
||||
void lv_test_mouse_read_cb(lv_indev_drv_t * drv, lv_indev_data_t * data);
|
||||
|
||||
void lv_test_mouse_move_to(lv_coord_t x, lv_coord_t y);
|
||||
void lv_test_mouse_move_by(lv_coord_t x, lv_coord_t y);
|
||||
void lv_test_mouse_press(void);
|
||||
void lv_test_mouse_release(void);
|
||||
void lv_test_mouse_click_at(lv_coord_t x, lv_coord_t y);
|
||||
void lv_test_mouse_wait(uint32_t ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_TEST_INDEV_H*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../lvgl.h"
|
||||
|
||||
#if LV_BUILD_TEST
|
||||
#include "lv_test_init.h"
|
||||
#include "lv_test_indev.h"
|
||||
#include <sys/time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -12,6 +12,7 @@
|
||||
static void hal_init(void);
|
||||
static void dummy_flush_cb(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
|
||||
|
||||
lv_indev_t * lv_test_mouse_indev;
|
||||
lv_color_t test_fb[HOR_RES * VER_RES];
|
||||
static lv_color_t disp_buf1[HOR_RES * VER_RES];
|
||||
|
||||
@@ -98,6 +99,13 @@ static void hal_init(void)
|
||||
disp_drv.hor_res = HOR_RES;
|
||||
disp_drv.ver_res = VER_RES;
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
|
||||
static lv_indev_drv_t indev_drv;
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read_cb = lv_test_mouse_read_cb;
|
||||
lv_test_mouse_indev = lv_indev_drv_register(&indev_drv);
|
||||
|
||||
|
||||
static lv_fs_drv_t drv;
|
||||
lv_fs_drv_init(&drv); /*Basic initialization*/
|
||||
|
||||
@@ -7,10 +7,13 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <../lvgl.h>
|
||||
|
||||
void lv_test_init(void);
|
||||
void lv_test_deinit(void);
|
||||
|
||||
extern lv_indev_t * lv_test_mouse_indev;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
#if LV_BUILD_TEST
|
||||
|
||||
#include "unity/unity.h"
|
||||
#include "lv_test_indev.h"
|
||||
|
||||
void test_dropdown_create_delete(void);
|
||||
void test_dropdown_set_text_and_symbol(void);
|
||||
void test_dropdown_set_options(void);
|
||||
void test_dropdown_select(void);
|
||||
void test_dropdown_click(void);
|
||||
void test_dropdown_render(void);
|
||||
|
||||
void test_dropdown_create_delete(void)
|
||||
@@ -134,6 +136,24 @@ void test_dropdown_select(void)
|
||||
TEST_ASSERT_EQUAL(2, lv_dropdown_get_selected(dd1));
|
||||
}
|
||||
|
||||
void test_dropdown_click(void)
|
||||
{
|
||||
lv_obj_clean(lv_scr_act());
|
||||
lv_obj_t * dd1 = lv_dropdown_create(lv_scr_act());
|
||||
lv_obj_update_layout(dd1);
|
||||
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
lv_test_mouse_click_at(dd1->coords.x1 + 5, dd1->coords.y1 + 5);
|
||||
TEST_ASSERT_NOT_NULL(lv_dropdown_get_list(dd1));
|
||||
|
||||
lv_obj_t * list = lv_dropdown_get_list(dd1);
|
||||
TEST_ASSERT_EQUAL(0, lv_dropdown_get_selected(dd1));
|
||||
lv_test_mouse_click_at(list->coords.x1 + 5, list->coords.y2 - 25);
|
||||
TEST_ASSERT_EQUAL(2, lv_dropdown_get_selected(dd1));
|
||||
TEST_ASSERT_NULL(lv_dropdown_get_list(dd1));
|
||||
}
|
||||
|
||||
|
||||
void test_dropdown_render(void)
|
||||
{
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
Reference in New Issue
Block a user