expo: Test some cedit actions

Refactor the action-processing code into a new cedit_do_action()
function so we can call it from a test. Check moving to a new field and
opening the menu, to ensure that rendering is correct.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-05-02 08:46:21 -06:00
parent 932ea4a104
commit 5f99334296
3 changed files with 100 additions and 36 deletions

View File

@@ -226,8 +226,10 @@ BOOTSTD_TEST(cedit_cmos, UTF_CONSOLE);
/* Check the cedit displays correctely */
static int cedit_render(struct unit_test_state *uts)
{
struct scene_obj_menu *menu;
struct video_priv *vid_priv;
extern struct expo *cur_exp;
struct expo_action act;
struct udevice *dev;
struct scene *scn;
struct expo *exp;
@@ -237,9 +239,50 @@ static int cedit_render(struct unit_test_state *uts)
exp = cur_exp;
ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev));
ut_asserteq(ID_SCENE1, cedit_prepare(exp, &vid_priv, &scn));
menu = scene_obj_find(scn, ID_POWER_LOSS, SCENEOBJT_MENU);
ut_assertnonnull(menu);
ut_asserteq(ID_AC_OFF, menu->cur_item_id);
ut_assertok(expo_render(exp));
ut_asserteq(4929, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
/* move to the second menu */
act.type = EXPOACT_POINT_OBJ;
act.select.id = ID_POWER_LOSS;
ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
ut_assertok(expo_render(exp));
ut_asserteq(4986, video_compress_fb(uts, dev, false));
/* open the menu */
act.type = EXPOACT_OPEN;
act.select.id = ID_POWER_LOSS;
ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
ut_assertok(expo_render(exp));
ut_asserteq(5393, video_compress_fb(uts, dev, false));
/* close the menu */
act.type = EXPOACT_CLOSE;
act.select.id = ID_POWER_LOSS;
ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
ut_assertok(expo_render(exp));
ut_asserteq(4986, video_compress_fb(uts, dev, false));
/* open the menu again to check it looks the same */
act.type = EXPOACT_OPEN;
act.select.id = ID_POWER_LOSS;
ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
ut_assertok(expo_render(exp));
ut_asserteq(5393, video_compress_fb(uts, dev, false));
/* close the menu */
act.type = EXPOACT_CLOSE;
act.select.id = ID_POWER_LOSS;
ut_assertok(cedit_do_action(exp, scn, vid_priv, &act));
ut_assertok(expo_render(exp));
ut_asserteq(4986, video_compress_fb(uts, dev, false));
expo_destroy(exp);
cur_exp = NULL;