aboutsummaryrefslogtreecommitdiff
path: root/test/core.c
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2019-01-02 17:47:24 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2019-01-02 17:47:24 +0100
commit06ec95490b9b181fbdfbb395dba4347263a2f4bc (patch)
tree85cbcf6f42a88c2a6b3c01fe46a594fee43b4718 /test/core.c
parentb514b59a1c2ab17000b147029f5265531cadaf9f (diff)
downloadd2tk-06ec95490b9b181fbdfbb395dba4347263a2f4bc.tar.xz
all: prototype linear gradient meter.
Diffstat (limited to 'test/core.c')
-rw-r--r--test/core.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/test/core.c b/test/core.c
index 3200dd5..93d3c77 100644
--- a/test/core.c
+++ b/test/core.c
@@ -542,6 +542,70 @@ _test_color()
#undef COLOR_RGBA
+#define LINEAR_GRADIENT_X_0 10
+#define LINEAR_GRADIENT_Y_0 20
+#define LINEAR_GRADIENT_X_1 30
+#define LINEAR_GRADIENT_Y_1 40
+#define LINEAR_GRADIENT_RGBA_0 0xff00ff00
+#define LINEAR_GRADIENT_RGBA_1 0xffff00ff
+
+static void
+_check_linear_gradient(const d2tk_com_t *com, const d2tk_clip_t *clip)
+{
+ assert(clip->x0 == CLIP_X);
+ assert(clip->y0 == CLIP_Y);
+ assert(clip->x1 == CLIP_X + CLIP_W);
+ assert(clip->y1 == CLIP_Y + CLIP_H);
+ assert(clip->w == CLIP_W);
+ assert(clip->h == CLIP_H);
+
+ assert(com->size == sizeof(d2tk_body_linear_gradient_t));
+ assert(com->instr == D2TK_INSTR_LINEAR_GRADIENT);
+ assert(com->body->linear_gradient.p[0].x == LINEAR_GRADIENT_X_0);
+ assert(com->body->linear_gradient.p[0].y == LINEAR_GRADIENT_Y_0);
+ assert(com->body->linear_gradient.p[1].x == LINEAR_GRADIENT_X_1);
+ assert(com->body->linear_gradient.p[1].y == LINEAR_GRADIENT_Y_1);
+ assert(com->body->linear_gradient.rgba[0] == LINEAR_GRADIENT_RGBA_0);
+ assert(com->body->linear_gradient.rgba[1] == LINEAR_GRADIENT_RGBA_1);
+}
+
+static void
+_test_linear_gradient()
+{
+ d2tk_mock_ctx_t ctx = {
+ .check = _check_linear_gradient
+ };
+
+ d2tk_core_t *core = d2tk_core_new(&d2tk_mock_driver, &ctx);
+ assert(core);
+
+ d2tk_core_pre(core);
+ const ssize_t ref = d2tk_core_bbox_push(core, true,
+ &D2TK_RECT(CLIP_X, CLIP_Y, CLIP_W, CLIP_H));
+ assert(ref >= 0);
+
+ const d2tk_point_t p [2] = {
+ D2TK_POINT(LINEAR_GRADIENT_X_0, LINEAR_GRADIENT_Y_0),
+ D2TK_POINT(LINEAR_GRADIENT_X_1, LINEAR_GRADIENT_Y_1)
+ };
+ const uint32_t rgba [2] = {
+ LINEAR_GRADIENT_RGBA_0,
+ LINEAR_GRADIENT_RGBA_1
+ };
+ d2tk_core_linear_gradient(core, p, rgba);
+
+ d2tk_core_bbox_pop(core, ref);
+ d2tk_core_post(core);
+ d2tk_core_free(core);
+}
+
+#undef LINEAR_GRADIENT_X_0
+#undef LINEAR_GRADIENT_Y_0
+#undef LINEAR_GRADIENT_X_1
+#undef LINEAR_GRADIENT_Y_1
+#undef LINEAR_GRADIENT_RGBA_0
+#undef LINEAR_GRADIENT_RGBA_1
+
static void
_check_stroke(const d2tk_com_t *com, const d2tk_clip_t *clip)
{
@@ -1141,6 +1205,7 @@ main(int argc __attribute__((unused)), char **argv __attribute__((unused)))
_test_arc();
_test_curve_to();
_test_color();
+ _test_linear_gradient();
_test_stroke();
_test_fill();
_test_save();