Changeset 35cffea in mainline for uspace/srv/hid/display/test/window.c


Ignore:
Timestamp:
2022-05-19T08:02:31Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ad698f4
Parents:
fd05ea6
git-author:
Jiri Svoboda <jiri@…> (2022-05-18 17:02:12)
git-committer:
Jiri Svoboda <jiri@…> (2022-05-19 08:02:31)
Message:

Maximizing/unmaximizing a window

File:
1 edited

Legend:

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

    rfd05ea6 r35cffea  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2022 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    9999}
    100100
     101/** Test ds_window_get_pos(). */
     102PCUT_TEST(get_pos)
     103{
     104        ds_display_t *disp;
     105        ds_client_t *client;
     106        ds_seat_t *seat;
     107        ds_window_t *wnd;
     108        display_wnd_params_t params;
     109        gfx_coord2_t pos;
     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_client_create(disp, NULL, NULL, &client);
     116        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     117
     118        rc = ds_seat_create(disp, &seat);
     119        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     120
     121        display_wnd_params_init(&params);
     122        params.rect.p0.x = params.rect.p0.y = 0;
     123        params.rect.p1.x = params.rect.p1.y = 10;
     124
     125        rc = ds_window_create(client, &params, &wnd);
     126        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     127
     128        wnd->dpos.x = 100;
     129        wnd->dpos.y = 100;
     130
     131        ds_window_get_pos(wnd, &pos);
     132
     133        PCUT_ASSERT_INT_EQUALS(100, pos.x);
     134        PCUT_ASSERT_INT_EQUALS(100, pos.y);
     135
     136        ds_window_destroy(wnd);
     137        ds_seat_destroy(seat);
     138        ds_client_destroy(client);
     139        ds_display_destroy(disp);
     140}
     141
     142/** Test ds_window_get_max_rect(). */
     143PCUT_TEST(get_max_rect)
     144{
     145        ds_display_t *disp;
     146        ds_client_t *client;
     147        ds_seat_t *seat;
     148        ds_window_t *wnd;
     149        display_wnd_params_t params;
     150        gfx_rect_t rect;
     151        errno_t rc;
     152
     153        rc = ds_display_create(NULL, df_none, &disp);
     154        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     155
     156        rc = ds_client_create(disp, NULL, NULL, &client);
     157        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     158
     159        rc = ds_seat_create(disp, &seat);
     160        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     161
     162        display_wnd_params_init(&params);
     163        params.rect.p0.x = params.rect.p0.y = 0;
     164        params.rect.p1.x = params.rect.p1.y = 10;
     165
     166        rc = ds_window_create(client, &params, &wnd);
     167        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     168
     169        wnd->dpos.x = 100;
     170        wnd->dpos.y = 100;
     171
     172        ds_window_get_max_rect(wnd, &rect);
     173
     174        PCUT_ASSERT_INT_EQUALS(disp->rect.p0.x, rect.p0.x);
     175        PCUT_ASSERT_INT_EQUALS(disp->rect.p0.y, rect.p0.y);
     176        PCUT_ASSERT_INT_EQUALS(disp->rect.p1.x, rect.p1.x);
     177        PCUT_ASSERT_INT_EQUALS(disp->rect.p1.y, rect.p1.y);
     178
     179        ds_window_destroy(wnd);
     180        ds_seat_destroy(seat);
     181        ds_client_destroy(client);
     182        ds_display_destroy(disp);
     183}
     184
     185/** Test ds_window_maximize(). */
     186PCUT_TEST(window_maximize)
     187{
     188        ds_display_t *disp;
     189        ds_client_t *client;
     190        ds_seat_t *seat;
     191        ds_window_t *wnd;
     192        display_wnd_params_t params;
     193        errno_t rc;
     194
     195        rc = ds_display_create(NULL, df_none, &disp);
     196        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     197
     198        rc = ds_client_create(disp, NULL, NULL, &client);
     199        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     200
     201        rc = ds_seat_create(disp, &seat);
     202        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     203
     204        display_wnd_params_init(&params);
     205        params.rect.p0.x = params.rect.p0.y = 0;
     206        params.rect.p1.x = params.rect.p1.y = 10;
     207
     208        rc = ds_window_create(client, &params, &wnd);
     209        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     210
     211        wnd->dpos.x = 100;
     212        wnd->dpos.y = 100;
     213
     214        rc = ds_window_maximize(wnd);
     215        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     216
     217        PCUT_ASSERT_INT_EQUALS(wndf_maximized, wnd->flags & wndf_maximized);
     218
     219        ds_window_destroy(wnd);
     220        ds_seat_destroy(seat);
     221        ds_client_destroy(client);
     222        ds_display_destroy(disp);
     223}
     224
     225/** Test ds_window_unmaximize(). */
     226PCUT_TEST(window_unmaximize)
     227{
     228        ds_display_t *disp;
     229        ds_client_t *client;
     230        ds_seat_t *seat;
     231        ds_window_t *wnd;
     232        display_wnd_params_t params;
     233        errno_t rc;
     234
     235        rc = ds_display_create(NULL, df_none, &disp);
     236        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     237
     238        rc = ds_client_create(disp, NULL, NULL, &client);
     239        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     240
     241        rc = ds_seat_create(disp, &seat);
     242        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     243
     244        display_wnd_params_init(&params);
     245        params.rect.p0.x = params.rect.p0.y = 0;
     246        params.rect.p1.x = params.rect.p1.y = 10;
     247
     248        rc = ds_window_create(client, &params, &wnd);
     249        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     250
     251        wnd->dpos.x = 100;
     252        wnd->dpos.y = 100;
     253
     254        rc = ds_window_maximize(wnd);
     255        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     256
     257        rc = ds_window_unmaximize(wnd);
     258        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     259
     260        PCUT_ASSERT_INT_EQUALS(0, wnd->flags & wndf_maximized);
     261
     262        ds_window_destroy(wnd);
     263        ds_seat_destroy(seat);
     264        ds_client_destroy(client);
     265        ds_display_destroy(disp);
     266}
     267
    101268/** Test ds_window_get_ctx(). */
    102269PCUT_TEST(window_get_ctx)
Note: See TracChangeset for help on using the changeset viewer.