[bef51cf] | 1 | /*
|
---|
[35cffea] | 2 | * Copyright (c) 2022 Jiri Svoboda
|
---|
[bef51cf] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[3434233] | 29 | #include <disp_srv.h>
|
---|
[bef51cf] | 30 | #include <errno.h>
|
---|
[a40ae0d] | 31 | #include <gfx/context.h>
|
---|
[bef51cf] | 32 | #include <pcut/pcut.h>
|
---|
| 33 | #include <stdio.h>
|
---|
| 34 | #include <str.h>
|
---|
| 35 |
|
---|
[b3c185b6] | 36 | #include "../client.h"
|
---|
[b2d1df3] | 37 | #include "../display.h"
|
---|
[9901f267] | 38 | #include "../seat.h"
|
---|
[bef51cf] | 39 | #include "../window.h"
|
---|
| 40 |
|
---|
| 41 | PCUT_INIT;
|
---|
| 42 |
|
---|
| 43 | PCUT_TEST_SUITE(window);
|
---|
| 44 |
|
---|
[a40ae0d] | 45 | static errno_t dummy_set_color(void *, gfx_color_t *);
|
---|
| 46 | static errno_t dummy_fill_rect(void *, gfx_rect_t *);
|
---|
| 47 |
|
---|
| 48 | static gfx_context_ops_t dummy_ops = {
|
---|
| 49 | .set_color = dummy_set_color,
|
---|
| 50 | .fill_rect = dummy_fill_rect
|
---|
| 51 | };
|
---|
| 52 |
|
---|
[0e6e77f] | 53 | /** Test ds_window_resize(). */
|
---|
| 54 | PCUT_TEST(window_resize)
|
---|
| 55 | {
|
---|
| 56 | ds_display_t *disp;
|
---|
| 57 | ds_client_t *client;
|
---|
[9901f267] | 58 | ds_seat_t *seat;
|
---|
[0e6e77f] | 59 | ds_window_t *wnd;
|
---|
| 60 | display_wnd_params_t params;
|
---|
| 61 | gfx_coord2_t offs;
|
---|
| 62 | gfx_rect_t nrect;
|
---|
| 63 | errno_t rc;
|
---|
| 64 |
|
---|
[8aef01c] | 65 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[0e6e77f] | 66 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 67 |
|
---|
| 68 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 69 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 70 |
|
---|
[9901f267] | 71 | rc = ds_seat_create(disp, &seat);
|
---|
| 72 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 73 |
|
---|
[0e6e77f] | 74 | display_wnd_params_init(¶ms);
|
---|
| 75 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 76 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
| 77 |
|
---|
| 78 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 79 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 80 |
|
---|
| 81 | wnd->dpos.x = 100;
|
---|
| 82 | wnd->dpos.y = 100;
|
---|
| 83 |
|
---|
| 84 | offs.x = -2;
|
---|
| 85 | offs.y = -3;
|
---|
| 86 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 87 | params.rect.p1.x = 12;
|
---|
| 88 | params.rect.p1.y = 13;
|
---|
| 89 | rc = ds_window_resize(wnd, &offs, &nrect);
|
---|
| 90 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 91 |
|
---|
| 92 | PCUT_ASSERT_INT_EQUALS(98, wnd->dpos.x);
|
---|
| 93 | PCUT_ASSERT_INT_EQUALS(97, wnd->dpos.y);
|
---|
| 94 |
|
---|
[35cffea] | 95 | ds_window_destroy(wnd);
|
---|
| 96 | ds_seat_destroy(seat);
|
---|
| 97 | ds_client_destroy(client);
|
---|
| 98 | ds_display_destroy(disp);
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | /** Test ds_window_get_pos(). */
|
---|
| 102 | PCUT_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(¶ms);
|
---|
| 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, ¶ms, &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(). */
|
---|
| 143 | PCUT_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(¶ms);
|
---|
| 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, ¶ms, &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(). */
|
---|
| 186 | PCUT_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(¶ms);
|
---|
| 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, ¶ms, &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(). */
|
---|
| 226 | PCUT_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(¶ms);
|
---|
| 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, ¶ms, &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 |
|
---|
[0e6e77f] | 262 | ds_window_destroy(wnd);
|
---|
[9901f267] | 263 | ds_seat_destroy(seat);
|
---|
[0e6e77f] | 264 | ds_client_destroy(client);
|
---|
| 265 | ds_display_destroy(disp);
|
---|
| 266 | }
|
---|
| 267 |
|
---|
[bef51cf] | 268 | /** Test ds_window_get_ctx(). */
|
---|
| 269 | PCUT_TEST(window_get_ctx)
|
---|
| 270 | {
|
---|
[b2d1df3] | 271 | ds_display_t *disp;
|
---|
[b3c185b6] | 272 | ds_client_t *client;
|
---|
[9e84d2c] | 273 | ds_seat_t *seat;
|
---|
[bef51cf] | 274 | ds_window_t *wnd;
|
---|
[3434233] | 275 | display_wnd_params_t params;
|
---|
[bef51cf] | 276 | gfx_context_t *gc;
|
---|
| 277 | errno_t rc;
|
---|
| 278 |
|
---|
[8aef01c] | 279 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[b2d1df3] | 280 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 281 |
|
---|
| 282 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
[bef51cf] | 283 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 284 |
|
---|
[9e84d2c] | 285 | rc = ds_seat_create(disp, &seat);
|
---|
| 286 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 287 |
|
---|
[3434233] | 288 | display_wnd_params_init(¶ms);
|
---|
| 289 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 290 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 291 |
|
---|
| 292 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
[bef51cf] | 293 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 294 |
|
---|
| 295 | gc = ds_window_get_ctx(wnd);
|
---|
| 296 | PCUT_ASSERT_NOT_NULL(gc);
|
---|
| 297 |
|
---|
[648e2ac] | 298 | ds_window_destroy(wnd);
|
---|
[9e84d2c] | 299 | ds_seat_destroy(seat);
|
---|
[b3c185b6] | 300 | ds_client_destroy(client);
|
---|
[b2d1df3] | 301 | ds_display_destroy(disp);
|
---|
[bef51cf] | 302 | }
|
---|
| 303 |
|
---|
[338d0935] | 304 | /** Test ds_window_post_kbd_event() with Alt-F4 sends close event */
|
---|
| 305 | PCUT_TEST(window_post_kbd_event_alt_f4)
|
---|
| 306 | {
|
---|
| 307 | gfx_context_t *gc;
|
---|
| 308 | ds_display_t *disp;
|
---|
| 309 | ds_client_t *client;
|
---|
[9e84d2c] | 310 | ds_seat_t *seat;
|
---|
[338d0935] | 311 | ds_window_t *wnd;
|
---|
| 312 | ds_window_t *rwindow;
|
---|
| 313 | display_wnd_ev_t revent;
|
---|
| 314 | display_wnd_params_t params;
|
---|
| 315 | kbd_event_t event;
|
---|
| 316 | errno_t rc;
|
---|
| 317 |
|
---|
| 318 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 319 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 320 |
|
---|
[8aef01c] | 321 | rc = ds_display_create(gc, df_none, &disp);
|
---|
[338d0935] | 322 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 323 |
|
---|
| 324 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 325 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 326 |
|
---|
[9e84d2c] | 327 | rc = ds_seat_create(disp, &seat);
|
---|
| 328 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 329 |
|
---|
[338d0935] | 330 | display_wnd_params_init(¶ms);
|
---|
| 331 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 332 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 333 |
|
---|
| 334 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 335 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 336 |
|
---|
[9e84d2c] | 337 | /* New window gets focused event */
|
---|
| 338 | rc = ds_client_get_event(client, &rwindow, &revent);
|
---|
| 339 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 340 |
|
---|
[338d0935] | 341 | event.type = KEY_PRESS;
|
---|
| 342 | event.mods = KM_ALT;
|
---|
| 343 | event.key = KC_F4;
|
---|
| 344 | rc = ds_window_post_kbd_event(wnd, &event);
|
---|
| 345 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 346 |
|
---|
| 347 | rc = ds_client_get_event(client, &rwindow, &revent);
|
---|
| 348 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 349 | PCUT_ASSERT_EQUALS(wnd, rwindow);
|
---|
| 350 | PCUT_ASSERT_EQUALS(wev_close, revent.etype);
|
---|
| 351 |
|
---|
| 352 | rc = ds_client_get_event(client, &rwindow, &revent);
|
---|
| 353 | PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
|
---|
| 354 |
|
---|
| 355 | ds_window_destroy(wnd);
|
---|
[9e84d2c] | 356 | ds_seat_destroy(seat);
|
---|
[338d0935] | 357 | ds_client_destroy(client);
|
---|
| 358 | ds_display_destroy(disp);
|
---|
| 359 | }
|
---|
| 360 |
|
---|
[a40ae0d] | 361 | /** Test ds_window_post_pos_event() */
|
---|
| 362 | PCUT_TEST(window_post_pos_event)
|
---|
| 363 | {
|
---|
| 364 | gfx_context_t *gc;
|
---|
| 365 | ds_display_t *disp;
|
---|
| 366 | ds_client_t *client;
|
---|
[9e84d2c] | 367 | ds_seat_t *seat;
|
---|
[a40ae0d] | 368 | ds_window_t *wnd;
|
---|
| 369 | display_wnd_params_t params;
|
---|
| 370 | pos_event_t event;
|
---|
| 371 | errno_t rc;
|
---|
| 372 |
|
---|
| 373 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 374 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 375 |
|
---|
[8aef01c] | 376 | rc = ds_display_create(gc, df_none, &disp);
|
---|
[a40ae0d] | 377 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 378 |
|
---|
| 379 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 380 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 381 |
|
---|
[9e84d2c] | 382 | rc = ds_seat_create(disp, &seat);
|
---|
| 383 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 384 |
|
---|
[a40ae0d] | 385 | display_wnd_params_init(¶ms);
|
---|
| 386 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 387 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 388 |
|
---|
| 389 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 390 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 391 |
|
---|
| 392 | PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
|
---|
| 393 |
|
---|
[a2e104e] | 394 | wnd->dpos.x = 10;
|
---|
| 395 | wnd->dpos.y = 10;
|
---|
| 396 |
|
---|
[a40ae0d] | 397 | event.type = POS_PRESS;
|
---|
[a2e104e] | 398 | event.btn_num = 2;
|
---|
[a40ae0d] | 399 | event.hpos = 10;
|
---|
| 400 | event.vpos = 10;
|
---|
| 401 | rc = ds_window_post_pos_event(wnd, &event);
|
---|
| 402 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 403 |
|
---|
| 404 | PCUT_ASSERT_INT_EQUALS(dsw_moving, wnd->state);
|
---|
| 405 |
|
---|
| 406 | event.type = POS_UPDATE;
|
---|
| 407 | event.hpos = 11;
|
---|
| 408 | event.vpos = 12;
|
---|
| 409 | rc = ds_window_post_pos_event(wnd, &event);
|
---|
| 410 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 411 |
|
---|
| 412 | PCUT_ASSERT_INT_EQUALS(dsw_moving, wnd->state);
|
---|
[83cb672] | 413 | /* Window position does not update until after release */
|
---|
| 414 | PCUT_ASSERT_INT_EQUALS(10, wnd->dpos.x);
|
---|
| 415 | PCUT_ASSERT_INT_EQUALS(10, wnd->dpos.y);
|
---|
[a40ae0d] | 416 |
|
---|
| 417 | event.type = POS_RELEASE;
|
---|
| 418 | event.hpos = 13;
|
---|
| 419 | event.vpos = 14;
|
---|
| 420 |
|
---|
| 421 | rc = ds_window_post_pos_event(wnd, &event);
|
---|
| 422 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 423 |
|
---|
| 424 | PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
|
---|
[a2e104e] | 425 | PCUT_ASSERT_INT_EQUALS(13, wnd->dpos.x);
|
---|
| 426 | PCUT_ASSERT_INT_EQUALS(14, wnd->dpos.y);
|
---|
| 427 |
|
---|
| 428 | ds_window_destroy(wnd);
|
---|
[9e84d2c] | 429 | ds_seat_destroy(seat);
|
---|
[a2e104e] | 430 | ds_client_destroy(client);
|
---|
| 431 | ds_display_destroy(disp);
|
---|
| 432 | }
|
---|
| 433 |
|
---|
| 434 | /** Test ds_window_move_req() */
|
---|
| 435 | PCUT_TEST(window_move_req)
|
---|
| 436 | {
|
---|
| 437 | gfx_context_t *gc;
|
---|
| 438 | ds_display_t *disp;
|
---|
| 439 | ds_client_t *client;
|
---|
[9e84d2c] | 440 | ds_seat_t *seat;
|
---|
[a2e104e] | 441 | ds_window_t *wnd;
|
---|
| 442 | display_wnd_params_t params;
|
---|
| 443 | gfx_coord2_t pos;
|
---|
| 444 | errno_t rc;
|
---|
| 445 |
|
---|
| 446 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 447 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 448 |
|
---|
[8aef01c] | 449 | rc = ds_display_create(gc, df_none, &disp);
|
---|
[a2e104e] | 450 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 451 |
|
---|
| 452 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 453 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 454 |
|
---|
[9e84d2c] | 455 | rc = ds_seat_create(disp, &seat);
|
---|
| 456 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 457 |
|
---|
[a2e104e] | 458 | display_wnd_params_init(¶ms);
|
---|
| 459 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 460 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 461 |
|
---|
| 462 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 463 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 464 |
|
---|
| 465 | PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
|
---|
| 466 |
|
---|
| 467 | pos.x = 42;
|
---|
| 468 | pos.y = 43;
|
---|
| 469 | ds_window_move_req(wnd, &pos);
|
---|
| 470 |
|
---|
| 471 | PCUT_ASSERT_INT_EQUALS(dsw_moving, wnd->state);
|
---|
| 472 | PCUT_ASSERT_INT_EQUALS(pos.x, wnd->orig_pos.x);
|
---|
| 473 | PCUT_ASSERT_INT_EQUALS(pos.y, wnd->orig_pos.y);
|
---|
[a40ae0d] | 474 |
|
---|
| 475 | ds_window_destroy(wnd);
|
---|
[9e84d2c] | 476 | ds_seat_destroy(seat);
|
---|
[a40ae0d] | 477 | ds_client_destroy(client);
|
---|
| 478 | ds_display_destroy(disp);
|
---|
| 479 | }
|
---|
| 480 |
|
---|
[e022819] | 481 | /** Test ds_window_resize_req() */
|
---|
| 482 | PCUT_TEST(window_resize_req)
|
---|
| 483 | {
|
---|
| 484 | gfx_context_t *gc;
|
---|
| 485 | ds_display_t *disp;
|
---|
| 486 | ds_client_t *client;
|
---|
[9901f267] | 487 | ds_seat_t *seat;
|
---|
[e022819] | 488 | ds_window_t *wnd;
|
---|
| 489 | display_wnd_params_t params;
|
---|
| 490 | gfx_coord2_t pos;
|
---|
| 491 | errno_t rc;
|
---|
| 492 |
|
---|
| 493 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 494 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 495 |
|
---|
[8aef01c] | 496 | rc = ds_display_create(gc, df_none, &disp);
|
---|
[e022819] | 497 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 498 |
|
---|
| 499 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 500 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 501 |
|
---|
[9901f267] | 502 | rc = ds_seat_create(disp, &seat);
|
---|
| 503 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 504 |
|
---|
[e022819] | 505 | display_wnd_params_init(¶ms);
|
---|
| 506 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 507 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 508 |
|
---|
| 509 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 510 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 511 |
|
---|
| 512 | PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
|
---|
| 513 |
|
---|
| 514 | pos.x = 42;
|
---|
| 515 | pos.y = 43;
|
---|
| 516 | ds_window_resize_req(wnd, display_wr_top_right, &pos);
|
---|
| 517 |
|
---|
| 518 | PCUT_ASSERT_INT_EQUALS(dsw_resizing, wnd->state);
|
---|
| 519 | PCUT_ASSERT_INT_EQUALS(display_wr_top_right, wnd->rsztype);
|
---|
| 520 | PCUT_ASSERT_INT_EQUALS(pos.x, wnd->orig_pos.x);
|
---|
| 521 | PCUT_ASSERT_INT_EQUALS(pos.y, wnd->orig_pos.y);
|
---|
| 522 |
|
---|
| 523 | ds_window_destroy(wnd);
|
---|
[9901f267] | 524 | ds_seat_destroy(seat);
|
---|
[e022819] | 525 | ds_client_destroy(client);
|
---|
| 526 | ds_display_destroy(disp);
|
---|
| 527 | }
|
---|
| 528 |
|
---|
| 529 | PCUT_TEST(window_calc_resize)
|
---|
| 530 | {
|
---|
| 531 | ds_display_t *disp;
|
---|
| 532 | ds_client_t *client;
|
---|
[9e84d2c] | 533 | ds_seat_t *seat;
|
---|
[e022819] | 534 | ds_window_t *wnd;
|
---|
| 535 | display_wnd_params_t params;
|
---|
| 536 | gfx_coord2_t dresize;
|
---|
[b3825aa] | 537 | gfx_coord2_t dresizen;
|
---|
| 538 | gfx_coord2_t dresizeb;
|
---|
| 539 | gfx_coord2_t dresizebn;
|
---|
[e022819] | 540 | gfx_rect_t nrect;
|
---|
| 541 | errno_t rc;
|
---|
| 542 |
|
---|
[8aef01c] | 543 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[e022819] | 544 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 545 |
|
---|
| 546 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 547 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 548 |
|
---|
[9e84d2c] | 549 | rc = ds_seat_create(disp, &seat);
|
---|
| 550 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 551 |
|
---|
[e022819] | 552 | display_wnd_params_init(¶ms);
|
---|
| 553 | params.rect.p0.x = 10;
|
---|
| 554 | params.rect.p0.y = 11;
|
---|
[b3825aa] | 555 | params.rect.p1.x = 30;
|
---|
| 556 | params.rect.p1.y = 31;
|
---|
| 557 | params.min_size.x = 2;
|
---|
| 558 | params.min_size.y = 3;
|
---|
[e022819] | 559 |
|
---|
| 560 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 561 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 562 |
|
---|
| 563 | wnd->state = dsw_resizing;
|
---|
[b3825aa] | 564 |
|
---|
[e022819] | 565 | dresize.x = 5;
|
---|
| 566 | dresize.y = 6;
|
---|
| 567 |
|
---|
[b3825aa] | 568 | dresizen.x = -5;
|
---|
| 569 | dresizen.y = -6;
|
---|
| 570 |
|
---|
| 571 | dresizeb.x = 50;
|
---|
| 572 | dresizeb.y = 60;
|
---|
| 573 |
|
---|
| 574 | dresizebn.x = -50;
|
---|
| 575 | dresizebn.y = -60;
|
---|
| 576 |
|
---|
| 577 | /* Resize top */
|
---|
[e022819] | 578 | wnd->rsztype = display_wr_top;
|
---|
[b3825aa] | 579 |
|
---|
[e022819] | 580 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 581 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 582 | PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y);
|
---|
[b3825aa] | 583 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 584 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 585 |
|
---|
| 586 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 587 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 588 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.y);
|
---|
| 589 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 590 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 591 |
|
---|
| 592 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 593 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 594 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.y);
|
---|
| 595 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 596 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 597 |
|
---|
| 598 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 599 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 600 | PCUT_ASSERT_INT_EQUALS(-49, nrect.p0.y);
|
---|
| 601 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 602 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
[e022819] | 603 |
|
---|
[b3825aa] | 604 | /* Resize top left */
|
---|
[e022819] | 605 | wnd->rsztype = display_wr_top_left;
|
---|
[b3825aa] | 606 |
|
---|
[e022819] | 607 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 608 | PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x);
|
---|
| 609 | PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y);
|
---|
[b3825aa] | 610 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 611 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 612 |
|
---|
| 613 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 614 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.x);
|
---|
| 615 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.y);
|
---|
| 616 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 617 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 618 |
|
---|
| 619 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 620 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.x);
|
---|
| 621 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.y);
|
---|
| 622 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 623 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 624 |
|
---|
| 625 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 626 | PCUT_ASSERT_INT_EQUALS(-40, nrect.p0.x);
|
---|
| 627 | PCUT_ASSERT_INT_EQUALS(-49, nrect.p0.y);
|
---|
| 628 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 629 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 630 |
|
---|
| 631 | /* Resize left */
|
---|
[e022819] | 632 | wnd->rsztype = display_wr_left;
|
---|
[b3825aa] | 633 |
|
---|
[e022819] | 634 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 635 | PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x);
|
---|
| 636 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[b3825aa] | 637 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 638 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 639 |
|
---|
| 640 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 641 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.x);
|
---|
| 642 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 643 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 644 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
[e022819] | 645 |
|
---|
[b3825aa] | 646 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 647 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.x);
|
---|
| 648 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 649 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 650 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 651 |
|
---|
| 652 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 653 | PCUT_ASSERT_INT_EQUALS(-40, nrect.p0.x);
|
---|
| 654 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 655 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 656 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 657 |
|
---|
| 658 | /* Resize bottom left */
|
---|
[e022819] | 659 | wnd->rsztype = display_wr_bottom_left;
|
---|
[b3825aa] | 660 |
|
---|
[e022819] | 661 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 662 | PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x);
|
---|
| 663 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[b3825aa] | 664 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 665 | PCUT_ASSERT_INT_EQUALS(37, nrect.p1.y);
|
---|
| 666 |
|
---|
| 667 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 668 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.x);
|
---|
| 669 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 670 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 671 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.y);
|
---|
| 672 |
|
---|
| 673 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 674 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.x);
|
---|
| 675 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 676 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 677 | PCUT_ASSERT_INT_EQUALS(91, nrect.p1.y);
|
---|
| 678 |
|
---|
| 679 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 680 | PCUT_ASSERT_INT_EQUALS(-40, nrect.p0.x);
|
---|
| 681 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 682 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 683 | PCUT_ASSERT_INT_EQUALS(14, nrect.p1.y);
|
---|
[e022819] | 684 |
|
---|
[b3825aa] | 685 | /* Resize bottom */
|
---|
[e022819] | 686 | wnd->rsztype = display_wr_bottom;
|
---|
[b3825aa] | 687 |
|
---|
[e022819] | 688 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 689 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 690 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[b3825aa] | 691 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 692 | PCUT_ASSERT_INT_EQUALS(37, nrect.p1.y);
|
---|
| 693 |
|
---|
| 694 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 695 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 696 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 697 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 698 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.y);
|
---|
| 699 |
|
---|
| 700 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 701 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 702 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 703 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 704 | PCUT_ASSERT_INT_EQUALS(91, nrect.p1.y);
|
---|
| 705 |
|
---|
| 706 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 707 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 708 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 709 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 710 | PCUT_ASSERT_INT_EQUALS(14, nrect.p1.y);
|
---|
[e022819] | 711 |
|
---|
[b3825aa] | 712 | /* Resize bottom right */
|
---|
[e022819] | 713 | wnd->rsztype = display_wr_bottom_right;
|
---|
[b3825aa] | 714 |
|
---|
[e022819] | 715 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 716 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 717 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[b3825aa] | 718 | PCUT_ASSERT_INT_EQUALS(35, nrect.p1.x);
|
---|
| 719 | PCUT_ASSERT_INT_EQUALS(37, nrect.p1.y);
|
---|
| 720 |
|
---|
| 721 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 722 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 723 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[e022819] | 724 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x);
|
---|
[b3825aa] | 725 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.y);
|
---|
| 726 |
|
---|
| 727 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 728 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 729 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 730 | PCUT_ASSERT_INT_EQUALS(80, nrect.p1.x);
|
---|
| 731 | PCUT_ASSERT_INT_EQUALS(91, nrect.p1.y);
|
---|
[e022819] | 732 |
|
---|
[b3825aa] | 733 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 734 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 735 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 736 | PCUT_ASSERT_INT_EQUALS(12, nrect.p1.x);
|
---|
| 737 | PCUT_ASSERT_INT_EQUALS(14, nrect.p1.y);
|
---|
| 738 |
|
---|
| 739 | /* Resize right */
|
---|
[e022819] | 740 | wnd->rsztype = display_wr_right;
|
---|
[b3825aa] | 741 |
|
---|
[e022819] | 742 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 743 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 744 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[b3825aa] | 745 | PCUT_ASSERT_INT_EQUALS(35, nrect.p1.x);
|
---|
| 746 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 747 |
|
---|
| 748 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 749 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 750 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[e022819] | 751 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x);
|
---|
[b3825aa] | 752 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 753 |
|
---|
| 754 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 755 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 756 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 757 | PCUT_ASSERT_INT_EQUALS(80, nrect.p1.x);
|
---|
| 758 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 759 |
|
---|
| 760 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 761 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 762 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 763 | PCUT_ASSERT_INT_EQUALS(12, nrect.p1.x);
|
---|
| 764 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
[e022819] | 765 |
|
---|
[b3825aa] | 766 | /* Resize top right */
|
---|
[e022819] | 767 | wnd->rsztype = display_wr_top_right;
|
---|
[b3825aa] | 768 |
|
---|
[e022819] | 769 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 770 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 771 | PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y);
|
---|
[b3825aa] | 772 | PCUT_ASSERT_INT_EQUALS(35, nrect.p1.x);
|
---|
| 773 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 774 |
|
---|
| 775 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 776 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 777 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.y);
|
---|
[e022819] | 778 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x);
|
---|
[b3825aa] | 779 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 780 |
|
---|
| 781 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 782 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 783 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.y);
|
---|
| 784 | PCUT_ASSERT_INT_EQUALS(80, nrect.p1.x);
|
---|
| 785 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 786 |
|
---|
| 787 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 788 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 789 | PCUT_ASSERT_INT_EQUALS(-49, nrect.p0.y);
|
---|
| 790 | PCUT_ASSERT_INT_EQUALS(12, nrect.p1.x);
|
---|
| 791 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
[e022819] | 792 |
|
---|
| 793 | ds_window_destroy(wnd);
|
---|
[9e84d2c] | 794 | ds_seat_destroy(seat);
|
---|
[e022819] | 795 | ds_client_destroy(client);
|
---|
| 796 | ds_display_destroy(disp);
|
---|
| 797 | }
|
---|
| 798 |
|
---|
[9242ad9] | 799 | /** Test ds_window_set_cursor() */
|
---|
| 800 | PCUT_TEST(window_set_cursor)
|
---|
| 801 | {
|
---|
| 802 | gfx_context_t *gc;
|
---|
| 803 | ds_display_t *disp;
|
---|
| 804 | ds_client_t *client;
|
---|
[9e84d2c] | 805 | ds_seat_t *seat;
|
---|
[9242ad9] | 806 | ds_window_t *wnd;
|
---|
| 807 | display_wnd_params_t params;
|
---|
| 808 | errno_t rc;
|
---|
| 809 |
|
---|
| 810 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 811 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 812 |
|
---|
[8aef01c] | 813 | rc = ds_display_create(gc, df_none, &disp);
|
---|
[9242ad9] | 814 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 815 |
|
---|
| 816 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 817 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 818 |
|
---|
[9e84d2c] | 819 | rc = ds_seat_create(disp, &seat);
|
---|
| 820 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 821 |
|
---|
[9242ad9] | 822 | display_wnd_params_init(¶ms);
|
---|
| 823 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 824 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 825 |
|
---|
| 826 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 827 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 828 |
|
---|
| 829 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
---|
| 830 |
|
---|
| 831 | rc = ds_window_set_cursor(wnd, -1);
|
---|
| 832 | PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
|
---|
| 833 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
---|
| 834 |
|
---|
| 835 | rc = ds_window_set_cursor(wnd, dcurs_limit);
|
---|
| 836 | PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
|
---|
| 837 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
---|
| 838 |
|
---|
| 839 | rc = ds_window_set_cursor(wnd, dcurs_limit + 1);
|
---|
| 840 | PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
|
---|
| 841 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
---|
| 842 |
|
---|
| 843 | rc = ds_window_set_cursor(wnd, dcurs_size_lr);
|
---|
| 844 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 845 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_size_lr], wnd->cursor);
|
---|
| 846 |
|
---|
| 847 | ds_window_destroy(wnd);
|
---|
[9e84d2c] | 848 | ds_seat_destroy(seat);
|
---|
[9242ad9] | 849 | ds_client_destroy(client);
|
---|
| 850 | ds_display_destroy(disp);
|
---|
| 851 | }
|
---|
| 852 |
|
---|
[a40ae0d] | 853 | static errno_t dummy_set_color(void *arg, gfx_color_t *color)
|
---|
| 854 | {
|
---|
| 855 | return EOK;
|
---|
| 856 | }
|
---|
| 857 |
|
---|
| 858 | static errno_t dummy_fill_rect(void *arg, gfx_rect_t *rect)
|
---|
| 859 | {
|
---|
| 860 | return EOK;
|
---|
| 861 | }
|
---|
| 862 |
|
---|
[bef51cf] | 863 | PCUT_EXPORT(window);
|
---|