From patchwork Mon Sep 15 12:28:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 336 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939433; bh=eHLDGkMLhmV/z5Wqlv345DECszwxYbRlZMhnFUag/uI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=l5SqhMhH2bcjlvO/mzYAZFvvvOmjrEhSy66DZPvPaG80WL02xevHV5ymVRZQ/14mU LfHYcOin7ZXDNnGLYdKDSv559C+0TI6FQAq0y+8SFJNkxRBUkdhIsZass9ZwlyzzMR taCOZYnNK+nMcmZ+xcBOsXVCxdFuv7eGVvhAn/g+TLoZXjg1HOJkQqfK6OGP/lkHXw gAGJq9aM9lKtJrUWNjjf/XkZI0vhNg1yCaCfUm6izz4pfRqf1YRR26fllwo/PBlpjr vsFPul+4OW2QEtHK1pv4WYVfss2wPft2eWgoCMcytNptcjdBGxzzCh/CqDDukGyS70 hzNIEx2bdxCAg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6A9AD67BE2 for ; Mon, 15 Sep 2025 06:30:33 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id s-9dsEQwJonR for ; Mon, 15 Sep 2025 06:30:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939432; bh=eHLDGkMLhmV/z5Wqlv345DECszwxYbRlZMhnFUag/uI=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=PnMjDFiHp0UTu0cWOCxB9XOUEjBVLJiSgzzEKzKyPDyKjdDeqGmIU/+SNTTqsvPtY VjsaJjj79KvPIjmW6oMfNo334R5Jmsd6EFP195BYwKObm4sZIX1OhQdrdU7dBTrJ1E CWRrWpHX105lzcDI0U8bi0Z1UHYNh3NnJWZpZZ5SUM6dBLh1f8pbNg/cDjE1P7m9JA fEXpzc+8k4MoDhEJfJRRJ7Khe5kWereTpICyf/BX/BYyLTrBZRpCpETOEn18Nmzko0 T7uAVY5pWsNM05qRZ0cyEhsFhFb+MoYihE3lah972k31vdznpcys5jaaEXBc9mBU3/ n1+PrpVuRqfQA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 63E1567B34 for ; Mon, 15 Sep 2025 06:30:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939431; bh=kha969gy7Hzr40G3bLtykG6UIKNsGfbbAlvqhxfQRtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AhwQC7YMafblAlODxg8RtqhNVy5GTgG513pqItgV7+8Q8devQEhQHVjd+h/WwmvG3 tG2rAsrpgxXbfTlGMZWtt5v9+8amd9DRNu8RbJDJB5UI9LiFuAYnHiWBPvB7YzErXs 9bN77/OekpBS+UYOBHL8ZfGvY0v8Pzl0NAqmfmlnCn1CDApxw2KBHv8Rr33bS9h1+Z DJIIY4lWjgIty4YxQJdjGlyTqJ1QytVBhbq5RM9xZydZrsLuI999Tib86qrsXnE6En SiSn9szldOQboYddPxCl7yHUp/mtvxnA6IXsw4YpHqacLLlXousM6bBXV4q5Il5mDm XocZlrtIn3eVw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 19B0967BDA; Mon, 15 Sep 2025 06:30:31 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id RbLtgbKLt900; Mon, 15 Sep 2025 06:30:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1757939430; bh=2R4UDncuwSAdUvvN2ZAPUw/+m2Wi9zTB9xIzQ09xiSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dRtxJmeVBCbTWRovUSrTb/hw66H9ps2yosl6swUVaQGNwtOLNzc92omlqgksNx3bq UbPmMYsvfMYWJ8HHgwnL8sl1dSL6eD20jwrSzzsTBQSWXAQUqFfYqNJrnkf94iB7nu MPiN+VAuDno4nx4YONqiO5cMLC/SJS0YNAw08EzKtXE8Fhu+RahTnZahAaTrTKBPbZ gi8IAPJtzdpm/DRr3ojldTuiWAzkmI/8n5/M+7YCOCrrTg63mZAjus0HRachQX1+TJ 6PlecPljHUV9i9Thxf1QLSfwYu6Ppzy9mPbHUF1ibeawsGjKNVYDwAuEsHGdZUlS8I CM0Be2Oy4nhxQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5F77167B34; Mon, 15 Sep 2025 06:30:30 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 15 Sep 2025 06:28:54 -0600 Message-ID: <20250915122905.1217249-22-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250915122905.1217249-1-sjg@u-boot.org> References: <20250915122905.1217249-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 64YAA6XK3BT42G6JW7AMDDTCSDUFH7HU X-Message-ID-Hash: 64YAA6XK3BT42G6JW7AMDDTCSDUFH7HU X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 21/23] expo: Add a test helper for clicking on objects List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass 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 --- 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 #include #include +#include #include #include #include "bootstd_common.h" -#include +#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 #include #include +#include #include #include #include "bootstd_common.h" -#include +#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 + */ + +#include +#include +#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 + */ + +#ifndef __expo_common_h +#define __expo_common_h + +#include + +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