Changeset 4df6607 in mainline for uspace/lib/ui/test


Ignore:
Timestamp:
2020-11-01T18:37:09Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c6f00b40
Parents:
8009dc27
Message:

Paint controls via layout

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

Legend:

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

    r8009dc27 r4df6607  
    2727 */
    2828
     29#include <errno.h>
    2930#include <mem.h>
    3031#include <io/pos_event.h>
     
    3839PCUT_TEST_SUITE(control);
    3940
     41static errno_t test_ctl_paint(void *);
    4042static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *);
    4143
    4244static ui_control_ops_t test_ctl_ops = {
     45        .paint = test_ctl_paint,
    4346        .pos_event = test_ctl_pos_event
    4447};
     
    4851        /** Claim to return */
    4952        ui_evclaim_t claim;
     53        /** Result code to return */
     54        errno_t rc;
     55
     56        /** @c true iff paint was called */
     57        bool paint;
    5058
    5159        /** @c true iff pos_event was called */
     
    7280{
    7381        ui_control_delete(NULL);
     82}
     83
     84/** Test sending paint request to control */
     85PCUT_TEST(paint)
     86{
     87        ui_control_t *control = NULL;
     88        test_resp_t resp;
     89        errno_t rc;
     90
     91        rc = ui_control_new(&test_ctl_ops, &resp, &control);
     92        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     93        PCUT_ASSERT_NOT_NULL(control);
     94
     95        resp.rc = EOK;
     96        resp.paint = false;
     97
     98        rc = ui_control_paint(control);
     99        PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
     100        PCUT_ASSERT_TRUE(resp.paint);
     101
     102        resp.rc = EINVAL;
     103        resp.paint = false;
     104
     105        rc = ui_control_paint(control);
     106        PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
     107        PCUT_ASSERT_TRUE(resp.paint);
     108
     109        ui_control_delete(control);
    74110}
    75111
     
    107143}
    108144
     145static errno_t test_ctl_paint(void *arg)
     146{
     147        test_resp_t *resp = (test_resp_t *) arg;
     148
     149        resp->paint = true;
     150        return resp->rc;
     151}
     152
    109153static ui_evclaim_t test_ctl_pos_event(void *arg, pos_event_t *event)
    110154{
  • uspace/lib/ui/test/fixed.c

    r8009dc27 r4df6607  
    2727 */
    2828
     29#include <errno.h>
    2930#include <pcut/pcut.h>
    3031#include <stddef.h>
     
    3738PCUT_TEST_SUITE(fixed);
    3839
     40static errno_t test_ctl_paint(void *);
    3941static ui_evclaim_t test_ctl_pos_event(void *, pos_event_t *);
    4042
    4143static ui_control_ops_t test_ctl_ops = {
     44        .paint = test_ctl_paint,
    4245        .pos_event = test_ctl_pos_event
    4346};
     
    4750        /** Claim to return */
    4851        ui_evclaim_t claim;
     52        /** Result code to return */
     53        errno_t rc;
     54
     55        /** @c true iff paint was called */
     56        bool paint;
    4957
    5058        /** @c true iff pos_event was called */
     
    107115}
    108116
    109 /** ui_pos_event() delivers position event to control */
     117/** ui_fixed_paint() delivers paint request to control */
     118PCUT_TEST(paint)
     119{
     120        ui_fixed_t *fixed = NULL;
     121        ui_control_t *control;
     122        test_resp_t resp;
     123        errno_t rc;
     124
     125        rc = ui_fixed_create(&fixed);
     126        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     127
     128        rc = ui_control_new(&test_ctl_ops, (void *) &resp, &control);
     129        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     130
     131        rc = ui_fixed_add(fixed, control);
     132        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     133
     134        resp.paint = false;
     135        resp.rc = EOK;
     136
     137        rc = ui_fixed_paint(fixed);
     138        PCUT_ASSERT_EQUALS(resp.rc, rc);
     139        PCUT_ASSERT_TRUE(resp.paint);
     140
     141        resp.paint = false;
     142        resp.rc = EINVAL;
     143
     144        rc = ui_fixed_paint(fixed);
     145        PCUT_ASSERT_EQUALS(resp.rc, rc);
     146        PCUT_ASSERT_TRUE(resp.paint);
     147
     148        ui_fixed_remove(fixed, control);
     149        ui_fixed_destroy(fixed);
     150}
     151
     152/** ui_fixed_pos_event() delivers position event to control */
    110153PCUT_TEST(pos_event)
    111154{
     
    147190}
    148191
     192static errno_t test_ctl_paint(void *arg)
     193{
     194        test_resp_t *resp = (test_resp_t *) arg;
     195
     196        resp->paint = true;
     197        return resp->rc;
     198}
     199
    149200static ui_evclaim_t test_ctl_pos_event(void *arg, pos_event_t *event)
    150201{
Note: See TracChangeset for help on using the changeset viewer.