Index: uspace/lib/ui/test/menu.c
===================================================================
--- uspace/lib/ui/test/menu.c	(revision 46bd63c90e62ae2887633555d123a6aa959d3b05)
+++ uspace/lib/ui/test/menu.c	(revision c68c18b9bb5f07126605a1631863634fac2f1ffb)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2023 Jiri Svoboda
+ * Copyright (c) 2021 Jiri Svoboda
  * All rights reserved.
  *
@@ -36,5 +36,4 @@
 #include <ui/menu.h>
 #include <ui/menubar.h>
-#include <ui/menuentry.h>
 #include <ui/ui.h>
 #include <ui/window.h>
@@ -46,40 +45,25 @@
 PCUT_TEST_SUITE(menu);
 
-typedef struct {
-	bool left_called;
-	bool right_called;
-	bool close_req_called;
-	bool press_accel_called;
-	ui_menu_t *menu;
-	sysarg_t idev_id;
-	char32_t c;
-} test_resp_t;
-
-static void testmenu_left(ui_menu_t *, void *, sysarg_t);
-static void testmenu_right(ui_menu_t *, void *, sysarg_t);
-static void testmenu_close_req(ui_menu_t *, void *);
-static void testmenu_press_accel(ui_menu_t *, void *, char32_t, sysarg_t);
-
-ui_menu_cb_t testmenu_cb = {
-	.left = testmenu_left,
-	.right = testmenu_right,
-	.close_req = testmenu_close_req,
-	.press_accel = testmenu_press_accel
-};
-
-ui_menu_cb_t dummy_cb = {
-};
-
 /** Create and destroy menu */
 PCUT_TEST(create_destroy)
 {
-	ui_menu_t *menu = NULL;
-	errno_t rc;
-
-	rc = ui_menu_create(NULL, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
+	ui_menu_bar_t *mbar = NULL;
+	ui_menu_t *menu = NULL;
+	errno_t rc;
+
+	rc = ui_menu_bar_create(NULL, NULL, &mbar);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_menu_create(mbar, "Test", &menu);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(menu);
+
+	/*
+	 * Normally we don't need to destroy a menu explicitly, it will
+	 * be destroyed along with menu bar, but here we'll test destroying
+	 * it explicitly.
+	 */
 	ui_menu_destroy(menu);
+	ui_menu_bar_destroy(mbar);
 }
 
@@ -90,21 +74,230 @@
 }
 
