Changeset 913add60 in mainline for uspace/srv/hid/display/test


Ignore:
Timestamp:
2022-10-31T10:53:53Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b92d4b
Parents:
7cc30e9
git-author:
Jiri Svoboda <jiri@…> (2022-10-30 10:53:48)
git-committer:
Jiri Svoboda <jiri@…> (2022-10-31 10:53:53)
Message:

Deliver WM events for windows being added and removed

Location:
uspace/srv/hid/display/test
Files:
1 added
3 edited

Legend:

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

    r7cc30e9 r913add60  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2022 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3636#include "../seat.h"
    3737#include "../window.h"
     38#include "../wmclient.h"
    3839
    3940PCUT_INIT;
     
    4748};
    4849
     50static void test_ds_wmev_pending(void *);
     51
     52static ds_wmclient_cb_t test_ds_wmclient_cb = {
     53        .ev_pending = test_ds_wmev_pending
     54};
     55
    4956static void test_ds_ev_pending(void *arg)
    5057{
     
    5360}
    5461
     62static void test_ds_wmev_pending(void *arg)
     63{
     64        bool *called_cb = (bool *) arg;
     65        *called_cb = true;
     66}
     67
    5568/** Display creation and destruction. */
    5669PCUT_TEST(display_create_destroy)
     
    8699
    87100        ds_client_destroy(client);
     101        ds_display_destroy(disp);
     102}
     103
     104/** Basic WM client operation. */
     105PCUT_TEST(display_wmclient)
     106{
     107        ds_display_t *disp;
     108        ds_wmclient_t *wmclient;
     109        ds_wmclient_t *c0, *c1;
     110        errno_t rc;
     111
     112        rc = ds_display_create(NULL, df_none, &disp);
     113        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     114
     115        rc = ds_wmclient_create(disp, &test_ds_wmclient_cb, NULL, &wmclient);
     116        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     117
     118        c0 = ds_display_first_wmclient(disp);
     119        PCUT_ASSERT_EQUALS(c0, wmclient);
     120
     121        c1 = ds_display_next_wmclient(c0);
     122        PCUT_ASSERT_NULL(c1);
     123
     124        ds_wmclient_destroy(wmclient);
    88125        ds_display_destroy(disp);
    89126}
     
    150187        wnd = ds_display_find_window(disp, w0->id + 1);
    151188        PCUT_ASSERT_NULL(wnd);
     189
     190        ds_window_destroy(w0);
     191        ds_window_destroy(w1);
     192        ds_seat_destroy(seat);
     193        ds_client_destroy(client);
     194        ds_display_destroy(disp);
     195}
     196
     197/** Test ds_display_window_to_top() */
     198PCUT_TEST(display_window_to_top)
     199{
     200        ds_display_t *disp;
     201        ds_client_t *client;
     202        ds_seat_t *seat;
     203        ds_window_t *w0;
     204        ds_window_t *w1;
     205        display_wnd_params_t params;
     206        bool called_cb = false;
     207        errno_t rc;
     208
     209        rc = ds_display_create(NULL, df_none, &disp);
     210        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     211
     212        rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
     213        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     214
     215        rc = ds_seat_create(disp, &seat);
     216        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     217
     218        display_wnd_params_init(&params);
     219        params.rect.p0.x = params.rect.p0.y = 0;
     220        params.rect.p1.x = params.rect.p1.y = 100;
     221
     222        rc = ds_window_create(client, &params, &w0);
     223        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     224
     225        rc = ds_window_create(client, &params, &w1);
     226        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     227
     228        PCUT_ASSERT_EQUALS(w1, ds_display_first_window(disp));
     229        ds_display_window_to_top(w0);
     230        PCUT_ASSERT_EQUALS(w0, ds_display_first_window(disp));
    152231
    153232        ds_window_destroy(w0);
  • uspace/srv/hid/display/test/main.c

    r7cc30e9 r913add60  
    3737PCUT_IMPORT(seat);
    3838PCUT_IMPORT(window);
     39PCUT_IMPORT(wmclient);
    3940
    4041PCUT_MAIN();
  • uspace/srv/hid/display/test/window.c

    r7cc30e9 r913add60  
    5151};
    5252
     53/** Test creating and destroying window */
     54PCUT_TEST(create_destroy)
     55{
     56        ds_display_t *disp;
     57        ds_client_t *client;
     58        ds_seat_t *seat;
     59        ds_window_t *wnd;
     60        display_wnd_params_t params;
     61        errno_t rc;
     62
     63        rc = ds_display_create(NULL, df_none, &disp);
     64        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     65
     66        rc = ds_client_create(disp, NULL, NULL, &client);
     67        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     68
     69        rc = ds_seat_create(disp, &seat);
     70        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     71
     72        display_wnd_params_init(&params);
     73        params.rect.p0.x = params.rect.p0.y = 0;
     74        params.rect.p1.x = params.rect.p1.y = 10;
     75
     76        rc = ds_window_create(client, &params, &wnd);
     77        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     78
     79        ds_window_destroy(wnd);
     80        ds_seat_destroy(seat);
     81        ds_client_destroy(client);
     82        ds_display_destroy(disp);
     83}
     84
     85/** Test ds_window_bring_to_top() brings window to top */
     86PCUT_TEST(bring_to_top)
     87{
     88        ds_display_t *disp;
     89        ds_client_t *client;
     90        ds_seat_t *seat;
     91        ds_window_t *w1;
     92        ds_window_t *w2;
     93        display_wnd_params_t params;
     94        errno_t rc;
     95
     96        rc = ds_display_create(NULL, df_none, &disp);
     97        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     98
     99        rc = ds_client_create(disp, NULL, NULL, &client);
     100        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     101
     102        rc = ds_seat_create(disp, &seat);
     103        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     104
     105        display_wnd_params_init(&params);
     106        params.rect.p0.x = params.rect.p0.y = 0;
     107        params.rect.p1.x = params.rect.p1.y = 10;
     108
     109        rc = ds_window_create(client, &params, &w1);
     110        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     111
     112        rc = ds_window_create(client, &params, &w2);
     113        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     114
     115        /* w2 should be on the top */
     116        PCUT_ASSERT_EQUALS(w2, ds_display_first_window(disp));
     117
     118        /* Bring w1 to top */
     119        ds_window_bring_to_top(w1);
     120
     121        /* Now w1 should be on the top */
     122        PCUT_ASSERT_EQUALS(w1, ds_display_first_window(disp));
     123
     124        ds_window_destroy(w1);
     125        ds_window_destroy(w2);
     126        ds_seat_destroy(seat);
     127        ds_client_destroy(client);
     128        ds_display_destroy(disp);
     129}
     130
    53131/** Test ds_window_resize(). */
    54132PCUT_TEST(window_resize)
Note: See TracChangeset for help on using the changeset viewer.