Changeset f0ccb2a in mainline


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:
4d2a4cd
Parents:
f536a16
git-author:
Jiri Svoboda <jiri@…> (2021-04-02 17:35:19)
git-committer:
jxsvoboda <5887334+jxsvoboda@…> (2021-04-09 22:41:22)
Message:

Fix libui unit tests

Location:
uspace/lib/ui
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/dummygc.c

    rf536a16 rf0ccb2a  
    4343static errno_t dummygc_set_color(void *, gfx_color_t *);
    4444static errno_t dummygc_fill_rect(void *, gfx_rect_t *);
     45static errno_t dummygc_update(void *);
    4546static errno_t dummygc_bitmap_create(void *, gfx_bitmap_params_t *,
    4647    gfx_bitmap_alloc_t *, void **);
     
    5354        .set_color = dummygc_set_color,
    5455        .fill_rect = dummygc_fill_rect,
     56        .update = dummygc_update,
    5557        .bitmap_create = dummygc_bitmap_create,
    5658        .bitmap_destroy = dummygc_bitmap_destroy,
     
    128130        (void) arg;
    129131        (void) rect;
     132        return EOK;
     133}
     134
     135/** Update dummy GC
     136 *
     137 * @param arg Argument (dummy_gc_t)
     138 * @return EOK on success or an error code
     139 */
     140static errno_t dummygc_update(void *arg)
     141{
     142        (void) arg;
    130143        return EOK;
    131144}
  • uspace/lib/ui/test/checkbox.c

    rf536a16 rf0ccb2a  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4343static errno_t testgc_set_color(void *, gfx_color_t *);
    4444static errno_t testgc_fill_rect(void *, gfx_rect_t *);
     45static errno_t testgc_update(void *);
    4546static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    4647    gfx_bitmap_alloc_t *, void **);
     
    5253        .set_color = testgc_set_color,
    5354        .fill_rect = testgc_fill_rect,
     55        .update = testgc_update,
    5456        .bitmap_create = testgc_bitmap_create,
    5557        .bitmap_destroy = testgc_bitmap_destroy,
     
    492494        (void) arg;
    493495        (void) rect;
     496        return EOK;
     497}
     498
     499static errno_t testgc_update(void *arg)
     500{
     501        (void) arg;
    494502        return EOK;
    495503}
  • uspace/lib/ui/test/entry.c

    rf536a16 rf0ccb2a  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4343static errno_t testgc_set_color(void *, gfx_color_t *);
    4444static errno_t testgc_fill_rect(void *, gfx_rect_t *);
     45static errno_t testgc_update(void *);
    4546static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    4647    gfx_bitmap_alloc_t *, void **);
     
    5253        .set_color = testgc_set_color,
    5354        .fill_rect = testgc_fill_rect,
     55        .update = testgc_update,
    5456        .bitmap_create = testgc_bitmap_create,
    5557        .bitmap_destroy = testgc_bitmap_destroy,
     
    220222        (void) arg;
    221223        (void) rect;
     224        return EOK;
     225}
     226
     227static errno_t testgc_update(void *arg)
     228{
     229        (void) arg;
    222230        return EOK;
    223231}
  • uspace/lib/ui/test/image.c

    rf536a16 rf0ccb2a  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3434#include <ui/control.h>
    3535#include <ui/image.h>
     36#include <ui/resource.h>
    3637#include <ui/ui.h>
    3738#include "../private/dummygc.h"
     
    8788PCUT_TEST(set_rect)
    8889{
     90        errno_t rc;
     91        dummy_gc_t *dgc;
     92        gfx_context_t *gc;
     93        ui_resource_t *resource = NULL;
    8994        ui_image_t *image = NULL;
    9095        gfx_rect_t brect;
    9196        gfx_rect_t rect;
    92         errno_t rc;
    93 
    94         rc = ui_image_create(NULL, NULL, &brect, &image);
     97
     98        rc = dummygc_create(&dgc);
     99        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     100
     101        gc = dummygc_get_ctx(dgc);
     102
     103        rc = ui_resource_create(gc, false, &resource);
     104        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     105        PCUT_ASSERT_NOT_NULL(resource);
     106
     107        rc = ui_image_create(resource, NULL, &brect, &image);
    95108        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    96109        PCUT_ASSERT_NOT_NULL(image);
     
    108121
    109122        ui_image_destroy(image);
     123        ui_resource_destroy(resource);
     124        dummygc_destroy(dgc);
    110125}
    111126
     
    139154        dummy_gc_t *dgc;
    140155        gfx_context_t *gc;
     156        ui_resource_t *resource = NULL;
    141157        errno_t rc;
    142158
     
    146162        gc = dummygc_get_ctx(dgc);
    147163
    148         rc = ui_image_create(NULL, NULL, &brect, &image);
     164        rc = ui_resource_create(gc, false, &resource);
     165        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     166        PCUT_ASSERT_NOT_NULL(resource);
     167
     168        rc = ui_image_create(resource, NULL, &brect, &image);
    149169        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    150170        PCUT_ASSERT_NOT_NULL(image);
     
    172192
    173193        ui_image_destroy(image);
     194        ui_resource_destroy(resource);
     195        dummygc_destroy(dgc);
    174196}
    175197
     
    181203        gfx_bitmap_params_t params;
    182204        gfx_bitmap_t *bitmap;
     205        ui_resource_t *resource = NULL;
    183206        ui_image_t *image = NULL;
    184207        gfx_rect_t brect;
     
    189212
    190213        gc = dummygc_get_ctx(dgc);
     214
     215        rc = ui_resource_create(gc, false, &resource);
     216        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     217        PCUT_ASSERT_NOT_NULL(resource);
    191218
    192219        gfx_bitmap_params_init(&params);
     
    194221        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    195222
    196         rc = ui_image_create(NULL, bitmap, &brect, &image);
     223        rc = ui_image_create(resource, bitmap, &brect, &image);
    197224        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    198225        PCUT_ASSERT_NOT_NULL(image);
     
    209236
    210237        ui_image_destroy(image);
     238        ui_resource_destroy(resource);
     239        dummygc_destroy(dgc);
    211240}
    212241
  • uspace/lib/ui/test/label.c

    rf536a16 rf0ccb2a  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4343static errno_t testgc_set_color(void *, gfx_color_t *);
    4444static errno_t testgc_fill_rect(void *, gfx_rect_t *);
     45static errno_t testgc_update(void *);
    4546static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    4647    gfx_bitmap_alloc_t *, void **);
     
    5253        .set_color = testgc_set_color,
    5354        .fill_rect = testgc_fill_rect,
     55        .update = testgc_update,
    5456        .bitmap_create = testgc_bitmap_create,
    5557        .bitmap_destroy = testgc_bitmap_destroy,
     
    220222        (void) arg;
    221223        (void) rect;
     224        return EOK;
     225}
     226
     227static errno_t testgc_update(void *arg)
     228{
     229        (void) arg;
    222230        return EOK;
    223231}
  • uspace/lib/ui/test/pbutton.c

    rf536a16 rf0ccb2a  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4343static errno_t testgc_set_color(void *, gfx_color_t *);
    4444static errno_t testgc_fill_rect(void *, gfx_rect_t *);
     45static errno_t testgc_update(void *);
    4546static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    4647    gfx_bitmap_alloc_t *, void **);
     
    5253        .set_color = testgc_set_color,
    5354        .fill_rect = testgc_fill_rect,
     55        .update = testgc_update,
    5456        .bitmap_create = testgc_bitmap_create,
    5557        .bitmap_destroy = testgc_bitmap_destroy,
     
    499501        (void) arg;
    500502        (void) rect;
     503        return EOK;
     504}
     505
     506static errno_t testgc_update(void *arg)
     507{
     508        (void) arg;
    501509        return EOK;
    502510}
  • uspace/lib/ui/test/rbutton.c

    rf536a16 rf0ccb2a  
    4343static errno_t testgc_set_color(void *, gfx_color_t *);
    4444static errno_t testgc_fill_rect(void *, gfx_rect_t *);
     45static errno_t testgc_update(void *);
    4546static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    4647    gfx_bitmap_alloc_t *, void **);
     
    5253        .set_color = testgc_set_color,
    5354        .fill_rect = testgc_fill_rect,
     55        .update = testgc_update,
    5456        .bitmap_create = testgc_bitmap_create,
    5557        .bitmap_destroy = testgc_bitmap_destroy,
     
    564566        (void) arg;
    565567        (void) rect;
     568        return EOK;
     569}
     570
     571static errno_t testgc_update(void *arg)
     572{
     573        (void) arg;
    566574        return EOK;
    567575}
  • uspace/lib/ui/test/slider.c

    rf536a16 rf0ccb2a  
    4343static errno_t testgc_set_color(void *, gfx_color_t *);
    4444static errno_t testgc_fill_rect(void *, gfx_rect_t *);
     45static errno_t testgc_update(void *);
    4546static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    4647    gfx_bitmap_alloc_t *, void **);
     
    5253        .set_color = testgc_set_color,
    5354        .fill_rect = testgc_fill_rect,
     55        .update = testgc_update,
    5456        .bitmap_create = testgc_bitmap_create,
    5557        .bitmap_destroy = testgc_bitmap_destroy,
     
    439441        (void) arg;
    440442        (void) rect;
     443        return EOK;
     444}
     445
     446static errno_t testgc_update(void *arg)
     447{
     448        (void) arg;
    441449        return EOK;
    442450}
  • uspace/lib/ui/test/wdecor.c

    rf536a16 rf0ccb2a  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4343static errno_t testgc_set_color(void *, gfx_color_t *);
    4444static errno_t testgc_fill_rect(void *, gfx_rect_t *);
     45static errno_t testgc_update(void *);
    4546static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
    4647    gfx_bitmap_alloc_t *, void **);
     
    5253        .set_color = testgc_set_color,
    5354        .fill_rect = testgc_fill_rect,
     55        .update = testgc_update,
    5456        .bitmap_create = testgc_bitmap_create,
    5557        .bitmap_destroy = testgc_bitmap_destroy,
     
    354356PCUT_TEST(pos_event_move)
    355357{
    356         ui_wdecor_t *wdecor;
     358        errno_t rc;
    357359        gfx_rect_t rect;
    358360        pos_event_t event;
     361        gfx_context_t *gc = NULL;
     362        test_gc_t tgc;
    359363        test_cb_resp_t resp;
    360         errno_t rc;
    361 
    362         rc = ui_wdecor_create(NULL, "Hello", ui_wds_decorated, &wdecor);
     364        ui_resource_t *resource = NULL;
     365        ui_wdecor_t *wdecor;
     366
     367        memset(&tgc, 0, sizeof(tgc));
     368        rc = gfx_context_new(&ops, &tgc, &gc);
     369        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     370
     371        rc = ui_resource_create(gc, false, &resource);
     372        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     373        PCUT_ASSERT_NOT_NULL(resource);
     374
     375        rc = ui_wdecor_create(resource, "Hello", ui_wds_decorated, &wdecor);
    363376        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    364377
     
    386399
    387400        ui_wdecor_destroy(wdecor);
     401        ui_resource_destroy(resource);
     402
     403        rc = gfx_context_delete(gc);
     404        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    388405}
    389406
     
    391408PCUT_TEST(get_geom_none)
    392409{
     410        gfx_context_t *gc = NULL;
     411        test_gc_t tgc;
     412        ui_resource_t *resource = NULL;
    393413        ui_wdecor_t *wdecor;
    394414        gfx_rect_t rect;
     
    396416        errno_t rc;
    397417
    398         rc = ui_wdecor_create(NULL, "Hello", ui_wds_none, &wdecor);
     418        memset(&tgc, 0, sizeof(tgc));
     419        rc = gfx_context_new(&ops, &tgc, &gc);
     420        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     421
     422        rc = ui_resource_create(gc, false, &resource);
     423        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     424        PCUT_ASSERT_NOT_NULL(resource);
     425
     426        rc = ui_wdecor_create(resource, "Hello", ui_wds_none, &wdecor);
    399427        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    400428
     
    428456
    429457        ui_wdecor_destroy(wdecor);
     458        ui_resource_destroy(resource);
     459
     460        rc = gfx_context_delete(gc);
     461        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    430462}
    431463
     
    433465PCUT_TEST(get_geom_frame)
    434466{
     467        gfx_context_t *gc = NULL;
     468        test_gc_t tgc;
     469        ui_resource_t *resource = NULL;
    435470        ui_wdecor_t *wdecor;
    436471        gfx_rect_t rect;
     
    438473        errno_t rc;
    439474
    440         rc = ui_wdecor_create(NULL, "Hello", ui_wds_frame, &wdecor);
     475        memset(&tgc, 0, sizeof(tgc));
     476        rc = gfx_context_new(&ops, &tgc, &gc);
     477        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     478
     479        rc = ui_resource_create(gc, false, &resource);
     480        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     481        PCUT_ASSERT_NOT_NULL(resource);
     482
     483        rc = ui_wdecor_create(resource, "Hello", ui_wds_frame, &wdecor);
    441484        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    442485
     
    470513
    471514        ui_wdecor_destroy(wdecor);
     515        ui_resource_destroy(resource);
     516
     517        rc = gfx_context_delete(gc);
     518        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    472519}
    473520
     
    475522PCUT_TEST(get_geom_frame_titlebar)
    476523{
     524        gfx_context_t *gc = NULL;
     525        test_gc_t tgc;
     526        ui_resource_t *resource = NULL;
    477527        ui_wdecor_t *wdecor;
    478528        gfx_rect_t rect;
     
    480530        errno_t rc;
    481531
    482         rc = ui_wdecor_create(NULL, "Hello", ui_wds_frame | ui_wds_titlebar,
     532        memset(&tgc, 0, sizeof(tgc));
     533        rc = gfx_context_new(&ops, &tgc, &gc);
     534        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     535
     536        rc = ui_resource_create(gc, false, &resource);
     537        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     538        PCUT_ASSERT_NOT_NULL(resource);
     539
     540        rc = ui_wdecor_create(resource, "Hello", ui_wds_frame | ui_wds_titlebar,
    483541            &wdecor);
    484542        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     
    513571
    514572        ui_wdecor_destroy(wdecor);
     573        ui_resource_destroy(resource);
     574
     575        rc = gfx_context_delete(gc);
     576        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    515577}
    516578
     
    518580PCUT_TEST(get_geom_decorated)
    519581{
     582        gfx_context_t *gc = NULL;
     583        test_gc_t tgc;
     584        ui_resource_t *resource = NULL;
    520585        ui_wdecor_t *wdecor;
    521586        gfx_rect_t rect;
     
    523588        errno_t rc;
    524589
    525         rc = ui_wdecor_create(NULL, "Hello", ui_wds_decorated, &wdecor);
     590        memset(&tgc, 0, sizeof(tgc));
     591        rc = gfx_context_new(&ops, &tgc, &gc);
     592        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     593
     594        rc = ui_resource_create(gc, false, &resource);
     595        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     596        PCUT_ASSERT_NOT_NULL(resource);
     597
     598        rc = ui_wdecor_create(resource, "Hello", ui_wds_decorated, &wdecor);
    526599        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    527600
     
    555628
    556629        ui_wdecor_destroy(wdecor);
     630        ui_resource_destroy(resource);
     631
     632        rc = gfx_context_delete(gc);
     633        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    557634}
    558635
     
    782859}
    783860
     861static errno_t testgc_update(void *arg)
     862{
     863        (void) arg;
     864        return EOK;
     865}
     866
    784867static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    785868    gfx_bitmap_alloc_t *alloc, void **rbm)
Note: See TracChangeset for help on using the changeset viewer.