Changeset f1f433d in mainline for uspace/lib
- Timestamp:
- 2022-11-04T20:54:04Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3a6d44b7
- Parents:
- fc00f0d
- Location:
- uspace/lib
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/include/ui/pbutton.h
rfc00f0d rf1f433d 56 56 extern void ui_pbutton_set_rect(ui_pbutton_t *, gfx_rect_t *); 57 57 extern void ui_pbutton_set_default(ui_pbutton_t *, bool); 58 extern errno_t ui_pbutton_set_caption(ui_pbutton_t *, const char *); 58 59 extern errno_t ui_pbutton_paint(ui_pbutton_t *); 59 60 extern void ui_pbutton_press(ui_pbutton_t *); -
uspace/lib/ui/private/pbutton.h
rfc00f0d rf1f433d 62 62 gfx_rect_t rect; 63 63 /** Caption */ 64 c onst char *caption;64 char *caption; 65 65 /** Button is selected as default */ 66 66 bool isdefault; -
uspace/lib/ui/src/pbutton.c
rfc00f0d rf1f433d 114 114 115 115 ui_control_delete(pbutton->control); 116 free(pbutton->caption); 116 117 free(pbutton); 117 118 } … … 183 184 { 184 185 pbutton->isdefault = isdefault; 186 } 187 188 /** Set push button caption. 189 * 190 * @param pbutton Button 191 * @param caption New caption 192 * @return EOK on success, ENOMEM if out of memory 193 */ 194 errno_t ui_pbutton_set_caption(ui_pbutton_t *pbutton, const char *caption) 195 { 196 char *dcaption; 197 198 dcaption = str_dup(caption); 199 if (dcaption == NULL) 200 return ENOMEM; 201 202 free(pbutton->caption); 203 pbutton->caption = dcaption; 204 return EOK; 185 205 } 186 206 -
uspace/lib/ui/test/pbutton.c
rfc00f0d rf1f433d 190 190 } 191 191 192 /** Set caption sets internal field */ 193 PCUT_TEST(set_caption) 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 PCUT_ASSERT_STR_EQUALS("Hello", pbutton->caption); 202 203 rc = ui_pbutton_set_caption(pbutton, "World"); 204 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 205 206 PCUT_ASSERT_STR_EQUALS("World", pbutton->caption); 207 208 ui_pbutton_destroy(pbutton); 209 } 210 192 211 /** Paint button */ 193 212 PCUT_TEST(paint) -
uspace/lib/wndmgt/include/types/wndmgt.h
rfc00f0d rf1f433d 53 53 /** Window removed */ 54 54 void (*window_removed)(void *, sysarg_t); 55 /** Window changed */ 56 void (*window_changed)(void *, sysarg_t); 55 57 } wndmgt_cb_t; 56 58 … … 60 62 wmev_window_added, 61 63 /** Window removed */ 62 wmev_window_removed 64 wmev_window_removed, 65 /** Window changed */ 66 wmev_window_changed 63 67 } wndmgt_ev_type_t; 64 68 -
uspace/lib/wndmgt/src/wndmgt.c
rfc00f0d rf1f433d 387 387 } 388 388 break; 389 case wmev_window_changed: 390 if (wndmgt->cb != NULL && 391 wndmgt->cb->window_changed != NULL) { 392 wndmgt->cb->window_changed(wndmgt->cb_arg, 393 event.wnd_id); 394 } 395 break; 389 396 } 390 397 } -
uspace/lib/wndmgt/test/wndmgt.c
rfc00f0d rf1f433d 54 54 static void test_window_added(void *, sysarg_t); 55 55 static void test_window_removed(void *, sysarg_t); 56 static void test_window_changed(void *, sysarg_t); 56 57 57 58 static wndmgt_ops_t test_wndmgt_srv_ops = { … … 65 66 static wndmgt_cb_t test_wndmgt_cb = { 66 67 .window_added = test_window_added, 67 .window_removed = test_window_removed 68 .window_removed = test_window_removed, 69 .window_changed = test_window_changed 68 70 }; 69 71 … … 98 100 bool window_removed_called; 99 101 sysarg_t window_removed_wnd_id; 102 103 bool window_changed_called; 104 sysarg_t window_changed_wnd_id; 100 105 101 106 fibril_condvar_t event_cv; … … 529 534 } 530 535 536 /** Window changed event can be delivered from server to client callback function */ 537 PCUT_TEST(window_changed_deliver) 538 { 539 errno_t rc; 540 service_id_t sid; 541 wndmgt_t *wndmgt = NULL; 542 test_response_t resp; 543 544 async_set_fallback_port_handler(test_wndmgt_conn, &resp); 545 546 // FIXME This causes this test to be non-reentrant! 547 rc = loc_server_register(test_wndmgt_server); 548 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 549 550 rc = loc_service_register(test_wndmgt_svc, &sid); 551 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 552 553 rc = wndmgt_open(test_wndmgt_svc, &test_wndmgt_cb, &resp, &wndmgt); 554 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 555 PCUT_ASSERT_NOT_NULL(wndmgt); 556 PCUT_ASSERT_NOT_NULL(resp.srv); 557 558 resp.event_cnt = 1; 559 resp.event.etype = wmev_window_changed; 560 resp.event.wnd_id = 42; 561 resp.window_changed_called = false; 562 fibril_mutex_initialize(&resp.event_lock); 563 fibril_condvar_initialize(&resp.event_cv); 564 wndmgt_srv_ev_pending(resp.srv); 565 566 /* Wait for the event handler to be called. */ 567 fibril_mutex_lock(&resp.event_lock); 568 while (!resp.window_changed_called) { 569 fibril_condvar_wait(&resp.event_cv, &resp.event_lock); 570 } 571 fibril_mutex_unlock(&resp.event_lock); 572 573 /* Verify that the event was delivered correctly */ 574 PCUT_ASSERT_INT_EQUALS(resp.event.etype, 575 resp.revent.etype); 576 577 wndmgt_close(wndmgt); 578 579 rc = loc_service_unregister(sid); 580 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 581 } 582 531 583 /** Test window management service connection. */ 532 584 static void test_wndmgt_conn(ipc_call_t *icall, void *arg) … … 569 621 resp->window_removed_called = true; 570 622 resp->window_removed_wnd_id = wnd_id; 623 fibril_condvar_broadcast(&resp->event_cv); 624 fibril_mutex_unlock(&resp->event_lock); 625 } 626 627 static void test_window_changed(void *arg, sysarg_t wnd_id) 628 { 629 test_response_t *resp = (test_response_t *) arg; 630 631 resp->revent.etype = wmev_window_changed; 632 633 fibril_mutex_lock(&resp->event_lock); 634 resp->window_changed_called = true; 635 resp->window_changed_wnd_id = wnd_id; 571 636 fibril_condvar_broadcast(&resp->event_cv); 572 637 fibril_mutex_unlock(&resp->event_lock);
Note:
See TracChangeset
for help on using the changeset viewer.