1 | /*
|
---|
2 | * Copyright (c) 2023 Jiri Svoboda
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | #include <gfx/context.h>
|
---|
30 | #include <gfx/coord.h>
|
---|
31 | #include <mem.h>
|
---|
32 | #include <pcut/pcut.h>
|
---|
33 | #include <stdbool.h>
|
---|
34 | #include <ui/paint.h>
|
---|
35 | #include <ui/resource.h>
|
---|
36 | #include "../private/testgc.h"
|
---|
37 |
|
---|
38 | PCUT_INIT;
|
---|
39 |
|
---|
40 | PCUT_TEST_SUITE(paint);
|
---|
41 |
|
---|
42 | /** Test box characters */
|
---|
43 | static ui_box_chars_t test_box_chars = {
|
---|
44 | {
|
---|
45 | { "A", "B", "C" },
|
---|
46 | { "D", " ", "E" },
|
---|
47 | { "F", "G", "H" }
|
---|
48 | }
|
---|
49 | };
|
---|
50 |
|
---|
51 | /** Paint bevel */
|
---|
52 | PCUT_TEST(bevel)
|
---|
53 | {
|
---|
54 | errno_t rc;
|
---|
55 | gfx_context_t *gc = NULL;
|
---|
56 | test_gc_t tgc;
|
---|
57 | gfx_rect_t rect;
|
---|
58 | gfx_color_t *color1;
|
---|
59 | gfx_color_t *color2;
|
---|
60 | gfx_rect_t inside;
|
---|
61 |
|
---|
62 | memset(&tgc, 0, sizeof(tgc));
|
---|
63 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
64 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
65 |
|
---|
66 | rc = gfx_color_new_rgb_i16(1, 2, 3, &color1);
|
---|
67 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
68 |
|
---|
69 | rc = gfx_color_new_rgb_i16(4, 5, 6, &color2);
|
---|
70 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
71 |
|
---|
72 | rect.p0.x = 10;
|
---|
73 | rect.p0.y = 20;
|
---|
74 | rect.p1.x = 30;
|
---|
75 | rect.p1.y = 40;
|
---|
76 |
|
---|
77 | /* Paint bevel with NULL 'inside' output parameter */
|
---|
78 | rc = ui_paint_bevel(gc, &rect, color1, color2, 2, NULL);
|
---|
79 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
80 |
|
---|
81 | /* Paint bevel with valid 'inside' output parameter */
|
---|
82 | rc = ui_paint_bevel(gc, &rect, color1, color2, 2, &inside);
|
---|
83 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
84 |
|
---|
85 | gfx_color_delete(color2);
|
---|
86 | gfx_color_delete(color1);
|
---|
87 | rc = gfx_context_delete(gc);
|
---|
88 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
89 | }
|
---|
90 |
|
---|
91 | /** Get bevel inside */
|
---|
92 | PCUT_TEST(get_bevel_inside)
|
---|
93 | {
|
---|
94 | errno_t rc;
|
---|
95 | gfx_context_t *gc = NULL;
|
---|
96 | test_gc_t tgc;
|
---|
97 | gfx_rect_t rect;
|
---|
98 | gfx_rect_t inside;
|
---|
99 |
|
---|
100 | memset(&tgc, 0, sizeof(tgc));
|
---|
101 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
102 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
103 |
|
---|
104 | rect.p0.x = 10;
|
---|
105 | rect.p0.y = 20;
|
---|
106 | rect.p1.x = 30;
|
---|
107 | rect.p1.y = 40;
|
---|
108 |
|
---|
109 | ui_paint_get_bevel_inside(gc, &rect, 2, &inside);
|
---|
110 | PCUT_ASSERT_INT_EQUALS(12, inside.p0.x);
|
---|
111 | PCUT_ASSERT_INT_EQUALS(22, inside.p0.y);
|
---|
112 | PCUT_ASSERT_INT_EQUALS(28, inside.p1.x);
|
---|
113 | PCUT_ASSERT_INT_EQUALS(38, inside.p1.y);
|
---|
114 |
|
---|
115 | rc = gfx_context_delete(gc);
|
---|
116 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
117 | }
|
---|
118 |
|
---|
119 | /** Paint inset frame */
|
---|
120 | PCUT_TEST(inset_frame)
|
---|
121 | {
|
---|
122 | errno_t rc;
|
---|
123 | gfx_context_t *gc = NULL;
|
---|
124 | ui_resource_t *resource = NULL;
|
---|
125 | test_gc_t tgc;
|
---|
126 | gfx_rect_t rect;
|
---|
127 | gfx_rect_t inside;
|
---|
128 |
|
---|
129 | memset(&tgc, 0, sizeof(tgc));
|
---|
130 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
131 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
132 |
|
---|
133 | rc = ui_resource_create(gc, false, &resource);
|
---|
134 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
135 | PCUT_ASSERT_NOT_NULL(resource);
|
---|
136 |
|
---|
137 | rect.p0.x = 10;
|
---|
138 | rect.p0.y = 20;
|
---|
139 | rect.p1.x = 30;
|
---|
140 | rect.p1.y = 40;
|
---|
141 |
|
---|
142 | /* Paint inset frame with NULL 'inside' output parameter */
|
---|
143 | rc = ui_paint_inset_frame(resource, &rect, NULL);
|
---|
144 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
145 |
|
---|
146 | /* Paint inset frame with valid 'inside' output parameter */
|
---|
147 | rc = ui_paint_inset_frame(resource, &rect, &inside);
|
---|
148 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
149 |
|
---|
150 | ui_resource_destroy(resource);
|
---|
151 | rc = gfx_context_delete(gc);
|
---|
152 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
153 | }
|
---|
154 |
|
---|
155 | /** Get inset frame inside */
|
---|
156 | PCUT_TEST(get_inset_frame_inside)
|
---|
157 | {
|
---|
158 | errno_t rc;
|
---|
159 | gfx_context_t *gc = NULL;
|
---|
160 | ui_resource_t *resource = NULL;
|
---|
161 | test_gc_t tgc;
|
---|
162 | gfx_rect_t rect;
|
---|
163 | gfx_rect_t inside;
|
---|
164 |
|
---|
165 | memset(&tgc, 0, sizeof(tgc));
|
---|
166 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
167 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
168 |
|
---|
169 | rc = ui_resource_create(gc, false, &resource);
|
---|
170 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
171 | PCUT_ASSERT_NOT_NULL(resource);
|
---|
172 |
|
---|
173 | rect.p0.x = 10;
|
---|
174 | rect.p0.y = 20;
|
---|
175 | rect.p1.x = 30;
|
---|
176 | rect.p1.y = 40;
|
---|
177 |
|
---|
178 | ui_paint_get_inset_frame_inside(resource, &rect, &inside);
|
---|
179 | PCUT_ASSERT_INT_EQUALS(12, inside.p0.x);
|
---|
180 | PCUT_ASSERT_INT_EQUALS(22, inside.p0.y);
|
---|
181 | PCUT_ASSERT_INT_EQUALS(28, inside.p1.x);
|
---|
182 | PCUT_ASSERT_INT_EQUALS(38, inside.p1.y);
|
---|
183 |
|
---|
184 | ui_resource_destroy(resource);
|
---|
185 | rc = gfx_context_delete(gc);
|
---|
186 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
187 | }
|
---|
188 |
|
---|
189 | /** Paint filled circle */
|
---|
190 | PCUT_TEST(filled_circle)
|
---|
191 | {
|
---|
192 | errno_t rc;
|
---|
193 | gfx_context_t *gc = NULL;
|
---|
194 | test_gc_t tgc;
|
---|
195 | gfx_coord2_t center;
|
---|
196 |
|
---|
197 | memset(&tgc, 0, sizeof(tgc));
|
---|
198 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
199 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
200 |
|
---|
201 | center.x = 0;
|
---|
202 | center.y = 0;
|
---|
203 |
|
---|
204 | /* Paint filled circle / upper-left half */
|
---|
205 | rc = ui_paint_filled_circle(gc, ¢er, 10, ui_fcircle_upleft);
|
---|
206 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
207 |
|
---|
208 | /* Paint filled circle / lower-right half */
|
---|
209 | rc = ui_paint_filled_circle(gc, ¢er, 10, ui_fcircle_lowright);
|
---|
210 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
211 |
|
---|
212 | /* Paint entire filled circle */
|
---|
213 | rc = ui_paint_filled_circle(gc, ¢er, 10, ui_fcircle_entire);
|
---|
214 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
215 |
|
---|
216 | rc = gfx_context_delete(gc);
|
---|
217 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
218 | }
|
---|
219 |
|
---|
220 | /** Paint up pointing triangle */
|
---|
221 | PCUT_TEST(up_triangle)
|
---|
222 | {
|
---|
223 | errno_t rc;
|
---|
224 | gfx_context_t *gc = NULL;
|
---|
225 | test_gc_t tgc;
|
---|
226 | gfx_coord2_t center;
|
---|
227 |
|
---|
228 | memset(&tgc, 0, sizeof(tgc));
|
---|
229 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
230 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
231 |
|
---|
232 | center.x = 0;
|
---|
233 | center.y = 0;
|
---|
234 |
|
---|
235 | rc = ui_paint_up_triangle(gc, ¢er, 5);
|
---|
236 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
237 |
|
---|
238 | rc = gfx_context_delete(gc);
|
---|
239 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
240 | }
|
---|
241 |
|
---|
242 | /** Paint down pointing triangle */
|
---|
243 | PCUT_TEST(down_triangle)
|
---|
244 | {
|
---|
245 | errno_t rc;
|
---|
246 | gfx_context_t *gc = NULL;
|
---|
247 | test_gc_t tgc;
|
---|
248 | gfx_coord2_t center;
|
---|
249 |
|
---|
250 | memset(&tgc, 0, sizeof(tgc));
|
---|
251 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
252 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
253 |
|
---|
254 | center.x = 0;
|
---|
255 | center.y = 0;
|
---|
256 |
|
---|
257 | rc = ui_paint_down_triangle(gc, ¢er, 5);
|
---|
258 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
259 |
|
---|
260 | rc = gfx_context_delete(gc);
|
---|
261 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
262 | }
|
---|
263 |
|
---|
264 | /** Paint left pointing triangle */
|
---|
265 | PCUT_TEST(left_triangle)
|
---|
266 | {
|
---|
267 | errno_t rc;
|
---|
268 | gfx_context_t *gc = NULL;
|
---|
269 | test_gc_t tgc;
|
---|
270 | gfx_coord2_t center;
|
---|
271 |
|
---|
272 | memset(&tgc, 0, sizeof(tgc));
|
---|
273 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
274 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
275 |
|
---|
276 | center.x = 0;
|
---|
277 | center.y = 0;
|
---|
278 |
|
---|
279 | rc = ui_paint_left_triangle(gc, ¢er, 5);
|
---|
280 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
281 |
|
---|
282 | rc = gfx_context_delete(gc);
|
---|
283 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
284 | }
|
---|
285 |
|
---|
286 | /** Paint right pointing triangle */
|
---|
287 | PCUT_TEST(right_triangle)
|
---|
288 | {
|
---|
289 | errno_t rc;
|
---|
290 | gfx_context_t *gc = NULL;
|
---|
291 | test_gc_t tgc;
|
---|
292 | gfx_coord2_t center;
|
---|
293 |
|
---|
294 | memset(&tgc, 0, sizeof(tgc));
|
---|
295 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
296 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
297 |
|
---|
298 | center.x = 0;
|
---|
299 | center.y = 0;
|
---|
300 |
|
---|
301 | rc = ui_paint_right_triangle(gc, ¢er, 5);
|
---|
302 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
303 |
|
---|
304 | rc = gfx_context_delete(gc);
|
---|
305 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
306 | }
|
---|
307 |
|
---|
308 | /** Paint diagonal cross (X) */
|
---|
309 | PCUT_TEST(cross)
|
---|
310 | {
|
---|
311 | errno_t rc;
|
---|
312 | gfx_context_t *gc = NULL;
|
---|
313 | test_gc_t tgc;
|
---|
314 | gfx_coord2_t center;
|
---|
315 |
|
---|
316 | memset(&tgc, 0, sizeof(tgc));
|
---|
317 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
318 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
319 |
|
---|
320 | center.x = 0;
|
---|
321 | center.y = 0;
|
---|
322 |
|
---|
323 | rc = ui_paint_cross(gc, ¢er, 5, 1, 2);
|
---|
324 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
325 |
|
---|
326 | rc = gfx_context_delete(gc);
|
---|
327 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
328 | }
|
---|
329 |
|
---|
330 | /** Paint mimimize icon */
|
---|
331 | PCUT_TEST(minicon)
|
---|
332 | {
|
---|
333 | errno_t rc;
|
---|
334 | gfx_context_t *gc = NULL;
|
---|
335 | ui_resource_t *resource = NULL;
|
---|
336 | test_gc_t tgc;
|
---|
337 | gfx_coord2_t center;
|
---|
338 |
|
---|
339 | memset(&tgc, 0, sizeof(tgc));
|
---|
340 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
341 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
342 |
|
---|
343 | rc = ui_resource_create(gc, false, &resource);
|
---|
344 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
345 | PCUT_ASSERT_NOT_NULL(resource);
|
---|
346 |
|
---|
347 | center.x = 0;
|
---|
348 | center.y = 0;
|
---|
349 |
|
---|
350 | rc = ui_paint_minicon(resource, ¢er, 8, 6);
|
---|
351 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
352 |
|
---|
353 | ui_resource_destroy(resource);
|
---|
354 | rc = gfx_context_delete(gc);
|
---|
355 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
356 | }
|
---|
357 |
|
---|
358 | /** Paint maximize icon */
|
---|
359 | PCUT_TEST(maxicon)
|
---|
360 | {
|
---|
361 | errno_t rc;
|
---|
362 | gfx_context_t *gc = NULL;
|
---|
363 | ui_resource_t *resource = NULL;
|
---|
364 | test_gc_t tgc;
|
---|
365 | gfx_coord2_t center;
|
---|
366 |
|
---|
367 | memset(&tgc, 0, sizeof(tgc));
|
---|
368 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
369 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
370 |
|
---|
371 | rc = ui_resource_create(gc, false, &resource);
|
---|
372 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
373 | PCUT_ASSERT_NOT_NULL(resource);
|
---|
374 |
|
---|
375 | center.x = 0;
|
---|
376 | center.y = 0;
|
---|
377 |
|
---|
378 | rc = ui_paint_maxicon(resource, ¢er, 8, 6);
|
---|
379 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
380 |
|
---|
381 | ui_resource_destroy(resource);
|
---|
382 | rc = gfx_context_delete(gc);
|
---|
383 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
384 | }
|
---|
385 |
|
---|
386 | /** Paint unmaximize icon */
|
---|
387 | PCUT_TEST(unmaxicon)
|
---|
388 | {
|
---|
389 | errno_t rc;
|
---|
390 | gfx_context_t *gc = NULL;
|
---|
391 | ui_resource_t *resource = NULL;
|
---|
392 | test_gc_t tgc;
|
---|
393 | gfx_coord2_t center;
|
---|
394 |
|
---|
395 | memset(&tgc, 0, sizeof(tgc));
|
---|
396 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
397 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
398 |
|
---|
399 | rc = ui_resource_create(gc, false, &resource);
|
---|
400 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
401 | PCUT_ASSERT_NOT_NULL(resource);
|
---|
402 |
|
---|
403 | center.x = 0;
|
---|
404 | center.y = 0;
|
---|
405 |
|
---|
406 | rc = ui_paint_unmaxicon(resource, ¢er, 8, 8, 3, 3);
|
---|
407 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
408 |
|
---|
409 | ui_resource_destroy(resource);
|
---|
410 | rc = gfx_context_delete(gc);
|
---|
411 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
412 | }
|
---|
413 |
|
---|
414 | /** Paint text box */
|
---|
415 | PCUT_TEST(text_box)
|
---|
416 | {
|
---|
417 | errno_t rc;
|
---|
418 | gfx_context_t *gc = NULL;
|
---|
419 | ui_resource_t *resource = NULL;
|
---|
420 | gfx_color_t *color = NULL;
|
---|
421 | test_gc_t tgc;
|
---|
422 | gfx_rect_t rect;
|
---|
423 |
|
---|
424 | memset(&tgc, 0, sizeof(tgc));
|
---|
425 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
426 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
427 |
|
---|
428 | rc = ui_resource_create(gc, false, &resource);
|
---|
429 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
430 | PCUT_ASSERT_NOT_NULL(resource);
|
---|
431 |
|
---|
432 | rc = gfx_color_new_rgb_i16(1, 2, 3, &color);
|
---|
433 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
434 |
|
---|
435 | rect.p0.x = 10;
|
---|
436 | rect.p0.y = 20;
|
---|
437 | rect.p1.x = 30;
|
---|
438 | rect.p1.y = 40;
|
---|
439 |
|
---|
440 | /* Paint text box */
|
---|
441 | rc = ui_paint_text_box(resource, &rect, ui_box_single, color);
|
---|
442 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
443 |
|
---|
444 | gfx_color_delete(color);
|
---|
445 | ui_resource_destroy(resource);
|
---|
446 | rc = gfx_context_delete(gc);
|
---|
447 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
448 | }
|
---|
449 |
|
---|
450 | /** Paint custom text box */
|
---|
451 | PCUT_TEST(text_box_custom)
|
---|
452 | {
|
---|
453 | errno_t rc;
|
---|
454 | gfx_context_t *gc = NULL;
|
---|
455 | ui_resource_t *resource = NULL;
|
---|
456 | gfx_color_t *color = NULL;
|
---|
457 | test_gc_t tgc;
|
---|
458 | gfx_rect_t rect;
|
---|
459 |
|
---|
460 | memset(&tgc, 0, sizeof(tgc));
|
---|
461 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
462 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
463 |
|
---|
464 | rc = ui_resource_create(gc, false, &resource);
|
---|
465 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
466 | PCUT_ASSERT_NOT_NULL(resource);
|
---|
467 |
|
---|
468 | rc = gfx_color_new_rgb_i16(1, 2, 3, &color);
|
---|
469 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
470 |
|
---|
471 | rect.p0.x = 10;
|
---|
472 | rect.p0.y = 20;
|
---|
473 | rect.p1.x = 30;
|
---|
474 | rect.p1.y = 40;
|
---|
475 |
|
---|
476 | /* Paint text box */
|
---|
477 | rc = ui_paint_text_box_custom(resource, &rect, &test_box_chars, color);
|
---|
478 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
479 |
|
---|
480 | gfx_color_delete(color);
|
---|
481 | ui_resource_destroy(resource);
|
---|
482 | rc = gfx_context_delete(gc);
|
---|
483 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
484 | }
|
---|
485 |
|
---|
486 | /** Paint text horizontal brace */
|
---|
487 | PCUT_TEST(text_hbrace)
|
---|
488 | {
|
---|
489 | errno_t rc;
|
---|
490 | gfx_context_t *gc = NULL;
|
---|
491 | ui_resource_t *resource = NULL;
|
---|
492 | gfx_color_t *color = NULL;
|
---|
493 | test_gc_t tgc;
|
---|
494 | gfx_rect_t rect;
|
---|
495 |
|
---|
496 | memset(&tgc, 0, sizeof(tgc));
|
---|
497 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
498 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
499 |
|
---|
500 | rc = ui_resource_create(gc, false, &resource);
|
---|
501 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
502 | PCUT_ASSERT_NOT_NULL(resource);
|
---|
503 |
|
---|
504 | rc = gfx_color_new_rgb_i16(1, 2, 3, &color);
|
---|
505 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
506 |
|
---|
507 | rect.p0.x = 10;
|
---|
508 | rect.p0.y = 20;
|
---|
509 | rect.p1.x = 30;
|
---|
510 | rect.p1.y = 40;
|
---|
511 |
|
---|
512 | /* Paint text horizontal brace */
|
---|
513 | rc = ui_paint_text_hbrace(resource, &rect, ui_box_single,
|
---|
514 | color);
|
---|
515 |
|
---|
516 | gfx_color_delete(color);
|
---|
517 | ui_resource_destroy(resource);
|
---|
518 | rc = gfx_context_delete(gc);
|
---|
519 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
520 | }
|
---|
521 |
|
---|
522 | /** Paint text rectangle */
|
---|
523 | PCUT_TEST(text_rect)
|
---|
524 | {
|
---|
525 | errno_t rc;
|
---|
526 | gfx_context_t *gc = NULL;
|
---|
527 | ui_resource_t *resource = NULL;
|
---|
528 | gfx_color_t *color = NULL;
|
---|
529 | test_gc_t tgc;
|
---|
530 | gfx_rect_t rect;
|
---|
531 |
|
---|
532 | memset(&tgc, 0, sizeof(tgc));
|
---|
533 | rc = gfx_context_new(&ops, &tgc, &gc);
|
---|
534 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
535 |
|
---|
536 | rc = ui_resource_create(gc, false, &resource);
|
---|
537 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
538 | PCUT_ASSERT_NOT_NULL(resource);
|
---|
539 |
|
---|
540 | rc = gfx_color_new_rgb_i16(1, 2, 3, &color);
|
---|
541 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
542 |
|
---|
543 | rect.p0.x = 10;
|
---|
544 | rect.p0.y = 20;
|
---|
545 | rect.p1.x = 30;
|
---|
546 | rect.p1.y = 40;
|
---|
547 |
|
---|
548 | /* Paint text box */
|
---|
549 | rc = ui_paint_text_rect(resource, &rect, color, "A");
|
---|
550 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
551 |
|
---|
552 | gfx_color_delete(color);
|
---|
553 | ui_resource_destroy(resource);
|
---|
554 | rc = gfx_context_delete(gc);
|
---|
555 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
556 | }
|
---|
557 |
|
---|
558 | PCUT_EXPORT(paint);
|
---|