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


Ignore:
Timestamp:
2021-04-09T22:41:22Z (3 years ago)
Author:
jxsvoboda <5887334+jxsvoboda@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
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/fixed.c

    r0262f16c r62223ec  
    4141static errno_t test_ctl_paint(void *);
    4242static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *);
     43static void test_ctl_unfocus(void *);
    4344
    4445static ui_control_ops_t test_ctl_ops = {
    4546        .destroy = test_ctl_destroy,
    4647        .paint = test_ctl_paint,
    47         .pos_event = test_ctl_pos_event
     48        .pos_event = test_ctl_pos_event,
     49        .unfocus = test_ctl_unfocus
    4850};
    4951
     
    6264        /** Position event that was sent */
    6365        pos_event_t pevent;
     66        /** @c true iff unfocus was called */
     67        bool unfocus;
    6468} test_resp_t;
    6569
     
    230234}
    231235
     236/** ui_fixed_unfocus() delivers unfocus notification to control */
     237PCUT_TEST(unfocus)
     238{
     239        ui_fixed_t *fixed = NULL;
     240        ui_control_t *control;
     241        test_resp_t resp;
     242        errno_t rc;
     243
     244        rc = ui_fixed_create(&fixed);
     245        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     246
     247        rc = ui_control_new(&test_ctl_ops, (void *) &resp, &control);
     248        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     249
     250        rc = ui_fixed_add(fixed, control);
     251        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     252
     253        resp.unfocus = false;
     254
     255        ui_fixed_unfocus(fixed);
     256        PCUT_ASSERT_TRUE(resp.unfocus);
     257
     258        ui_fixed_destroy(fixed);
     259}
     260
    232261static void test_ctl_destroy(void *arg)
    233262{
     
    255284}
    256285
     286static void test_ctl_unfocus(void *arg)
     287{
     288        test_resp_t *resp = (test_resp_t *) arg;
     289
     290        resp->unfocus = true;
     291}
     292
    257293PCUT_EXPORT(fixed);
Note: See TracChangeset for help on using the changeset viewer.