Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 62223ec in mainline for uspace/lib/ui/test/window.c


Ignore:
Timestamp:
2021-04-09T22:41:22Z (8 months ago)
Author:
jxsvoboda <5887334+jxsvoboda@…>
Branches:
master
Children:
f251883
Parents:
0262f16c
git-author:
Jiri Svoboda <jiri@…> (2021-04-01 21:04:11)
git-committer:
jxsvoboda <5887334+jxsvoboda@…> (2021-04-09 22:41:22)
Message:

Close menu when window is unfocused

This of course means we need to do all the plumbing for delivering
unfocus event to UI controls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/test/window.c

    r0262f16c r62223ec  
    6666static errno_t test_ctl_paint(void *);
    6767static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *);
     68static void test_ctl_unfocus(void *);
    6869
    6970static ui_control_ops_t test_ctl_ops = {
    7071        .paint = test_ctl_paint,
    71         .pos_event = test_ctl_pos_event
     72        .pos_event = test_ctl_pos_event,
     73        .unfocus = test_ctl_unfocus
    7274};
    7375
     
    9092        bool pos;
    9193        pos_event_t pos_event;
     94        bool unfocus;
    9295} test_ctl_resp_t;
    9396
     
    388391        PCUT_ASSERT_INT_EQUALS(event.hpos, resp.pos_event.hpos);
    389392        PCUT_ASSERT_INT_EQUALS(event.vpos, resp.pos_event.vpos);
     393
     394        /* Need to remove first because we didn't implement the destructor */
     395        ui_window_remove(window, control);
     396
     397        ui_window_destroy(window);
     398        ui_destroy(ui);
     399}
     400
     401/** ui_window_def_unfocus() delivers unfocus event to control in window */
     402PCUT_TEST(def_unfocus)
     403{
     404        errno_t rc;
     405        ui_t *ui = NULL;
     406        ui_wnd_params_t params;
     407        ui_window_t *window = NULL;
     408        ui_control_t *control = NULL;
     409        test_ctl_resp_t resp;
     410
     411        rc = ui_create_disp(NULL, &ui);
     412        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     413
     414        ui_wnd_params_init(&params);
     415        params.caption = "Hello";
     416
     417        rc = ui_window_create(ui, &params, &window);
     418        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     419
     420        rc = ui_control_new(&test_ctl_ops, &resp, &control);
     421        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     422
     423        ui_window_add(window, control);
     424
     425        resp.unfocus = false;
     426
     427        ui_window_def_unfocus(window);
     428        PCUT_ASSERT_TRUE(resp.unfocus);
    390429
    391430        /* Need to remove first because we didn't implement the destructor */
     
    701740}
    702741
     742static void test_ctl_unfocus(void *arg)
     743{
     744        test_ctl_resp_t *resp = (test_ctl_resp_t *) arg;
     745
     746        resp->unfocus = true;
     747}
     748
    703749PCUT_EXPORT(window);
Note: See TracChangeset for help on using the changeset viewer.