mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-28 13:36:27 +08:00
feat(xml): add new step tests click_on and set_language (#8931)
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
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
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
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
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
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
Co-authored-by: André Costa <andre_miguel_costa@hotmail.com> Co-authored-by: Liam Howatt <30486941+liamHowatt@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
2f40b98040
commit
c4cdfe7043
@@ -16,6 +16,7 @@
|
|||||||
#include "../../misc/lv_fs.h"
|
#include "../../misc/lv_fs.h"
|
||||||
#include "../../libs/expat/expat.h"
|
#include "../../libs/expat/expat.h"
|
||||||
#include "../../display/lv_display_private.h"
|
#include "../../display/lv_display_private.h"
|
||||||
|
#include "../../core/lv_obj_private.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
@@ -34,6 +35,8 @@ typedef struct {
|
|||||||
int32_t y;
|
int32_t y;
|
||||||
} mouse_pos;
|
} mouse_pos;
|
||||||
|
|
||||||
|
const char * str;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int32_t ms;
|
int32_t ms;
|
||||||
} wait;
|
} wait;
|
||||||
@@ -73,6 +76,7 @@ static lv_obj_t * create_cursor(lv_obj_t * parent);
|
|||||||
static bool execute_step(lv_xml_test_step_t * step, uint32_t slowdown);
|
static bool execute_step(lv_xml_test_step_t * step, uint32_t slowdown);
|
||||||
static void start_metadata_handler(void * user_data, const char * name, const char ** attrs);
|
static void start_metadata_handler(void * user_data, const char * name, const char ** attrs);
|
||||||
static void end_metadata_handler(void * user_data, const char * name);
|
static void end_metadata_handler(void * user_data, const char * name);
|
||||||
|
static void click_at(int32_t x, int32_t y, int32_t slowdown);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
@@ -182,6 +186,12 @@ void lv_xml_test_unregister(void)
|
|||||||
uint32_t i;
|
uint32_t i;
|
||||||
for(i = 0; i < test.step_cnt; i++) {
|
for(i = 0; i < test.step_cnt; i++) {
|
||||||
lv_xml_test_step_type_t type = test.steps[i].type;
|
lv_xml_test_step_type_t type = test.steps[i].type;
|
||||||
|
if(type == LV_XML_TEST_STEP_TYPE_CLICK_ON) {
|
||||||
|
lv_free((void *)test.steps[i].param.str);
|
||||||
|
}
|
||||||
|
if(type == LV_XML_TEST_STEP_TYPE_SET_LANGUAGE) {
|
||||||
|
lv_free((void *)test.steps[i].param.str);
|
||||||
|
}
|
||||||
if(type == LV_XML_TEST_STEP_TYPE_SCREENSHOT_COMPARE) {
|
if(type == LV_XML_TEST_STEP_TYPE_SCREENSHOT_COMPARE) {
|
||||||
lv_free((void *)test.steps[i].param.screenshot_compare.path);
|
lv_free((void *)test.steps[i].param.screenshot_compare.path);
|
||||||
}
|
}
|
||||||
@@ -302,19 +312,25 @@ static bool execute_step(lv_xml_test_step_t * step, uint32_t slowdown)
|
|||||||
if(step->type == LV_XML_TEST_STEP_TYPE_CLICK_AT) {
|
if(step->type == LV_XML_TEST_STEP_TYPE_CLICK_AT) {
|
||||||
int32_t x = step->param.mouse_pos.x;
|
int32_t x = step->param.mouse_pos.x;
|
||||||
int32_t y = step->param.mouse_pos.y;
|
int32_t y = step->param.mouse_pos.y;
|
||||||
|
click_at(x, y, slowdown);
|
||||||
|
}
|
||||||
|
else if(step->type == LV_XML_TEST_STEP_TYPE_CLICK_ON) {
|
||||||
|
const char * name = step->param.str;
|
||||||
|
lv_obj_t * obj = lv_obj_find_by_name(lv_screen_active(), name);
|
||||||
|
if(obj == NULL) {
|
||||||
|
LV_LOG_WARN("No widget found by `%s` name", name);
|
||||||
|
return LV_RESULT_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
lv_obj_remove_state(cursor, LV_STATE_PRESSED);
|
if(lv_obj_is_visible(obj) == false) {
|
||||||
lv_test_mouse_release();
|
LV_LOG_WARN("`%s` is not visible, so can't click on it", name);
|
||||||
lv_xml_test_wait(50, slowdown);
|
return LV_RESULT_INVALID;
|
||||||
lv_test_mouse_move_to(x, y);
|
}
|
||||||
lv_test_mouse_press();
|
|
||||||
lv_obj_set_pos(cursor, x, y);
|
int32_t x = obj->coords.x1 + lv_area_get_width(&obj->coords) / 2;
|
||||||
lv_obj_add_state(cursor, LV_STATE_PRESSED);
|
int32_t y = obj->coords.y1 + lv_area_get_height(&obj->coords) / 2;
|
||||||
lv_xml_test_wait(100, slowdown);
|
|
||||||
lv_test_mouse_release();
|
click_at(x, y, slowdown);
|
||||||
lv_xml_test_wait(50, slowdown);
|
|
||||||
lv_obj_remove_state(cursor, LV_STATE_PRESSED);
|
|
||||||
lv_refr_now(NULL);
|
|
||||||
}
|
}
|
||||||
else if(step->type == LV_XML_TEST_STEP_TYPE_PRESS) {
|
else if(step->type == LV_XML_TEST_STEP_TYPE_PRESS) {
|
||||||
lv_obj_add_state(cursor, LV_STATE_PRESSED);
|
lv_obj_add_state(cursor, LV_STATE_PRESSED);
|
||||||
@@ -395,6 +411,10 @@ static bool execute_step(lv_xml_test_step_t * step, uint32_t slowdown)
|
|||||||
LV_LOG_WARN("Not supported subject type %d", type);
|
LV_LOG_WARN("Not supported subject type %d", type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(step->type == LV_XML_TEST_STEP_TYPE_SET_LANGUAGE) {
|
||||||
|
const char * lang = step->param.str;
|
||||||
|
lv_translation_set_language(lang);
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -444,6 +464,20 @@ static void start_metadata_handler(void * user_data, const char * name, const ch
|
|||||||
test.steps[idx].param.mouse_pos.x = lv_xml_atoi(x);
|
test.steps[idx].param.mouse_pos.x = lv_xml_atoi(x);
|
||||||
test.steps[idx].param.mouse_pos.y = lv_xml_atoi(y);
|
test.steps[idx].param.mouse_pos.y = lv_xml_atoi(y);
|
||||||
}
|
}
|
||||||
|
else if(lv_streq(name, "click_on")) {
|
||||||
|
const char * obj_name = lv_xml_get_value_of(attrs, "name");
|
||||||
|
if(obj_name == NULL) {
|
||||||
|
LV_LOG_WARN("No name is set in test step");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
test.step_cnt++;
|
||||||
|
test.steps = lv_realloc(test.steps, sizeof(lv_xml_test_step_t) * test.step_cnt);
|
||||||
|
uint32_t idx = test.step_cnt - 1;
|
||||||
|
test.steps[idx].type = LV_XML_TEST_STEP_TYPE_CLICK_ON;
|
||||||
|
test.steps[idx].param.str = lv_strdup(obj_name);
|
||||||
|
LV_ASSERT_MALLOC(test.steps[idx].param.str);
|
||||||
|
}
|
||||||
else if(lv_streq(name, "move_to")) {
|
else if(lv_streq(name, "move_to")) {
|
||||||
test.step_cnt++;
|
test.step_cnt++;
|
||||||
const char * x = lv_xml_get_value_of(attrs, "x");
|
const char * x = lv_xml_get_value_of(attrs, "x");
|
||||||
@@ -534,6 +568,20 @@ static void start_metadata_handler(void * user_data, const char * name, const ch
|
|||||||
test.steps[idx].param.subject_compare.subject = subject;
|
test.steps[idx].param.subject_compare.subject = subject;
|
||||||
test.steps[idx].param.subject_compare.value = lv_strdup(value_str);
|
test.steps[idx].param.subject_compare.value = lv_strdup(value_str);
|
||||||
}
|
}
|
||||||
|
else if(lv_streq(name, "set_language")) {
|
||||||
|
const char * obj_name = lv_xml_get_value_of(attrs, "name");
|
||||||
|
if(obj_name == NULL) {
|
||||||
|
LV_LOG_WARN("No name is set in test step");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
test.step_cnt++;
|
||||||
|
test.steps = lv_realloc(test.steps, sizeof(lv_xml_test_step_t) * test.step_cnt);
|
||||||
|
uint32_t idx = test.step_cnt - 1;
|
||||||
|
test.steps[idx].type = LV_XML_TEST_STEP_TYPE_SET_LANGUAGE;
|
||||||
|
test.steps[idx].param.str = lv_strdup(obj_name);
|
||||||
|
LV_ASSERT_MALLOC(test.steps[idx].param.str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void end_metadata_handler(void * user_data, const char * name)
|
static void end_metadata_handler(void * user_data, const char * name)
|
||||||
@@ -546,4 +594,20 @@ static void end_metadata_handler(void * user_data, const char * name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void click_at(int32_t x, int32_t y, int32_t slowdown)
|
||||||
|
{
|
||||||
|
lv_obj_remove_state(cursor, LV_STATE_PRESSED);
|
||||||
|
lv_test_mouse_release();
|
||||||
|
lv_xml_test_wait(50, slowdown);
|
||||||
|
lv_test_mouse_move_to(x, y);
|
||||||
|
lv_test_mouse_press();
|
||||||
|
lv_obj_set_pos(cursor, x, y);
|
||||||
|
lv_obj_add_state(cursor, LV_STATE_PRESSED);
|
||||||
|
lv_xml_test_wait(100, slowdown);
|
||||||
|
lv_test_mouse_release();
|
||||||
|
lv_xml_test_wait(50, slowdown);
|
||||||
|
lv_obj_remove_state(cursor, LV_STATE_PRESSED);
|
||||||
|
lv_refr_now(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* LV_USE_XML */
|
#endif /* LV_USE_XML */
|
||||||
|
|||||||
@@ -26,11 +26,13 @@ typedef enum {
|
|||||||
LV_XML_TEST_STEP_TYPE_PRESS,
|
LV_XML_TEST_STEP_TYPE_PRESS,
|
||||||
LV_XML_TEST_STEP_TYPE_RELEASE,
|
LV_XML_TEST_STEP_TYPE_RELEASE,
|
||||||
LV_XML_TEST_STEP_TYPE_CLICK_AT,
|
LV_XML_TEST_STEP_TYPE_CLICK_AT,
|
||||||
|
LV_XML_TEST_STEP_TYPE_CLICK_ON,
|
||||||
LV_XML_TEST_STEP_TYPE_WAIT,
|
LV_XML_TEST_STEP_TYPE_WAIT,
|
||||||
LV_XML_TEST_STEP_TYPE_FREEZE,
|
LV_XML_TEST_STEP_TYPE_FREEZE,
|
||||||
LV_XML_TEST_STEP_TYPE_SCREENSHOT_COMPARE,
|
LV_XML_TEST_STEP_TYPE_SCREENSHOT_COMPARE,
|
||||||
LV_XML_TEST_STEP_TYPE_SUBJECT_SET,
|
LV_XML_TEST_STEP_TYPE_SUBJECT_SET,
|
||||||
LV_XML_TEST_STEP_TYPE_SUBJECT_COMPARE,
|
LV_XML_TEST_STEP_TYPE_SUBJECT_COMPARE,
|
||||||
|
LV_XML_TEST_STEP_TYPE_SET_LANGUAGE,
|
||||||
} lv_xml_test_step_type_t;
|
} lv_xml_test_step_type_t;
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
|
|||||||
Reference in New Issue
Block a user