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


Ignore:
Timestamp:
2020-11-01T22:49:05Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4ac11ff
Parents:
4df6607
git-author:
Jiri Svoboda <jiri@…> (2020-11-01 22:47:03)
git-committer:
Jiri Svoboda <jiri@…> (2020-11-01 22:49:05)
Message:

Add virtual destructor for UI control

File:
1 edited

Legend:

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

    r4df6607 rc6f00b40  
    3838PCUT_TEST_SUITE(fixed);
    3939
     40static void test_ctl_destroy(void *);
    4041static errno_t test_ctl_paint(void *);
    4142static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *);
    4243
    4344static ui_control_ops_t test_ctl_ops = {
     45        .destroy = test_ctl_destroy,
    4446        .paint = test_ctl_paint,
    4547        .pos_event = test_ctl_pos_event
     
    5254        /** Result code to return */
    5355        errno_t rc;
    54 
     56        /** @c true iff destroy was called */
     57        bool destroy;
    5558        /** @c true iff paint was called */
    5659        bool paint;
    57 
    5860        /** @c true iff pos_event was called */
    5961        bool pos;
     
    113115
    114116        ui_fixed_destroy(fixed);
     117        ui_control_delete(control);
     118}
     119
     120/** ui_fixed_destroy() delivers destroy request to control */
     121PCUT_TEST(destroy)
     122{
     123        ui_fixed_t *fixed = NULL;
     124        ui_control_t *control;
     125        test_resp_t resp;
     126        errno_t rc;
     127
     128        rc = ui_fixed_create(&fixed);
     129        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     130
     131        rc = ui_control_new(&test_ctl_ops, (void *) &resp, &control);
     132        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     133
     134        rc = ui_fixed_add(fixed, control);
     135        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     136
     137        resp.destroy = false;
     138
     139        ui_fixed_destroy(fixed);
     140        PCUT_ASSERT_TRUE(resp.destroy);
    115141}
    116142
     
    146172        PCUT_ASSERT_TRUE(resp.paint);
    147173
    148         ui_fixed_remove(fixed, control);
    149174        ui_fixed_destroy(fixed);
    150175}
     
    186211        PCUT_ASSERT_INT_EQUALS(resp.pevent.vpos, event.vpos);
    187212
    188         ui_fixed_remove(fixed, control);
    189         ui_fixed_destroy(fixed);
     213        ui_fixed_destroy(fixed);
     214}
     215
     216static void test_ctl_destroy(void *arg)
     217{
     218        test_resp_t *resp = (test_resp_t *) arg;
     219
     220        resp->destroy = true;
    190221}
    191222
Note: See TracChangeset for help on using the changeset viewer.