Changes in uspace/lib/ui/test/pbutton.c [3c54869:3583ffb] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/pbutton.c
r3c54869 r3583ffb 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2020 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 41 41 PCUT_TEST_SUITE(pbutton); 42 42 43 static errno_t testgc_set_clip_rect(void *, gfx_rect_t *);44 43 static errno_t testgc_set_color(void *, gfx_color_t *); 45 44 static errno_t testgc_fill_rect(void *, gfx_rect_t *); 46 static errno_t testgc_update(void *);47 45 static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *, 48 46 gfx_bitmap_alloc_t *, void **); … … 52 50 53 51 static gfx_context_ops_t ops = { 54 .set_clip_rect = testgc_set_clip_rect,55 52 .set_color = testgc_set_color, 56 53 .fill_rect = testgc_fill_rect, 57 .update = testgc_update,58 54 .bitmap_create = testgc_bitmap_create, 59 55 .bitmap_destroy = testgc_bitmap_destroy, … … 63 59 64 60 static void test_pbutton_clicked(ui_pbutton_t *, void *); 65 static void test_pbutton_down(ui_pbutton_t *, void *);66 static void test_pbutton_up(ui_pbutton_t *, void *);67 61 68 62 static ui_pbutton_cb_t test_pbutton_cb = { 69 .clicked = test_pbutton_clicked, 70 .down = test_pbutton_down, 71 .up = test_pbutton_up 63 .clicked = test_pbutton_clicked 72 64 }; 73 65 … … 94 86 typedef struct { 95 87 bool clicked; 96 bool down;97 bool up;98 88 } test_cb_resp_t; 99 89 … … 131 121 132 122 ui_control_destroy(control); 133 }134 135 /** Set flags sets internal field */136 PCUT_TEST(set_flags)137 {138 ui_pbutton_t *pbutton;139 errno_t rc;140 141 rc = ui_pbutton_create(NULL, "Hello", &pbutton);142 PCUT_ASSERT_ERRNO_VAL(EOK, rc);143 144 ui_pbutton_set_flags(pbutton, ui_pbf_no_text_depress);145 PCUT_ASSERT_INT_EQUALS(ui_pbf_no_text_depress, pbutton->flags);146 147 ui_pbutton_destroy(pbutton);148 123 } 149 124 … … 190 165 } 191 166 192 /** Get light gets internal field */193 PCUT_TEST(get_light)194 {195 ui_pbutton_t *pbutton;196 errno_t rc;197 198 rc = ui_pbutton_create(NULL, "Hello", &pbutton);199 PCUT_ASSERT_ERRNO_VAL(EOK, rc);200 201 pbutton->light = true;202 PCUT_ASSERT_TRUE(ui_pbutton_get_light(pbutton));203 204 pbutton->light = false;205 PCUT_ASSERT_FALSE(ui_pbutton_get_light(pbutton));206 207 ui_pbutton_destroy(pbutton);208 }209 210 /** Set light sets internal field */211 PCUT_TEST(set_light)212 {213 ui_pbutton_t *pbutton;214 errno_t rc;215 216 rc = ui_pbutton_create(NULL, "Hello", &pbutton);217 PCUT_ASSERT_ERRNO_VAL(EOK, rc);218 219 ui_pbutton_set_light(pbutton, true);220 PCUT_ASSERT_TRUE(pbutton->light);221 222 ui_pbutton_set_light(pbutton, false);223 PCUT_ASSERT_FALSE(pbutton->light);224 225 ui_pbutton_destroy(pbutton);226 }227 228 /** Set caption sets internal field */229 PCUT_TEST(set_caption)230 {231 ui_pbutton_t *pbutton;232 errno_t rc;233 234 rc = ui_pbutton_create(NULL, "Hello", &pbutton);235 PCUT_ASSERT_ERRNO_VAL(EOK, rc);236 237 PCUT_ASSERT_STR_EQUALS("Hello", pbutton->caption);238 239 rc = ui_pbutton_set_caption(pbutton, "World");240 PCUT_ASSERT_ERRNO_VAL(EOK, rc);241 242 PCUT_ASSERT_STR_EQUALS("World", pbutton->caption);243 244 ui_pbutton_destroy(pbutton);245 }246 247 167 /** Paint button */ 248 168 PCUT_TEST(paint) … … 258 178 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 259 179 260 rc = ui_resource_create(gc, false,&resource);180 rc = ui_resource_create(gc, &resource); 261 181 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 262 182 PCUT_ASSERT_NOT_NULL(resource); … … 301 221 } 302 222 303 /** Test ui_pbutton_down() */304 PCUT_TEST(down)305 {306 errno_t rc;307 ui_pbutton_t *pbutton;308 test_cb_resp_t resp;309 310 rc = ui_pbutton_create(NULL, "Hello", &pbutton);311 PCUT_ASSERT_ERRNO_VAL(EOK, rc);312 313 /* Down with no callbacks set */314 ui_pbutton_clicked(pbutton);315 316 /* Down with callback not implementing down */317 ui_pbutton_set_cb(pbutton, &dummy_pbutton_cb, NULL);318 ui_pbutton_down(pbutton);319 320 /* Down with real callback set */321 resp.down = false;322 ui_pbutton_set_cb(pbutton, &test_pbutton_cb, &resp);323 ui_pbutton_down(pbutton);324 PCUT_ASSERT_TRUE(resp.down);325 326 ui_pbutton_destroy(pbutton);327 }328 329 /** Test ui_pbutton_up() */330 PCUT_TEST(up)331 {332 errno_t rc;333 ui_pbutton_t *pbutton;334 test_cb_resp_t resp;335 336 rc = ui_pbutton_create(NULL, "Hello", &pbutton);337 PCUT_ASSERT_ERRNO_VAL(EOK, rc);338 339 /* Up with no callbacks set */340 ui_pbutton_clicked(pbutton);341 342 /* Up with callback not implementing up */343 ui_pbutton_set_cb(pbutton, &dummy_pbutton_cb, NULL);344 ui_pbutton_up(pbutton);345 346 /* Up with real callback set */347 resp.up = false;348 ui_pbutton_set_cb(pbutton, &test_pbutton_cb, &resp);349 ui_pbutton_up(pbutton);350 PCUT_ASSERT_TRUE(resp.up);351 352 ui_pbutton_destroy(pbutton);353 }354 355 223 /** Press and release button */ 356 224 PCUT_TEST(press_release) … … 367 235 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 368 236 369 rc = ui_resource_create(gc, false,&resource);237 rc = ui_resource_create(gc, &resource); 370 238 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 371 239 PCUT_ASSERT_NOT_NULL(resource); … … 375 243 376 244 resp.clicked = false; 377 resp.down = false;378 resp.up = false;379 245 ui_pbutton_set_cb(pbutton, &test_pbutton_cb, &resp); 380 246 … … 385 251 PCUT_ASSERT_TRUE(pbutton->held); 386 252 PCUT_ASSERT_TRUE(pbutton->inside); 387 PCUT_ASSERT_TRUE(resp.down);388 PCUT_ASSERT_FALSE(resp.up);389 253 PCUT_ASSERT_FALSE(resp.clicked); 390 254 … … 392 256 PCUT_ASSERT_FALSE(pbutton->held); 393 257 PCUT_ASSERT_TRUE(pbutton->inside); 394 PCUT_ASSERT_TRUE(resp.up);395 258 PCUT_ASSERT_TRUE(resp.clicked); 396 259 … … 416 279 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 417 280 418 rc = ui_resource_create(gc, false,&resource);281 rc = ui_resource_create(gc, &resource); 419 282 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 420 283 PCUT_ASSERT_NOT_NULL(resource); … … 465 328 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 466 329 467 rc = ui_resource_create(gc, false,&resource);330 rc = ui_resource_create(gc, &resource); 468 331 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 469 332 PCUT_ASSERT_NOT_NULL(resource); … … 521 384 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 522 385 523 rc = ui_resource_create(gc, false,&resource);386 rc = ui_resource_create(gc, &resource); 524 387 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 525 388 PCUT_ASSERT_NOT_NULL(resource); … … 582 445 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 583 446 584 rc = ui_resource_create(gc, false,&resource);447 rc = ui_resource_create(gc, &resource); 585 448 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 586 449 PCUT_ASSERT_NOT_NULL(resource); … … 625 488 } 626 489 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 490 static errno_t testgc_set_color(void *arg, gfx_color_t *color) 635 491 { … … 643 499 (void) arg; 644 500 (void) rect; 645 return EOK;646 }647 648 static errno_t testgc_update(void *arg)649 {650 (void) arg;651 501 return EOK; 652 502 } … … 721 571 } 722 572 723 static void test_pbutton_down(ui_pbutton_t *pbutton, void *arg)724 {725 test_cb_resp_t *resp = (test_cb_resp_t *) arg;726 727 resp->down = true;728 }729 730 static void test_pbutton_up(ui_pbutton_t *pbutton, void *arg)731 {732 test_cb_resp_t *resp = (test_cb_resp_t *) arg;733 734 resp->up = true;735 }736 737 573 PCUT_EXPORT(pbutton);
Note:
See TracChangeset
for help on using the changeset viewer.