Changeset 1fa6292 in mainline for uspace/lib/ui/test
- Timestamp:
- 2025-01-28T14:48:04Z (6 months ago)
- Branches:
- master
- Children:
- 56210a7a
- Parents:
- 97116a2
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-01-28 14:46:24)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-01-28 14:48:04)
- Location:
- uspace/lib/ui/test
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/checkbox.c
r97116a2 r1fa6292 36 36 #include <ui/resource.h> 37 37 #include "../private/checkbox.h" 38 #include "../private/testgc.h" 38 39 39 40 PCUT_INIT; 40 41 41 42 PCUT_TEST_SUITE(checkbox); 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);44 static errno_t testgc_set_color(void *, gfx_color_t *);45 static errno_t testgc_fill_rect(void *, gfx_rect_t *);46 static errno_t testgc_update(void *);47 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,48 gfx_bitmap_alloc_t *, void **);49 static errno_t testgc_bitmap_destroy(void *);50 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);51 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);52 53 static 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_alloc62 };63 43 64 44 static void test_checkbox_switched(ui_checkbox_t *, void *, bool); … … 70 50 static ui_checkbox_cb_t dummy_checkbox_cb = { 71 51 }; 72 73 typedef 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 84 typedef struct {85 test_gc_t *tgc;86 gfx_bitmap_alloc_t alloc;87 bool myalloc;88 } testgc_bitmap_t;89 52 90 53 typedef struct { … … 549 512 } 550 513 551 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)552 {553 (void) arg;554 (void) rect;555 return EOK;556 }557 558 static errno_t testgc_set_color(void *arg, gfx_color_t *color)559 {560 (void) arg;561 (void) color;562 return EOK;563 }564 565 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)566 {567 (void) arg;568 (void) rect;569 return EOK;570 }571 572 static errno_t testgc_update(void *arg)573 {574 (void) arg;575 return EOK;576 }577 578 static 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 612 static 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 622 static 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 632 static 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 640 514 static void test_checkbox_switched(ui_checkbox_t *checkbox, void *arg, 641 515 bool checked) -
uspace/lib/ui/test/label.c
r97116a2 r1fa6292 36 36 #include <ui/resource.h> 37 37 #include "../private/label.h" 38 #include "../private/testgc.h" 38 39 39 40 PCUT_INIT; 40 41 41 42 PCUT_TEST_SUITE(label); 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);44 static errno_t testgc_set_color(void *, gfx_color_t *);45 static errno_t testgc_fill_rect(void *, gfx_rect_t *);46 static errno_t testgc_update(void *);47 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,48 gfx_bitmap_alloc_t *, void **);49 static errno_t testgc_bitmap_destroy(void *);50 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);51 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);52 53 static 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_alloc62 };63 64 typedef struct {65 bool bm_created;66 bool bm_destroyed;67 gfx_bitmap_params_t bm_params;68 void *bm_pixels;69 gfx_rect_t bm_srect;70 gfx_coord2_t bm_offs;71 bool bm_rendered;72 bool bm_got_alloc;73 } test_gc_t;74 75 typedef struct {76 test_gc_t *tgc;77 gfx_bitmap_alloc_t alloc;78 bool myalloc;79 } testgc_bitmap_t;80 43 81 44 typedef struct { … … 213 176 } 214 177 215 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)216 {217 (void) arg;218 (void) rect;219 return EOK;220 }221 222 static errno_t testgc_set_color(void *arg, gfx_color_t *color)223 {224 (void) arg;225 (void) color;226 return EOK;227 }228 229 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)230 {231 (void) arg;232 (void) rect;233 return EOK;234 }235 236 static errno_t testgc_update(void *arg)237 {238 (void) arg;239 return EOK;240 }241 242 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,243 gfx_bitmap_alloc_t *alloc, void **rbm)244 {245 test_gc_t *tgc = (test_gc_t *) arg;246 testgc_bitmap_t *tbm;247 248 tbm = calloc(1, sizeof(testgc_bitmap_t));249 if (tbm == NULL)250 return ENOMEM;251 252 if (alloc == NULL) {253 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *254 sizeof(uint32_t);255 tbm->alloc.off0 = 0;256 tbm->alloc.pixels = calloc(sizeof(uint32_t),257 (params->rect.p1.x - params->rect.p0.x) *258 (params->rect.p1.y - params->rect.p0.y));259 tbm->myalloc = true;260 if (tbm->alloc.pixels == NULL) {261 free(tbm);262 return ENOMEM;263 }264 } else {265 tbm->alloc = *alloc;266 }267 268 tbm->tgc = tgc;269 tgc->bm_created = true;270 tgc->bm_params = *params;271 tgc->bm_pixels = tbm->alloc.pixels;272 *rbm = (void *)tbm;273 return EOK;274 }275 276 static errno_t testgc_bitmap_destroy(void *bm)277 {278 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;279 if (tbm->myalloc)280 free(tbm->alloc.pixels);281 tbm->tgc->bm_destroyed = true;282 free(tbm);283 return EOK;284 }285 286 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,287 gfx_coord2_t *offs)288 {289 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;290 tbm->tgc->bm_rendered = true;291 tbm->tgc->bm_srect = *srect;292 tbm->tgc->bm_offs = *offs;293 return EOK;294 }295 296 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)297 {298 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;299 *alloc = tbm->alloc;300 tbm->tgc->bm_got_alloc = true;301 return EOK;302 }303 304 178 PCUT_EXPORT(label); -
uspace/lib/ui/test/paint.c
r97116a2 r1fa6292 34 34 #include <ui/paint.h> 35 35 #include <ui/resource.h> 36 #include "../private/testgc.h" 36 37 37 38 PCUT_INIT; 38 39 39 40 PCUT_TEST_SUITE(paint); 40 41 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);42 static errno_t testgc_set_color(void *, gfx_color_t *);43 static errno_t testgc_fill_rect(void *, gfx_rect_t *);44 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,45 gfx_bitmap_alloc_t *, void **);46 static errno_t testgc_bitmap_destroy(void *);47 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);48 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);49 50 static gfx_context_ops_t ops = {51 .set_clip_rect = testgc_set_clip_rect,52 .set_color = testgc_set_color,53 .fill_rect = testgc_fill_rect,54 .bitmap_create = testgc_bitmap_create,55 .bitmap_destroy = testgc_bitmap_destroy,56 .bitmap_render = testgc_bitmap_render,57 .bitmap_get_alloc = testgc_bitmap_get_alloc58 };59 60 typedef struct {61 bool bm_created;62 bool bm_destroyed;63 gfx_bitmap_params_t bm_params;64 void *bm_pixels;65 gfx_rect_t bm_srect;66 gfx_coord2_t bm_offs;67 bool bm_rendered;68 bool bm_got_alloc;69 } test_gc_t;70 71 typedef struct {72 test_gc_t *tgc;73 gfx_bitmap_alloc_t alloc;74 bool myalloc;75 } testgc_bitmap_t;76 41 77 42 /** Test box characters */ … … 591 556 } 592 557 593 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)594 {595 (void) arg;596 (void) rect;597 return EOK;598 }599 600 static errno_t testgc_set_color(void *arg, gfx_color_t *color)601 {602 (void) arg;603 (void) color;604 return EOK;605 }606 607 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)608 {609 (void) arg;610 (void) rect;611 return EOK;612 }613 614 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,615 gfx_bitmap_alloc_t *alloc, void **rbm)616 {617 test_gc_t *tgc = (test_gc_t *) arg;618 testgc_bitmap_t *tbm;619 620 tbm = calloc(1, sizeof(testgc_bitmap_t));621 if (tbm == NULL)622 return ENOMEM;623 624 if (alloc == NULL) {625 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *626 sizeof(uint32_t);627 tbm->alloc.off0 = 0;628 tbm->alloc.pixels = calloc(sizeof(uint32_t),629 (params->rect.p1.x - params->rect.p0.x) *630 (params->rect.p1.y - params->rect.p0.y));631 tbm->myalloc = true;632 if (tbm->alloc.pixels == NULL) {633 free(tbm);634 return ENOMEM;635 }636 } else {637 tbm->alloc = *alloc;638 }639 640 tbm->tgc = tgc;641 tgc->bm_created = true;642 tgc->bm_params = *params;643 tgc->bm_pixels = tbm->alloc.pixels;644 *rbm = (void *)tbm;645 return EOK;646 }647 648 static errno_t testgc_bitmap_destroy(void *bm)649 {650 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;651 if (tbm->myalloc)652 free(tbm->alloc.pixels);653 tbm->tgc->bm_destroyed = true;654 free(tbm);655 return EOK;656 }657 658 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,659 gfx_coord2_t *offs)660 {661 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;662 tbm->tgc->bm_rendered = true;663 tbm->tgc->bm_srect = *srect;664 tbm->tgc->bm_offs = *offs;665 return EOK;666 }667 668 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)669 {670 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;671 *alloc = tbm->alloc;672 tbm->tgc->bm_got_alloc = true;673 return EOK;674 }675 676 558 PCUT_EXPORT(paint); -
uspace/lib/ui/test/pbutton.c
r97116a2 r1fa6292 36 36 #include <ui/resource.h> 37 37 #include "../private/pbutton.h" 38 #include "../private/testgc.h" 38 39 39 40 PCUT_INIT; 40 41 41 42 PCUT_TEST_SUITE(pbutton); 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);44 static errno_t testgc_set_color(void *, gfx_color_t *);45 static errno_t testgc_fill_rect(void *, gfx_rect_t *);46 static errno_t testgc_update(void *);47 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,48 gfx_bitmap_alloc_t *, void **);49 static errno_t testgc_bitmap_destroy(void *);50 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);51 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);52 53 static 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_alloc62 };63 43 64 44 static void test_pbutton_clicked(ui_pbutton_t *, void *); … … 74 54 static ui_pbutton_cb_t dummy_pbutton_cb = { 75 55 }; 76 77 typedef struct {78 bool bm_created;79 bool bm_destroyed;80 gfx_bitmap_params_t bm_params;81 void *bm_pixels;82 gfx_rect_t bm_srect;83 gfx_coord2_t bm_offs;84 bool bm_rendered;85 bool bm_got_alloc;86 } test_gc_t;87 88 typedef struct {89 test_gc_t *tgc;90 gfx_bitmap_alloc_t alloc;91 bool myalloc;92 } testgc_bitmap_t;93 56 94 57 typedef struct { … … 625 588 } 626 589 627 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)628 {629 (void) arg;630 (void) rect;631 return EOK;632 }633 634 static errno_t testgc_set_color(void *arg, gfx_color_t *color)635 {636 (void) arg;637 (void) color;638 return EOK;639 }640 641 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)642 {643 (void) arg;644 (void) rect;645 return EOK;646 }647 648 static errno_t testgc_update(void *arg)649 {650 (void) arg;651 return EOK;652 }653 654 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,655 gfx_bitmap_alloc_t *alloc, void **rbm)656 {657 test_gc_t *tgc = (test_gc_t *) arg;658 testgc_bitmap_t *tbm;659 660 tbm = calloc(1, sizeof(testgc_bitmap_t));661 if (tbm == NULL)662 return ENOMEM;663 664 if (alloc == NULL) {665 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *666 sizeof(uint32_t);667 tbm->alloc.off0 = 0;668 tbm->alloc.pixels = calloc(sizeof(uint32_t),669 (params->rect.p1.x - params->rect.p0.x) *670 (params->rect.p1.y - params->rect.p0.y));671 tbm->myalloc = true;672 if (tbm->alloc.pixels == NULL) {673 free(tbm);674 return ENOMEM;675 }676 } else {677 tbm->alloc = *alloc;678 }679 680 tbm->tgc = tgc;681 tgc->bm_created = true;682 tgc->bm_params = *params;683 tgc->bm_pixels = tbm->alloc.pixels;684 *rbm = (void *)tbm;685 return EOK;686 }687 688 static errno_t testgc_bitmap_destroy(void *bm)689 {690 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;691 if (tbm->myalloc)692 free(tbm->alloc.pixels);693 tbm->tgc->bm_destroyed = true;694 free(tbm);695 return EOK;696 }697 698 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,699 gfx_coord2_t *offs)700 {701 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;702 tbm->tgc->bm_rendered = true;703 tbm->tgc->bm_srect = *srect;704 tbm->tgc->bm_offs = *offs;705 return EOK;706 }707 708 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)709 {710 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;711 *alloc = tbm->alloc;712 tbm->tgc->bm_got_alloc = true;713 return EOK;714 }715 716 590 static void test_pbutton_clicked(ui_pbutton_t *pbutton, void *arg) 717 591 { -
uspace/lib/ui/test/rbutton.c
r97116a2 r1fa6292 36 36 #include <ui/resource.h> 37 37 #include "../private/rbutton.h" 38 #include "../private/testgc.h" 38 39 39 40 PCUT_INIT; 40 41 41 42 PCUT_TEST_SUITE(rbutton); 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);44 static errno_t testgc_set_color(void *, gfx_color_t *);45 static errno_t testgc_fill_rect(void *, gfx_rect_t *);46 static errno_t testgc_update(void *);47 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,48 gfx_bitmap_alloc_t *, void **);49 static errno_t testgc_bitmap_destroy(void *);50 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);51 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);52 53 static 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_alloc62 };63 43 64 44 static void test_rbutton_select(ui_rbutton_group_t *, void *, void *); … … 70 50 static ui_rbutton_group_cb_t dummy_rbutton_group_cb = { 71 51 }; 72 73 typedef 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 84 typedef struct {85 test_gc_t *tgc;86 gfx_bitmap_alloc_t alloc;87 bool myalloc;88 } testgc_bitmap_t;89 52 90 53 typedef struct { … … 592 555 } 593 556 594 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)595 {596 (void) arg;597 (void) rect;598 return EOK;599 }600 601 static errno_t testgc_set_color(void *arg, gfx_color_t *color)602 {603 (void) arg;604 (void) color;605 return EOK;606 }607 608 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)609 {610 (void) arg;611 (void) rect;612 return EOK;613 }614 615 static errno_t testgc_update(void *arg)616 {617 (void) arg;618 return EOK;619 }620 621 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,622 gfx_bitmap_alloc_t *alloc, void **rbm)623 {624 test_gc_t *tgc = (test_gc_t *) arg;625 testgc_bitmap_t *tbm;626 627 tbm = calloc(1, sizeof(testgc_bitmap_t));628 if (tbm == NULL)629 return ENOMEM;630 631 if (alloc == NULL) {632 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *633 sizeof(uint32_t);634 tbm->alloc.off0 = 0;635 tbm->alloc.pixels = calloc(sizeof(uint32_t),636 (params->rect.p1.x - params->rect.p0.x) *637 (params->rect.p1.y - params->rect.p0.y));638 tbm->myalloc = true;639 if (tbm->alloc.pixels == NULL) {640 free(tbm);641 return ENOMEM;642 }643 } else {644 tbm->alloc = *alloc;645 }646 647 tbm->tgc = tgc;648 tgc->bm_created = true;649 tgc->bm_params = *params;650 tgc->bm_pixels = tbm->alloc.pixels;651 *rbm = (void *)tbm;652 return EOK;653 }654 655 static errno_t testgc_bitmap_destroy(void *bm)656 {657 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;658 if (tbm->myalloc)659 free(tbm->alloc.pixels);660 tbm->tgc->bm_destroyed = true;661 free(tbm);662 return EOK;663 }664 665 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,666 gfx_coord2_t *offs)667 {668 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;669 tbm->tgc->bm_rendered = true;670 tbm->tgc->bm_srect = *srect;671 tbm->tgc->bm_offs = *offs;672 return EOK;673 }674 675 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)676 {677 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;678 *alloc = tbm->alloc;679 tbm->tgc->bm_got_alloc = true;680 return EOK;681 }682 683 557 static void test_rbutton_select(ui_rbutton_group_t *group, void *arg, 684 558 void *barg) -
uspace/lib/ui/test/resource.c
r97116a2 r1fa6292 33 33 #include <ui/resource.h> 34 34 #include "../private/resource.h" 35 #include "../private/testgc.h" 35 36 36 37 PCUT_INIT; … … 38 39 PCUT_TEST_SUITE(resource); 39 40 40 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,41 gfx_bitmap_alloc_t *, void **);42 static errno_t testgc_bitmap_destroy(void *);43 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);44 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);45 46 41 static void test_expose(void *); 47 48 static gfx_context_ops_t ops = {49 .bitmap_create = testgc_bitmap_create,50 .bitmap_destroy = testgc_bitmap_destroy,51 .bitmap_render = testgc_bitmap_render,52 .bitmap_get_alloc = testgc_bitmap_get_alloc53 };54 55 typedef struct {56 bool bm_created;57 bool bm_destroyed;58 gfx_bitmap_params_t bm_params;59 void *bm_pixels;60 gfx_rect_t bm_srect;61 gfx_coord2_t bm_offs;62 bool bm_rendered;63 bool bm_got_alloc;64 } test_gc_t;65 66 typedef struct {67 test_gc_t *tgc;68 gfx_bitmap_alloc_t alloc;69 bool myalloc;70 } testgc_bitmap_t;71 42 72 43 typedef struct { … … 240 211 } 241 212 242 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,243 gfx_bitmap_alloc_t *alloc, void **rbm)244 {245 test_gc_t *tgc = (test_gc_t *) arg;246 testgc_bitmap_t *tbm;247 248 tbm = calloc(1, sizeof(testgc_bitmap_t));249 if (tbm == NULL)250 return ENOMEM;251 252 if (alloc == NULL) {253 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *254 sizeof(uint32_t);255 tbm->alloc.off0 = 0;256 tbm->alloc.pixels = calloc(sizeof(uint32_t),257 (params->rect.p1.x - params->rect.p0.x) *258 (params->rect.p1.y - params->rect.p0.y));259 tbm->myalloc = true;260 if (tbm->alloc.pixels == NULL) {261 free(tbm);262 return ENOMEM;263 }264 } else {265 tbm->alloc = *alloc;266 }267 268 tbm->tgc = tgc;269 tgc->bm_created = true;270 tgc->bm_params = *params;271 tgc->bm_pixels = tbm->alloc.pixels;272 *rbm = (void *)tbm;273 return EOK;274 }275 276 static errno_t testgc_bitmap_destroy(void *bm)277 {278 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;279 if (tbm->myalloc)280 free(tbm->alloc.pixels);281 tbm->tgc->bm_destroyed = true;282 free(tbm);283 return EOK;284 }285 286 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,287 gfx_coord2_t *offs)288 {289 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;290 tbm->tgc->bm_rendered = true;291 tbm->tgc->bm_srect = *srect;292 tbm->tgc->bm_offs = *offs;293 return EOK;294 }295 296 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)297 {298 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;299 *alloc = tbm->alloc;300 tbm->tgc->bm_got_alloc = true;301 return EOK;302 }303 304 213 static void test_expose(void *arg) 305 214 { -
uspace/lib/ui/test/slider.c
r97116a2 r1fa6292 36 36 #include <ui/resource.h> 37 37 #include "../private/slider.h" 38 #include "../private/testgc.h" 38 39 39 40 PCUT_INIT; 40 41 41 42 PCUT_TEST_SUITE(slider); 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);44 static errno_t testgc_set_color(void *, gfx_color_t *);45 static errno_t testgc_fill_rect(void *, gfx_rect_t *);46 static errno_t testgc_update(void *);47 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,48 gfx_bitmap_alloc_t *, void **);49 static errno_t testgc_bitmap_destroy(void *);50 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);51 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);52 53 static 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_alloc62 };63 43 64 44 static void test_slider_moved(ui_slider_t *, void *, gfx_coord_t); … … 70 50 static ui_slider_cb_t dummy_slider_cb = { 71 51 }; 72 73 typedef 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 84 typedef struct {85 test_gc_t *tgc;86 gfx_bitmap_alloc_t alloc;87 bool myalloc;88 } testgc_bitmap_t;89 52 90 53 typedef struct { … … 462 425 } 463 426 464 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)465 {466 (void) arg;467 (void) rect;468 return EOK;469 }470 471 static errno_t testgc_set_color(void *arg, gfx_color_t *color)472 {473 (void) arg;474 (void) color;475 return EOK;476 }477 478 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)479 {480 (void) arg;481 (void) rect;482 return EOK;483 }484 485 static errno_t testgc_update(void *arg)486 {487 (void) arg;488 return EOK;489 }490 491 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,492 gfx_bitmap_alloc_t *alloc, void **rbm)493 {494 test_gc_t *tgc = (test_gc_t *) arg;495 testgc_bitmap_t *tbm;496 497 tbm = calloc(1, sizeof(testgc_bitmap_t));498 if (tbm == NULL)499 return ENOMEM;500 501 if (alloc == NULL) {502 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *503 sizeof(uint32_t);504 tbm->alloc.off0 = 0;505 tbm->alloc.pixels = calloc(sizeof(uint32_t),506 (params->rect.p1.x - params->rect.p0.x) *507 (params->rect.p1.y - params->rect.p0.y));508 tbm->myalloc = true;509 if (tbm->alloc.pixels == NULL) {510 free(tbm);511 return ENOMEM;512 }513 } else {514 tbm->alloc = *alloc;515 }516 517 tbm->tgc = tgc;518 tgc->bm_created = true;519 tgc->bm_params = *params;520 tgc->bm_pixels = tbm->alloc.pixels;521 *rbm = (void *)tbm;522 return EOK;523 }524 525 static errno_t testgc_bitmap_destroy(void *bm)526 {527 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;528 if (tbm->myalloc)529 free(tbm->alloc.pixels);530 tbm->tgc->bm_destroyed = true;531 free(tbm);532 return EOK;533 }534 535 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,536 gfx_coord2_t *offs)537 {538 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;539 tbm->tgc->bm_rendered = true;540 tbm->tgc->bm_srect = *srect;541 tbm->tgc->bm_offs = *offs;542 return EOK;543 }544 545 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)546 {547 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;548 *alloc = tbm->alloc;549 tbm->tgc->bm_got_alloc = true;550 return EOK;551 }552 553 427 static void test_slider_moved(ui_slider_t *slider, void *arg, gfx_coord_t pos) 554 428 { -
uspace/lib/ui/test/wdecor.c
r97116a2 r1fa6292 37 37 #include <ui/wdecor.h> 38 38 #include "../private/wdecor.h" 39 #include "../private/testgc.h" 39 40 40 41 PCUT_INIT; 41 42 42 43 PCUT_TEST_SUITE(wdecor); 43 44 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);45 static errno_t testgc_set_color(void *, gfx_color_t *);46 static errno_t testgc_fill_rect(void *, gfx_rect_t *);47 static errno_t testgc_update(void *);48 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,49 gfx_bitmap_alloc_t *, void **);50 static errno_t testgc_bitmap_destroy(void *);51 static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);52 static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);53 54 static gfx_context_ops_t ops = {55 .set_clip_rect = testgc_set_clip_rect,56 .set_color = testgc_set_color,57 .fill_rect = testgc_fill_rect,58 .update = testgc_update,59 .bitmap_create = testgc_bitmap_create,60 .bitmap_destroy = testgc_bitmap_destroy,61 .bitmap_render = testgc_bitmap_render,62 .bitmap_get_alloc = testgc_bitmap_get_alloc63 };64 44 65 45 static void test_wdecor_sysmenu_open(ui_wdecor_t *, void *, sysarg_t); … … 93 73 static ui_wdecor_cb_t dummy_wdecor_cb = { 94 74 }; 95 96 typedef struct {97 bool bm_created;98 bool bm_destroyed;99 gfx_bitmap_params_t bm_params;100 void *bm_pixels;101 gfx_rect_t bm_srect;102 gfx_coord2_t bm_offs;103 bool bm_rendered;104 bool bm_got_alloc;105 } test_gc_t;106 107 typedef struct {108 test_gc_t *tgc;109 gfx_bitmap_alloc_t alloc;110 bool myalloc;111 } testgc_bitmap_t;112 75 113 76 typedef struct { … … 1567 1530 } 1568 1531 1569 static errno_t testgc_set_clip_rect(void *arg, gfx_rect_t *rect)1570 {1571 (void) arg;1572 (void) rect;1573 return EOK;1574 }1575 1576 static errno_t testgc_set_color(void *arg, gfx_color_t *color)1577 {1578 (void) arg;1579 (void) color;1580 return EOK;1581 }1582 1583 static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)1584 {1585 (void) arg;1586 (void) rect;1587 return EOK;1588 }1589 1590 static errno_t testgc_update(void *arg)1591 {1592 (void) arg;1593 return EOK;1594 }1595 1596 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,1597 gfx_bitmap_alloc_t *alloc, void **rbm)1598 {1599 test_gc_t *tgc = (test_gc_t *) arg;1600 testgc_bitmap_t *tbm;1601 1602 tbm = calloc(1, sizeof(testgc_bitmap_t));1603 if (tbm == NULL)1604 return ENOMEM;1605 1606 if (alloc == NULL) {1607 tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *1608 sizeof(uint32_t);1609 tbm->alloc.off0 = 0;1610 tbm->alloc.pixels = calloc(sizeof(uint32_t),1611 (params->rect.p1.x - params->rect.p0.x) *1612 (params->rect.p1.y - params->rect.p0.y));1613 tbm->myalloc = true;1614 if (tbm->alloc.pixels == NULL) {1615 free(tbm);1616 return ENOMEM;1617 }1618 } else {1619 tbm->alloc = *alloc;1620 }1621 1622 tbm->tgc = tgc;1623 tgc->bm_created = true;1624 tgc->bm_params = *params;1625 tgc->bm_pixels = tbm->alloc.pixels;1626 *rbm = (void *)tbm;1627 return EOK;1628 }1629 1630 static errno_t testgc_bitmap_destroy(void *bm)1631 {1632 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;1633 if (tbm->myalloc)1634 free(tbm->alloc.pixels);1635 tbm->tgc->bm_destroyed = true;1636 free(tbm);1637 return EOK;1638 }1639 1640 static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,1641 gfx_coord2_t *offs)1642 {1643 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;1644 tbm->tgc->bm_rendered = true;1645 tbm->tgc->bm_srect = *srect;1646 tbm->tgc->bm_offs = *offs;1647 return EOK;1648 }1649 1650 static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)1651 {1652 testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;1653 *alloc = tbm->alloc;1654 tbm->tgc->bm_got_alloc = true;1655 return EOK;1656 }1657 1658 1532 static void test_wdecor_sysmenu_open(ui_wdecor_t *wdecor, void *arg, 1659 1533 sysarg_t idev_id)
Note:
See TracChangeset
for help on using the changeset viewer.