Changeset 7470d97 in mainline for uspace/srv/hid/display/test/clonegc.c
- Timestamp:
- 2021-04-30T15:05:06Z (4 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 051349b
- Parents:
- 252d03c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/test/clonegc.c
r252d03c r7470d97 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 39 39 PCUT_TEST_SUITE(clonegc); 40 40 41 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 41 42 static errno_t testgc_set_color(void *, gfx_color_t *); 42 43 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 48 49 49 50 static gfx_context_ops_t ops = { 51 .set_clip_rect = testgc_set_clip_rect, 50 52 .set_color = testgc_set_color, 51 53 .fill_rect = testgc_fill_rect, … … 59 61 /** Error code to return */ 60 62 errno_t rc; 63 64 bool set_clip_rect_called; 65 gfx_rect_t *set_clip_rect_rect; 61 66 62 67 bool set_color_called; … … 95 100 rc = ds_clonegc_create(NULL, &cgc); 96 101 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); 97 172 98 173 rc = ds_clonegc_delete(cgc); … … 628 703 } 629 704 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 630 715 static errno_t testgc_set_color(void *arg, gfx_color_t *color) 631 716 {
Note:
See TracChangeset
for help on using the changeset viewer.