Index: uspace/lib/gfx/test/render.c
===================================================================
--- uspace/lib/gfx/test/render.c	(revision 2ab8ab3c0a1e9771074c6e9d07ec1bf5e87ddafc)
+++ uspace/lib/gfx/test/render.c	(revision 8dbd13d0cc7a96fe917780001de3568ece3d7da7)
@@ -38,4 +38,5 @@
 PCUT_TEST_SUITE(render);
 
+static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
 static errno_t testgc_set_color(void *, gfx_color_t *);
 static errno_t testgc_fill_rect(void *, gfx_rect_t *);
@@ -43,4 +44,5 @@
 
 static gfx_context_ops_t ops = {
+	.set_clip_rect = testgc_set_clip_rect,
 	.set_color = testgc_set_color,
 	.fill_rect = testgc_fill_rect,
@@ -50,9 +52,100 @@
 /** Test graphics context data */
 typedef struct {
+	errno_t rc;
+
+	bool set_clip_rect;
+	gfx_rect_t crect;
+	bool do_clip;
+
+	bool set_color;
 	gfx_color_t *dclr;
-	gfx_rect_t *rect;
-	bool updated;
+
+	bool fill_rect;
+	gfx_rect_t frect;
+
+	bool update;
 } test_gc_t;
 
+/** Set clipping rectangle */
+PCUT_TEST(set_clip_rect)
+{
+	errno_t rc;
+	gfx_rect_t rect;
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+
+	memset(&tgc, 0, sizeof(tgc));
+
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rect.p0.x = 1;
+	rect.p0.y = 2;
+	rect.p1.x = 3;
+	rect.p1.y = 4;
+
+	tgc.rc = EOK;
+
+	rc = gfx_set_clip_rect(gc, &rect);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	PCUT_ASSERT_TRUE(tgc.set_clip_rect);
+	PCUT_ASSERT_TRUE(tgc.do_clip);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.x, tgc.crect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.y, tgc.crect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.x, tgc.crect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.y, tgc.crect.p1.y);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+/** Set null clipping rectangle */
+PCUT_TEST(set_clip_rect_null)
+{
+	errno_t rc;
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+
+	memset(&tgc, 0, sizeof(tgc));
+
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	tgc.rc = EOK;
+
+	rc = gfx_set_clip_rect(gc, NULL);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	PCUT_ASSERT_TRUE(tgc.set_clip_rect);
+	PCUT_ASSERT_FALSE(tgc.do_clip);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+/** Set clipping rectangle with error return */
+PCUT_TEST(set_clip_rect_failure)
+{
+	errno_t rc;
+	gfx_rect_t rect;
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+
+	memset(&tgc, 0, sizeof(tgc));
+
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	tgc.rc = EIO;
+
+	rc = gfx_set_clip_rect(gc, &rect);
+	PCUT_ASSERT_ERRNO_VAL(EIO, rc);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+/** Set drawing color */
 PCUT_TEST(set_color)
 {
@@ -60,4 +153,5 @@
 	gfx_color_t *color;
 	gfx_context_t *gc = NULL;
+	uint16_t r, g, b;
 	test_gc_t tgc;
 
@@ -70,8 +164,45 @@
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
+	PCUT_ASSERT_FALSE(tgc.set_color);
+
+	tgc.rc = EOK;
+
 	rc = gfx_set_color(gc, color);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_EQUALS(color, tgc.dclr);
-	PCUT_ASSERT_NULL(tgc.rect);
+
+	PCUT_ASSERT_TRUE(tgc.set_color);
+
+	gfx_color_get_rgb_i16(tgc.dclr, &r, &g, &b);
+
+	PCUT_ASSERT_INT_EQUALS(0xffff, r);
+	PCUT_ASSERT_INT_EQUALS(0xffff, g);
+	PCUT_ASSERT_INT_EQUALS(0xffff, b);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+/** Set drawing color with error return */
+PCUT_TEST(set_color_failure)
+{
+	errno_t rc;
+	gfx_color_t *color;
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+
+	memset(&tgc, 0, sizeof(tgc));
+
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	PCUT_ASSERT_FALSE(tgc.set_color);
+
+	tgc.rc = EIO;
+
+	rc = gfx_set_color(gc, color);
+	PCUT_ASSERT_ERRNO_VAL(EIO, rc);
 
 	gfx_color_delete(color);
@@ -81,8 +212,8 @@
 }
 
+/** Fill rectangle */
 PCUT_TEST(fill_rect)
 {
 	errno_t rc;
-	gfx_color_t *color;
 	gfx_rect_t rect;
 	gfx_context_t *gc = NULL;
@@ -94,21 +225,56 @@
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
-	rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	rc = gfx_set_color(gc, color);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_EQUALS(color, tgc.dclr);
+	rect.p0.x = 1;
+	rect.p0.y = 2;
+	rect.p1.x = 3;
+	rect.p1.y = 4;
+
+	PCUT_ASSERT_FALSE(tgc.fill_rect);
+
+	tgc.rc = EOK;
 
 	rc = gfx_fill_rect(gc, &rect);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-	PCUT_ASSERT_EQUALS(&rect, tgc.rect);
-
-	gfx_color_delete(color);
-
-	rc = gfx_context_delete(gc);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-}
-
+
+	PCUT_ASSERT_TRUE(tgc.fill_rect);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.x, tgc.frect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.y, tgc.frect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.x, tgc.frect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.y, tgc.frect.p1.y);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+/** Fill rectangle with error return */
+PCUT_TEST(fill_rect_failure)
+{
+	errno_t rc;
+	gfx_rect_t rect;
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+
+	memset(&tgc, 0, sizeof(tgc));
+
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rect.p0.x = 1;
+	rect.p0.y = 2;
+	rect.p1.x = 3;
+	rect.p1.y = 4;
+
+	PCUT_ASSERT_FALSE(tgc.fill_rect);
+
+	tgc.rc = EIO;
+
+	rc = gfx_fill_rect(gc, &rect);
+	PCUT_ASSERT_ERRNO_VAL(EIO, rc);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+/** Update GC */
 PCUT_TEST(update)
 {
@@ -122,10 +288,49 @@
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
-	PCUT_ASSERT_FALSE(tgc.updated);
-	gfx_update(gc);
-	PCUT_ASSERT_TRUE(tgc.updated);
-
-	rc = gfx_context_delete(gc);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	tgc.rc = EOK;
+
+	PCUT_ASSERT_FALSE(tgc.update);
+	rc = gfx_update(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_TRUE(tgc.update);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+/** Update GC with error return */
+PCUT_TEST(update_failure)
+{
+	errno_t rc;
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+
+	memset(&tgc, 0, sizeof(tgc));
+
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	tgc.rc = EIO;
+	rc = gfx_update(gc);
+
+	PCUT_ASSERT_ERRNO_VAL(EIO, rc);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
+{
+	test_gc_t *tgc = (test_gc_t *) arg;
+
+	tgc->set_clip_rect = true;
+	if (rect != NULL) {
+		tgc->do_clip = true;
+		tgc->crect = *rect;
+	} else {
+		tgc->do_clip = false;
+	}
+
+	return tgc->rc;
 }
 
@@ -133,8 +338,10 @@
 {
 	test_gc_t *tgc = (test_gc_t *) arg;
+
+	tgc->set_color = true;
 
 	/* Technically we should copy the data */
 	tgc->dclr = color;
-	return EOK;
+	return tgc->rc;
 }
 
@@ -143,7 +350,7 @@
 	test_gc_t *tgc = (test_gc_t *) arg;
 
-	/* Technically we should copy the data */
-	tgc->rect = rect;
-	return EOK;
+	tgc->fill_rect = true;
+	tgc->frect = *rect;
+	return tgc->rc;
 }
 
@@ -152,6 +359,6 @@
 	test_gc_t *tgc = (test_gc_t *) arg;
 
-	tgc->updated = true;
-	return EOK;
+	tgc->update = true;
+	return tgc->rc;
 }
 
