Index: uspace/lib/ui/test/control.c
===================================================================
--- uspace/lib/ui/test/control.c	(revision 1eaead40ef1e81dc0e203498597d60b2e71fcd27)
+++ uspace/lib/ui/test/control.c	(revision 62223ec4ecd7ed2de2744dc2b41d1183c548223c)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2023 Jiri Svoboda
+ * Copyright (c) 2020 Jiri Svoboda
  * All rights reserved.
  *
@@ -29,16 +29,47 @@
 #include <errno.h>
 #include <mem.h>
-#include <io/kbd_event.h>
 #include <io/pos_event.h>
 #include <pcut/pcut.h>
 #include <ui/control.h>
-#include <ui/testctl.h>
 #include <stdbool.h>
 #include <types/ui/event.h>
-#include "../private/testctl.h"
 
 PCUT_INIT;
 
 PCUT_TEST_SUITE(control);
+
+static void test_ctl_destroy(void *);
+static errno_t test_ctl_paint(void *);
+static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *);
+static void test_ctl_unfocus(void *);
+
+static ui_control_ops_t test_ctl_ops = {
+	.destroy = test_ctl_destroy,
+	.paint = test_ctl_paint,
+	.pos_event = test_ctl_pos_event,
+	.unfocus = test_ctl_unfocus
+};
+
+/** Test response */
+typedef struct {
+	/** Claim to return */
+	ui_evclaim_t claim;
+	/** Result code to return */
+	errno_t rc;
+
+	/** @c true iff destroy was called */
+	bool destroy;
+
+	/** @c true iff paint was called */
+	bool paint;
+
+	/** @c true iff pos_event was called */
+	bool pos;
+	/** Position event that was sent */
+	pos_event_t pevent;
+
+	/** @c true iff unfocus was called */
+	bool unfocus;
+} test_resp_t;
 
 /** Allocate and deallocate control */
@@ -48,5 +79,5 @@
 	errno_t rc;
 
-	rc = ui_control_new(&ui_test_ctl_ops, NULL, &control);
+	rc = ui_control_new(&test_ctl_ops, NULL, &control);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 	PCUT_ASSERT_NOT_NULL(control);
@@ -64,16 +95,16 @@
 PCUT_TEST(destroy)
 {
-	ui_test_ctl_t *testctl = NULL;
-	ui_tc_resp_t resp;
-	errno_t rc;
-
-	rc = ui_test_ctl_create(&resp, &testctl);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(testctl);
+	ui_control_t *control = NULL;
+	test_resp_t resp;
+	errno_t rc;
+
+	rc = ui_control_new(&test_ctl_ops, &resp, &control);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(control);
 
 	resp.rc = EOK;
 	resp.destroy = false;
 
-	ui_control_destroy(ui_test_ctl_ctl(testctl));
+	ui_control_destroy(control);
 	PCUT_ASSERT_TRUE(resp.destroy);
 }
