Changeset 045186b in mainline for uspace/lib/gfx/test/render.c


Ignore:
Timestamp:
2019-04-15T15:45:04Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9259d20
Parents:
d6dc9a12
Message:

Gfxdemo application stub, Gfx context virtual method dispatch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gfx/test/render.c

    rd6dc9a12 r045186b  
    2828
    2929#include <gfx/color.h>
     30#include <gfx/context.h>
    3031#include <gfx/render.h>
    3132#include <pcut/pcut.h>
     33#include <mem.h>
    3234
    3335PCUT_INIT;
    3436
    3537PCUT_TEST_SUITE(render);
     38
     39static errno_t testgc_set_color(void *, gfx_color_t *);
     40static errno_t testgc_fill_rect(void *, gfx_rect_t *);
     41
     42static gfx_context_ops_t ops = {
     43        .set_color = testgc_set_color,
     44        .fill_rect = testgc_fill_rect
     45};
     46
     47/** Test graphics context data */
     48typedef struct {
     49        gfx_color_t *dclr;
     50        gfx_rect_t *rect;
     51} test_gc_t;
    3652
    3753PCUT_TEST(set_color)
     
    4056        gfx_color_t *color;
    4157        gfx_context_t *gc = NULL;
     58        test_gc_t tgc;
     59
     60        memset(&tgc, 0, sizeof(tgc));
     61
     62        rc = gfx_context_new(&ops, &tgc, &gc);
     63        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    4264
    4365        rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
     
    4668        rc = gfx_set_color(gc, color);
    4769        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     70        PCUT_ASSERT_EQUALS(color, tgc.dclr);
     71        PCUT_ASSERT_NULL(tgc.rect);
    4872
    4973        gfx_color_delete(color);
     74
     75        rc = gfx_context_delete(gc);
     76        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    5077}
    5178
     
    5683        gfx_rect_t rect;
    5784        gfx_context_t *gc = NULL;
     85        test_gc_t tgc;
     86
     87        memset(&tgc, 0, sizeof(tgc));
     88
     89        rc = gfx_context_new(&ops, &tgc, &gc);
     90        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    5891
    5992        rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &color);
     
    6295        rc = gfx_set_color(gc, color);
    6396        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     97        PCUT_ASSERT_EQUALS(color, tgc.dclr);
    6498
    6599        rc = gfx_fill_rect(gc, &rect);
    66100        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     101        PCUT_ASSERT_EQUALS(&rect, tgc.rect);
    67102
    68103        gfx_color_delete(color);
     104
     105        rc = gfx_context_delete(gc);
     106        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     107}
     108
     109errno_t testgc_set_color(void *arg, gfx_color_t *color)
     110{
     111        test_gc_t *tgc = (test_gc_t *) arg;
     112
     113        /* Technically we should copy the data */
     114        tgc->dclr = color;
     115        return EOK;
     116}
     117
     118errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
     119{
     120        test_gc_t *tgc = (test_gc_t *) arg;
     121
     122        /* Technically we should copy the data */
     123        tgc->rect = rect;
     124        return EOK;
    69125}
    70126
Note: See TracChangeset for help on using the changeset viewer.