Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/test/clonegc.c

    r7470d97 r5271e4c  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2020 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3939PCUT_TEST_SUITE(clonegc);
    4040
    41 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
    4241static errno_t testgc_set_color(void *, gfx_color_t *);
    4342static errno_t testgc_fill_rect(void *, gfx_rect_t *);
     
    4948
    5049static gfx_context_ops_t ops = {
    51         .set_clip_rect = testgc_set_clip_rect,
    5250        .set_color = testgc_set_color,
    5351        .fill_rect = testgc_fill_rect,
     
    6159        /** Error code to return */
    6260        errno_t rc;
    63 
    64         bool set_clip_rect_called;
    65         gfx_rect_t *set_clip_rect_rect;
    6661
    6762        bool set_color_called;
     
    10095        rc = ds_clonegc_create(NULL, &cgc);
    10196        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    102 
    103         rc = ds_clonegc_delete(cgc);
    104         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    105 }
    106 
    107 /** Set clipping rectangle with two output GCs */
    108 PCUT_TEST(set_clip_rect)
    109 {
    110         ds_clonegc_t *cgc;
    111         gfx_context_t *gc;
    112         test_gc_t tgc1;
    113         gfx_context_t *gc1;
    114         test_gc_t tgc2;
    115         gfx_context_t *gc2;
    116         gfx_rect_t rect;
    117         errno_t rc;
    118 
    119         /* Create clone GC */
    120         rc = ds_clonegc_create(NULL, &cgc);
    121         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    122 
    123         gc = ds_clonegc_get_ctx(cgc);
    124         PCUT_ASSERT_NOT_NULL(gc);
    125 
    126         /* Add two output GCs */
    127 
    128         rc = gfx_context_new(&ops, &tgc1, &gc1);
    129         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    130 
    131         rc = ds_clonegc_add_output(cgc, gc1);
    132         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    133 
    134         rc = gfx_context_new(&ops, &tgc2, &gc2);
    135         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    136 
    137         rc = ds_clonegc_add_output(cgc, gc2);
    138         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    139 
    140         rect.p0.x = 1;
    141         rect.p0.y = 2;
    142         rect.p1.x = 3;
    143         rect.p1.y = 4;
    144 
    145         /* Set clipping rectangle returning error */
    146 
    147         tgc1.set_clip_rect_called = false;
    148         tgc2.set_clip_rect_called = false;
    149         tgc1.rc = EINVAL;
    150         tgc2.rc = EINVAL;
    151 
    152         rc = gfx_set_clip_rect(gc, &rect);
    153         PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
    154 
    155         PCUT_ASSERT_TRUE(tgc1.set_clip_rect_called);
    156         PCUT_ASSERT_EQUALS(&rect, tgc1.set_clip_rect_rect);
    157         PCUT_ASSERT_FALSE(tgc2.set_clip_rect_called);
    158 
    159         /* Set clipping rectangle returning success for all outputs */
    160         tgc1.set_clip_rect_called = false;
    161         tgc2.set_clip_rect_called = false;
    162         tgc1.rc = EOK;
    163         tgc2.rc = EOK;
    164 
    165         rc = gfx_set_clip_rect(gc, &rect);
    166         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    167 
    168         PCUT_ASSERT_TRUE(tgc1.set_clip_rect_called);
    169         PCUT_ASSERT_EQUALS(&rect, tgc1.set_clip_rect_rect);
    170         PCUT_ASSERT_TRUE(tgc2.set_clip_rect_called);
    171         PCUT_ASSERT_EQUALS(&rect, tgc2.set_clip_rect_rect);
    17297
    17398        rc = ds_clonegc_delete(cgc);
     
    703628}
    704629
    705 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
    706 {
    707         test_gc_t *tgc = (test_gc_t *) arg;
    708 
    709         tgc->set_clip_rect_called = true;
    710         tgc->set_clip_rect_rect = rect;
    711 
    712         return tgc->rc;
    713 }
    714 
    715630static errno_t testgc_set_color(void *arg, gfx_color_t *color)
    716631{
Note: See TracChangeset for help on using the changeset viewer.