blob: c0ef03b591122de81d8399d31df1f42ce667d6f7 [file] [log] [blame]
Simon Glass65924992023-01-06 08:52:39 -06001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2022 Google LLC
4 * Written by Simon Glass <sjg@chromium.org>
5 */
6
7#include <common.h>
8#include <dm.h>
9#include <expo.h>
10#include <menu.h>
11#include <video.h>
12#include <linux/input.h>
13#include <test/suites.h>
14#include <test/ut.h>
15#include "bootstd_common.h"
16#include "../../boot/scene_internal.h"
17
18enum {
19 /* scenes */
20 SCENE1 = 7,
21 SCENE2,
22
23 /* objects */
24 OBJ_LOGO,
25 OBJ_TEXT,
26 OBJ_TEXT2,
27 OBJ_MENU,
28 OBJ_MENU_TITLE,
29
30 /* strings */
Simon Glassea274b62023-06-01 10:22:27 -060031 STR_SCENE_TITLE,
32
Simon Glass65924992023-01-06 08:52:39 -060033 STR_TEXT,
34 STR_TEXT2,
35 STR_MENU_TITLE,
36 STR_POINTER_TEXT,
37
38 STR_ITEM1_LABEL,
39 STR_ITEM1_DESC,
40 STR_ITEM1_KEY,
41 STR_ITEM1_PREVIEW,
42
43 STR_ITEM2_LABEL,
44 STR_ITEM2_DESC,
45 STR_ITEM2_KEY,
46 STR_ITEM2_PREVIEW,
47
48 /* menu items */
49 ITEM1,
50 ITEM1_LABEL,
51 ITEM1_DESC,
52 ITEM1_KEY,
53 ITEM1_PREVIEW,
54
55 ITEM2,
56 ITEM2_LABEL,
57 ITEM2_DESC,
58 ITEM2_KEY,
59 ITEM2_PREVIEW,
60
61 /* pointer to current item */
62 POINTER_TEXT,
63};
64
65#define BAD_POINTER ((void *)1)
66
67/* names for various things */
68#define EXPO_NAME "my menus"
69#define SCENE_NAME1 "main"
70#define SCENE_NAME2 "second"
71#define SCENE_TITLE "Main Menu"
72#define LOGO_NAME "logo"
73
74/* Check base expo support */
75static int expo_base(struct unit_test_state *uts)
76{
77 struct udevice *dev;
78 struct expo *exp;
79 ulong start_mem;
80 char name[100];
81 int i;
82
83 ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev));
84
85 start_mem = ut_check_free();
86
87 exp = NULL;
88 strcpy(name, EXPO_NAME);
89 ut_assertok(expo_new(name, NULL, &exp));
90 *name = '\0';
91 ut_assertnonnull(exp);
92 ut_asserteq(0, exp->scene_id);
93 ut_asserteq(0, exp->next_id);
94
95 /* Make sure the name was allocated */
96 ut_assertnonnull(exp->name);
97 ut_asserteq_str(EXPO_NAME, exp->name);
98
99 ut_assertok(expo_set_display(exp, dev));
100 expo_destroy(exp);
101 ut_assertok(ut_check_delta(start_mem));
102
103 /* test handling out-of-memory conditions */
104 for (i = 0; i < 2; i++) {
105 struct expo *exp2;
106
107 malloc_enable_testing(i);
108 exp2 = BAD_POINTER;
109 ut_asserteq(-ENOMEM, expo_new(EXPO_NAME, NULL, &exp2));
110 ut_asserteq_ptr(BAD_POINTER, exp2);
111 malloc_disable_testing();
112 }
113
114 return 0;
115}
116BOOTSTD_TEST(expo_base, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
117
118/* Check creating a scene */
119static int expo_scene(struct unit_test_state *uts)
120{
121 struct scene *scn;
122 struct expo *exp;
123 ulong start_mem;
124 char name[100];
Simon Glassea274b62023-06-01 10:22:27 -0600125 int id, title_id;
Simon Glass65924992023-01-06 08:52:39 -0600126
127 start_mem = ut_check_free();
128
129 ut_assertok(expo_new(EXPO_NAME, NULL, &exp));
130
131 scn = NULL;
132 ut_asserteq(0, exp->next_id);
133 strcpy(name, SCENE_NAME1);
134 id = scene_new(exp, name, SCENE1, &scn);
135 *name = '\0';
136 ut_assertnonnull(scn);
137 ut_asserteq(SCENE1, id);
138 ut_asserteq(SCENE1 + 1, exp->next_id);
139 ut_asserteq_ptr(exp, scn->expo);
140
141 /* Make sure the name was allocated */
142 ut_assertnonnull(scn->name);
143 ut_asserteq_str(SCENE_NAME1, scn->name);
144
145 /* Set the title */
Simon Glassea274b62023-06-01 10:22:27 -0600146 title_id = expo_str(exp, "title", STR_SCENE_TITLE, SCENE_TITLE);
147 ut_assert(title_id >= 0);
Simon Glass65924992023-01-06 08:52:39 -0600148
Simon Glassea274b62023-06-01 10:22:27 -0600149 /* Use an allocated ID - this will be allocated after the title str */
Simon Glass65924992023-01-06 08:52:39 -0600150 scn = NULL;
151 id = scene_new(exp, SCENE_NAME2, 0, &scn);
152 ut_assertnonnull(scn);
Simon Glassea274b62023-06-01 10:22:27 -0600153 ut_assertok(scene_title_set(scn, title_id));
154 ut_asserteq(STR_SCENE_TITLE + 1, id);
155 ut_asserteq(STR_SCENE_TITLE + 2, exp->next_id);
Simon Glass65924992023-01-06 08:52:39 -0600156 ut_asserteq_ptr(exp, scn->expo);
157
158 ut_asserteq_str(SCENE_NAME2, scn->name);
Simon Glassea274b62023-06-01 10:22:27 -0600159 ut_asserteq(title_id, scn->title_id);
Simon Glass65924992023-01-06 08:52:39 -0600160
161 expo_destroy(exp);
162
163 ut_assertok(ut_check_delta(start_mem));
164
165 return 0;
166}
167BOOTSTD_TEST(expo_scene, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
168
169/* Check creating a scene with objects */
170static int expo_object(struct unit_test_state *uts)
171{
172 struct scene_obj_img *img;
173 struct scene_obj_txt *txt;
174 struct scene *scn;
175 struct expo *exp;
176 ulong start_mem;
177 char name[100];
178 char *data;
179 int id;
180
181 start_mem = ut_check_free();
182
183 ut_assertok(expo_new(EXPO_NAME, NULL, &exp));
184 id = scene_new(exp, SCENE_NAME1, SCENE1, &scn);
185 ut_assert(id > 0);
186
187 ut_asserteq(0, scene_obj_count(scn));
188
189 data = NULL;
190 strcpy(name, LOGO_NAME);
191 id = scene_img(scn, name, OBJ_LOGO, data, &img);
192 ut_assert(id > 0);
193 *name = '\0';
194 ut_assertnonnull(img);
195 ut_asserteq(OBJ_LOGO, id);
196 ut_asserteq(OBJ_LOGO + 1, exp->next_id);
197 ut_asserteq_ptr(scn, img->obj.scene);
198 ut_asserteq(SCENEOBJT_IMAGE, img->obj.type);
199
200 ut_asserteq_ptr(data, img->data);
201
202 /* Make sure the name was allocated */
203 ut_assertnonnull(scn->name);
204 ut_asserteq_str(SCENE_NAME1, scn->name);
205
206 ut_asserteq(1, scene_obj_count(scn));
207
208 id = scene_txt_str(scn, "text", OBJ_TEXT, STR_TEXT, "my string", &txt);
209 ut_assert(id > 0);
210 ut_assertnonnull(txt);
211 ut_asserteq(OBJ_TEXT, id);
212 ut_asserteq(SCENEOBJT_TEXT, txt->obj.type);
213 ut_asserteq(2, scene_obj_count(scn));
214
215 /* Check passing NULL as the final parameter */
216 id = scene_txt_str(scn, "text2", OBJ_TEXT2, STR_TEXT2, "another string",
217 NULL);
218 ut_assert(id > 0);
219 ut_asserteq(3, scene_obj_count(scn));
220
221 expo_destroy(exp);
222
223 ut_assertok(ut_check_delta(start_mem));
224
225 return 0;
226}
227BOOTSTD_TEST(expo_object, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
228
Simon Glassc999e172023-06-01 10:22:53 -0600229/* Check setting object attributes and using themes */
Simon Glass65924992023-01-06 08:52:39 -0600230static int expo_object_attr(struct unit_test_state *uts)
231{
232 struct scene_obj_menu *menu;
233 struct scene_obj_img *img;
234 struct scene_obj_txt *txt;
235 struct scene *scn;
236 struct expo *exp;
237 ulong start_mem;
238 char name[100];
Simon Glassc999e172023-06-01 10:22:53 -0600239 ofnode node;
Simon Glass65924992023-01-06 08:52:39 -0600240 char *data;
241 int id;
242
243 start_mem = ut_check_free();
244
245 ut_assertok(expo_new(EXPO_NAME, NULL, &exp));
246 id = scene_new(exp, SCENE_NAME1, SCENE1, &scn);
247 ut_assert(id > 0);
248
249 data = NULL;
250 id = scene_img(scn, LOGO_NAME, OBJ_LOGO, data, &img);
251 ut_assert(id > 0);
252
253 ut_assertok(scene_obj_set_pos(scn, OBJ_LOGO, 123, 456));
Simon Glass7b043952023-06-01 10:22:49 -0600254 ut_asserteq(123, img->obj.dim.x);
255 ut_asserteq(456, img->obj.dim.y);
Simon Glass65924992023-01-06 08:52:39 -0600256
257 ut_asserteq(-ENOENT, scene_obj_set_pos(scn, OBJ_TEXT2, 0, 0));
258
259 id = scene_txt_str(scn, "text", OBJ_TEXT, STR_TEXT, "my string", &txt);
260 ut_assert(id > 0);
261
262 strcpy(name, "font2");
263 ut_assertok(scene_txt_set_font(scn, OBJ_TEXT, name, 42));
264 ut_asserteq_ptr(name, txt->font_name);
265 ut_asserteq(42, txt->font_size);
266
267 ut_asserteq(-ENOENT, scene_txt_set_font(scn, OBJ_TEXT2, name, 42));
268
269 id = scene_menu(scn, "main", OBJ_MENU, &menu);
270 ut_assert(id > 0);
271
272 ut_assertok(scene_menu_set_title(scn, OBJ_MENU, OBJ_TEXT));
273
274 ut_asserteq(-ENOENT, scene_menu_set_title(scn, OBJ_TEXT2, OBJ_TEXT));
275 ut_asserteq(-EINVAL, scene_menu_set_title(scn, OBJ_MENU, OBJ_TEXT2));
276
Simon Glassc999e172023-06-01 10:22:53 -0600277 node = ofnode_path("/bootstd/theme");
278 ut_assert(ofnode_valid(node));
279 ut_assertok(expo_apply_theme(exp, node));
280 ut_asserteq(30, txt->font_size);
281
Simon Glass65924992023-01-06 08:52:39 -0600282 expo_destroy(exp);
283
284 ut_assertok(ut_check_delta(start_mem));
285
286 return 0;
287}
288BOOTSTD_TEST(expo_object_attr, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
289
290/* Check creating a scene with a menu */
291static int expo_object_menu(struct unit_test_state *uts)
292{
293 struct scene_obj_menu *menu;
294 struct scene_menitem *item;
295 int id, label_id, desc_id, key_id, pointer_id, preview_id;
296 struct scene_obj_txt *ptr, *name1, *desc1, *key1, *tit, *prev1;
297 struct scene *scn;
298 struct expo *exp;
299 ulong start_mem;
300
301 start_mem = ut_check_free();
302
303 ut_assertok(expo_new(EXPO_NAME, NULL, &exp));
304 id = scene_new(exp, SCENE_NAME1, SCENE1, &scn);
305 ut_assert(id > 0);
306
307 id = scene_menu(scn, "main", OBJ_MENU, &menu);
308 ut_assert(id > 0);
309 ut_assertnonnull(menu);
310 ut_asserteq(OBJ_MENU, id);
311 ut_asserteq(SCENEOBJT_MENU, menu->obj.type);
312 ut_asserteq(0, menu->title_id);
313 ut_asserteq(0, menu->pointer_id);
314
315 ut_assertok(scene_obj_set_pos(scn, OBJ_MENU, 50, 400));
Simon Glass7b043952023-06-01 10:22:49 -0600316 ut_asserteq(50, menu->obj.dim.x);
317 ut_asserteq(400, menu->obj.dim.y);
Simon Glass65924992023-01-06 08:52:39 -0600318
319 id = scene_txt_str(scn, "title", OBJ_MENU_TITLE, STR_MENU_TITLE,
320 "Main Menu", &tit);
321 ut_assert(id > 0);
322 ut_assertok(scene_menu_set_title(scn, OBJ_MENU, OBJ_MENU_TITLE));
323 ut_asserteq(OBJ_MENU_TITLE, menu->title_id);
324
325 pointer_id = scene_txt_str(scn, "cur_item", POINTER_TEXT,
326 STR_POINTER_TEXT, ">", &ptr);
327 ut_assert(pointer_id > 0);
328
329 ut_assertok(scene_menu_set_pointer(scn, OBJ_MENU, POINTER_TEXT));
330 ut_asserteq(POINTER_TEXT, menu->pointer_id);
331
332 label_id = scene_txt_str(scn, "label1", ITEM1_LABEL, STR_ITEM1_LABEL,
333 "Play", &name1);
334 ut_assert(label_id > 0);
335
336 desc_id = scene_txt_str(scn, "desc1", ITEM1_DESC, STR_ITEM1_DESC,
337 "Lord Melchett", &desc1);
338 ut_assert(desc_id > 0);
339
340 key_id = scene_txt_str(scn, "item1-key", ITEM1_KEY, STR_ITEM1_KEY, "1",
341 &key1);
342 ut_assert(key_id > 0);
343
344 preview_id = scene_txt_str(scn, "item1-preview", ITEM1_PREVIEW,
345 STR_ITEM1_PREVIEW, "(preview1)", &prev1);
346 ut_assert(preview_id > 0);
347
348 id = scene_menuitem(scn, OBJ_MENU, "linux", ITEM1, ITEM1_KEY,
349 ITEM1_LABEL, ITEM1_DESC, ITEM1_PREVIEW, 0, &item);
350 ut_asserteq(ITEM1, id);
351 ut_asserteq(id, item->id);
352 ut_asserteq(key_id, item->key_id);
353 ut_asserteq(label_id, item->label_id);
354 ut_asserteq(desc_id, item->desc_id);
355 ut_asserteq(preview_id, item->preview_id);
356
Simon Glassd7e32a82023-06-01 10:22:35 -0600357 ut_assertok(scene_arrange(scn));
358
359 /* arranging the scene should cause the first item to become current */
Simon Glass65924992023-01-06 08:52:39 -0600360 ut_asserteq(id, menu->cur_item_id);
361
362 /* the title should be at the top */
Simon Glass7b043952023-06-01 10:22:49 -0600363 ut_asserteq(menu->obj.dim.x, tit->obj.dim.x);
364 ut_asserteq(menu->obj.dim.y, tit->obj.dim.y);
Simon Glass65924992023-01-06 08:52:39 -0600365
366 /* the first item should be next */
Simon Glass7b043952023-06-01 10:22:49 -0600367 ut_asserteq(menu->obj.dim.x, name1->obj.dim.x);
368 ut_asserteq(menu->obj.dim.y + 32, name1->obj.dim.y);
Simon Glass65924992023-01-06 08:52:39 -0600369
Simon Glass7b043952023-06-01 10:22:49 -0600370 ut_asserteq(menu->obj.dim.x + 230, key1->obj.dim.x);
371 ut_asserteq(menu->obj.dim.y + 32, key1->obj.dim.y);
Simon Glass65924992023-01-06 08:52:39 -0600372
Simon Glass7b043952023-06-01 10:22:49 -0600373 ut_asserteq(menu->obj.dim.x + 200, ptr->obj.dim.x);
374 ut_asserteq(menu->obj.dim.y + 32, ptr->obj.dim.y);
Simon Glass65924992023-01-06 08:52:39 -0600375
Simon Glass7b043952023-06-01 10:22:49 -0600376 ut_asserteq(menu->obj.dim.x + 280, desc1->obj.dim.x);
377 ut_asserteq(menu->obj.dim.y + 32, desc1->obj.dim.y);
Simon Glass65924992023-01-06 08:52:39 -0600378
Simon Glass7b043952023-06-01 10:22:49 -0600379 ut_asserteq(-4, prev1->obj.dim.x);
380 ut_asserteq(menu->obj.dim.y + 32, prev1->obj.dim.y);
Simon Glass6081b0f2023-06-01 10:22:50 -0600381 ut_asserteq(false, prev1->obj.flags & SCENEOF_HIDE);
Simon Glass65924992023-01-06 08:52:39 -0600382
383 expo_destroy(exp);
384
385 ut_assertok(ut_check_delta(start_mem));
386
387 return 0;
388}
389BOOTSTD_TEST(expo_object_menu, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
390
391/* Check rendering a scene */
392static int expo_render_image(struct unit_test_state *uts)
393{
394 struct scene_obj_menu *menu;
395 struct scene *scn, *scn2;
396 struct expo_action act;
397 struct scene_obj *obj;
398 struct udevice *dev;
399 struct expo *exp;
400 int id;
401
402 console_record_reset_enable();
403 ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev));
404
405 ut_assertok(expo_new(EXPO_NAME, NULL, &exp));
406 id = scene_new(exp, SCENE_NAME1, SCENE1, &scn);
407 ut_assert(id > 0);
408 ut_assertok(expo_set_display(exp, dev));
409
410 id = scene_img(scn, "logo", OBJ_LOGO, video_get_u_boot_logo(), NULL);
411 ut_assert(id > 0);
412 ut_assertok(scene_obj_set_pos(scn, OBJ_LOGO, 50, 20));
413
414 id = scene_txt_str(scn, "text", OBJ_TEXT, STR_TEXT, "my string", NULL);
415 ut_assert(id > 0);
416 ut_assertok(scene_txt_set_font(scn, OBJ_TEXT, "cantoraone_regular",
417 40));
418 ut_assertok(scene_obj_set_pos(scn, OBJ_TEXT, 400, 100));
419
420 id = scene_txt_str(scn, "text", OBJ_TEXT2, STR_TEXT2, "another string",
421 NULL);
422 ut_assert(id > 0);
423 ut_assertok(scene_txt_set_font(scn, OBJ_TEXT2, "nimbus_sans_l_regular",
424 60));
425 ut_assertok(scene_obj_set_pos(scn, OBJ_TEXT2, 200, 600));
426
427 id = scene_menu(scn, "main", OBJ_MENU, &menu);
428 ut_assert(id > 0);
429
430 id = scene_txt_str(scn, "title", OBJ_MENU_TITLE, STR_MENU_TITLE,
431 "Main Menu", NULL);
432 ut_assert(id > 0);
433 ut_assertok(scene_menu_set_title(scn, OBJ_MENU, OBJ_MENU_TITLE));
434
435 id = scene_txt_str(scn, "cur_item", POINTER_TEXT, STR_POINTER_TEXT, ">",
436 NULL);
437 ut_assert(id > 0);
438 ut_assertok(scene_menu_set_pointer(scn, OBJ_MENU, POINTER_TEXT));
439
440 id = scene_txt_str(scn, "label1", ITEM1_LABEL, STR_ITEM1_LABEL, "Play",
441 NULL);
442 ut_assert(id > 0);
443 id = scene_txt_str(scn, "item1 txt", ITEM1_DESC, STR_ITEM1_DESC,
444 "Lord Melchett", NULL);
445 ut_assert(id > 0);
446 id = scene_txt_str(scn, "item1-key", ITEM1_KEY, STR_ITEM1_KEY, "1",
447 NULL);
448 ut_assert(id > 0);
449 id = scene_img(scn, "item1-preview", ITEM1_PREVIEW,
450 video_get_u_boot_logo(), NULL);
451 id = scene_menuitem(scn, OBJ_MENU, "item1", ITEM1, ITEM1_KEY,
452 ITEM1_LABEL, ITEM1_DESC, ITEM1_PREVIEW, 0, NULL);
453 ut_assert(id > 0);
454
455 id = scene_txt_str(scn, "label2", ITEM2_LABEL, STR_ITEM2_LABEL, "Now",
456 NULL);
457 ut_assert(id > 0);
458 id = scene_txt_str(scn, "item2 txt", ITEM2_DESC, STR_ITEM2_DESC,
459 "Lord Percy", NULL);
460 ut_assert(id > 0);
461 id = scene_txt_str(scn, "item2-key", ITEM2_KEY, STR_ITEM2_KEY, "2",
462 NULL);
463 ut_assert(id > 0);
464 id = scene_img(scn, "item2-preview", ITEM2_PREVIEW,
465 video_get_u_boot_logo(), NULL);
466 ut_assert(id > 0);
467
468 id = scene_menuitem(scn, OBJ_MENU, "item2", ITEM2, ITEM2_KEY,
469 ITEM2_LABEL, ITEM2_DESC, ITEM2_PREVIEW, 0, NULL);
470 ut_assert(id > 0);
471
472 ut_assertok(scene_obj_set_pos(scn, OBJ_MENU, 50, 400));
473
474 scn2 = expo_lookup_scene_id(exp, SCENE1);
475 ut_asserteq_ptr(scn, scn2);
476 scn2 = expo_lookup_scene_id(exp, SCENE2);
477 ut_assertnull(scn2);
478
479 /* render without a scene */
480 ut_asserteq(-ECHILD, expo_render(exp));
481
Simon Glass7a960052023-06-01 10:22:52 -0600482 ut_assertok(expo_calc_dims(exp));
483 ut_assertok(scene_arrange(scn));
484
485 /* check dimensions of text */
486 obj = scene_obj_find(scn, OBJ_TEXT, SCENEOBJT_NONE);
487 ut_assertnonnull(obj);
488 ut_asserteq(400, obj->dim.x);
489 ut_asserteq(100, obj->dim.y);
490 ut_asserteq(126, obj->dim.w);
491 ut_asserteq(40, obj->dim.h);
492
493 /* check dimensions of image */
494 obj = scene_obj_find(scn, OBJ_LOGO, SCENEOBJT_NONE);
495 ut_assertnonnull(obj);
496 ut_asserteq(50, obj->dim.x);
497 ut_asserteq(20, obj->dim.y);
498 ut_asserteq(160, obj->dim.w);
499 ut_asserteq(160, obj->dim.h);
500
501 /* check dimensions of menu labels - both should be the same width */
502 obj = scene_obj_find(scn, ITEM1_LABEL, SCENEOBJT_NONE);
503 ut_assertnonnull(obj);
504 ut_asserteq(50, obj->dim.x);
505 ut_asserteq(436, obj->dim.y);
506 ut_asserteq(29, obj->dim.w);
507 ut_asserteq(18, obj->dim.h);
508
509 obj = scene_obj_find(scn, ITEM2_LABEL, SCENEOBJT_NONE);
510 ut_assertnonnull(obj);
511 ut_asserteq(50, obj->dim.x);
512 ut_asserteq(454, obj->dim.y);
513 ut_asserteq(29, obj->dim.w);
514 ut_asserteq(18, obj->dim.h);
515
516 /* check dimensions of menu */
517 obj = scene_obj_find(scn, OBJ_MENU, SCENEOBJT_NONE);
518 ut_assertnonnull(obj);
519 ut_asserteq(50, obj->dim.x);
520 ut_asserteq(400, obj->dim.y);
521 ut_asserteq(160, obj->dim.w);
522 ut_asserteq(160, obj->dim.h);
523
Simon Glass65924992023-01-06 08:52:39 -0600524 /* render it */
525 expo_set_scene_id(exp, SCENE1);
526 ut_assertok(expo_render(exp));
527
528 /* move down */
529 ut_assertok(expo_send_key(exp, BKEY_DOWN));
530
531 ut_assertok(expo_action_get(exp, &act));
532
533 ut_asserteq(EXPOACT_POINT, act.type);
534 ut_asserteq(ITEM2, act.select.id);
535 ut_assertok(expo_render(exp));
536
537 /* make sure only the preview for the second item is shown */
538 obj = scene_obj_find(scn, ITEM1_PREVIEW, SCENEOBJT_NONE);
Simon Glass6081b0f2023-06-01 10:22:50 -0600539 ut_asserteq(true, obj->flags & SCENEOF_HIDE);
Simon Glass65924992023-01-06 08:52:39 -0600540
541 obj = scene_obj_find(scn, ITEM2_PREVIEW, SCENEOBJT_NONE);
Simon Glass6081b0f2023-06-01 10:22:50 -0600542 ut_asserteq(false, obj->flags & SCENEOF_HIDE);
Simon Glass65924992023-01-06 08:52:39 -0600543
544 /* select it */
545 ut_assertok(expo_send_key(exp, BKEY_SELECT));
546
547 ut_assertok(expo_action_get(exp, &act));
548 ut_asserteq(EXPOACT_SELECT, act.type);
549 ut_asserteq(ITEM2, act.select.id);
550
551 /* make sure the action doesn't come again */
552 ut_asserteq(-EAGAIN, expo_action_get(exp, &act));
553
554 /* make sure there was no console output */
555 ut_assert_console_end();
556
557 /* now try in text mode */
Simon Glassb2c40342023-06-01 10:22:37 -0600558 expo_set_text_mode(exp, true);
Simon Glass65924992023-01-06 08:52:39 -0600559 ut_assertok(expo_render(exp));
560
561 ut_assert_nextline("U-Boot : Boot Menu");
562 ut_assert_nextline("%s", "");
563 ut_assert_nextline("Main Menu");
564 ut_assert_nextline("%s", "");
565 ut_assert_nextline(" 1 Play Lord Melchett");
566 ut_assert_nextline(" > 2 Now Lord Percy");
567
568 /* Move back up to the first item */
569 ut_assertok(expo_send_key(exp, BKEY_UP));
570
571 ut_assertok(expo_action_get(exp, &act));
572
573 ut_asserteq(EXPOACT_POINT, act.type);
574 ut_asserteq(ITEM1, act.select.id);
575
576 ut_assertok(expo_render(exp));
577 ut_assert_nextline("U-Boot : Boot Menu");
578 ut_assert_nextline("%s", "");
579 ut_assert_nextline("Main Menu");
580 ut_assert_nextline("%s", "");
581 ut_assert_nextline(" > 1 Play Lord Melchett");
582 ut_assert_nextline(" 2 Now Lord Percy");
583
584 ut_assert_console_end();
585
586 expo_destroy(exp);
587
588 return 0;
589}
590BOOTSTD_TEST(expo_render_image, UT_TESTF_DM | UT_TESTF_SCAN_FDT);