mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-12-24 02:42:18 +01:00
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:
parent
932ea4a104
commit
5f99334296
80
boot/cedit.c
80
boot/cedit.c
@ -149,6 +149,47 @@ int cedit_prepare(struct expo *exp, struct video_priv **vid_privp,
|
||||
return scene_id;
|
||||
}
|
||||
|
||||
int cedit_do_action(struct expo *exp, struct scene *scn,
|
||||
struct video_priv *vid_priv, struct expo_action *act)
|
||||
{
|
||||
switch (act->type) {
|
||||
case EXPOACT_NONE:
|
||||
case EXPOACT_POINT_ITEM:
|
||||
return -EAGAIN;
|
||||
case EXPOACT_POINT_OBJ:
|
||||
scene_set_highlight_id(scn, act->select.id);
|
||||
cedit_arange(exp, vid_priv, scn->id);
|
||||
break;
|
||||
case EXPOACT_OPEN:
|
||||
scene_set_open(scn, act->select.id, true);
|
||||
cedit_arange(exp, vid_priv, scn->id);
|
||||
switch (scn->highlight_id) {
|
||||
case EXPOID_SAVE:
|
||||
exp->done = true;
|
||||
exp->save = true;
|
||||
break;
|
||||
case EXPOID_DISCARD:
|
||||
exp->done = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case EXPOACT_CLOSE:
|
||||
scene_set_open(scn, act->select.id, false);
|
||||
cedit_arange(exp, vid_priv, scn->id);
|
||||
break;
|
||||
case EXPOACT_SELECT:
|
||||
scene_set_open(scn, scn->highlight_id, false);
|
||||
cedit_arange(exp, vid_priv, scn->id);
|
||||
break;
|
||||
case EXPOACT_QUIT:
|
||||
log_debug("quitting\n");
|
||||
exp->done = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cedit_run(struct expo *exp)
|
||||
{
|
||||
struct video_priv *vid_priv;
|
||||
@ -167,43 +208,10 @@ int cedit_run(struct expo *exp)
|
||||
struct expo_action act;
|
||||
|
||||
ret = expo_poll(exp, &act);
|
||||
if (!ret) {
|
||||
switch (act.type) {
|
||||
case EXPOACT_POINT_OBJ:
|
||||
scene_set_highlight_id(scn, act.select.id);
|
||||
cedit_arange(exp, vid_priv, scene_id);
|
||||
break;
|
||||
case EXPOACT_OPEN:
|
||||
scene_set_open(scn, act.select.id, true);
|
||||
cedit_arange(exp, vid_priv, scene_id);
|
||||
switch (scn->highlight_id) {
|
||||
case EXPOID_SAVE:
|
||||
exp->done = true;
|
||||
exp->save = true;
|
||||
break;
|
||||
case EXPOID_DISCARD:
|
||||
exp->done = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case EXPOACT_CLOSE:
|
||||
scene_set_open(scn, act.select.id, false);
|
||||
cedit_arange(exp, vid_priv, scene_id);
|
||||
break;
|
||||
case EXPOACT_SELECT:
|
||||
scene_set_open(scn, scn->highlight_id, false);
|
||||
cedit_arange(exp, vid_priv, scene_id);
|
||||
break;
|
||||
case EXPOACT_QUIT:
|
||||
log_debug("quitting\n");
|
||||
exp->done = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (ret != -EAGAIN) {
|
||||
if (!ret)
|
||||
cedit_do_action(exp, scn, vid_priv, &act);
|
||||
else if (ret != -EAGAIN)
|
||||
return log_msg_ret("cep", ret);
|
||||
}
|
||||
} while (!exp->done);
|
||||
|
||||
if (ret)
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
struct abuf;
|
||||
struct expo;
|
||||
struct expo_action;
|
||||
struct scene;
|
||||
struct udevice;
|
||||
struct video_priv;
|
||||
@ -62,6 +63,18 @@ int cedit_run(struct expo *exp);
|
||||
int cedit_prepare(struct expo *exp, struct video_priv **vid_privp,
|
||||
struct scene **scnp);
|
||||
|
||||
/**
|
||||
* cedit_do_action() - Process an action on a cedit
|
||||
*
|
||||
* @exp: Expo to use
|
||||
* @scn: Current scene
|
||||
* @vid_priv: Private data for the video device
|
||||
* @act: Action to process
|
||||
* Return: 0 on success, -EAGAIN if there was no action taken
|
||||
*/
|
||||
int cedit_do_action(struct expo *exp, struct scene *scn,
|
||||
struct video_priv *vid_priv, struct expo_action *act);
|
||||
|
||||
/**
|
||||
* cedit_write_settings() - Write settings in FDT format
|
||||
*
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user