
From: Simon Glass <sjg@chromium.org> Provide a way to click on an object and check that the expected action resulted. Put it in a common file so it can be used by cedit and expo tests. Tidy up the include-order in both cedit and expo. Signed-off-by: Simon Glass <sjg@chromium.org> --- test/boot/Makefile | 4 ++-- test/boot/cedit.c | 3 ++- test/boot/expo.c | 3 ++- test/boot/expo_common.c | 24 ++++++++++++++++++++++++ test/boot/expo_common.h | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 test/boot/expo_common.c create mode 100644 test/boot/expo_common.h diff --git a/test/boot/Makefile b/test/boot/Makefile index e8b423b0c43..7c492ba92af 100644 --- a/test/boot/Makefile +++ b/test/boot/Makefile @@ -6,8 +6,8 @@ ifdef CONFIG_UT_BOOTSTD obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o obj-$(CONFIG_FIT) += image.o -obj-$(CONFIG_EXPO) += expo.o -obj-$(CONFIG_CEDIT) += cedit.o +obj-$(CONFIG_EXPO) += expo.o expo_common.o +obj-$(CONFIG_CEDIT) += cedit.o expo_common.o endif ifdef CONFIG_SANDBOX diff --git a/test/boot/cedit.c b/test/boot/cedit.c index 3426bf13ec3..425e4a1fe41 100644 --- a/test/boot/cedit.c +++ b/test/boot/cedit.c @@ -10,10 +10,11 @@ #include <expo.h> #include <mapmem.h> #include <dm/ofnode.h> +#include <test/cedit-test.h> #include <test/ut.h> #include <test/video.h> #include "bootstd_common.h" -#include <test/cedit-test.h> +#include "expo_common.h" #include "../../boot/scene_internal.h" /* Check the cedit command */ diff --git a/test/boot/expo.c b/test/boot/expo.c index e8674d359d7..21bfd8e586b 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -10,10 +10,11 @@ #include <menu.h> #include <video.h> #include <linux/input.h> +#include <test/cedit-test.h> #include <test/ut.h> #include <test/video.h> #include "bootstd_common.h" -#include <test/cedit-test.h> +#include "expo_common.h" #include "../../boot/scene_internal.h" enum { diff --git a/test/boot/expo_common.c b/test/boot/expo_common.c new file mode 100644 index 00000000000..5ee0ca79fb1 --- /dev/null +++ b/test/boot/expo_common.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Common functions for expo tests + * + * Copyright 2025 Simon Glass <sjg@chromium.org> + */ + +#include <expo.h> +#include <test/ut.h> +#include "../../boot/scene_internal.h" + +int click_check(struct unit_test_state *uts, struct scene *scn, uint id, + enum expoact_type expect_type, struct expo_action *act) +{ + struct scene_obj *obj; + + obj = scene_obj_find(scn, id, SCENEOBJT_NONE); + ut_assertnonnull(obj); + ut_assertok(scene_send_click(scn, (obj->bbox.x0 + obj->bbox.x1) / 2, + obj->bbox.y0 + 5, act)); + ut_asserteq(expect_type, act->type); + + return 0; +} diff --git a/test/boot/expo_common.h b/test/boot/expo_common.h new file mode 100644 index 00000000000..e3ae1d1dd59 --- /dev/null +++ b/test/boot/expo_common.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Common functions for expo tests + * + * Copyright 2025 Simon Glass <sjg@chromium.org> + */ + +#ifndef __expo_common_h +#define __expo_common_h + +#include <linux/types.h> + +enum expoact_type; +struct expo_action; +struct scene; +struct unit_test_state; + +/** + * click_check() - Click on an object and check the resulting action type + * + * Clicks halfway along the object, 5 pixels from the top + * + * @uts: Test state + * @scn: Scene containing the object + * @id: ID of object to click on + * @expect_type: Expected action type + * @act: Returns the action from the click + * Returns: 0 if OK, 1 if assertion failed + */ +int click_check(struct unit_test_state *uts, struct scene *scn, uint id, + enum expoact_type expect_type, struct expo_action *act); + +#endif -- 2.43.0