mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
video: Add a test for font measurement
Add a simple test which measures a line of text using a Truetype font. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -777,3 +777,32 @@ static int dm_test_video_damage(struct unit_test_state *uts)
|
||||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_video_damage, UTF_SCAN_PDATA | UTF_SCAN_FDT);
|
||||
|
||||
/* Test font measurement */
|
||||
static int dm_test_font_measure(struct unit_test_state *uts)
|
||||
{
|
||||
const char *test_string = "There is always much to be said for not "
|
||||
"attempting more than you can do and for making a certainty of "
|
||||
"what you try. But this principle, like others in life and "
|
||||
"war, has its exceptions.";
|
||||
struct vidconsole_bbox bbox;
|
||||
struct video_priv *priv;
|
||||
struct udevice *dev, *con;
|
||||
|
||||
ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
|
||||
priv = dev_get_uclass_priv(dev);
|
||||
ut_asserteq(1366, priv->xsize);
|
||||
ut_asserteq(768, priv->ysize);
|
||||
|
||||
/* this is using the Nimbus font with size of 18 pixels */
|
||||
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
|
||||
vidconsole_position_cursor(con, 0, 0);
|
||||
ut_assertok(vidconsole_measure(con, NULL, 0, test_string, &bbox));
|
||||
ut_asserteq(0, bbox.x0);
|
||||
ut_asserteq(0, bbox.y0);
|
||||
ut_asserteq(0x47a, bbox.x1);
|
||||
ut_asserteq(0x12, bbox.y1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_font_measure, UTF_SCAN_FDT);
|
||||
|
||||
Reference in New Issue
Block a user