From patchwork Fri Sep 19 20:14:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 384 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=1758313062; bh=0HUUt0OU8nC72ISnuzq4JIOLbhFNfDqahXT34OmXcfc=; 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=HLLGcocfGqFPFY6uCjuKFwfAOsDy6yEn7le00aAFAJ285/VjyRDSCPAz0T9emDSz5 EVUqwZ6irzrF9YGI5oeBg24T6ag+T3KFiUjS4tAs8Gwd9DMenUILIWAEidxHEacImb i49F70FH4BHwGR/4k/PiFyALER5MDZdLRYqUZGmVoMiC7Qc4NUYmicMrqtN0WVBxkY /NTQXCzo3uvR04sQU0qaP1BK+bLGmo2jLYahFByO/OgVDLXAsoHfPrXC3y90AuN97Y IMu6lAVPSHq4uS0irmT/qkJua93LwXfbEEl9syQo9e1KLhvr2iLGLQ2kUW67Pvcibt n1jpwA86WZ/Ug== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 56AAC67C6C for ; Fri, 19 Sep 2025 14:17:42 -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 SL8PUIzdAOxN for ; Fri, 19 Sep 2025 14:17:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313062; bh=0HUUt0OU8nC72ISnuzq4JIOLbhFNfDqahXT34OmXcfc=; 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=HLLGcocfGqFPFY6uCjuKFwfAOsDy6yEn7le00aAFAJ285/VjyRDSCPAz0T9emDSz5 EVUqwZ6irzrF9YGI5oeBg24T6ag+T3KFiUjS4tAs8Gwd9DMenUILIWAEidxHEacImb i49F70FH4BHwGR/4k/PiFyALER5MDZdLRYqUZGmVoMiC7Qc4NUYmicMrqtN0WVBxkY /NTQXCzo3uvR04sQU0qaP1BK+bLGmo2jLYahFByO/OgVDLXAsoHfPrXC3y90AuN97Y IMu6lAVPSHq4uS0irmT/qkJua93LwXfbEEl9syQo9e1KLhvr2iLGLQ2kUW67Pvcibt n1jpwA86WZ/Ug== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4607C67C0E for ; Fri, 19 Sep 2025 14:17:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313059; bh=i2tAqW6ydtqqKLSww9Vus7CL2E+bNcFtsPYAU7ZLOmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wzMnRcnkIcD8n6PzCIbutseXWBCddir/phOR3ZvkVY+ynuanF9RIvNPYqDxIllBnc qTKXMNfFT845iH19/6IxpFrcf1mSfnXpoVHjicueKIdNA0iOydC+4iA7ZZdY6iNvbb tdICx7oxxN8OKVGoiHnjqioY/CqFb6+p8UhKceIiCsbVAFqEIbav+6roWHkdHi0H9w ihEAwvyx/drLsfg5DU0cS+Ic3M7xz7BvReGAKxTWRAmZg3GtdEzzPajpMG1BgHCWN4 dP/MrSdhPjbUbetkVvKqscAV0JabukH+xQtWyhJHQq2/tdTIMly+loUsFXjxys7yg4 y9VPBL4fcUXJA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EC09267B55; Fri, 19 Sep 2025 14:17:39 -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 rtAhqdpWDrhM; Fri, 19 Sep 2025 14:17:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313054; bh=1mBJ86kC6BKmzCXq2SpIV8D8v85Qu98+jCnQNNZBOzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r4Bevdgho4bGG4qTsfsP/aiW/RCypmsCI/j7KaskssSInIqn4rjkT8uBdpFF5awBk lPUr39VP+rTsDWOhpEH0UxBiXSiDMntpMQdnH62gWB/VZeAEjlLMhooYHKB1LBeSVY s7/1L75bgJnQTQ4IVHYPX8dp2AG6iN9F1i9vAkHa09L2hylMBUt412K7sjxZzwQ01y pGMBFxVZmEixiFZjJTj71bemq87ShnX/SnCo/L0d5TZN/S+sFP5IEjaxUeKgqyL+B8 /XL2L2zTimI7FMxyKz/pUEcCnSh6O9sxQNC1MU7DFhhl2mwgoPrMrr3QN75G2Mdthj xS/+99yfWTvWg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5A6C467BFC; Fri, 19 Sep 2025 14:17:34 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 19 Sep 2025 14:14:49 -0600 Message-ID: <20250919201507.4024144-43-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250919201507.4024144-1-sjg@u-boot.org> References: <20250919201507.4024144-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: M4KW4LEKSGIBLNUDMHUEHBQW5FIJ6HX3 X-Message-ID-Hash: M4KW4LEKSGIBLNUDMHUEHBQW5FIJ6HX3 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 42/42] console: Add some cursor tests 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 Add a few tests of cursor operation. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/dm/video.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/test/dm/video.c b/test/dm/video.c index 3395fd9f1b3..bb88c17e272 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -997,3 +997,87 @@ static int dm_test_video_font_switch(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_video_font_switch, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +/* cursor backspace without artifacts */ +static int check_cursor_backspace(struct unit_test_state *uts, + struct udevice *dev, struct udevice *con, + int exp_height) +{ + int with_a, with_cursor, after_backspace, after_idle, after_hide; + struct vidconsole_priv *vc_priv = dev_get_uclass_priv(con); + struct vidconsole_cursor *curs = &vc_priv->curs; + + /* Output chars without cursor */ + ut_assert(!curs->visible); + ut_assert(!curs->enabled); + ut_assert(!curs->saved); + ut_assert(!curs->height); + ut_assertok(vidconsole_put_char(con, ' ')); + ut_assertok(vidconsole_put_char(con, 'a')); + with_a = video_compress_fb(uts, dev, false); + + /* Show cursor at current position (after 'a') */ + ut_assertok(vidconsole_show_cursor(con)); + ut_assert(curs->visible); + ut_assert(curs->saved); + ut_asserteq(exp_height, curs->height); + with_cursor = video_compress_fb(uts, dev, false); + + /* Enable the cursor so that backspace will move it */ + curs->enabled = true; + + /* Do backspace - the cursor will be hidden */ + ut_assertok(vidconsole_put_char(con, '\b')); + ut_assert(!curs->visible); + ut_assert(!curs->saved); + after_backspace = video_compress_fb(uts, dev, false); + ut_asserteq(with_a, after_backspace); + ut_assert(curs->enabled); + + /* Run idle function - this should show the cursor */ + vidconsole_idle(con); + ut_assert(curs->visible); + ut_assert(curs->saved); + after_idle = video_compress_fb(uts, dev, false); + ut_assert(after_idle != with_a); + + /* Hide the cursor */ + ut_assertok(vidconsole_hide_cursor(con)); + ut_assert(curs->enabled); + ut_assert(!curs->visible); + ut_assert(!curs->saved); + after_hide = video_compress_fb(uts, dev, false); + + ut_asserteq(with_a, after_hide); + + return 0; +} + +/* cursor backspace without artifacts */ +static int dm_test_video_backspace_normal(struct unit_test_state *uts) +{ + struct udevice *dev, *con; + + ut_assertok(select_vidconsole(uts, "vidconsole0")); + ut_assertok(video_get_nologo(uts, &dev)); + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + ut_assertok(vidconsole_select_font(con, "8x16", 0)); + ut_assertok(check_cursor_backspace(uts, dev, con, 16)); + + return 0; +} +DM_TEST(dm_test_video_backspace_normal, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +/* cursor backspace without artifacts on truetype */ +static int dm_test_video_backspace_truetype(struct unit_test_state *uts) +{ + struct udevice *dev, *con; + + ut_assertok(video_get_nologo(uts, &dev)); + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + ut_assertok(vidconsole_select_font(con, NULL, 30)); + ut_assertok(check_cursor_backspace(uts, dev, con, 30)); + + return 0; +} +DM_TEST(dm_test_video_backspace_truetype, UTF_SCAN_PDATA | UTF_SCAN_FDT);