Ignore:
Timestamp:
2019-11-06T13:20:41Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
648e2ac
Parents:
be15256
git-author:
Jiri Svoboda <jiri@…> (2019-10-03 18:20:38)
git-committer:
Jiri Svoboda <jiri@…> (2019-11-06 13:20:41)
Message:

Fix test, add missing tests for ds_client and ds_display

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/test/display.c

    rbe15256 rb2d1df3  
    3434#include "../client.h"
    3535#include "../display.h"
     36#include "../window.h"
    3637
    3738PCUT_INIT;
     
    4748static void test_ds_ev_pending(void *arg)
    4849{
     50        bool *called_cb = (bool *) arg;
    4951        printf("test_ds_ev_pending\n");
     52        *called_cb = true;
     53
    5054}
    51 
    5255
    5356/** Display creation and destruction. */
     
    8790}
    8891
     92/** Test ds_display_find_window(). */
     93PCUT_TEST(display_find_window)
     94{
     95        ds_display_t *disp;
     96        ds_client_t *client;
     97        ds_window_t *w0;
     98        ds_window_t *w1;
     99        ds_window_t *wnd;
     100        errno_t rc;
     101
     102        rc = ds_display_create(NULL, &disp);
     103        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     104
     105        rc = ds_client_create(disp, &test_ds_client_cb, NULL, &client);
     106        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     107
     108        rc = ds_window_create(client, &w0);
     109        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     110
     111        rc = ds_window_create(client, &w1);
     112        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     113
     114        wnd = ds_display_find_window(disp, w0->id);
     115        PCUT_ASSERT_EQUALS(w0, wnd);
     116
     117        wnd = ds_display_find_window(disp, w1->id);
     118        PCUT_ASSERT_EQUALS(w1, wnd);
     119
     120        wnd = ds_display_find_window(disp, 0);
     121        PCUT_ASSERT_NULL(wnd);
     122
     123        wnd = ds_display_find_window(disp, w1->id + 1);
     124        PCUT_ASSERT_NULL(wnd);
     125
     126        ds_window_delete(w0);
     127        ds_window_delete(w1);
     128        ds_client_destroy(client);
     129        ds_display_destroy(disp);
     130}
     131
     132/** Test ds_display_post_kbd_event(). */
     133PCUT_TEST(display_post_kbd_event)
     134{
     135        ds_display_t *disp;
     136        ds_client_t *client;
     137        ds_window_t *wnd;
     138        kbd_event_t event;
     139        bool called_cb = NULL;
     140        errno_t rc;
     141
     142        rc = ds_display_create(NULL, &disp);
     143        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     144
     145        rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
     146        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     147
     148        rc = ds_window_create(client, &wnd);
     149        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     150
     151        event.type = KEY_PRESS;
     152        event.key = KC_ENTER;
     153        event.mods = 0;
     154        event.c = L'\0';
     155
     156        PCUT_ASSERT_FALSE(called_cb);
     157
     158        rc = ds_display_post_kbd_event(disp, &event);
     159        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     160        PCUT_ASSERT_TRUE(called_cb);
     161
     162        ds_window_delete(wnd);
     163        ds_client_destroy(client);
     164        ds_display_destroy(disp);
     165}
     166
    89167PCUT_EXPORT(display);
Note: See TracChangeset for help on using the changeset viewer.