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>
diff --git a/test/boot/cedit.c b/test/boot/cedit.c
index df191a0..5b3e9b5 100644
--- a/test/boot/cedit.c
+++ b/test/boot/cedit.c
@@ -226,8 +226,10 @@
/* 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 @@
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;