@@ -82,16 +113,16 @@
 PCUT_TEST(paint)
 {
-	ui_test_ctl_t *testctl = NULL;
-	ui_tc_resp_t resp;
-	errno_t rc;
-
-	rc = ui_test_ctl_create(&resp, &testctl);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(testctl);
+	ui_control_t *control = NULL;
+	test_resp_t resp;
+	errno_t rc;
+
+	rc = ui_control_new(&test_ctl_ops, &resp, &control);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(control);
 
 	resp.rc = EOK;
 	resp.paint = false;
 
-	rc = ui_control_paint(ui_test_ctl_ctl(testctl));
+	rc = ui_control_paint(control);
 	PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
 	PCUT_ASSERT_TRUE(resp.paint);
@@ -100,40 +131,9 @@
 	resp.paint = false;
 
-	rc = ui_control_paint(ui_test_ctl_ctl(testctl));
+	rc = ui_control_paint(control);
 	PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
 	PCUT_ASSERT_TRUE(resp.paint);
 
-	ui_test_ctl_destroy(testctl);
-}
-
-/** Test sending keyboard event to control */
-PCUT_TEST(kbd_event)
-{
-	ui_test_ctl_t *testctl = NULL;
-	ui_tc_resp_t resp;
-	kbd_event_t event;
-	ui_evclaim_t claim;
-	errno_t rc;
-
-	rc = ui_test_ctl_create(&resp, &testctl);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(testctl);
-
-	resp.claim = ui_claimed;
-	resp.kbd = false;
-	event.type = KEY_PRESS;
-	event.key = KC_2;
-	event.mods = KM_LSHIFT;
-	event.c = '@';
-
-	claim = ui_control_kbd_event(ui_test_ctl_ctl(testctl), &event);
-	PCUT_ASSERT_EQUALS(resp.claim, claim);
-	PCUT_ASSERT_TRUE(resp.kbd);
-	PCUT_ASSERT_EQUALS(resp.kevent.type, event.type);
-	PCUT_ASSERT_INT_EQUALS(resp.kevent.key, event.key);
-	PCUT_ASSERT_INT_EQUALS(resp.kevent.mods, event.mods);
-	PCUT_ASSERT_INT_EQUALS(resp.kevent.c, event.c);
-
-	ui_test_ctl_destroy(testctl);
+	ui_control_delete(control);
 }
 
@@ -141,13 +141,13 @@
 PCUT_TEST(pos_event)
 {
-	ui_test_ctl_t *testctl = NULL;
-	ui_tc_resp_t resp;
+	ui_control_t *control = NULL;
+	test_resp_t resp;
 	pos_event_t event;
 	ui_evclaim_t claim;
 	errno_t rc;
 
-	rc = ui_test_ctl_create(&resp, &testctl);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(testctl);
+	rc = ui_control_new(&test_ctl_ops, &resp, &control);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(control);
 
 	resp.claim = ui_claimed;
@@ -159,5 +159,5 @@
 	event.vpos = 4;
 
-	claim = ui_control_pos_event(ui_test_ctl_ctl(testctl), &event);
+	claim = ui_control_pos_event(control, &event);
 	PCUT_ASSERT_EQUALS(resp.claim, claim);
 	PCUT_ASSERT_TRUE(resp.pos);
@@ -168,5 +168,5 @@
 	PCUT_ASSERT_INT_EQUALS(resp.pevent.vpos, event.vpos);
 
-	ui_test_ctl_destroy(testctl);
+	ui_control_delete(control);
 }
 
@@ -174,19 +174,50 @@
 PCUT_TEST(unfocus)
 {
-	ui_test_ctl_t *testctl = NULL;
-	ui_tc_resp_t resp;
-	errno_t rc;
-
-	rc = ui_test_ctl_create(&resp, &testctl);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_NOT_NULL(testctl);
+	ui_control_t *control = NULL;
+	test_resp_t resp;
+	errno_t rc;
+
+	rc = ui_control_new(&test_ctl_ops, &resp, &control);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(control);
 
 	resp.unfocus = false;
 
-	ui_control_unfocus(ui_test_ctl_ctl(testctl), 42);
+	ui_control_unfocus(control);
 	PCUT_ASSERT_TRUE(resp.unfocus);
-	PCUT_ASSERT_INT_EQUALS(42, resp.unfocus_nfocus);
-
-	ui_test_ctl_destroy(testctl);
+
+	ui_control_delete(control);
+}
+
+static void test_ctl_destroy(void *arg)
+{
+	test_resp_t *resp = (test_resp_t *) arg;
+
+	resp->destroy = true;
+}
+
+static errno_t test_ctl_paint(void *arg)
+{
+	test_resp_t *resp = (test_resp_t *) arg;
+
+	resp->paint = true;
+	return resp->rc;
+}
+
+static ui_evclaim_t test_ctl_pos_event(void *arg, pos_event_t *event)
+{
+	test_resp_t *resp = (test_resp_t *) arg;
+
+	resp->pos = true;
+	resp->pevent = *event;
+
+	return resp->claim;
+}
+
+static void test_ctl_unfocus(void *arg)
+{
+	test_resp_t *resp = (test_resp_t *) arg;
+
+	resp->unfocus = true;
 }
 