-/** ui_menu_set_cb() sets the internal fields */
-PCUT_TEST(set_cb)
-{
-	ui_menu_t *menu = NULL;
-	ui_menu_cb_t cb;
-	int obj;
-	errno_t rc;
-
-	rc = ui_menu_create(NULL, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	ui_menu_set_cb(menu, &cb, (void *)&obj);
-	PCUT_ASSERT_EQUALS(&cb, menu->cb);
-	PCUT_ASSERT_EQUALS((void *)&obj, menu->arg);
-
-	ui_menu_destroy(menu);
+/** ui_menu_first() / ui_menu_next() iterate over menus */
+PCUT_TEST(first_next)
+{
+	ui_t *ui = NULL;
+	ui_window_t *window = NULL;
+	ui_wnd_params_t params;
+	ui_menu_bar_t *mbar = NULL;
+	ui_menu_t *menu1 = NULL;
+	ui_menu_t *menu2 = NULL;
+	ui_menu_t *m;
+	errno_t rc;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	rc = ui_menu_bar_create(ui, window, &mbar);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(mbar);
+
+	rc = ui_menu_create(mbar, "Test 1", &menu1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(menu1);
+
+	rc = ui_menu_create(mbar, "Test 1", &menu2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(menu2);
+
+	m = ui_menu_first(mbar);
+	PCUT_ASSERT_EQUALS(menu1, m);
+
+	m = ui_menu_next(m);
+	PCUT_ASSERT_EQUALS(menu2, m);
+
+	m = ui_menu_next(m);
+	PCUT_ASSERT_NULL(m);
+
+	ui_menu_bar_destroy(mbar);
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+/** ui_menu_caption() returns the menu's caption */
+PCUT_TEST(caption)
+{
+	ui_t *ui = NULL;
+	ui_window_t *window = NULL;
+	ui_wnd_params_t params;
+	ui_menu_bar_t *mbar = NULL;
+	ui_menu_t *menu = NULL;
+	const char *caption;
+	errno_t rc;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	rc = ui_menu_bar_create(ui, window, &mbar);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(mbar);
+
+	rc = ui_menu_create(mbar, "Test", &menu);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(menu);
+
+	caption = ui_menu_caption(menu);
+	PCUT_ASSERT_NOT_NULL(caption);
+
+	PCUT_ASSERT_INT_EQUALS(0, str_cmp(caption, "Test"));
+
+	ui_menu_bar_destroy(mbar);
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+/** ui_menu_get_rect() returns outer menu rectangle */
+PCUT_TEST(get_rect)
+{
+	ui_t *ui = NULL;
+	ui_window_t *window = NULL;
+	ui_wnd_params_t params;
+	ui_menu_bar_t *mbar = NULL;
+	ui_menu_t *menu = NULL;
+	gfx_coord2_t pos;
+	gfx_rect_t rect;
+	const char *caption;
+	errno_t rc;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	rc = ui_menu_bar_create(ui, window, &mbar);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(mbar);
+
+	rc = ui_menu_create(mbar, "Test", &menu);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(menu);
+
+	caption = ui_menu_caption(menu);
+	PCUT_ASSERT_NOT_NULL(caption);
+
+	pos.x = 0;
+	pos.y = 0;
+	ui_menu_get_rect(menu, &pos, &rect);
+
+	PCUT_ASSERT_INT_EQUALS(0, rect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(0, rect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(16, rect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(8, rect.p1.y);
+
+	ui_menu_bar_destroy(mbar);
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+/** Paint menu */
+PCUT_TEST(paint)
+{
+	ui_t *ui = NULL;
+	ui_window_t *window = NULL;
+	ui_wnd_params_t params;
+	ui_menu_bar_t *mbar = NULL;
+	ui_menu_t *menu = NULL;
+	gfx_rect_t prect;
+	gfx_coord2_t pos;
+	errno_t rc;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	rc = ui_menu_bar_create(ui, window, &mbar);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(mbar);
+
+	rc = ui_menu_create(mbar, "Test", &menu);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(menu);
+
+	prect.p0.x = 0;
+	prect.p0.y = 0;
+	prect.p1.x = 0;
+	prect.p1.y = 0;
+
+	/* Menu needs to be open to be able to paint it */
+	rc = ui_menu_open(menu, &prect);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	pos.x = 0;
+	pos.y = 0;
+	rc = ui_menu_paint(menu, &pos);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_menu_bar_destroy(mbar);
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+/** ui_menu_pos_event() inside menu is claimed */
+PCUT_TEST(pos_event_inside)
+{
+	ui_t *ui = NULL;
+	ui_window_t *window = NULL;
+	ui_wnd_params_t params;
+	ui_menu_bar_t *mbar = NULL;
+	ui_menu_t *menu = NULL;
+	ui_evclaim_t claimed;
+	gfx_coord2_t pos;
+	pos_event_t event;
+	errno_t rc;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	rc = ui_menu_bar_create(ui, window, &mbar);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(mbar);
+
+	rc = ui_menu_create(mbar, "Test", &menu);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(menu);
+
+	pos.x = 0;
+	pos.y = 0;
+	event.type = POS_PRESS;
+	event.hpos = 0;
+	event.vpos = 0;
+	claimed = ui_menu_pos_event(menu, &pos, &event);
+	PCUT_ASSERT_EQUALS(ui_claimed, claimed);
+
+	ui_menu_bar_destroy(mbar);
+	ui_window_destroy(window);
+	ui_destroy(ui);
 }
 
@@ -115,4 +308,5 @@
 	ui_window_t *window = NULL;
 	ui_wnd_params_t params;
+	ui_menu_bar_t *mbar = NULL;
 	ui_menu_t *menu = NULL;
 	ui_menu_geom_t geom;
@@ -130,5 +324,9 @@
 	PCUT_ASSERT_NOT_NULL(window);
 
-	rc = ui_menu_create(window, &menu);
+	rc = ui_menu_bar_create(ui, window, &mbar);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(mbar);
+
+	rc = ui_menu_create(mbar, "Test", &menu);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 	PCUT_ASSERT_NOT_NULL(menu);
@@ -147,695 +345,7 @@
 	PCUT_ASSERT_INT_EQUALS(4, geom.entries_rect.p1.y);
 
-	ui_menu_destroy(menu);
-	ui_window_destroy(window);
-	ui_destroy(ui);
-}
-
-/** ui_menu_get_res() gets the menu's resource */
-PCUT_TEST(get_res)
-{
-	ui_t *ui = NULL;
-	ui_window_t *window = NULL;
-	ui_wnd_params_t params;
-	ui_menu_t *menu = NULL;
-	ui_resource_t *res;
-	gfx_rect_t prect;
-	errno_t rc;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_wnd_params_init(&params);
-	params.caption = "Hello";
-
-	rc = ui_window_create(ui, &params, &window);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(window);
-
-	rc = ui_menu_create(window, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	prect.p0.x = 0;
-	prect.p0.y = 0;
-	prect.p1.x = 0;
-	prect.p1.y = 0;
-
-	/* The menu must be open first */
-	rc = ui_menu_open(menu, &prect, 0);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	res = ui_menu_get_res(menu);
-	PCUT_ASSERT_NOT_NULL(res);
-
-	ui_menu_destroy(menu);
-
-	ui_window_destroy(window);
-	ui_destroy(ui);
-}
-
-/** Open and close menu with ui_menu_open() / ui_menu_close() */
-PCUT_TEST(open_close)
-{
-	ui_t *ui = NULL;
-	ui_window_t *window = NULL;
-	ui_wnd_params_t params;
-	ui_menu_t *menu = NULL;
-	gfx_rect_t prect;
-	errno_t rc;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_wnd_params_init(&params);
-	params.caption = "Hello";
-
-	rc = ui_window_create(ui, &params, &window);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(window);
-
-	rc = ui_menu_create(window, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	prect.p0.x = 0;
-	prect.p0.y = 0;
-	prect.p1.x = 0;
-	prect.p1.y = 0;
-
-	/* Open and close */
-	rc = ui_menu_open(menu, &prect, 0);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_menu_close(menu);
-
-	ui_menu_destroy(menu);
-	ui_window_destroy(window);
-	ui_destroy(ui);
-}
-
-/** ui_menu_is_open() correctly returns menu state */
-PCUT_TEST(is_open)
-{
-	ui_t *ui = NULL;
-	ui_window_t *window = NULL;
-	ui_wnd_params_t params;
-	ui_menu_t *menu = NULL;
-	gfx_rect_t prect;
-	bool open;
-	errno_t rc;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_wnd_params_init(&params);
-	params.caption = "Hello";
-
-	rc = ui_window_create(ui, &params, &window);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(window);
-
-	rc = ui_menu_create(window, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	prect.p0.x = 0;
-	prect.p0.y = 0;
-	prect.p1.x = 0;
-	prect.p1.y = 0;
-
-	open = ui_menu_is_open(menu);
-	PCUT_ASSERT_FALSE(open);
-
-	rc = ui_menu_open(menu, &prect, 0);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	open = ui_menu_is_open(menu);
-	PCUT_ASSERT_TRUE(open);
-
-	ui_menu_close(menu);
-
-	open = ui_menu_is_open(menu);
-	PCUT_ASSERT_FALSE(open);
-
-	ui_menu_destroy(menu);
-	ui_window_destroy(window);
-	ui_destroy(ui);
-}
-
-/** Paint background in graphics mode */
-PCUT_TEST(paint_bg_gfx)
-{
-	ui_t *ui = NULL;
-	ui_window_t *window = NULL;
-	ui_wnd_params_t params;
-	ui_menu_t *menu = NULL;
-	gfx_rect_t prect;
-	gfx_coord2_t pos;
-	errno_t rc;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_wnd_params_init(&params);
-	params.caption = "Hello";
-
-	rc = ui_window_create(ui, &params, &window);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(window);
-
-	rc = ui_menu_create(window, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	prect.p0.x = 0;
-	prect.p0.y = 0;
-	prect.p1.x = 0;
-	prect.p1.y = 0;
-
-	/* Menu needs to be open to be able to paint it */
-	rc = ui_menu_open(menu, &prect, 0);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	pos.x = 0;
-	pos.y = 0;
-	rc = ui_menu_paint_bg_gfx(menu, &pos);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_window_destroy(window);
-	ui_destroy(ui);
-}
-
-/** Paint background in text mode */
-PCUT_TEST(paint_bg_text)
-{
-	ui_t *ui = NULL;
-	ui_window_t *window = NULL;
-	ui_wnd_params_t params;
-	ui_menu_t *menu = NULL;
-	gfx_rect_t prect;
-	gfx_coord2_t pos;
-	errno_t rc;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_wnd_params_init(&params);
-	params.caption = "Hello";
-
-	rc = ui_window_create(ui, &params, &window);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(window);
-
-	rc = ui_menu_create(window, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	prect.p0.x = 0;
-	prect.p0.y = 0;
-	prect.p1.x = 0;
-	prect.p1.y = 0;
-
-	/* Menu needs to be open to be able to paint it */
-	rc = ui_menu_open(menu, &prect, 0);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	pos.x = 0;
-	pos.y = 0;
-	rc = ui_menu_paint_bg_text(menu, &pos);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_window_destroy(window);
-	ui_destroy(ui);
-}
-
-/** Paint menu */
-PCUT_TEST(paint)
-{
-	ui_t *ui = NULL;
-	ui_window_t *window = NULL;
-	ui_wnd_params_t params;
-	ui_menu_t *menu = NULL;
-	gfx_rect_t prect;
-	gfx_coord2_t pos;
-	errno_t rc;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_wnd_params_init(&params);
-	params.caption = "Hello";
-
-	rc = ui_window_create(ui, &params, &window);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(window);
-
-	rc = ui_menu_create(window, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	prect.p0.x = 0;
-	prect.p0.y = 0;
-	prect.p1.x = 0;
-	prect.p1.y = 0;
-
-	/* Menu needs to be open to be able to paint it */
-	rc = ui_menu_open(menu, &prect, 0);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	pos.x = 0;
-	pos.y = 0;
-	rc = ui_menu_paint(menu, &pos);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_window_destroy(window);
-	ui_destroy(ui);
-}
-
-/** ui_menu_pos_event() inside menu is claimed */
-PCUT_TEST(pos_event_inside)
-{
-	ui_t *ui = NULL;
-	ui_window_t *window = NULL;
-	ui_wnd_params_t params;
-	ui_menu_t *menu = NULL;
-	ui_evclaim_t claimed;
-	gfx_coord2_t pos;
-	pos_event_t event;
-	errno_t rc;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_wnd_params_init(&params);
-	params.caption = "Hello";
-
-	rc = ui_window_create(ui, &params, &window);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(window);
-
-	rc = ui_menu_create(window, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	pos.x = 0;
-	pos.y = 0;
-	event.type = POS_PRESS;
-	event.hpos = 0;
-	event.vpos = 0;
-	claimed = ui_menu_pos_event(menu, &pos, &event);
-	PCUT_ASSERT_EQUALS(ui_claimed, claimed);
-
-	ui_window_destroy(window);
-	ui_destroy(ui);
-}
-
-/** ui_menu_up() with empty menu does nothing */
-PCUT_TEST(up_empty)
-{
-	ui_t *ui = NULL;
-	ui_window_t *window = NULL;
-	ui_wnd_params_t params;
-	ui_menu_t *menu = NULL;
-	gfx_rect_t prect;
-	errno_t rc;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_wnd_params_init(&params);
-	params.caption = "Hello";
-
-	rc = ui_window_create(ui, &params, &window);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(window);
-
-	rc = ui_menu_create(window, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	prect.p0.x = 0;
-	prect.p0.y = 0;
-	prect.p1.x = 0;
-	prect.p1.y = 0;
-
-	/* Menu needs to be open to be able to move around it */
-	rc = ui_menu_open(menu, &prect, 0);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_menu_up(menu);
-
-	ui_window_destroy(window);
-	ui_destroy(ui);
-}
-
-/** ui_menu_up() moves one entry up, skips separators, wraps around */
-PCUT_TEST(up)
-{
-	ui_t *ui = NULL;
-	ui_window_t *window = NULL;
-	ui_wnd_params_t params;
-	ui_menu_t *menu = NULL;
-	ui_menu_entry_t *mentry1 = NULL;
-	ui_menu_entry_t *mentry2 = NULL;
-	ui_menu_entry_t *mentry3 = NULL;
-	gfx_rect_t prect;
-	errno_t rc;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_wnd_params_init(&params);
-	params.caption = "Hello";
-
-	rc = ui_window_create(ui, &params, &window);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(window);
-
-	rc = ui_menu_create(window, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	rc = ui_menu_entry_create(menu, "Foo", "F1", &mentry1);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(mentry1);
-
-	rc = ui_menu_entry_sep_create(menu, &mentry2);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(mentry2);
-
-	rc = ui_menu_entry_create(menu, "Bar", "F2", &mentry3);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(mentry3);
-
-	prect.p0.x = 0;
-	prect.p0.y = 0;
-	prect.p1.x = 0;
-	prect.p1.y = 0;
-
-	/* Menu needs to be open to be able to move around it */
-	rc = ui_menu_open(menu, &prect, 0);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	/* When menu is open, the first entry is selected */
-	PCUT_ASSERT_EQUALS(mentry1, menu->selected);
-
-	ui_menu_up(menu);
-
-	/* Now we've wrapped around to the last entry */
-	PCUT_ASSERT_EQUALS(mentry3, menu->selected);
-
-	ui_menu_up(menu);
-
-	/* mentry2 is a separator and was skipped */
-	PCUT_ASSERT_EQUALS(mentry1, menu->selected);
-
-	ui_window_destroy(window);
-	ui_destroy(ui);
-}
-
-/** ui_menu_down() with empty menu does nothing */
-PCUT_TEST(down_empty)
-{
-	ui_t *ui = NULL;
-	ui_window_t *window = NULL;
-	ui_wnd_params_t params;
-	ui_menu_t *menu = NULL;
-	gfx_rect_t prect;
-	errno_t rc;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_wnd_params_init(&params);
-	params.caption = "Hello";
-
-	rc = ui_window_create(ui, &params, &window);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(window);
-
-	rc = ui_menu_create(window, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	prect.p0.x = 0;
-	prect.p0.y = 0;
-	prect.p1.x = 0;
-	prect.p1.y = 0;
-
-	/* Menu needs to be open to be able to move around it */
-	rc = ui_menu_open(menu, &prect, 0);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_menu_down(menu);
-
-	ui_window_destroy(window);
-	ui_destroy(ui);
-}
-
-/** ui_menu_down() moves one entry down, skips separators, wraps around */
-PCUT_TEST(down)
-{
-	ui_t *ui = NULL;
-	ui_window_t *window = NULL;
-	ui_wnd_params_t params;
-	ui_menu_t *menu = NULL;
-	ui_menu_entry_t *mentry1 = NULL;
-	ui_menu_entry_t *mentry2 = NULL;
-	ui_menu_entry_t *mentry3 = NULL;
-	gfx_rect_t prect;
-	errno_t rc;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_wnd_params_init(&params);
-	params.caption = "Hello";
-
-	rc = ui_window_create(ui, &params, &window);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(window);
-
-	rc = ui_menu_create(window, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	rc = ui_menu_entry_create(menu, "Foo", "F1", &mentry1);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(mentry1);
-
-	rc = ui_menu_entry_sep_create(menu, &mentry2);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(mentry2);
-
-	rc = ui_menu_entry_create(menu, "Bar", "F2", &mentry3);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(mentry3);
-
-	prect.p0.x = 0;
-	prect.p0.y = 0;
-	prect.p1.x = 0;
-	prect.p1.y = 0;
-
-	/* Menu needs to be open to be able to move around it */
-	rc = ui_menu_open(menu, &prect, 0);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	/* When menu is open, the first entry is selected */
-	PCUT_ASSERT_EQUALS(mentry1, menu->selected);
-
-	ui_menu_down(menu);
-
-	/* mentry2 is a separator and was skipped */
-	PCUT_ASSERT_EQUALS(mentry3, menu->selected);
-
-	ui_menu_up(menu);
-
-	/* Now we've wrapped around to the first entry */
-	PCUT_ASSERT_EQUALS(mentry1, menu->selected);
-
-	ui_window_destroy(window);
-	ui_destroy(ui);
-}
-
-/** Sending an unhandled event does nothing. */
-PCUT_TEST(send_unhandled)
-{
-	ui_menu_t *menu = NULL;
-	errno_t rc;
-	sysarg_t idev_id;
-	char32_t c;
-
-	rc = ui_menu_create(NULL, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	/* Send events without setting callback */
-	c = 'A';
-	idev_id = 42;
-	ui_menu_left(menu, idev_id);
-	ui_menu_right(menu, idev_id);
-	ui_menu_close_req(menu);
-	ui_menu_press_accel(menu, c, idev_id);
-
-	/* Set dummy callback structure */
-	ui_menu_set_cb(menu, &dummy_cb, NULL);
-
-	/* Send unhandled events */
-	ui_menu_left(menu, idev_id);
-	ui_menu_right(menu, idev_id);
-	ui_menu_close_req(menu);
-	ui_menu_press_accel(menu, c, idev_id);
-
-	ui_menu_destroy(menu);
-}
-
-/** ui_menu_left() sends left event */
-PCUT_TEST(left)
-{
-	ui_menu_t *menu = NULL;
-	errno_t rc;
-	test_resp_t resp;
-	sysarg_t idev_id;
-
-	rc = ui_menu_create(NULL, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	ui_menu_set_cb(menu, &testmenu_cb, (void *)&resp);
-
-	memset(&resp, 0, sizeof(resp));
-	PCUT_ASSERT_FALSE(resp.left_called);
-
-	idev_id = 42;
-	ui_menu_left(menu, idev_id);
-
-	PCUT_ASSERT_TRUE(resp.left_called);
-	PCUT_ASSERT_EQUALS(menu, resp.menu);
-	PCUT_ASSERT_INT_EQUALS(idev_id, resp.idev_id);
-
-	ui_menu_destroy(menu);
-}
-
-/** ui_menu_right() sends right event */
-PCUT_TEST(right)
-{
-	ui_menu_t *menu = NULL;
-	errno_t rc;
-	test_resp_t resp;
-	sysarg_t idev_id;
-
-	rc = ui_menu_create(NULL, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	ui_menu_set_cb(menu, &testmenu_cb, (void *)&resp);
-
-	memset(&resp, 0, sizeof(resp));
-	PCUT_ASSERT_FALSE(resp.right_called);
-
-	idev_id = 42;
-	ui_menu_right(menu, idev_id);
-
-	PCUT_ASSERT_TRUE(resp.right_called);
-	PCUT_ASSERT_EQUALS(menu, resp.menu);
-	PCUT_ASSERT_INT_EQUALS(idev_id, resp.idev_id);
-
-	ui_menu_destroy(menu);
-}
-
-/** ui_menu_close_req() sends close_req event */
-PCUT_TEST(close_req)
-{
-	ui_menu_t *menu = NULL;
-	errno_t rc;
-	test_resp_t resp;
-
-	rc = ui_menu_create(NULL, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	ui_menu_set_cb(menu, &testmenu_cb, (void *)&resp);
-
-	memset(&resp, 0, sizeof(resp));
-	PCUT_ASSERT_FALSE(resp.close_req_called);
-
-	ui_menu_close_req(menu);
-
-	PCUT_ASSERT_TRUE(resp.close_req_called);
-	PCUT_ASSERT_EQUALS(menu, resp.menu);
-
-	ui_menu_destroy(menu);
-}
-
-/** ui_menu_press_accel() sends press_accel event */
-PCUT_TEST(press_accel)
-{
-	ui_menu_t *menu = NULL;
-	errno_t rc;
-	test_resp_t resp;
-	char32_t c;
-	sysarg_t idev_id;
-
-	rc = ui_menu_create(NULL, &menu);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(menu);
-
-	ui_menu_set_cb(menu, &testmenu_cb, (void *)&resp);
-
-	memset(&resp, 0, sizeof(resp));
-	PCUT_ASSERT_FALSE(resp.press_accel_called);
-
-	c = 'A';
-	idev_id = 42;
-	ui_menu_press_accel(menu, c, idev_id);
-
-	PCUT_ASSERT_TRUE(resp.press_accel_called);
-	PCUT_ASSERT_EQUALS(menu, resp.menu);
-	PCUT_ASSERT_EQUALS(c, resp.c);
-	PCUT_ASSERT_INT_EQUALS(idev_id, resp.idev_id);
-
-	ui_menu_destroy(menu);
-}
-
-/** Test menu left callback */
-static void testmenu_left(ui_menu_t *menu, void *arg, sysarg_t idev_id)
-{
-	test_resp_t *resp = (test_resp_t *)arg;
-
-	resp->left_called = true;
-	resp->menu = menu;
-	resp->idev_id = idev_id;
-}
-
-/** Test menu right callback */
-static void testmenu_right(ui_menu_t *menu, void *arg, sysarg_t idev_id)
-{
-	test_resp_t *resp = (test_resp_t *)arg;
-
-	resp->right_called = true;
-	resp->menu = menu;
-	resp->idev_id = idev_id;
-}
-
-/** Test menu close callback */
-static void testmenu_close_req(ui_menu_t *menu, void *arg)
-{
-	test_resp_t *resp = (test_resp_t *)arg;
-
-	resp->close_req_called = true;
-	resp->menu = menu;
-}
-
-/** Test menu press accel callback */
-static void testmenu_press_accel(ui_menu_t *menu, void *arg,
-    char32_t c, sysarg_t kbd_id)
-{
-	test_resp_t *resp = (test_resp_t *)arg;
-
-	resp->press_accel_called = true;
-	resp->menu = menu;
-	resp->c = c;
-	resp->idev_id = kbd_id;
+	ui_menu_bar_destroy(mbar);
+	ui_window_destroy(window);
+	ui_destroy(ui);
 }
 
