source: mainline/uspace/lib/ui/test/checkbox.c@ 97116a2

Last change on this file since 97116a2 was 806d761, checked in by Jiri Svoboda <jiri@…>, 17 months ago

Start menu should have 'open in terminal' functionality

Makes it easier for the user and if we are running in console mode,
we correctly start the application, instead of failing to start a
terminal.

  • Property mode set to 100644
File size: 16.0 KB
Line 
1/*
2 * Copyright (c) 2024 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/control.h>
35#include <ui/checkbox.h>
36#include <ui/resource.h>
37#include "../private/checkbox.h"
38
39PCUT_INIT;
40
41PCUT_TEST_SUITE(checkbox);
42
43static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);
44static errno_t testgc_set_color(void *, gfx_color_t *);
45static errno_t testgc_fill_rect(void *, gfx_rect_t *);
46static errno_t testgc_update(void *);
47static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
48 gfx_bitmap_alloc_t *, void **);
49static errno_t testgc_bitmap_destroy(void *);
50static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
51static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
52
53static gfx_context_ops_t ops = {
54 .set_clip_rect = testgc_set_clip_rect,
55 .set_color = testgc_set_color,
56 .fill_rect = testgc_fill_rect,
57 .update = testgc_update,
58 .bitmap_create = testgc_bitmap_create,
59 .bitmap_destroy = testgc_bitmap_destroy,
60 .bitmap_render = testgc_bitmap_render,
61 .bitmap_get_alloc = testgc_bitmap_get_alloc
62};
63
64static void test_checkbox_switched(ui_checkbox_t *, void *, bool);
65
66static ui_checkbox_cb_t test_checkbox_cb = {
67 .switched = test_checkbox_switched
68};
69
70static ui_checkbox_cb_t dummy_checkbox_cb = {
71};
72
73typedef struct {
74 bool bm_created;
75 bool bm_destroyed;
76 gfx_bitmap_params_t bm_params;
77 void *bm_pixels;
78 gfx_rect_t bm_srect;
79 gfx_coord2_t bm_offs;
80 bool bm_rendered;
81 bool bm_got_alloc;
82} test_gc_t;
83
84typedef struct {
85 test_gc_t *tgc;
86 gfx_bitmap_alloc_t alloc;
87 bool myalloc;
88} testgc_bitmap_t;
89
90typedef struct {
91 bool switched;
92} test_cb_resp_t;
93
94/** Create and destroy check box */
95PCUT_TEST(create_destroy)
96{
97 ui_checkbox_t *checkbox = NULL;
98 errno_t rc;
99
100 rc = ui_checkbox_create(NULL, "Hello", &checkbox);
101 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
102 PCUT_ASSERT_NOT_NULL(checkbox);
103
104 ui_checkbox_destroy(checkbox);
105}
106
107/** ui_checkbox_destroy() can take NULL argument (no-op) */
108PCUT_TEST(destroy_null)
109{
110 ui_checkbox_destroy(NULL);
111}
112
113/** ui_checkbox_ctl() returns control that has a working virtual destructor */
114PCUT_TEST(ctl)
115{
116 ui_checkbox_t *checkbox;
117 ui_control_t *control;
118 errno_t rc;
119
120 rc = ui_checkbox_create(NULL, "Hello", &checkbox);
121 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
122
123 control = ui_checkbox_ctl(checkbox);
124 PCUT_ASSERT_NOT_NULL(control);
125
126 ui_control_destroy(control);
127}
128
129/** Set check box rectangle sets internal field */
130PCUT_TEST(set_rect)
131{
132 ui_checkbox_t *checkbox;
133 gfx_rect_t rect;
134 errno_t rc;
135
136 rc = ui_checkbox_create(NULL, "Hello", &checkbox);
137 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
138
139 rect.p0.x = 1;
140 rect.p0.y = 2;
141 rect.p1.x = 3;
142 rect.p1.y = 4;
143
144 ui_checkbox_set_rect(checkbox, &rect);
145 PCUT_ASSERT_INT_EQUALS(rect.p0.x, checkbox->rect.p0.x);
146 PCUT_ASSERT_INT_EQUALS(rect.p0.y, checkbox->rect.p0.y);
147 PCUT_ASSERT_INT_EQUALS(rect.p1.x, checkbox->rect.p1.x);
148 PCUT_ASSERT_INT_EQUALS(rect.p1.y, checkbox->rect.p1.y);
149
150 ui_checkbox_destroy(checkbox);
151}
152
153/** Get check box checked returns internal field */
154PCUT_TEST(get_checked)
155{
156 ui_checkbox_t *checkbox;
157 errno_t rc;
158
159 rc = ui_checkbox_create(NULL, "Hello", &checkbox);
160 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
161
162 checkbox->checked = false;
163 PCUT_ASSERT_FALSE(ui_checkbox_get_checked(checkbox));
164 checkbox->checked = true;
165 PCUT_ASSERT_TRUE(ui_checkbox_get_checked(checkbox));
166
167 ui_checkbox_destroy(checkbox);
168}
169
170/** Set check box checked sets internal field */
171PCUT_TEST(set_checked)
172{
173 ui_checkbox_t *checkbox;
174 errno_t rc;
175
176 rc = ui_checkbox_create(NULL, "Hello", &checkbox);
177 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
178
179 ui_checkbox_set_checked(checkbox, true);
180 PCUT_ASSERT_TRUE(checkbox->checked);
181 ui_checkbox_set_checked(checkbox, false);
182 PCUT_ASSERT_FALSE(checkbox->checked);
183
184 ui_checkbox_destroy(checkbox);
185}
186
187/** Paint check box in graphics mode */
188PCUT_TEST(paint_gfx)
189{
190 errno_t rc;
191 gfx_context_t *gc = NULL;
192 test_gc_t tgc;
193 ui_resource_t *resource = NULL;
194 ui_checkbox_t *checkbox;
195
196 memset(&tgc, 0, sizeof(tgc));
197 rc = gfx_context_new(&ops, &tgc, &gc);
198 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
199
200 rc = ui_resource_create(gc, false, &resource);
201 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
202 PCUT_ASSERT_NOT_NULL(resource);
203
204 rc = ui_checkbox_create(resource, "Hello", &checkbox);
205 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
206
207 rc = ui_checkbox_paint_gfx(checkbox);
208 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
209
210 ui_checkbox_destroy(checkbox);
211 ui_resource_destroy(resource);
212
213 rc = gfx_context_delete(gc);
214 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
215}
216
217/** Paint check box in text mode */
218PCUT_TEST(paint_text)
219{
220 errno_t rc;
221 gfx_context_t *gc = NULL;
222 test_gc_t tgc;
223 ui_resource_t *resource = NULL;
224 ui_checkbox_t *checkbox;
225
226 memset(&tgc, 0, sizeof(tgc));
227 rc = gfx_context_new(&ops, &tgc, &gc);
228 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
229
230 rc = ui_resource_create(gc, false, &resource);
231 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
232 PCUT_ASSERT_NOT_NULL(resource);
233
234 rc = ui_checkbox_create(resource, "Hello", &checkbox);
235 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
236
237 rc = ui_checkbox_paint_text(checkbox);
238 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
239
240 ui_checkbox_destroy(checkbox);
241 ui_resource_destroy(resource);
242
243 rc = gfx_context_delete(gc);
244 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
245}
246
247/** Test ui_checkbox_switched() */
248PCUT_TEST(switched)
249{
250 errno_t rc;
251 ui_checkbox_t *checkbox;
252 test_cb_resp_t resp;
253
254 rc = ui_checkbox_create(NULL, "Hello", &checkbox);
255 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
256
257 /* Switched with no callbacks set */
258 ui_checkbox_switched(checkbox);
259
260 /* Switched with callback not implementing switched */
261 ui_checkbox_set_cb(checkbox, &dummy_checkbox_cb, NULL);
262 ui_checkbox_switched(checkbox);
263
264 /* Switched with real callback set */
265 resp.switched = false;
266 ui_checkbox_set_cb(checkbox, &test_checkbox_cb, &resp);
267 ui_checkbox_switched(checkbox);
268 PCUT_ASSERT_TRUE(resp.switched);
269
270 ui_checkbox_destroy(checkbox);
271}
272
273/** Press and release check box */
274PCUT_TEST(press_release)
275{
276 errno_t rc;
277 gfx_context_t *gc = NULL;
278 test_gc_t tgc;
279 ui_resource_t *resource = NULL;
280 ui_checkbox_t *checkbox;
281 test_cb_resp_t resp;
282
283 memset(&tgc, 0, sizeof(tgc));
284 rc = gfx_context_new(&ops, &tgc, &gc);
285 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
286
287 rc = ui_resource_create(gc, false, &resource);
288 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
289 PCUT_ASSERT_NOT_NULL(resource);
290
291 rc = ui_checkbox_create(resource, "Hello", &checkbox);
292 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
293 PCUT_ASSERT_FALSE(checkbox->checked);
294
295 resp.switched = false;
296 ui_checkbox_set_cb(checkbox, &test_checkbox_cb, &resp);
297
298 PCUT_ASSERT_FALSE(checkbox->held);
299 PCUT_ASSERT_FALSE(checkbox->inside);
300
301 ui_checkbox_press(checkbox);
302 PCUT_ASSERT_TRUE(checkbox->held);
303 PCUT_ASSERT_TRUE(checkbox->inside);
304 PCUT_ASSERT_FALSE(resp.switched);
305 PCUT_ASSERT_FALSE(checkbox->checked);
306
307 ui_checkbox_release(checkbox);
308 PCUT_ASSERT_FALSE(checkbox->held);
309 PCUT_ASSERT_TRUE(checkbox->inside);
310 PCUT_ASSERT_TRUE(resp.switched);
311 PCUT_ASSERT_TRUE(checkbox->checked);
312
313 ui_checkbox_destroy(checkbox);
314 ui_resource_destroy(resource);
315
316 rc = gfx_context_delete(gc);
317 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
318}
319
320/** Press, leave and release check box */
321PCUT_TEST(press_leave_release)
322{
323 errno_t rc;
324 gfx_context_t *gc = NULL;
325 test_gc_t tgc;
326 ui_resource_t *resource = NULL;
327 ui_checkbox_t *checkbox;
328 test_cb_resp_t resp;
329
330 memset(&tgc, 0, sizeof(tgc));
331 rc = gfx_context_new(&ops, &tgc, &gc);
332 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
333
334 rc = ui_resource_create(gc, false, &resource);
335 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
336 PCUT_ASSERT_NOT_NULL(resource);
337
338 rc = ui_checkbox_create(resource, "Hello", &checkbox);
339 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
340
341 resp.switched = false;
342 ui_checkbox_set_cb(checkbox, &test_checkbox_cb, &resp);
343
344 PCUT_ASSERT_FALSE(checkbox->held);
345 PCUT_ASSERT_FALSE(checkbox->inside);
346
347 ui_checkbox_press(checkbox);
348 PCUT_ASSERT_TRUE(checkbox->held);
349 PCUT_ASSERT_TRUE(checkbox->inside);
350 PCUT_ASSERT_FALSE(resp.switched);
351 PCUT_ASSERT_FALSE(checkbox->checked);
352
353 ui_checkbox_leave(checkbox);
354 PCUT_ASSERT_TRUE(checkbox->held);
355 PCUT_ASSERT_FALSE(checkbox->inside);
356 PCUT_ASSERT_FALSE(resp.switched);
357 PCUT_ASSERT_FALSE(checkbox->checked);
358
359 ui_checkbox_release(checkbox);
360 PCUT_ASSERT_FALSE(checkbox->held);
361 PCUT_ASSERT_FALSE(checkbox->inside);
362 PCUT_ASSERT_FALSE(resp.switched);
363 PCUT_ASSERT_FALSE(checkbox->checked);
364
365 ui_checkbox_destroy(checkbox);
366 ui_resource_destroy(resource);
367
368 rc = gfx_context_delete(gc);
369 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
370}
371
372/** Press, leave, enter and release check box */
373PCUT_TEST(press_leave_enter_release)
374{
375 errno_t rc;
376 gfx_context_t *gc = NULL;
377 test_gc_t tgc;
378 ui_resource_t *resource = NULL;
379 ui_checkbox_t *checkbox;
380 test_cb_resp_t resp;
381
382 memset(&tgc, 0, sizeof(tgc));
383 rc = gfx_context_new(&ops, &tgc, &gc);
384 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
385
386 rc = ui_resource_create(gc, false, &resource);
387 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
388 PCUT_ASSERT_NOT_NULL(resource);
389
390 rc = ui_checkbox_create(resource, "Hello", &checkbox);
391 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
392 PCUT_ASSERT_FALSE(checkbox->checked);
393
394 resp.switched = false;
395 ui_checkbox_set_cb(checkbox, &test_checkbox_cb, &resp);
396
397 PCUT_ASSERT_FALSE(checkbox->held);
398 PCUT_ASSERT_FALSE(checkbox->inside);
399
400 ui_checkbox_press(checkbox);
401 PCUT_ASSERT_TRUE(checkbox->held);
402 PCUT_ASSERT_TRUE(checkbox->inside);
403 PCUT_ASSERT_FALSE(resp.switched);
404 PCUT_ASSERT_FALSE(checkbox->checked);
405
406 ui_checkbox_leave(checkbox);
407 PCUT_ASSERT_TRUE(checkbox->held);
408 PCUT_ASSERT_FALSE(checkbox->inside);
409 PCUT_ASSERT_FALSE(resp.switched);
410 PCUT_ASSERT_FALSE(checkbox->checked);
411
412 ui_checkbox_enter(checkbox);
413 PCUT_ASSERT_TRUE(checkbox->held);
414 PCUT_ASSERT_TRUE(checkbox->inside);
415 PCUT_ASSERT_FALSE(resp.switched);
416 PCUT_ASSERT_FALSE(checkbox->checked);
417
418 ui_checkbox_release(checkbox);
419 PCUT_ASSERT_FALSE(checkbox->held);
420 PCUT_ASSERT_TRUE(checkbox->inside);
421 PCUT_ASSERT_TRUE(resp.switched);
422 PCUT_ASSERT_TRUE(checkbox->checked);
423
424 ui_checkbox_destroy(checkbox);
425 ui_resource_destroy(resource);
426
427 rc = gfx_context_delete(gc);
428 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
429}
430
431/** ui_pos_event() correctly translates POS_PRESS/POS_RELEASE */
432PCUT_TEST(pos_event_press_release)
433{
434 errno_t rc;
435 gfx_context_t *gc = NULL;
436 test_gc_t tgc;
437 ui_resource_t *resource = NULL;
438 ui_checkbox_t *checkbox;
439 ui_evclaim_t claim;
440 pos_event_t event;
441 gfx_rect_t rect;
442
443 memset(&tgc, 0, sizeof(tgc));
444 rc = gfx_context_new(&ops, &tgc, &gc);
445 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
446
447 rc = ui_resource_create(gc, false, &resource);
448 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
449 PCUT_ASSERT_NOT_NULL(resource);
450
451 rc = ui_checkbox_create(resource, "Hello", &checkbox);
452 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
453
454 PCUT_ASSERT_FALSE(checkbox->held);
455
456 rect.p0.x = 10;
457 rect.p0.y = 20;
458 rect.p1.x = 30;
459 rect.p1.y = 40;
460 ui_checkbox_set_rect(checkbox, &rect);
461
462 /* Press outside is not claimed and does nothing */
463 event.type = POS_PRESS;
464 event.hpos = 9;
465 event.vpos = 20;
466 claim = ui_checkbox_pos_event(checkbox, &event);
467 PCUT_ASSERT_FALSE(checkbox->held);
468 PCUT_ASSERT_EQUALS(ui_unclaimed, claim);
469
470 /* Press inside is claimed and depresses check box */
471 event.type = POS_PRESS;
472 event.hpos = 10;
473 event.vpos = 20;
474 claim = ui_checkbox_pos_event(checkbox, &event);
475 PCUT_ASSERT_TRUE(checkbox->held);
476 PCUT_ASSERT_EQUALS(ui_claimed, claim);
477
478 /* Release outside (or anywhere) is claimed and relases check box */
479 event.type = POS_RELEASE;
480 event.hpos = 9;
481 event.vpos = 20;
482 claim = ui_checkbox_pos_event(checkbox, &event);
483 PCUT_ASSERT_FALSE(checkbox->held);
484 PCUT_ASSERT_EQUALS(ui_claimed, claim);
485
486 ui_checkbox_destroy(checkbox);
487 ui_resource_destroy(resource);
488
489 rc = gfx_context_delete(gc);
490 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
491}
492
493/** ui_pos_event() correctly translates POS_UPDATE to enter/leave */
494PCUT_TEST(pos_event_enter_leave)
495{
496 errno_t rc;
497 gfx_context_t *gc = NULL;
498 test_gc_t tgc;
499 ui_resource_t *resource = NULL;
500 ui_checkbox_t *checkbox;
501 pos_event_t event;
502 gfx_rect_t rect;
503
504 memset(&tgc, 0, sizeof(tgc));
505 rc = gfx_context_new(&ops, &tgc, &gc);
506 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
507
508 rc = ui_resource_create(gc, false, &resource);
509 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
510 PCUT_ASSERT_NOT_NULL(resource);
511
512 rc = ui_checkbox_create(resource, "Hello", &checkbox);
513 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
514
515 PCUT_ASSERT_FALSE(checkbox->inside);
516
517 rect.p0.x = 10;
518 rect.p0.y = 20;
519 rect.p1.x = 30;
520 rect.p1.y = 40;
521 ui_checkbox_set_rect(checkbox, &rect);
522
523 /* Moving outside does nothing */
524 event.type = POS_UPDATE;
525 event.hpos = 9;
526 event.vpos = 20;
527 ui_checkbox_pos_event(checkbox, &event);
528 PCUT_ASSERT_FALSE(checkbox->inside);
529
530 /* Moving inside sets inside flag */
531 event.type = POS_UPDATE;
532 event.hpos = 10;
533 event.vpos = 20;
534 ui_checkbox_pos_event(checkbox, &event);
535 PCUT_ASSERT_TRUE(checkbox->inside);
536
537 /* Moving outside clears inside flag */
538 event.type = POS_UPDATE;
539 event.hpos = 9;
540 event.vpos = 20;
541 ui_checkbox_pos_event(checkbox, &event);
542 PCUT_ASSERT_FALSE(checkbox->inside);
543
544 ui_checkbox_destroy(checkbox);
545 ui_resource_destroy(resource);
546
547 rc = gfx_context_delete(gc);
548 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
549}
550
551static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)
552{
553 (void) arg;
554 (void) rect;
555 return EOK;
556}
557
558static errno_t testgc_set_color(void *arg, gfx_color_t *color)
559{
560 (void) arg;
561 (void) color;
562 return EOK;
563}
564
565static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
566{
567 (void) arg;
568 (void) rect;
569 return EOK;
570}
571
572static errno_t testgc_update(void *arg)
573{
574 (void) arg;
575 return EOK;
576}
577
578static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
579 gfx_bitmap_alloc_t *alloc, void **rbm)
580{
581 test_gc_t *tgc = (test_gc_t *) arg;
582 testgc_bitmap_t *tbm;
583
584 tbm = calloc(1, sizeof(testgc_bitmap_t));
585 if (tbm == NULL)
586 return ENOMEM;
587
588 if (alloc == NULL) {
589 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
590 sizeof(uint32_t);
591 tbm->alloc.off0 = 0;
592 tbm->alloc.pixels = calloc(sizeof(uint32_t),
593 (params->rect.p1.x - params->rect.p0.x) *
594 (params->rect.p1.y - params->rect.p0.y));
595 tbm->myalloc = true;
596 if (tbm->alloc.pixels == NULL) {
597 free(tbm);
598 return ENOMEM;
599 }
600 } else {
601 tbm->alloc = *alloc;
602 }
603
604 tbm->tgc = tgc;
605 tgc->bm_created = true;
606 tgc->bm_params = *params;
607 tgc->bm_pixels = tbm->alloc.pixels;
608 *rbm = (void *)tbm;
609 return EOK;
610}
611
612static errno_t testgc_bitmap_destroy(void *bm)
613{
614 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
615 if (tbm->myalloc)
616 free(tbm->alloc.pixels);
617 tbm->tgc->bm_destroyed = true;
618 free(tbm);
619 return EOK;
620}
621
622static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
623 gfx_coord2_t *offs)
624{
625 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
626 tbm->tgc->bm_rendered = true;
627 tbm->tgc->bm_srect = *srect;
628 tbm->tgc->bm_offs = *offs;
629 return EOK;
630}
631
632static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
633{
634 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
635 *alloc = tbm->alloc;
636 tbm->tgc->bm_got_alloc = true;
637 return EOK;
638}
639
640static void test_checkbox_switched(ui_checkbox_t *checkbox, void *arg,
641 bool checked)
642{
643 test_cb_resp_t *resp = (test_cb_resp_t *) arg;
644
645 resp->switched = true;
646}
647
648PCUT_EXPORT(checkbox);
Note: See TracBrowser for help on using the repository browser.