Changes in uspace/lib/ui/test/paint.c [de9992c:d63623f] in mainline
- File:
-
- 1 edited
-
uspace/lib/ui/test/paint.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/paint.c
rde9992c rd63623f 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 33 33 #include <stdbool.h> 34 34 #include <ui/paint.h> 35 #include <ui/resource.h> 35 36 36 37 PCUT_INIT; … … 38 39 PCUT_TEST_SUITE(paint); 39 40 41 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *); 40 42 static errno_t testgc_set_color(void *, gfx_color_t *); 41 43 static errno_t testgc_fill_rect(void *, gfx_rect_t *); … … 47 49 48 50 static gfx_context_ops_t ops = { 51 .set_clip_rect = testgc_set_clip_rect, 49 52 .set_color = testgc_set_color, 50 53 .fill_rect = testgc_fill_rect, … … 93 96 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 94 97 98 rect.p0.x = 10; 99 rect.p0.y = 20; 100 rect.p1.x = 30; 101 rect.p1.y = 40; 102 95 103 /* Paint bevel with NULL 'inside' output parameter */ 96 104 rc = ui_paint_bevel(gc, &rect, color1, color2, 2, NULL); … … 105 113 rc = gfx_context_delete(gc); 106 114 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 115 } 116 117 /** Get bevel inside */ 118 PCUT_TEST(get_bevel_inside) 119 { 120 errno_t rc; 121 gfx_context_t *gc = NULL; 122 test_gc_t tgc; 123 gfx_rect_t rect; 124 gfx_rect_t inside; 125 126 memset(&tgc, 0, sizeof(tgc)); 127 rc = gfx_context_new(&ops, &tgc, &gc); 128 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 129 130 rect.p0.x = 10; 131 rect.p0.y = 20; 132 rect.p1.x = 30; 133 rect.p1.y = 40; 134 135 ui_paint_get_bevel_inside(gc, &rect, 2, &inside); 136 PCUT_ASSERT_INT_EQUALS(12, inside.p0.x); 137 PCUT_ASSERT_INT_EQUALS(22, inside.p0.y); 138 PCUT_ASSERT_INT_EQUALS(28, inside.p1.x); 139 PCUT_ASSERT_INT_EQUALS(38, inside.p1.y); 140 141 rc = gfx_context_delete(gc); 142 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 143 } 144 145 /** Paint inset frame */ 146 PCUT_TEST(inset_frame) 147 { 148 errno_t rc; 149 gfx_context_t *gc = NULL; 150 ui_resource_t *resource = NULL; 151 test_gc_t tgc; 152 gfx_rect_t rect; 153 gfx_rect_t inside; 154 155 memset(&tgc, 0, sizeof(tgc)); 156 rc = gfx_context_new(&ops, &tgc, &gc); 157 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 158 159 rc = ui_resource_create(gc, false, &resource); 160 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 161 PCUT_ASSERT_NOT_NULL(resource); 162 163 rect.p0.x = 10; 164 rect.p0.y = 20; 165 rect.p1.x = 30; 166 rect.p1.y = 40; 167 168 /* Paint inset frame with NULL 'inside' output parameter */ 169 rc = ui_paint_inset_frame(resource, &rect, NULL); 170 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 171 172 /* Paint inset frame with valid 'inside' output parameter */ 173 rc = ui_paint_inset_frame(resource, &rect, &inside); 174 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 175 176 ui_resource_destroy(resource); 177 rc = gfx_context_delete(gc); 178 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 179 } 180 181 /** Get inset frame inside */ 182 PCUT_TEST(get_inset_frame_inside) 183 { 184 errno_t rc; 185 gfx_context_t *gc = NULL; 186 ui_resource_t *resource = NULL; 187 test_gc_t tgc; 188 gfx_rect_t rect; 189 gfx_rect_t inside; 190 191 memset(&tgc, 0, sizeof(tgc)); 192 rc = gfx_context_new(&ops, &tgc, &gc); 193 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 194 195 rc = ui_resource_create(gc, false, &resource); 196 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 197 PCUT_ASSERT_NOT_NULL(resource); 198 199 rect.p0.x = 10; 200 rect.p0.y = 20; 201 rect.p1.x = 30; 202 rect.p1.y = 40; 203 204 ui_paint_get_inset_frame_inside(resource, &rect, &inside); 205 PCUT_ASSERT_INT_EQUALS(12, inside.p0.x); 206 PCUT_ASSERT_INT_EQUALS(22, inside.p0.y); 207 PCUT_ASSERT_INT_EQUALS(28, inside.p1.x); 208 PCUT_ASSERT_INT_EQUALS(38, inside.p1.y); 209 210 ui_resource_destroy(resource); 211 rc = gfx_context_delete(gc); 212 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 213 } 214 215 /** Paint filled circle */ 216 PCUT_TEST(filled_circle) 217 { 218 errno_t rc; 219 gfx_context_t *gc = NULL; 220 test_gc_t tgc; 221 gfx_coord2_t center; 222 223 memset(&tgc, 0, sizeof(tgc)); 224 rc = gfx_context_new(&ops, &tgc, &gc); 225 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 226 227 /* Paint filled circle / upper-left half */ 228 rc = ui_paint_filled_circle(gc, ¢er, 10, ui_fcircle_upleft); 229 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 230 231 /* Paint filled circle / lower-right half */ 232 rc = ui_paint_filled_circle(gc, ¢er, 10, ui_fcircle_lowright); 233 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 234 235 /* Paint entire filled circle */ 236 rc = ui_paint_filled_circle(gc, ¢er, 10, ui_fcircle_entire); 237 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 238 239 rc = gfx_context_delete(gc); 240 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 241 } 242 243 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect) 244 { 245 (void) arg; 246 (void) rect; 247 return EOK; 107 248 } 108 249
Note:
See TracChangeset
for help on using the changeset viewer.
