Changeset d4ea1f6 in mainline for uspace/lib/ui/test/pbutton.c
- Timestamp:
- 2022-03-21T17:38:57Z (2 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8965860c
- Parents:
- 26c90dd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/pbutton.c
r26c90dd rd4ea1f6 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 *); 65 67 66 68 static ui_pbutton_cb_t test_pbutton_cb = { 67 .clicked = test_pbutton_clicked 69 .clicked = test_pbutton_clicked, 70 .down = test_pbutton_down, 71 .up = test_pbutton_up 68 72 }; 69 73 … … 90 94 typedef struct { 91 95 bool clicked; 96 bool down; 97 bool up; 92 98 } test_cb_resp_t; 93 99 … … 225 231 } 226 232 233 /** Test ui_pbutton_down() */ 234 PCUT_TEST(down) 235 { 236 errno_t rc; 237 ui_pbutton_t *pbutton; 238 test_cb_resp_t resp; 239 240 rc = ui_pbutton_create(NULL, "Hello", &pbutton); 241 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 242 243 /* Down with no callbacks set */ 244 ui_pbutton_clicked(pbutton); 245 246 /* Down with callback not implementing down */ 247 ui_pbutton_set_cb(pbutton, &dummy_pbutton_cb, NULL); 248 ui_pbutton_down(pbutton); 249 250 /* Down with real callback set */ 251 resp.down = false; 252 ui_pbutton_set_cb(pbutton, &test_pbutton_cb, &resp); 253 ui_pbutton_down(pbutton); 254 PCUT_ASSERT_TRUE(resp.down); 255 256 ui_pbutton_destroy(pbutton); 257 } 258 259 /** Test ui_pbutton_up() */ 260 PCUT_TEST(up) 261 { 262 errno_t rc; 263 ui_pbutton_t *pbutton; 264 test_cb_resp_t resp; 265 266 rc = ui_pbutton_create(NULL, "Hello", &pbutton); 267 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 268 269 /* Up with no callbacks set */ 270 ui_pbutton_clicked(pbutton); 271 272 /* Up with callback not implementing up */ 273 ui_pbutton_set_cb(pbutton, &dummy_pbutton_cb, NULL); 274 ui_pbutton_up(pbutton); 275 276 /* Up with real callback set */ 277 resp.up = false; 278 ui_pbutton_set_cb(pbutton, &test_pbutton_cb, &resp); 279 ui_pbutton_up(pbutton); 280 PCUT_ASSERT_TRUE(resp.up); 281 282 ui_pbutton_destroy(pbutton); 283 } 284 227 285 /** Press and release button */ 228 286 PCUT_TEST(press_release) … … 247 305 248 306 resp.clicked = false; 307 resp.down = false; 308 resp.up = false; 249 309 ui_pbutton_set_cb(pbutton, &test_pbutton_cb, &resp); 250 310 … … 255 315 PCUT_ASSERT_TRUE(pbutton->held); 256 316 PCUT_ASSERT_TRUE(pbutton->inside); 317 PCUT_ASSERT_TRUE(resp.down); 318 PCUT_ASSERT_FALSE(resp.up); 257 319 PCUT_ASSERT_FALSE(resp.clicked); 258 320 … … 260 322 PCUT_ASSERT_FALSE(pbutton->held); 261 323 PCUT_ASSERT_TRUE(pbutton->inside); 324 PCUT_ASSERT_TRUE(resp.up); 262 325 PCUT_ASSERT_TRUE(resp.clicked); 263 326 … … 588 651 } 589 652 653 static void test_pbutton_down(ui_pbutton_t *pbutton, void *arg) 654 { 655 test_cb_resp_t *resp = (test_cb_resp_t *) arg; 656 657 resp->down = true; 658 } 659 660 static void test_pbutton_up(ui_pbutton_t *pbutton, void *arg) 661 { 662 test_cb_resp_t *resp = (test_cb_resp_t *) arg; 663 664 resp->up = true; 665 } 666 590 667 PCUT_EXPORT(pbutton);
Note:
See TracChangeset
for help on using the changeset viewer.