Changes in uspace/lib/ui/test/pbutton.c [3c54869:7470d97] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/pbutton.c
r3c54869 r7470d97 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 63 63 64 64 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 65 68 66 static ui_pbutton_cb_t test_pbutton_cb = { 69 .clicked = test_pbutton_clicked, 70 .down = test_pbutton_down, 71 .up = test_pbutton_up 67 .clicked = test_pbutton_clicked 72 68 }; 73 69 … … 94 90 typedef struct { 95 91 bool clicked; 96 bool down;97 bool up;98 92 } test_cb_resp_t; 99 93 … … 131 125 132 126 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 127 } 149 128 … … 190 169 } 191 170 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 171 /** Paint button */ 248 172 PCUT_TEST(paint) … … 301 225 } 302 226 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 227 /** Press and release button */ 356 228 PCUT_TEST(press_release) … … 375 247 376 248 resp.clicked = false; 377 resp.down = false;378 resp.up = false;379 249 ui_pbutton_set_cb(pbutton, &test_pbutton_cb, &resp); 380 250 … … 385 255 PCUT_ASSERT_TRUE(pbutton->held); 386 256 PCUT_ASSERT_TRUE(pbutton->inside); 387 PCUT_ASSERT_TRUE(resp.down);388 PCUT_ASSERT_FALSE(resp.up);389 257 PCUT_ASSERT_FALSE(resp.clicked); 390 258 … … 392 260 PCUT_ASSERT_FALSE(pbutton->held); 393 261 PCUT_ASSERT_TRUE(pbutton->inside); 394 PCUT_ASSERT_TRUE(resp.up);395 262 PCUT_ASSERT_TRUE(resp.clicked); 396 263 … … 721 588 } 722 589 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 590 PCUT_EXPORT(pbutton);
Note:
See TracChangeset
for help on using the changeset viewer.