Index: uspace/lib/memgfx/test/memgfx.c
===================================================================
--- uspace/lib/memgfx/test/memgfx.c	(revision 2ab8ab3c0a1e9771074c6e9d07ec1bf5e87ddafc)
+++ uspace/lib/memgfx/test/memgfx.c	(revision 5d1ff11b4512cee9dacb90efeb0da9ad63df6996)
@@ -32,4 +32,5 @@
 #include <gfx/coord.h>
 #include <gfx/context.h>
+#include <gfx/cursor.h>
 #include <gfx/render.h>
 #include <io/pixelmap.h>
@@ -44,6 +45,19 @@
 static void test_invalidate_rect(void *arg, gfx_rect_t *rect);
 static void test_update(void *arg);
+static errno_t test_cursor_get_pos(void *arg, gfx_coord2_t *);
+static errno_t test_cursor_set_pos(void *arg, gfx_coord2_t *);
+static errno_t test_cursor_set_visible(void *arg, bool);
+
+static mem_gc_cb_t test_mem_gc_cb = {
+	.invalidate = test_invalidate_rect,
+	.update = test_update,
+	.cursor_get_pos = test_cursor_get_pos,
+	.cursor_set_pos = test_cursor_set_pos,
+	.cursor_set_visible = test_cursor_set_visible
+};
 
 typedef struct {
+	/** Return code to return */
+	errno_t rc;
 	/** True if invalidate was called */
 	bool invalidate_called;
@@ -52,4 +66,16 @@
 	/** True if update was called */
 	bool update_called;
+	/** True if cursor_get_pos was called */
+	bool cursor_get_pos_called;
+	/** Position to return from cursor_get_pos */
+	gfx_coord2_t get_pos_pos;
+	/** True if cursor_set_pos was called */
+	bool cursor_set_pos_called;
+	/** Position passed to cursor_set_pos */
+	gfx_coord2_t set_pos_pos;
+	/** True if cursor_set_visible was called */
+	bool cursor_set_visible_called;
+	/** Value passed to cursor_set_visible */
+	bool set_visible_vis;
 } test_resp_t;
 
@@ -72,5 +98,5 @@
 	PCUT_ASSERT_NOT_NULL(alloc.pixels);
 
-	rc = mem_gc_create(&rect, &alloc, NULL, NULL, NULL, &mgc);
+	rc = mem_gc_create(&rect, &alloc, NULL, NULL, &mgc);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -106,6 +132,5 @@
 	PCUT_ASSERT_NOT_NULL(alloc.pixels);
 
-	rc = mem_gc_create(&rect, &alloc, test_invalidate_rect,
-	    test_update, &resp, &mgc);
+	rc = mem_gc_create(&rect, &alloc, &test_mem_gc_cb, &resp, &mgc);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -187,6 +212,5 @@
 	PCUT_ASSERT_NOT_NULL(alloc.pixels);
 
-	rc = mem_gc_create(&rect, &alloc, test_invalidate_rect,
-	    test_update, &resp, &mgc);
+	rc = mem_gc_create(&rect, &alloc, &test_mem_gc_cb, &resp, &mgc);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -277,6 +301,5 @@
 	PCUT_ASSERT_NOT_NULL(alloc.pixels);
 
-	rc = mem_gc_create(&rect, &alloc, test_invalidate_rect,
-	    test_update, &resp, &mgc);
+	rc = mem_gc_create(&rect, &alloc, &test_mem_gc_cb, &resp, &mgc);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -294,4 +317,135 @@
 }
 
