diff options
Diffstat (limited to 'test/boot')
-rw-r--r-- | test/boot/bootdev.c | 1 | ||||
-rw-r--r-- | test/boot/bootflow.c | 10 | ||||
-rw-r--r-- | test/boot/bootm.c | 1 | ||||
-rw-r--r-- | test/boot/bootmeth.c | 1 | ||||
-rw-r--r-- | test/boot/cedit.c | 217 | ||||
-rw-r--r-- | test/boot/expo.c | 214 | ||||
-rw-r--r-- | test/boot/measurement.c | 1 | ||||
-rw-r--r-- | test/boot/upl.c | 1 |
8 files changed, 395 insertions, 51 deletions
diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 9af94786870..a5f3d4462a9 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -10,6 +10,7 @@ #include <dm.h> #include <bootdev.h> #include <bootflow.h> +#include <env.h> #include <mapmem.h> #include <os.h> #include <test/ut.h> diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index b261bd5f620..8de5a310add 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -14,6 +14,7 @@ #include <dm.h> #include <efi.h> #include <efi_loader.h> +#include <env.h> #include <expo.h> #include <mapmem.h> #ifdef CONFIG_SANDBOX @@ -857,7 +858,7 @@ static int check_font(struct unit_test_state *uts, struct scene *scn, uint id, txt = scene_obj_find(scn, id, SCENEOBJT_TEXT); ut_assertnonnull(txt); - ut_asserteq(font_size, txt->font_size); + ut_asserteq(font_size, txt->gen.font_size); return 0; } @@ -877,9 +878,10 @@ static int bootflow_menu_theme(struct unit_test_state *uts) ut_assertok(scan_mmc4_bootdev(uts)); ut_assertok(bootflow_menu_new(&exp)); + ut_assertok(bootflow_menu_add_all(exp)); node = ofnode_path("/bootstd/theme"); ut_assert(ofnode_valid(node)); - ut_assertok(bootflow_menu_apply_theme(exp, node)); + ut_assertok(expo_apply_theme(exp, node)); scn = expo_lookup_scene_id(exp, MAIN); ut_assertnonnull(scn); @@ -890,8 +892,8 @@ static int bootflow_menu_theme(struct unit_test_state *uts) * * Check both menu items, since there are two bootflows */ - ut_assertok(check_font(uts, scn, OBJ_PROMPT, font_size)); - ut_assertok(check_font(uts, scn, OBJ_POINTER, font_size)); + for (i = OBJ_PROMPT1A; i <= OBJ_AUTOBOOT; i++) + ut_assertok(check_font(uts, scn, i, font_size)); for (i = 0; i < 2; i++) { ut_assertok(check_font(uts, scn, ITEM_DESC + i, font_size)); ut_assertok(check_font(uts, scn, ITEM_KEY + i, font_size)); diff --git a/test/boot/bootm.c b/test/boot/bootm.c index 1d1efe71ad5..ed60094f3c1 100644 --- a/test/boot/bootm.c +++ b/test/boot/bootm.c @@ -6,6 +6,7 @@ */ #include <bootm.h> +#include <env.h> #include <asm/global_data.h> #include <test/test.h> #include <test/ut.h> diff --git a/test/boot/bootmeth.c b/test/boot/bootmeth.c index 577f259fb37..2ef3569ad83 100644 --- a/test/boot/bootmeth.c +++ b/test/boot/bootmeth.c @@ -9,6 +9,7 @@ #include <bootmeth.h> #include <bootstd.h> #include <dm.h> +#include <env.h> #include <test/ut.h> #include "bootstd_common.h" diff --git a/test/boot/cedit.c b/test/boot/cedit.c index 4d1b99bc2ea..dbf781902fb 100644 --- a/test/boot/cedit.c +++ b/test/boot/cedit.c @@ -5,11 +5,13 @@ */ #include <cedit.h> +#include <dm.h> #include <env.h> #include <expo.h> #include <mapmem.h> #include <dm/ofnode.h> #include <test/ut.h> +#include <test/video.h> #include "bootstd_common.h" #include <test/cedit-test.h> #include "../../boot/scene_internal.h" @@ -46,7 +48,7 @@ static int cedit_base(struct unit_test_state *uts) txt = scene_obj_find(scn, menu->title_id, SCENEOBJT_NONE); ut_assertnonnull(txt); - ut_asserteq_str("AC Power", expo_get_str(exp, txt->str_id)); + ut_asserteq_str("AC Power", expo_get_str(exp, txt->gen.str_id)); ut_asserteq(ID_AC_ON, menu->cur_item_id); @@ -61,6 +63,7 @@ static int cedit_fdt(struct unit_test_state *uts) struct video_priv *vid_priv; extern struct expo *cur_exp; struct scene_obj_menu *menu; + struct udevice *dev; ulong addr = 0x1000; struct ofprop prop; struct scene *scn; @@ -70,9 +73,12 @@ static int cedit_fdt(struct unit_test_state *uts) void *fdt; int i; + ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev)); + vid_priv = dev_get_uclass_priv(dev); + ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0)); - ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, &vid_priv, &scn)); + ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, dev, &scn)); /* get a menu to fiddle with */ menu = scene_obj_find(scn, ID_CPU_SPEED, SCENEOBJT_MENU); @@ -132,12 +138,16 @@ static int cedit_env(struct unit_test_state *uts) struct video_priv *vid_priv; extern struct expo *cur_exp; struct scene_obj_menu *menu; + struct udevice *dev; struct scene *scn; char *str; ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0)); - ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, &vid_priv, &scn)); + ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev)); + vid_priv = dev_get_uclass_priv(dev); + + ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, dev, &scn)); /* get a menu to fiddle with */ menu = scene_obj_find(scn, ID_CPU_SPEED, SCENEOBJT_MENU); @@ -187,11 +197,14 @@ static int cedit_cmos(struct unit_test_state *uts) struct scene_obj_menu *menu, *menu2; struct video_priv *vid_priv; extern struct expo *cur_exp; + struct udevice *dev; struct scene *scn; ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0)); - ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, &vid_priv, &scn)); + ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev)); + vid_priv = dev_get_uclass_priv(dev); + ut_asserteq(ID_SCENE1, cedit_prepare(cur_exp, dev, &scn)); /* get the menus to fiddle with */ menu = scene_obj_find(scn, ID_CPU_SPEED, SCENEOBJT_MENU); @@ -220,3 +233,199 @@ static int cedit_cmos(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(cedit_cmos, UTF_CONSOLE); + +/* Check the cedit displays correctly */ +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 evt; + struct expo_action act; + struct udevice *dev, *con; + struct stdio_dev *sdev; + struct scene *scn; + struct expo *exp; + int i; + + ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0)); + + exp = cur_exp; + sdev = stdio_get_by_name("vidconsole"); + ut_assertnonnull(sdev); + con = sdev->priv; + + dev = dev_get_parent(con); + vid_priv = dev_get_uclass_priv(dev); + ut_asserteq(ID_SCENE1, cedit_prepare(exp, dev, &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)); + + 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)); + + act.type = EXPOACT_POINT_ITEM; + act.select.id = ID_AC_ON; + ut_assertok(cedit_do_action(exp, scn, vid_priv, &act)); + ut_assertok(expo_render(exp)); + ut_asserteq(5365, video_compress_fb(uts, dev, false)); + + /* select it */ + act.type = EXPOACT_SELECT; + act.select.id = ID_AC_ON; + ut_assertok(cedit_do_action(exp, scn, vid_priv, &act)); + ut_assertok(expo_render(exp)); + ut_asserteq(4980, video_compress_fb(uts, dev, false)); + + ut_asserteq(ID_AC_ON, menu->cur_item_id); + + /* move to the line-edit field */ + act.type = EXPOACT_POINT_OBJ; + act.select.id = ID_MACHINE_NAME; + ut_assertok(cedit_do_action(exp, scn, vid_priv, &act)); + ut_assertok(expo_render(exp)); + ut_asserteq(4862, video_compress_fb(uts, dev, false)); + + /* open it */ + act.type = EXPOACT_OPEN; + act.select.id = ID_MACHINE_NAME; + ut_assertok(cedit_do_action(exp, scn, vid_priv, &act)); + ut_assertok(expo_render(exp)); + ut_asserteq(4851, video_compress_fb(uts, dev, false)); + + /* + * Send some keypresses. Note that the console must be enabled so that + * the characters actually reach the putc_xy() in console_truetype, + * since in scene_textline_send_key(), the lineedit restores the + * vidconsole state, outputs the character and then saves the state + * again. If the character is never output, then the state won't be + * updated and the lineedit will be inconsistent. + */ + ut_unsilence_console(uts); + for (i = 'a'; i < 'd'; i++) + ut_assertok(scene_send_key(scn, i, &evt)); + ut_silence_console(uts); + ut_assertok(cedit_arange(exp, vid_priv, scn->id)); + ut_assertok(expo_render(exp)); + ut_asserteq(4996, video_compress_fb(uts, dev, false)); + + expo_destroy(exp); + cur_exp = NULL; + + return 0; +} +BOOTSTD_TEST(cedit_render, UTF_DM | UTF_SCAN_FDT); + +/* Check the cedit displays lineedits correctly */ +static int cedit_render_lineedit(struct unit_test_state *uts) +{ + struct scene_obj_textline *tline; + struct video_priv *vid_priv; + extern struct expo *cur_exp; + struct expo_action evt; + struct expo_action act; + struct udevice *dev, *con; + struct stdio_dev *sdev; + struct scene *scn; + struct expo *exp; + char *str; + int i; + + ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0)); + + exp = cur_exp; + sdev = stdio_get_by_name("vidconsole"); + ut_assertnonnull(sdev); + con = sdev->priv; + + dev = dev_get_parent(con); + vid_priv = dev_get_uclass_priv(dev); + ut_asserteq(ID_SCENE1, cedit_prepare(exp, dev, &scn)); + + /* set up an initial value for the textline */ + tline = scene_obj_find(scn, ID_MACHINE_NAME, SCENEOBJT_TEXTLINE); + ut_assertnonnull(tline); + str = abuf_data(&tline->buf); + strcpy(str, "my-machine"); + ut_asserteq(20, tline->pos); + + ut_assertok(expo_render(exp)); + ut_asserteq(5336, video_compress_fb(uts, dev, false)); + ut_assertok(video_check_copy_fb(uts, dev)); + + /* move to the line-edit field */ + act.type = EXPOACT_POINT_OBJ; + act.select.id = ID_MACHINE_NAME; + ut_assertok(cedit_do_action(exp, scn, vid_priv, &act)); + ut_assertok(expo_render(exp)); + ut_asserteq(5363, video_compress_fb(uts, dev, false)); + + /* open it */ + act.type = EXPOACT_OPEN; + act.select.id = ID_MACHINE_NAME; + ut_assertok(cedit_do_action(exp, scn, vid_priv, &act)); + // ut_asserteq(0, tline->pos); + ut_assertok(expo_render(exp)); + ut_asserteq(5283, video_compress_fb(uts, dev, false)); + + /* delete some characters */ + ut_unsilence_console(uts); + for (i = 0; i < 3; i++) + ut_assertok(scene_send_key(scn, '\b', &evt)); + ut_silence_console(uts); + ut_asserteq_str("my-mach", str); + + ut_assertok(cedit_arange(exp, vid_priv, scn->id)); + ut_assertok(expo_render(exp)); + ut_asserteq(5170, video_compress_fb(uts, dev, false)); + + expo_destroy(exp); + cur_exp = NULL; + + return 0; +} +BOOTSTD_TEST(cedit_render_lineedit, UTF_DM | UTF_SCAN_FDT); diff --git a/test/boot/expo.c b/test/boot/expo.c index 1d283a2ac95..ddfb739f9cf 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -11,6 +11,7 @@ #include <video.h> #include <linux/input.h> #include <test/ut.h> +#include <test/video.h> #include "bootstd_common.h" #include <test/cedit-test.h> #include "../../boot/scene_internal.h" @@ -24,14 +25,20 @@ enum { OBJ_LOGO, OBJ_TEXT, OBJ_TEXT2, + OBJ_TEXT3, OBJ_MENU, OBJ_MENU_TITLE, + OBJ_BOX, + OBJ_BOX2, + OBJ_TEXTED, /* strings */ STR_SCENE_TITLE, STR_TEXT, STR_TEXT2, + STR_TEXT3, + STR_TEXTED, STR_MENU_TITLE, STR_POINTER_TEXT, @@ -270,8 +277,8 @@ static int expo_object_attr(struct unit_test_state *uts) ut_assert(id > 0); ut_assertok(scene_obj_set_pos(scn, OBJ_LOGO, 123, 456)); - ut_asserteq(123, img->obj.dim.x); - ut_asserteq(456, img->obj.dim.y); + ut_asserteq(123, img->obj.bbox.x0); + ut_asserteq(456, img->obj.bbox.y0); ut_asserteq(-ENOENT, scene_obj_set_pos(scn, OBJ_TEXT2, 0, 0)); @@ -280,8 +287,8 @@ static int expo_object_attr(struct unit_test_state *uts) strcpy(name, "font2"); ut_assertok(scene_txt_set_font(scn, OBJ_TEXT, name, 42)); - ut_asserteq_ptr(name, txt->font_name); - ut_asserteq(42, txt->font_size); + ut_asserteq_ptr(name, txt->gen.font_name); + ut_asserteq(42, txt->gen.font_size); ut_asserteq(-ENOENT, scene_txt_set_font(scn, OBJ_TEXT2, name, 42)); @@ -296,7 +303,7 @@ static int expo_object_attr(struct unit_test_state *uts) node = ofnode_path("/bootstd/theme"); ut_assert(ofnode_valid(node)); ut_assertok(expo_apply_theme(exp, node)); - ut_asserteq(30, txt->font_size); + ut_asserteq(30, txt->gen.font_size); expo_destroy(exp); @@ -360,8 +367,8 @@ static int expo_object_menu(struct unit_test_state *uts) ut_asserteq(0, menu->pointer_id); ut_assertok(scene_obj_set_pos(scn, OBJ_MENU, 50, 400)); - ut_asserteq(50, menu->obj.dim.x); - ut_asserteq(400, menu->obj.dim.y); + ut_asserteq(50, menu->obj.bbox.x0); + ut_asserteq(400, menu->obj.bbox.y0); id = scene_txt_str(scn, "title", OBJ_MENU_TITLE, STR_MENU_TITLE, "Main Menu", &tit); @@ -407,24 +414,24 @@ static int expo_object_menu(struct unit_test_state *uts) ut_asserteq(id, menu->cur_item_id); /* the title should be at the top */ - ut_asserteq(menu->obj.dim.x, tit->obj.dim.x); - ut_asserteq(menu->obj.dim.y, tit->obj.dim.y); + ut_asserteq(menu->obj.bbox.x0, tit->obj.bbox.x0); + ut_asserteq(menu->obj.bbox.y0, tit->obj.bbox.y0); /* the first item should be next */ - ut_asserteq(menu->obj.dim.x, name1->obj.dim.x); - ut_asserteq(menu->obj.dim.y + 32, name1->obj.dim.y); + ut_asserteq(menu->obj.bbox.x0, name1->obj.bbox.x0); + ut_asserteq(menu->obj.bbox.y0 + 32, name1->obj.bbox.y0); - ut_asserteq(menu->obj.dim.x + 230, key1->obj.dim.x); - ut_asserteq(menu->obj.dim.y + 32, key1->obj.dim.y); + ut_asserteq(menu->obj.bbox.x0 + 230, key1->obj.bbox.x0); + ut_asserteq(menu->obj.bbox.y0 + 32, key1->obj.bbox.y0); - ut_asserteq(menu->obj.dim.x + 200, ptr->obj.dim.x); - ut_asserteq(menu->obj.dim.y + 32, ptr->obj.dim.y); + ut_asserteq(menu->obj.bbox.x0 + 200, ptr->obj.bbox.x0); + ut_asserteq(menu->obj.bbox.y0 + 32, ptr->obj.bbox.y0); - ut_asserteq(menu->obj.dim.x + 280, desc1->obj.dim.x); - ut_asserteq(menu->obj.dim.y + 32, desc1->obj.dim.y); + ut_asserteq(menu->obj.bbox.x0 + 280, desc1->obj.bbox.x0); + ut_asserteq(menu->obj.bbox.y0 + 32, desc1->obj.bbox.y0); - ut_asserteq(-4, prev1->obj.dim.x); - ut_asserteq(menu->obj.dim.y + 32, prev1->obj.dim.y); + ut_asserteq(-4, prev1->obj.bbox.x0); + ut_asserteq(menu->obj.bbox.y0 + 32, prev1->obj.bbox.y0); ut_asserteq(true, prev1->obj.flags & SCENEOF_HIDE); /* check iterating through scene items */ @@ -457,6 +464,7 @@ static int expo_render_image(struct unit_test_state *uts) { struct scene_obj_menu *menu; struct scene *scn, *scn2; + struct abuf orig, *text; struct expo_action act; struct scene_obj *obj; struct udevice *dev; @@ -487,6 +495,15 @@ static int expo_render_image(struct unit_test_state *uts) 60)); ut_assertok(scene_obj_set_pos(scn, OBJ_TEXT2, 200, 600)); + /* this string is clipped as it extends beyond its bottom bound */ + id = scene_txt_str(scn, "text", OBJ_TEXT3, STR_TEXT3, + "this is yet\nanother string, with word-wrap and it goes on for quite a while", + NULL); + ut_assert(id > 0); + ut_assertok(scene_txt_set_font(scn, OBJ_TEXT3, "nimbus_sans_l_regular", + 60)); + ut_assertok(scene_obj_set_bbox(scn, OBJ_TEXT3, 500, 200, 1000, 350)); + id = scene_menu(scn, "main", OBJ_MENU, &menu); ut_assert(id > 0); @@ -534,6 +551,22 @@ static int expo_render_image(struct unit_test_state *uts) ut_assertok(scene_obj_set_pos(scn, OBJ_MENU, 50, 400)); + id = scene_box(scn, "box", OBJ_BOX, 3, NULL); + ut_assert(id > 0); + ut_assertok(scene_obj_set_bbox(scn, OBJ_BOX, 40, 390, 1000, 510)); + + id = scene_box(scn, "box2", OBJ_BOX2, 1, NULL); + ut_assert(id > 0); + ut_assertok(scene_obj_set_bbox(scn, OBJ_BOX, 500, 200, 1000, 350)); + + id = scene_texted(scn, "editor", OBJ_TEXTED, STR_TEXTED, NULL); + ut_assert(id > 0); + ut_assertok(scene_obj_set_bbox(scn, OBJ_TEXTED, 100, 200, 400, 650)); + ut_assertok(expo_edit_str(exp, STR_TEXTED, &orig, &text)); + + abuf_printf(text, "This\nis the initial contents of the text editor " + "but it is quite likely that more will be added later"); + scn2 = expo_lookup_scene_id(exp, SCENE1); ut_asserteq_ptr(scn, scn2); scn2 = expo_lookup_scene_id(exp, SCENE2); @@ -548,46 +581,98 @@ static int expo_render_image(struct unit_test_state *uts) /* check dimensions of text */ obj = scene_obj_find(scn, OBJ_TEXT, SCENEOBJT_NONE); ut_assertnonnull(obj); - ut_asserteq(400, obj->dim.x); - ut_asserteq(100, obj->dim.y); - ut_asserteq(126, obj->dim.w); - ut_asserteq(40, obj->dim.h); + ut_asserteq(400, obj->bbox.x0); + ut_asserteq(100, obj->bbox.y0); + ut_asserteq(400 + 126, obj->bbox.x1); + ut_asserteq(100 + 40, obj->bbox.y1); /* check dimensions of image */ obj = scene_obj_find(scn, OBJ_LOGO, SCENEOBJT_NONE); ut_assertnonnull(obj); - ut_asserteq(50, obj->dim.x); - ut_asserteq(20, obj->dim.y); - ut_asserteq(160, obj->dim.w); - ut_asserteq(160, obj->dim.h); + ut_asserteq(50, obj->bbox.x0); + ut_asserteq(20, obj->bbox.y0); + ut_asserteq(50 + 160, obj->bbox.x1); + ut_asserteq(20 + 160, obj->bbox.y1); /* check dimensions of menu labels - both should be the same width */ obj = scene_obj_find(scn, ITEM1_LABEL, SCENEOBJT_NONE); ut_assertnonnull(obj); - ut_asserteq(50, obj->dim.x); - ut_asserteq(436, obj->dim.y); - ut_asserteq(29, obj->dim.w); - ut_asserteq(18, obj->dim.h); + ut_asserteq(50, obj->bbox.x0); + ut_asserteq(436, obj->bbox.y0); + ut_asserteq(50 + 29, obj->bbox.x1); + ut_asserteq(436 + 18, obj->bbox.y1); obj = scene_obj_find(scn, ITEM2_LABEL, SCENEOBJT_NONE); ut_assertnonnull(obj); - ut_asserteq(50, obj->dim.x); - ut_asserteq(454, obj->dim.y); - ut_asserteq(29, obj->dim.w); - ut_asserteq(18, obj->dim.h); + ut_asserteq(50, obj->bbox.x0); + ut_asserteq(454, obj->bbox.y0); + ut_asserteq(50 + 29, obj->bbox.x1); + ut_asserteq(454 + 18, obj->bbox.y1); + + /* same for the key */ + obj = scene_obj_find(scn, ITEM1_KEY, SCENEOBJT_NONE); + ut_assertnonnull(obj); + ut_asserteq(280, obj->bbox.x0); + ut_asserteq(436, obj->bbox.y0); + ut_asserteq(280 + 9, obj->bbox.x1); + ut_asserteq(436 + 18, obj->bbox.y1); + + obj = scene_obj_find(scn, ITEM2_KEY, SCENEOBJT_NONE); + ut_assertnonnull(obj); + ut_asserteq(280, obj->bbox.x0); + ut_asserteq(454, obj->bbox.y0); + ut_asserteq(280 + 9, obj->bbox.x1); + ut_asserteq(454 + 18, obj->bbox.y1); + + /* and the description */ + obj = scene_obj_find(scn, ITEM1_DESC, SCENEOBJT_NONE); + ut_assertnonnull(obj); + ut_asserteq(330, obj->bbox.x0); + ut_asserteq(436, obj->bbox.y0); + ut_asserteq(330 + 89, obj->bbox.x1); + ut_asserteq(436 + 18, obj->bbox.y1); + + obj = scene_obj_find(scn, ITEM2_DESC, SCENEOBJT_NONE); + ut_assertnonnull(obj); + ut_asserteq(330, obj->bbox.x0); + ut_asserteq(454, obj->bbox.y0); + ut_asserteq(330 + 89, obj->bbox.x1); + ut_asserteq(454 + 18, obj->bbox.y1); /* check dimensions of menu */ obj = scene_obj_find(scn, OBJ_MENU, SCENEOBJT_NONE); ut_assertnonnull(obj); - ut_asserteq(50, obj->dim.x); - ut_asserteq(400, obj->dim.y); - ut_asserteq(160, obj->dim.w); - ut_asserteq(160, obj->dim.h); + ut_asserteq(50, obj->bbox.x0); + ut_asserteq(400, obj->bbox.y0); + ut_asserteq(50 + 160, obj->bbox.x1); + ut_asserteq(400 + 160, obj->bbox.y1); + + scene_obj_set_width(scn, OBJ_MENU, 170); + ut_asserteq(50 + 170, obj->bbox.x1); + scene_obj_set_bbox(scn, OBJ_MENU, 60, 410, 50 + 160, 400 + 160); + ut_asserteq(60, obj->bbox.x0); + ut_asserteq(410, obj->bbox.y0); + ut_asserteq(50 + 160, obj->bbox.x1); + ut_asserteq(400 + 160, obj->bbox.y1); + + /* reset back to normal */ + scene_obj_set_bbox(scn, OBJ_MENU, 50, 400, 50 + 160, 400 + 160); /* render it */ expo_set_scene_id(exp, SCENE1); ut_assertok(expo_render(exp)); + ut_asserteq(0, scn->highlight_id); + ut_assertok(scene_arrange(scn)); + ut_asserteq(0, scn->highlight_id); + + scene_set_highlight_id(scn, OBJ_MENU); + 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)); + /* move down */ ut_assertok(expo_send_key(exp, BKEY_DOWN)); @@ -595,7 +680,31 @@ static int expo_render_image(struct unit_test_state *uts) ut_asserteq(EXPOACT_POINT_ITEM, act.type); ut_asserteq(ITEM2, act.select.id); + ut_assertok(scene_menu_select_item(scn, OBJ_MENU, act.select.id)); + ut_asserteq(ITEM2, scene_menu_get_cur_item(scn, OBJ_MENU)); + ut_assertok(scene_arrange(scn)); + ut_assertok(expo_render(exp)); + ut_asserteq(19673, video_compress_fb(uts, dev, false)); + ut_assertok(video_check_copy_fb(uts, dev)); + + /* hide the text editor since the following tets don't need it */ + scene_obj_set_hide(scn, OBJ_TEXTED, true); + + /* do some alignment checks */ + ut_assertok(scene_obj_set_halign(scn, OBJ_TEXT3, SCENEOA_CENTRE)); + ut_assertok(expo_render(exp)); + ut_asserteq(16368, video_compress_fb(uts, dev, false)); + ut_assertok(scene_obj_set_halign(scn, OBJ_TEXT3, SCENEOA_RIGHT)); + ut_assertok(expo_render(exp)); + ut_asserteq(16321, video_compress_fb(uts, dev, false)); + + ut_assertok(scene_obj_set_halign(scn, OBJ_TEXT3, SCENEOA_LEFT)); + ut_assertok(scene_obj_set_valign(scn, OBJ_TEXT3, SCENEOA_CENTRE)); + ut_assertok(expo_render(exp)); + ut_asserteq(18763, video_compress_fb(uts, dev, false)); + ut_assertok(scene_obj_set_valign(scn, OBJ_TEXT3, SCENEOA_BOTTOM)); ut_assertok(expo_render(exp)); + ut_asserteq(18714, video_compress_fb(uts, dev, false)); /* make sure only the preview for the second item is shown */ obj = scene_obj_find(scn, ITEM1_PREVIEW, SCENEOBJT_NONE); @@ -617,6 +726,12 @@ static int expo_render_image(struct unit_test_state *uts) /* make sure there was no console output */ ut_assert_console_end(); + /* now try with the highlight */ + exp->show_highlight = true; + ut_assertok(scene_arrange(scn)); + ut_assertok(expo_render(exp)); + ut_asserteq(18844, video_compress_fb(uts, dev, false)); + /* now try in text mode */ expo_set_text_mode(exp, true); ut_assertok(expo_render(exp)); @@ -635,6 +750,7 @@ static int expo_render_image(struct unit_test_state *uts) ut_asserteq(EXPOACT_POINT_ITEM, act.type); ut_asserteq(ITEM1, act.select.id); + ut_assertok(scene_menu_select_item(scn, OBJ_MENU, act.select.id)); ut_assertok(expo_render(exp)); ut_assert_nextline("U-Boot : Boot Menu"); @@ -658,6 +774,7 @@ static int expo_test_build(struct unit_test_state *uts) struct scene_obj_menu *menu; struct scene_menitem *item; struct scene_obj_txt *txt; + struct abuf orig, *copy; struct scene_obj *obj; struct scene *scn; struct expo *exp; @@ -678,7 +795,7 @@ static int expo_test_build(struct unit_test_state *uts) ut_assertnonnull(scn); ut_asserteq_str("main", scn->name); ut_asserteq(ID_SCENE1, scn->id); - ut_asserteq(ID_DYNAMIC_START + 1, scn->title_id); + ut_asserteq(ID_DYNAMIC_START, scn->title_id); ut_asserteq(0, scn->highlight_id); /* check the title */ @@ -690,7 +807,8 @@ static int expo_test_build(struct unit_test_state *uts) ut_asserteq(scn->title_id, obj->id); ut_asserteq(SCENEOBJT_TEXT, obj->type); ut_asserteq(0, obj->flags); - ut_asserteq_str("Test Configuration", expo_get_str(exp, txt->str_id)); + ut_asserteq_str("Test Configuration", + expo_get_str(exp, txt->gen.str_id)); /* check the menu */ menu = scene_obj_find(scn, ID_CPU_SPEED, SCENEOBJT_NONE); @@ -702,7 +820,7 @@ static int expo_test_build(struct unit_test_state *uts) ut_asserteq(0, obj->flags); txt = scene_obj_find(scn, menu->title_id, SCENEOBJT_NONE); - ut_asserteq_str("CPU speed", expo_get_str(exp, txt->str_id)); + ut_asserteq_str("CPU speed", expo_get_str(exp, txt->gen.str_id)); ut_asserteq(0, menu->cur_item_id); ut_asserteq(0, menu->pointer_id); @@ -719,11 +837,21 @@ static int expo_test_build(struct unit_test_state *uts) ut_asserteq(0, item->value); txt = scene_obj_find(scn, item->label_id, SCENEOBJT_NONE); - ut_asserteq_str("2 GHz", expo_get_str(exp, txt->str_id)); + ut_asserteq_str("2 GHz", expo_get_str(exp, txt->gen.str_id)); count = list_count_nodes(&menu->item_head); ut_asserteq(3, count); + /* try editing some text */ + ut_assertok(expo_edit_str(exp, txt->gen.str_id, &orig, ©)); + ut_asserteq_str("2 GHz", orig.data); + ut_asserteq_str("2 GHz", copy->data); + + /* change it and check that things look right */ + abuf_printf(copy, "atlantic %d", 123); + ut_asserteq_str("2 GHz", orig.data); + ut_asserteq_str("atlantic 123", copy->data); + expo_destroy(exp); return 0; diff --git a/test/boot/measurement.c b/test/boot/measurement.c index 1d38663fc0f..71f503f1567 100644 --- a/test/boot/measurement.c +++ b/test/boot/measurement.c @@ -7,6 +7,7 @@ */ #include <bootm.h> +#include <env.h> #include <malloc.h> #include <test/test.h> #include <test/ut.h> diff --git a/test/boot/upl.c b/test/boot/upl.c index eec89026fc3..e2dc3d51eda 100644 --- a/test/boot/upl.c +++ b/test/boot/upl.c @@ -7,6 +7,7 @@ */ #include <abuf.h> +#include <env.h> #include <mapmem.h> #include <upl.h> #include <dm/ofnode.h> |