Changeset c6f00b40 in mainline for uspace/lib/ui/test


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

Location:
uspace/lib/ui/test
Files:
2 edited

Legend:

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

    r4df6607 rc6f00b40  
    2121 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    2222 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23 * DATA, OR PROFITS; OR BUSINESS INTvvhhzccgggrERRUPTION) HOWEVER CAUSED AND ON ANY
    2424 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2525 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     
    3939PCUT_TEST_SUITE(control);
    4040
     41static void test_ctl_destroy(void *);
    4142static errno_t test_ctl_paint(void *);
    4243static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *);
    4344
    4445static ui_control_ops_t test_ctl_ops = {
     46        .destroy = test_ctl_destroy,
    4547        .paint = test_ctl_paint,
    4648        .pos_event = test_ctl_pos_event
     
    5355        /** Result code to return */
    5456        errno_t rc;
     57
     58        /** @c true iff destroy was called */
     59        bool destroy;
    5560
    5661        /** @c true iff paint was called */
     
    8085{
    8186        ui_control_delete(NULL);
     87}
     88
     89/** Test sending destroy request to control */
     90PCUT_TEST(destroy)
     91{
     92        ui_control_t *control = NULL;
     93        test_resp_t resp;
     94        errno_t rc;
     95
     96        rc = ui_control_new(&test_ctl_ops, &resp, &control);
     97        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     98        PCUT_ASSERT_NOT_NULL(control);
     99
     100        resp.rc = EOK;
     101        resp.destroy = false;
     102
     103        ui_control_destroy(control);
     104        PCUT_ASSERT_TRUE(resp.destroy);
    82105}
    83106
     
    143166}
    144167
     168static void test_ctl_destroy(void *arg)
     169{
     170        test_resp_t *resp = (test_resp_t *) arg;
     171
     172        resp->destroy = true;
     173}
     174
    145175static errno_t test_ctl_paint(void *arg)
    146176{
  • 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.