+/** Test gfx_cursor_get_pos() on a memory GC */
+PCUT_TEST(gfx_cursor_get_pos)
+{
+	mem_gc_t *mgc;
+	gfx_rect_t rect;
+	gfx_bitmap_alloc_t alloc;
+	gfx_coord2_t pos;
+	gfx_context_t *gc;
+	test_resp_t resp;
+	errno_t rc;
+
+	/* Bounding rectangle for memory GC */
+	rect.p0.x = 0;
+	rect.p0.y = 0;
+	rect.p1.x = 10;
+	rect.p1.y = 10;
+
+	alloc.pitch = (rect.p1.x - rect.p0.x) * sizeof(uint32_t);
+	alloc.off0 = 0;
+	alloc.pixels = calloc(1, alloc.pitch * (rect.p1.y - rect.p0.y));
+	PCUT_ASSERT_NOT_NULL(alloc.pixels);
+
+	rc = mem_gc_create(&rect, &alloc, &test_mem_gc_cb, &resp, &mgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	gc = mem_gc_get_ctx(mgc);
+	PCUT_ASSERT_NOT_NULL(gc);
+
+	memset(&resp, 0, sizeof(resp));
+	resp.rc = EOK;
+	resp.get_pos_pos.x = 1;
+	resp.get_pos_pos.y = 2;
+	PCUT_ASSERT_FALSE(resp.cursor_get_pos_called);
+
+	rc = gfx_cursor_get_pos(gc, &pos);
+	PCUT_ASSERT_TRUE(resp.cursor_get_pos_called);
+	PCUT_ASSERT_INT_EQUALS(resp.get_pos_pos.x, pos.x);
+	PCUT_ASSERT_INT_EQUALS(resp.get_pos_pos.y, pos.y);
+
+	mem_gc_delete(mgc);
+	free(alloc.pixels);
+}
+
+/** Test gfx_cursor_set_pos() on a memory GC */
+PCUT_TEST(gfx_cursor_set_pos)
+{
+	mem_gc_t *mgc;
+	gfx_rect_t rect;
+	gfx_bitmap_alloc_t alloc;
+	gfx_coord2_t pos;
+	gfx_context_t *gc;
+	test_resp_t resp;
+	errno_t rc;
+
+	/* Bounding rectangle for memory GC */
+	rect.p0.x = 0;
+	rect.p0.y = 0;
+	rect.p1.x = 10;
+	rect.p1.y = 10;
+
+	alloc.pitch = (rect.p1.x - rect.p0.x) * sizeof(uint32_t);
+	alloc.off0 = 0;
+	alloc.pixels = calloc(1, alloc.pitch * (rect.p1.y - rect.p0.y));
+	PCUT_ASSERT_NOT_NULL(alloc.pixels);
+
+	rc = mem_gc_create(&rect, &alloc, &test_mem_gc_cb, &resp, &mgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	gc = mem_gc_get_ctx(mgc);
+	PCUT_ASSERT_NOT_NULL(gc);
+
+	memset(&resp, 0, sizeof(resp));
+	resp.rc = EOK;
+	pos.x = 1;
+	pos.y = 2;
+	PCUT_ASSERT_FALSE(resp.cursor_set_pos_called);
+
+	rc = gfx_cursor_set_pos(gc, &pos);
+	PCUT_ASSERT_TRUE(resp.cursor_set_pos_called);
+	PCUT_ASSERT_INT_EQUALS(pos.x, resp.set_pos_pos.x);
+	PCUT_ASSERT_INT_EQUALS(pos.y, resp.set_pos_pos.y);
+
+	mem_gc_delete(mgc);
+	free(alloc.pixels);
+}
+
+/** Test gfx_cursor_set_visible() on a memory GC */
+PCUT_TEST(gfx_cursor_set_visible)
+{
+	mem_gc_t *mgc;
+	gfx_rect_t rect;
+	gfx_bitmap_alloc_t alloc;
+	gfx_context_t *gc;
+	test_resp_t resp;
+	errno_t rc;
+
+	/* Bounding rectangle for memory GC */
+	rect.p0.x = 0;
+	rect.p0.y = 0;
+	rect.p1.x = 10;
+	rect.p1.y = 10;
+
+	alloc.pitch = (rect.p1.x - rect.p0.x) * sizeof(uint32_t);
+	alloc.off0 = 0;
+	alloc.pixels = calloc(1, alloc.pitch * (rect.p1.y - rect.p0.y));
+	PCUT_ASSERT_NOT_NULL(alloc.pixels);
+
+	rc = mem_gc_create(&rect, &alloc, &test_mem_gc_cb, &resp, &mgc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	gc = mem_gc_get_ctx(mgc);
+	PCUT_ASSERT_NOT_NULL(gc);
+
+	memset(&resp, 0, sizeof(resp));
+	resp.rc = EOK;
+	PCUT_ASSERT_FALSE(resp.cursor_set_visible_called);
+
+	rc = gfx_cursor_set_visible(gc, true);
+	PCUT_ASSERT_TRUE(resp.cursor_set_visible_called);
+	PCUT_ASSERT_TRUE(resp.set_visible_vis);
+
+	resp.cursor_set_visible_called = false;
+
+	rc = gfx_cursor_set_visible(gc, false);
+	PCUT_ASSERT_TRUE(resp.cursor_set_visible_called);
+	PCUT_ASSERT_FALSE(resp.set_visible_vis);
+
+	mem_gc_delete(mgc);
+	free(alloc.pixels);
+}
+
 /** Called by memory GC when a rectangle is modified. */
 static void test_invalidate_rect(void *arg, gfx_rect_t *rect)
@@ -311,3 +465,33 @@
 }
 
+/** Called by memory GC when cursor_get_pos is called. */
+static errno_t test_cursor_get_pos(void *arg, gfx_coord2_t *pos)
+{
+	test_resp_t *resp = (test_resp_t *)arg;
+
+	resp->cursor_get_pos_called = true;
+	*pos = resp->get_pos_pos;
+	return resp->rc;
+}
+
+/** Called by memory GC when cursor_set_pos is called. */
+static errno_t test_cursor_set_pos(void *arg, gfx_coord2_t *pos)
+{
+	test_resp_t *resp = (test_resp_t *)arg;
+
+	resp->cursor_set_pos_called = true;
+	resp->set_pos_pos = *pos;
+	return resp->rc;
+}
+
+/** Called by memory GC when cursor_set_visible is called. */
+static errno_t test_cursor_set_visible(void *arg, bool visible)
+{
+	test_resp_t *resp = (test_resp_t *)arg;
+
+	resp->cursor_set_visible_called = true;
+	resp->set_visible_vis = visible;
+	return resp->rc;
+}
+
 PCUT_EXPORT(memgfx);
