blob: f3411f734fa26df0c94038d53e89ed1ccfb55efe [file] [log] [blame]
Simon Glass44e4ec72023-08-14 16:40:26 -06001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2023 Google LLC
4 * Written by Simon Glass <sjg@chromium.org>
5 */
6
7#include <common.h>
8#include <cedit.h>
9#include <expo.h>
10#include <test/ut.h>
11#include "bootstd_common.h"
12#include <test/cedit-test.h>
13#include "../../boot/scene_internal.h"
14
15/* Check the cedit command */
16static int cedit_base(struct unit_test_state *uts)
17{
18 extern struct expo *cur_exp;
19 struct scene_obj_menu *menu;
20 struct scene_obj_txt *txt;
21 struct expo *exp;
22 struct scene *scn;
23
24 ut_assertok(run_command("cedit load hostfs - cedit.dtb", 0));
25
26 console_record_reset_enable();
27
28 /*
29 * ^N Move down to second menu
30 * ^M Open menu
31 * ^N Move down to second item
32 * ^M Select item
33 * \e Quit
34 */
35 console_in_puts("\x0e\x0d\x0e\x0d\e");
36 ut_assertok(run_command("cedit run", 0));
37
38 exp = cur_exp;
39 scn = expo_lookup_scene_id(exp, exp->scene_id);
40 ut_assertnonnull(scn);
41
42 menu = scene_obj_find(scn, scn->highlight_id, SCENEOBJT_NONE);
43 ut_assertnonnull(menu);
44
45 txt = scene_obj_find(scn, menu->title_id, SCENEOBJT_NONE);
46 ut_assertnonnull(txt);
47 ut_asserteq_str("AC Power", expo_get_str(exp, txt->str_id));
48
49 ut_asserteq(ID_AC_ON, menu->cur_item_id);
50
51 return 0;
52}
53BOOTSTD_TEST(cedit_base, 0);