expo: Use a different logo for the second menu-item

When testing menu items it is easier to check that the correct preview
is shown if the preview images are different. Make a copy of the image
and modify the palette for the second menu item, so this is obvious.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-05-05 17:42:40 +02:00
parent baa389273a
commit e57c6e3c58
4 changed files with 30 additions and 10 deletions

View File

@@ -67,7 +67,7 @@ int bootflow_menu_new(struct expo **expp)
SCENEOB_DISPLAY_MAX, 30);
ret |= scene_obj_set_halign(scn, OBJ_MENU_TITLE, SCENEOA_CENTRE);
logo = video_get_u_boot_logo();
logo = video_get_u_boot_logo(NULL);
if (logo) {
ret |= scene_img(scn, "ulogo", OBJ_U_BOOT_LOGO, logo, NULL);
ret |= scene_obj_set_pos(scn, OBJ_U_BOOT_LOGO, 1165, 100);

View File

@@ -582,11 +582,15 @@ int video_get_ysize(struct udevice *dev)
extern u8 __splash_ ## _name ## _end[]
#define SPLASH_START(_name) __splash_ ## _name ## _begin
#define SPLASH_END(_name) __splash_ ## _name ## _end
SPLASH_DECL(u_boot_logo);
void *video_get_u_boot_logo(void)
void *video_get_u_boot_logo(int *sizep)
{
if (sizep)
*sizep = SPLASH_END(u_boot_logo) - SPLASH_START(u_boot_logo);
return SPLASH_START(u_boot_logo);
}

View File

@@ -418,9 +418,10 @@ bool video_is_active(void);
/**
* video_get_u_boot_logo() - Get a pointer to the U-Boot logo
*
* @sizep: If non-null, returns the size of the logic in bytes
* Returns: Pointer to logo
*/
void *video_get_u_boot_logo(void);
void *video_get_u_boot_logo(int *sizep);
/*
* bmp_display() - Display BMP (bitmap) data located in memory

View File

@@ -463,13 +463,15 @@ BOOTSTD_TEST(expo_object_menu, UTF_DM | UTF_SCAN_FDT);
static int expo_render_image(struct unit_test_state *uts)
{
struct scene_obj_menu *menu;
struct abuf buf, logo_copy;
struct scene *scn, *scn2;
struct abuf orig, *text;
struct expo_action act;
struct scene_obj *obj;
struct udevice *dev;
struct expo *exp;
int id;
int id, size;
void *logo;
ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev));
@@ -478,7 +480,8 @@ static int expo_render_image(struct unit_test_state *uts)
ut_assert(id > 0);
ut_assertok(expo_set_display(exp, dev));
id = scene_img(scn, "logo", OBJ_LOGO, video_get_u_boot_logo(), NULL);
id = scene_img(scn, "logo", OBJ_LOGO, video_get_u_boot_logo(NULL),
NULL);
ut_assert(id > 0);
ut_assertok(scene_obj_set_pos(scn, OBJ_LOGO, 50, 20));
@@ -526,8 +529,18 @@ static int expo_render_image(struct unit_test_state *uts)
id = scene_txt_str(scn, "item1-key", ITEM1_KEY, STR_ITEM1_KEY, "1",
NULL);
ut_assert(id > 0);
id = scene_img(scn, "item1-preview", ITEM1_PREVIEW,
video_get_u_boot_logo(), NULL);
/*
* hack the logo to change the palette and use that for item2 so we can
* tell them apart
*/
logo = video_get_u_boot_logo(&size);
abuf_init_const(&buf, logo, size);
ut_assert(abuf_copy(&buf, &logo_copy));
memset(logo_copy.data + 0x70, '\x45', 0x20);
id = scene_img(scn, "item1-preview", ITEM1_PREVIEW, logo_copy.data,
NULL);
id = scene_menuitem(scn, OBJ_MENU, "item1", ITEM1, ITEM1_KEY,
ITEM1_LABEL, ITEM1_DESC, ITEM1_PREVIEW, 0, NULL);
ut_assert(id > 0);
@@ -542,7 +555,7 @@ static int expo_render_image(struct unit_test_state *uts)
NULL);
ut_assert(id > 0);
id = scene_img(scn, "item2-preview", ITEM2_PREVIEW,
video_get_u_boot_logo(), NULL);
video_get_u_boot_logo(NULL), NULL);
ut_assert(id > 0);
id = scene_menuitem(scn, OBJ_MENU, "item2", ITEM2, ITEM2_KEY,
@@ -670,8 +683,7 @@ static int expo_render_image(struct unit_test_state *uts)
ut_assertok(scene_arrange(scn));
ut_asserteq(OBJ_MENU, scn->highlight_id);
ut_assertok(expo_render(exp));
ut_asserteq(19704, video_compress_fb(uts, dev, false));
ut_asserteq(20433, video_compress_fb(uts, dev, false));
/* move down */
ut_assertok(expo_send_key(exp, BKEY_DOWN));
@@ -762,6 +774,9 @@ static int expo_render_image(struct unit_test_state *uts)
ut_assert_console_end();
abuf_uninit(&buf);
abuf_uninit(&logo_copy);
expo_destroy(exp);
return 0;