Ignore:
File:
1 edited

Legend:

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

    rb71c0fc r46a47c0  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2023 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    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 *, unsigned);
    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;
     68        /** Number of remaining foci */
     69        unsigned unfocus_nfocus;
    6470} test_resp_t;
    6571
     
    230236}
    231237
     238/** ui_fixed_unfocus() delivers unfocus notification to control */
     239PCUT_TEST(unfocus)
     240{
     241        ui_fixed_t *fixed = NULL;
     242        ui_control_t *control;
     243        test_resp_t resp;
     244        errno_t rc;
     245
     246        rc = ui_fixed_create(&fixed);
     247        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     248
     249        rc = ui_control_new(&test_ctl_ops, (void *) &resp, &control);
     250        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     251
     252        rc = ui_fixed_add(fixed, control);
     253        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     254
     255        resp.unfocus = false;
     256
     257        ui_fixed_unfocus(fixed, 42);
     258        PCUT_ASSERT_TRUE(resp.unfocus);
     259        PCUT_ASSERT_INT_EQUALS(42, resp.unfocus_nfocus);
     260
     261        ui_fixed_destroy(fixed);
     262}
     263
    232264static void test_ctl_destroy(void *arg)
    233265{
     
    255287}
    256288
     289static void test_ctl_unfocus(void *arg, unsigned nfocus)
     290{
     291        test_resp_t *resp = (test_resp_t *) arg;
     292
     293        resp->unfocus = true;
     294        resp->unfocus_nfocus = nfocus;
     295}
     296
    257297PCUT_EXPORT(fixed);
Note: See TracChangeset for help on using the changeset viewer.