Changeset 95a9cbc in mainline for uspace/lib/ui/test/resource.c


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:
d65accb
Parents:
1746ede
git-author:
Jiri Svoboda <jiri@…> (2021-04-09 22:01:35)
git-committer:
jxsvoboda <5887334+jxsvoboda@…> (2021-04-09 22:41:22)
Message:

UI menu unit tests

File:
1 edited

Legend:

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

    r1746ede r95a9cbc  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4444static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
    4545
     46static void test_expose(void *);
     47
    4648static gfx_context_ops_t ops = {
    4749        .bitmap_create = testgc_bitmap_create,
     
    6870} testgc_bitmap_t;
    6971
     72typedef struct {
     73        bool expose;
     74} test_resp_t;
     75
    7076/** Create and destroy UI resource */
    7177PCUT_TEST(create_destroy)
     
    97103{
    98104        ui_resource_destroy(NULL);
     105}
     106
     107/** ui_resource_set_expose_cb() / ui_resource_expose() */
     108PCUT_TEST(set_expose_cb_expose)
     109{
     110        errno_t rc;
     111        gfx_context_t *gc = NULL;
     112        test_gc_t tgc;
     113        ui_resource_t *resource = NULL;
     114        test_resp_t resp;
     115
     116        memset(&tgc, 0, sizeof(tgc));
     117        rc = gfx_context_new(&ops, &tgc, &gc);
     118        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     119
     120        rc = ui_resource_create(gc, false, &resource);
     121        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     122        PCUT_ASSERT_NOT_NULL(resource);
     123
     124        ui_resource_set_expose_cb(resource, test_expose, &resp);
     125
     126        resp.expose = false;
     127        ui_resource_expose(resource);
     128        PCUT_ASSERT_TRUE(resp.expose);
     129
     130        ui_resource_destroy(resource);
     131
     132        rc = gfx_context_delete(gc);
     133        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    99134}
    100135
     
    161196}
    162197
     198static void test_expose(void *arg)
     199{
     200        test_resp_t *resp = (test_resp_t *) arg;
     201
     202        resp->expose = true;
     203}
     204
    163205PCUT_EXPORT(resource);
Note: See TracChangeset for help on using the changeset viewer.