[bef51cf] | 1 | /*
|
---|
[3c54869] | 2 | * Copyright (c) 2023 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"
|
---|
[6828a56] | 38 | #include "../idevcfg.h"
|
---|
[9901f267] | 39 | #include "../seat.h"
|
---|
[bef51cf] | 40 | #include "../window.h"
|
---|
| 41 |
|
---|
| 42 | PCUT_INIT;
|
---|
| 43 |
|
---|
| 44 | PCUT_TEST_SUITE(window);
|
---|
| 45 |
|
---|
[a40ae0d] | 46 | static errno_t dummy_set_color(void *, gfx_color_t *);
|
---|
| 47 | static errno_t dummy_fill_rect(void *, gfx_rect_t *);
|
---|
| 48 |
|
---|
| 49 | static gfx_context_ops_t dummy_ops = {
|
---|
| 50 | .set_color = dummy_set_color,
|
---|
| 51 | .fill_rect = dummy_fill_rect
|
---|
| 52 | };
|
---|
| 53 |
|
---|
[913add60] | 54 | /** Test creating and destroying window */
|
---|
| 55 | PCUT_TEST(create_destroy)
|
---|
| 56 | {
|
---|
| 57 | ds_display_t *disp;
|
---|
| 58 | ds_client_t *client;
|
---|
| 59 | ds_seat_t *seat;
|
---|
| 60 | ds_window_t *wnd;
|
---|
| 61 | display_wnd_params_t params;
|
---|
| 62 | errno_t rc;
|
---|
| 63 |
|
---|
| 64 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
| 65 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 66 |
|
---|
| 67 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 68 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 69 |
|
---|
[d8503fd] | 70 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[913add60] | 71 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 72 |
|
---|
| 73 | display_wnd_params_init(¶ms);
|
---|
| 74 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 75 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
| 76 |
|
---|
| 77 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 78 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 79 |
|
---|
| 80 | ds_window_destroy(wnd);
|
---|
| 81 | ds_seat_destroy(seat);
|
---|
| 82 | ds_client_destroy(client);
|
---|
| 83 | ds_display_destroy(disp);
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | /** Test ds_window_bring_to_top() brings window to top */
|
---|
| 87 | PCUT_TEST(bring_to_top)
|
---|
| 88 | {
|
---|
| 89 | ds_display_t *disp;
|
---|
| 90 | ds_client_t *client;
|
---|
| 91 | ds_seat_t *seat;
|
---|
| 92 | ds_window_t *w1;
|
---|
| 93 | ds_window_t *w2;
|
---|
| 94 | display_wnd_params_t params;
|
---|
| 95 | errno_t rc;
|
---|
| 96 |
|
---|
| 97 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
| 98 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 99 |
|
---|
| 100 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 101 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 102 |
|
---|
[d8503fd] | 103 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[913add60] | 104 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 105 |
|
---|
| 106 | display_wnd_params_init(¶ms);
|
---|
| 107 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 108 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
| 109 |
|
---|
| 110 | rc = ds_window_create(client, ¶ms, &w1);
|
---|
| 111 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 112 |
|
---|
| 113 | rc = ds_window_create(client, ¶ms, &w2);
|
---|
| 114 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 115 |
|
---|
| 116 | /* w2 should be on the top */
|
---|
| 117 | PCUT_ASSERT_EQUALS(w2, ds_display_first_window(disp));
|
---|
| 118 |
|
---|
| 119 | /* Bring w1 to top */
|
---|
| 120 | ds_window_bring_to_top(w1);
|
---|
| 121 |
|
---|
| 122 | /* Now w1 should be on the top */
|
---|
| 123 | PCUT_ASSERT_EQUALS(w1, ds_display_first_window(disp));
|
---|
| 124 |
|
---|
| 125 | ds_window_destroy(w1);
|
---|
| 126 | ds_window_destroy(w2);
|
---|
| 127 | ds_seat_destroy(seat);
|
---|
| 128 | ds_client_destroy(client);
|
---|
| 129 | ds_display_destroy(disp);
|
---|
| 130 | }
|
---|
| 131 |
|
---|
[0e6e77f] | 132 | /** Test ds_window_resize(). */
|
---|
| 133 | PCUT_TEST(window_resize)
|
---|
| 134 | {
|
---|
| 135 | ds_display_t *disp;
|
---|
| 136 | ds_client_t *client;
|
---|
[9901f267] | 137 | ds_seat_t *seat;
|
---|
[0e6e77f] | 138 | ds_window_t *wnd;
|
---|
| 139 | display_wnd_params_t params;
|
---|
| 140 | gfx_coord2_t offs;
|
---|
| 141 | gfx_rect_t nrect;
|
---|
| 142 | errno_t rc;
|
---|
| 143 |
|
---|
[8aef01c] | 144 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[0e6e77f] | 145 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 146 |
|
---|
| 147 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 148 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 149 |
|
---|
[d8503fd] | 150 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[9901f267] | 151 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 152 |
|
---|
[0e6e77f] | 153 | display_wnd_params_init(¶ms);
|
---|
| 154 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 155 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
| 156 |
|
---|
| 157 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 158 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 159 |
|
---|
| 160 | wnd->dpos.x = 100;
|
---|
| 161 | wnd->dpos.y = 100;
|
---|
| 162 |
|
---|
| 163 | offs.x = -2;
|
---|
| 164 | offs.y = -3;
|
---|
| 165 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 166 | params.rect.p1.x = 12;
|
---|
| 167 | params.rect.p1.y = 13;
|
---|
| 168 | rc = ds_window_resize(wnd, &offs, &nrect);
|
---|
| 169 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 170 |
|
---|
| 171 | PCUT_ASSERT_INT_EQUALS(98, wnd->dpos.x);
|
---|
| 172 | PCUT_ASSERT_INT_EQUALS(97, wnd->dpos.y);
|
---|
| 173 |
|
---|
[35cffea] | 174 | ds_window_destroy(wnd);
|
---|
| 175 | ds_seat_destroy(seat);
|
---|
| 176 | ds_client_destroy(client);
|
---|
| 177 | ds_display_destroy(disp);
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | /** Test ds_window_get_pos(). */
|
---|
| 181 | PCUT_TEST(get_pos)
|
---|
| 182 | {
|
---|
| 183 | ds_display_t *disp;
|
---|
| 184 | ds_client_t *client;
|
---|
| 185 | ds_seat_t *seat;
|
---|
| 186 | ds_window_t *wnd;
|
---|
| 187 | display_wnd_params_t params;
|
---|
| 188 | gfx_coord2_t pos;
|
---|
| 189 | errno_t rc;
|
---|
| 190 |
|
---|
| 191 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
| 192 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 193 |
|
---|
| 194 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 195 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 196 |
|
---|
[d8503fd] | 197 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[35cffea] | 198 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 199 |
|
---|
| 200 | display_wnd_params_init(¶ms);
|
---|
| 201 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 202 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
| 203 |
|
---|
| 204 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 205 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 206 |
|
---|
| 207 | wnd->dpos.x = 100;
|
---|
| 208 | wnd->dpos.y = 100;
|
---|
| 209 |
|
---|
| 210 | ds_window_get_pos(wnd, &pos);
|
---|
| 211 |
|
---|
| 212 | PCUT_ASSERT_INT_EQUALS(100, pos.x);
|
---|
| 213 | PCUT_ASSERT_INT_EQUALS(100, pos.y);
|
---|
| 214 |
|
---|
| 215 | ds_window_destroy(wnd);
|
---|
| 216 | ds_seat_destroy(seat);
|
---|
| 217 | ds_client_destroy(client);
|
---|
| 218 | ds_display_destroy(disp);
|
---|
| 219 | }
|
---|
| 220 |
|
---|
| 221 | /** Test ds_window_get_max_rect(). */
|
---|
| 222 | PCUT_TEST(get_max_rect)
|
---|
| 223 | {
|
---|
| 224 | ds_display_t *disp;
|
---|
| 225 | ds_client_t *client;
|
---|
| 226 | ds_seat_t *seat;
|
---|
| 227 | ds_window_t *wnd;
|
---|
| 228 | display_wnd_params_t params;
|
---|
| 229 | gfx_rect_t rect;
|
---|
| 230 | errno_t rc;
|
---|
| 231 |
|
---|
| 232 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
| 233 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 234 |
|
---|
| 235 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 236 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 237 |
|
---|
[d8503fd] | 238 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[35cffea] | 239 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 240 |
|
---|
| 241 | display_wnd_params_init(¶ms);
|
---|
| 242 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 243 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
| 244 |
|
---|
| 245 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 246 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 247 |
|
---|
| 248 | wnd->dpos.x = 100;
|
---|
| 249 | wnd->dpos.y = 100;
|
---|
| 250 |
|
---|
| 251 | ds_window_get_max_rect(wnd, &rect);
|
---|
| 252 |
|
---|
| 253 | PCUT_ASSERT_INT_EQUALS(disp->rect.p0.x, rect.p0.x);
|
---|
| 254 | PCUT_ASSERT_INT_EQUALS(disp->rect.p0.y, rect.p0.y);
|
---|
| 255 | PCUT_ASSERT_INT_EQUALS(disp->rect.p1.x, rect.p1.x);
|
---|
| 256 | PCUT_ASSERT_INT_EQUALS(disp->rect.p1.y, rect.p1.y);
|
---|
| 257 |
|
---|
| 258 | ds_window_destroy(wnd);
|
---|
| 259 | ds_seat_destroy(seat);
|
---|
| 260 | ds_client_destroy(client);
|
---|
| 261 | ds_display_destroy(disp);
|
---|
| 262 | }
|
---|
| 263 |
|
---|
[06176e1] | 264 | /** Test ds_window_minimize(). */
|
---|
| 265 | PCUT_TEST(window_minimize)
|
---|
| 266 | {
|
---|
| 267 | ds_display_t *disp;
|
---|
| 268 | ds_client_t *client;
|
---|
| 269 | ds_seat_t *seat;
|
---|
| 270 | ds_window_t *wnd;
|
---|
| 271 | display_wnd_params_t params;
|
---|
| 272 | errno_t rc;
|
---|
| 273 |
|
---|
| 274 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
| 275 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 276 |
|
---|
| 277 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 278 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 279 |
|
---|
[d8503fd] | 280 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[06176e1] | 281 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 282 |
|
---|
| 283 | display_wnd_params_init(¶ms);
|
---|
| 284 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 285 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
| 286 |
|
---|
| 287 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 288 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 289 |
|
---|
| 290 | rc = ds_window_minimize(wnd);
|
---|
| 291 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 292 |
|
---|
| 293 | PCUT_ASSERT_INT_EQUALS(wndf_minimized, wnd->flags & wndf_minimized);
|
---|
| 294 |
|
---|
| 295 | ds_window_destroy(wnd);
|
---|
| 296 | ds_seat_destroy(seat);
|
---|
| 297 | ds_client_destroy(client);
|
---|
| 298 | ds_display_destroy(disp);
|
---|
| 299 | }
|
---|
| 300 |
|
---|
| 301 | /** Test ds_window_unminimize(). */
|
---|
| 302 | PCUT_TEST(window_unminimize)
|
---|
| 303 | {
|
---|
| 304 | ds_display_t *disp;
|
---|
| 305 | ds_client_t *client;
|
---|
| 306 | ds_seat_t *seat;
|
---|
| 307 | ds_window_t *wnd;
|
---|
| 308 | display_wnd_params_t params;
|
---|
| 309 | errno_t rc;
|
---|
| 310 |
|
---|
| 311 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
| 312 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 313 |
|
---|
| 314 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 315 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 316 |
|
---|
[d8503fd] | 317 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[06176e1] | 318 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 319 |
|
---|
| 320 | display_wnd_params_init(¶ms);
|
---|
| 321 | params.flags |= wndf_minimized;
|
---|
| 322 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 323 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
| 324 |
|
---|
| 325 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 326 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 327 |
|
---|
| 328 | rc = ds_window_unminimize(wnd);
|
---|
| 329 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 330 |
|
---|
| 331 | PCUT_ASSERT_INT_EQUALS(0, wnd->flags & wndf_minimized);
|
---|
| 332 |
|
---|
| 333 | ds_window_destroy(wnd);
|
---|
| 334 | ds_seat_destroy(seat);
|
---|
| 335 | ds_client_destroy(client);
|
---|
| 336 | ds_display_destroy(disp);
|
---|
| 337 | }
|
---|
| 338 |
|
---|
[35cffea] | 339 | /** Test ds_window_maximize(). */
|
---|
| 340 | PCUT_TEST(window_maximize)
|
---|
| 341 | {
|
---|
| 342 | ds_display_t *disp;
|
---|
| 343 | ds_client_t *client;
|
---|
| 344 | ds_seat_t *seat;
|
---|
| 345 | ds_window_t *wnd;
|
---|
| 346 | display_wnd_params_t params;
|
---|
| 347 | errno_t rc;
|
---|
| 348 |
|
---|
| 349 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
| 350 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 351 |
|
---|
| 352 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 353 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 354 |
|
---|
[d8503fd] | 355 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[35cffea] | 356 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 357 |
|
---|
| 358 | display_wnd_params_init(¶ms);
|
---|
| 359 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 360 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
| 361 |
|
---|
| 362 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 363 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 364 |
|
---|
| 365 | wnd->dpos.x = 100;
|
---|
| 366 | wnd->dpos.y = 100;
|
---|
| 367 |
|
---|
| 368 | rc = ds_window_maximize(wnd);
|
---|
| 369 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 370 |
|
---|
| 371 | PCUT_ASSERT_INT_EQUALS(wndf_maximized, wnd->flags & wndf_maximized);
|
---|
| 372 |
|
---|
| 373 | ds_window_destroy(wnd);
|
---|
| 374 | ds_seat_destroy(seat);
|
---|
| 375 | ds_client_destroy(client);
|
---|
| 376 | ds_display_destroy(disp);
|
---|
| 377 | }
|
---|
| 378 |
|
---|
| 379 | /** Test ds_window_unmaximize(). */
|
---|
| 380 | PCUT_TEST(window_unmaximize)
|
---|
| 381 | {
|
---|
| 382 | ds_display_t *disp;
|
---|
| 383 | ds_client_t *client;
|
---|
| 384 | ds_seat_t *seat;
|
---|
| 385 | ds_window_t *wnd;
|
---|
| 386 | display_wnd_params_t params;
|
---|
| 387 | errno_t rc;
|
---|
| 388 |
|
---|
| 389 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
| 390 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 391 |
|
---|
| 392 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 393 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 394 |
|
---|
[d8503fd] | 395 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[35cffea] | 396 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 397 |
|
---|
| 398 | display_wnd_params_init(¶ms);
|
---|
| 399 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 400 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
| 401 |
|
---|
| 402 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 403 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 404 |
|
---|
| 405 | wnd->dpos.x = 100;
|
---|
| 406 | wnd->dpos.y = 100;
|
---|
| 407 |
|
---|
| 408 | rc = ds_window_maximize(wnd);
|
---|
| 409 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 410 |
|
---|
| 411 | rc = ds_window_unmaximize(wnd);
|
---|
| 412 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 413 |
|
---|
| 414 | PCUT_ASSERT_INT_EQUALS(0, wnd->flags & wndf_maximized);
|
---|
| 415 |
|
---|
[0e6e77f] | 416 | ds_window_destroy(wnd);
|
---|
[9901f267] | 417 | ds_seat_destroy(seat);
|
---|
[0e6e77f] | 418 | ds_client_destroy(client);
|
---|
| 419 | ds_display_destroy(disp);
|
---|
| 420 | }
|
---|
| 421 |
|
---|
[bef51cf] | 422 | /** Test ds_window_get_ctx(). */
|
---|
| 423 | PCUT_TEST(window_get_ctx)
|
---|
| 424 | {
|
---|
[b2d1df3] | 425 | ds_display_t *disp;
|
---|
[b3c185b6] | 426 | ds_client_t *client;
|
---|
[9e84d2c] | 427 | ds_seat_t *seat;
|
---|
[bef51cf] | 428 | ds_window_t *wnd;
|
---|
[3434233] | 429 | display_wnd_params_t params;
|
---|
[bef51cf] | 430 | gfx_context_t *gc;
|
---|
| 431 | errno_t rc;
|
---|
| 432 |
|
---|
[8aef01c] | 433 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[b2d1df3] | 434 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 435 |
|
---|
| 436 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
[bef51cf] | 437 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 438 |
|
---|
[d8503fd] | 439 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[9e84d2c] | 440 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 441 |
|
---|
[3434233] | 442 | display_wnd_params_init(¶ms);
|
---|
| 443 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 444 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 445 |
|
---|
| 446 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
[bef51cf] | 447 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 448 |
|
---|
| 449 | gc = ds_window_get_ctx(wnd);
|
---|
| 450 | PCUT_ASSERT_NOT_NULL(gc);
|
---|
| 451 |
|
---|
[648e2ac] | 452 | ds_window_destroy(wnd);
|
---|
[9e84d2c] | 453 | ds_seat_destroy(seat);
|
---|
[b3c185b6] | 454 | ds_client_destroy(client);
|
---|
[b2d1df3] | 455 | ds_display_destroy(disp);
|
---|
[bef51cf] | 456 | }
|
---|
| 457 |
|
---|
[06176e1] | 458 | /** Test ds_window_is_visible() */
|
---|
| 459 | PCUT_TEST(is_visible)
|
---|
| 460 | {
|
---|
| 461 | ds_display_t *disp;
|
---|
| 462 | ds_client_t *client;
|
---|
| 463 | ds_seat_t *seat;
|
---|
| 464 | ds_window_t *wnd;
|
---|
| 465 | display_wnd_params_t params;
|
---|
| 466 | errno_t rc;
|
---|
| 467 |
|
---|
| 468 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
| 469 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 470 |
|
---|
| 471 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 472 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 473 |
|
---|
[d8503fd] | 474 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[06176e1] | 475 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 476 |
|
---|
| 477 | display_wnd_params_init(¶ms);
|
---|
| 478 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 479 | params.rect.p1.x = params.rect.p1.y = 10;
|
---|
| 480 |
|
---|
| 481 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 482 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 483 |
|
---|
| 484 | PCUT_ASSERT_TRUE(ds_window_is_visible(wnd));
|
---|
| 485 |
|
---|
| 486 | wnd->flags |= wndf_minimized;
|
---|
| 487 |
|
---|
| 488 | PCUT_ASSERT_FALSE(ds_window_is_visible(wnd));
|
---|
| 489 |
|
---|
| 490 | ds_window_destroy(wnd);
|
---|
| 491 | ds_seat_destroy(seat);
|
---|
| 492 | ds_client_destroy(client);
|
---|
| 493 | ds_display_destroy(disp);
|
---|
| 494 | }
|
---|
| 495 |
|
---|
[338d0935] | 496 | /** Test ds_window_post_kbd_event() with Alt-F4 sends close event */
|
---|
| 497 | PCUT_TEST(window_post_kbd_event_alt_f4)
|
---|
| 498 | {
|
---|
| 499 | gfx_context_t *gc;
|
---|
| 500 | ds_display_t *disp;
|
---|
| 501 | ds_client_t *client;
|
---|
[9e84d2c] | 502 | ds_seat_t *seat;
|
---|
[338d0935] | 503 | ds_window_t *wnd;
|
---|
| 504 | ds_window_t *rwindow;
|
---|
| 505 | display_wnd_ev_t revent;
|
---|
| 506 | display_wnd_params_t params;
|
---|
| 507 | kbd_event_t event;
|
---|
| 508 | errno_t rc;
|
---|
| 509 |
|
---|
| 510 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 511 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 512 |
|
---|
[8aef01c] | 513 | rc = ds_display_create(gc, df_none, &disp);
|
---|
[338d0935] | 514 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 515 |
|
---|
| 516 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 517 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 518 |
|
---|
[d8503fd] | 519 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[9e84d2c] | 520 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 521 |
|
---|
[338d0935] | 522 | display_wnd_params_init(¶ms);
|
---|
| 523 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 524 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 525 |
|
---|
| 526 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 527 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 528 |
|
---|
[9e84d2c] | 529 | /* New window gets focused event */
|
---|
| 530 | rc = ds_client_get_event(client, &rwindow, &revent);
|
---|
| 531 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 532 |
|
---|
[338d0935] | 533 | event.type = KEY_PRESS;
|
---|
| 534 | event.mods = KM_ALT;
|
---|
| 535 | event.key = KC_F4;
|
---|
| 536 | rc = ds_window_post_kbd_event(wnd, &event);
|
---|
| 537 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 538 |
|
---|
| 539 | rc = ds_client_get_event(client, &rwindow, &revent);
|
---|
| 540 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 541 | PCUT_ASSERT_EQUALS(wnd, rwindow);
|
---|
| 542 | PCUT_ASSERT_EQUALS(wev_close, revent.etype);
|
---|
| 543 |
|
---|
| 544 | rc = ds_client_get_event(client, &rwindow, &revent);
|
---|
| 545 | PCUT_ASSERT_ERRNO_VAL(ENOENT, rc);
|
---|
| 546 |
|
---|
| 547 | ds_window_destroy(wnd);
|
---|
[9e84d2c] | 548 | ds_seat_destroy(seat);
|
---|
[338d0935] | 549 | ds_client_destroy(client);
|
---|
| 550 | ds_display_destroy(disp);
|
---|
| 551 | }
|
---|
| 552 |
|
---|
[a40ae0d] | 553 | /** Test ds_window_post_pos_event() */
|
---|
| 554 | PCUT_TEST(window_post_pos_event)
|
---|
| 555 | {
|
---|
| 556 | gfx_context_t *gc;
|
---|
| 557 | ds_display_t *disp;
|
---|
| 558 | ds_client_t *client;
|
---|
[9e84d2c] | 559 | ds_seat_t *seat;
|
---|
[a40ae0d] | 560 | ds_window_t *wnd;
|
---|
| 561 | display_wnd_params_t params;
|
---|
| 562 | pos_event_t event;
|
---|
| 563 | errno_t rc;
|
---|
| 564 |
|
---|
| 565 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 566 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 567 |
|
---|
[8aef01c] | 568 | rc = ds_display_create(gc, df_none, &disp);
|
---|
[a40ae0d] | 569 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 570 |
|
---|
| 571 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 572 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 573 |
|
---|
[d8503fd] | 574 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[9e84d2c] | 575 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 576 |
|
---|
[a40ae0d] | 577 | display_wnd_params_init(¶ms);
|
---|
| 578 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 579 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 580 |
|
---|
| 581 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 582 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 583 |
|
---|
| 584 | PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
|
---|
| 585 |
|
---|
[a2e104e] | 586 | wnd->dpos.x = 10;
|
---|
| 587 | wnd->dpos.y = 10;
|
---|
| 588 |
|
---|
[a40ae0d] | 589 | event.type = POS_PRESS;
|
---|
[a2e104e] | 590 | event.btn_num = 2;
|
---|
[a40ae0d] | 591 | event.hpos = 10;
|
---|
| 592 | event.vpos = 10;
|
---|
| 593 | rc = ds_window_post_pos_event(wnd, &event);
|
---|
| 594 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 595 |
|
---|
| 596 | PCUT_ASSERT_INT_EQUALS(dsw_moving, wnd->state);
|
---|
| 597 |
|
---|
| 598 | event.type = POS_UPDATE;
|
---|
| 599 | event.hpos = 11;
|
---|
| 600 | event.vpos = 12;
|
---|
| 601 | rc = ds_window_post_pos_event(wnd, &event);
|
---|
| 602 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 603 |
|
---|
| 604 | PCUT_ASSERT_INT_EQUALS(dsw_moving, wnd->state);
|
---|
[83cb672] | 605 | /* Window position does not update until after release */
|
---|
| 606 | PCUT_ASSERT_INT_EQUALS(10, wnd->dpos.x);
|
---|
| 607 | PCUT_ASSERT_INT_EQUALS(10, wnd->dpos.y);
|
---|
[a40ae0d] | 608 |
|
---|
| 609 | event.type = POS_RELEASE;
|
---|
| 610 | event.hpos = 13;
|
---|
| 611 | event.vpos = 14;
|
---|
| 612 |
|
---|
| 613 | rc = ds_window_post_pos_event(wnd, &event);
|
---|
| 614 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 615 |
|
---|
| 616 | PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
|
---|
[a2e104e] | 617 | PCUT_ASSERT_INT_EQUALS(13, wnd->dpos.x);
|
---|
| 618 | PCUT_ASSERT_INT_EQUALS(14, wnd->dpos.y);
|
---|
| 619 |
|
---|
| 620 | ds_window_destroy(wnd);
|
---|
[9e84d2c] | 621 | ds_seat_destroy(seat);
|
---|
[a2e104e] | 622 | ds_client_destroy(client);
|
---|
| 623 | ds_display_destroy(disp);
|
---|
| 624 | }
|
---|
| 625 |
|
---|
[3c54869] | 626 | /** Test ds_window_post_focus_event() */
|
---|
| 627 | PCUT_TEST(window_post_focus_event)
|
---|
| 628 | {
|
---|
| 629 | gfx_context_t *gc;
|
---|
| 630 | ds_display_t *disp;
|
---|
| 631 | ds_client_t *client;
|
---|
| 632 | ds_seat_t *seat;
|
---|
| 633 | ds_window_t *wnd;
|
---|
| 634 | display_wnd_params_t params;
|
---|
| 635 | errno_t rc;
|
---|
| 636 |
|
---|
| 637 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 638 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 639 |
|
---|
| 640 | rc = ds_display_create(gc, df_none, &disp);
|
---|
| 641 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 642 |
|
---|
| 643 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 644 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 645 |
|
---|
[d8503fd] | 646 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[3c54869] | 647 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 648 |
|
---|
| 649 | display_wnd_params_init(¶ms);
|
---|
| 650 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 651 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 652 |
|
---|
| 653 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 654 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 655 |
|
---|
| 656 | rc = ds_window_post_focus_event(wnd);
|
---|
| 657 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 658 |
|
---|
| 659 | ds_window_destroy(wnd);
|
---|
| 660 | ds_seat_destroy(seat);
|
---|
| 661 | ds_client_destroy(client);
|
---|
| 662 | ds_display_destroy(disp);
|
---|
| 663 | }
|
---|
| 664 |
|
---|
| 665 | /** Test ds_window_post_unfocus_event() */
|
---|
| 666 | PCUT_TEST(window_post_unfocus_event)
|
---|
| 667 | {
|
---|
| 668 | gfx_context_t *gc;
|
---|
| 669 | ds_display_t *disp;
|
---|
| 670 | ds_client_t *client;
|
---|
| 671 | ds_seat_t *seat;
|
---|
| 672 | ds_window_t *wnd;
|
---|
| 673 | display_wnd_params_t params;
|
---|
| 674 | errno_t rc;
|
---|
| 675 |
|
---|
| 676 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 677 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 678 |
|
---|
| 679 | rc = ds_display_create(gc, df_none, &disp);
|
---|
| 680 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 681 |
|
---|
| 682 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 683 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 684 |
|
---|
[d8503fd] | 685 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[3c54869] | 686 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 687 |
|
---|
| 688 | display_wnd_params_init(¶ms);
|
---|
| 689 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 690 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 691 |
|
---|
| 692 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 693 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 694 |
|
---|
| 695 | rc = ds_window_post_focus_event(wnd);
|
---|
| 696 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 697 |
|
---|
| 698 | ds_window_destroy(wnd);
|
---|
| 699 | ds_seat_destroy(seat);
|
---|
| 700 | ds_client_destroy(client);
|
---|
| 701 | ds_display_destroy(disp);
|
---|
| 702 | }
|
---|
| 703 |
|
---|
[a2e104e] | 704 | /** Test ds_window_move_req() */
|
---|
| 705 | PCUT_TEST(window_move_req)
|
---|
| 706 | {
|
---|
| 707 | gfx_context_t *gc;
|
---|
| 708 | ds_display_t *disp;
|
---|
| 709 | ds_client_t *client;
|
---|
[9e84d2c] | 710 | ds_seat_t *seat;
|
---|
[a2e104e] | 711 | ds_window_t *wnd;
|
---|
| 712 | display_wnd_params_t params;
|
---|
| 713 | gfx_coord2_t pos;
|
---|
[3be5366] | 714 | sysarg_t pos_id;
|
---|
[a2e104e] | 715 | errno_t rc;
|
---|
| 716 |
|
---|
| 717 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 718 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 719 |
|
---|
[8aef01c] | 720 | rc = ds_display_create(gc, df_none, &disp);
|
---|
[a2e104e] | 721 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 722 |
|
---|
| 723 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 724 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 725 |
|
---|
[d8503fd] | 726 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[9e84d2c] | 727 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 728 |
|
---|
[a2e104e] | 729 | display_wnd_params_init(¶ms);
|
---|
| 730 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 731 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 732 |
|
---|
| 733 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 734 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 735 |
|
---|
| 736 | PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
|
---|
| 737 |
|
---|
| 738 | pos.x = 42;
|
---|
| 739 | pos.y = 43;
|
---|
[3be5366] | 740 | pos_id = 44;
|
---|
| 741 | ds_window_move_req(wnd, &pos, pos_id);
|
---|
[a2e104e] | 742 |
|
---|
| 743 | PCUT_ASSERT_INT_EQUALS(dsw_moving, wnd->state);
|
---|
| 744 | PCUT_ASSERT_INT_EQUALS(pos.x, wnd->orig_pos.x);
|
---|
| 745 | PCUT_ASSERT_INT_EQUALS(pos.y, wnd->orig_pos.y);
|
---|
[3be5366] | 746 | PCUT_ASSERT_INT_EQUALS(pos_id, wnd->orig_pos_id);
|
---|
[a40ae0d] | 747 |
|
---|
| 748 | ds_window_destroy(wnd);
|
---|
[9e84d2c] | 749 | ds_seat_destroy(seat);
|
---|
[a40ae0d] | 750 | ds_client_destroy(client);
|
---|
| 751 | ds_display_destroy(disp);
|
---|
| 752 | }
|
---|
| 753 |
|
---|
[e022819] | 754 | /** Test ds_window_resize_req() */
|
---|
| 755 | PCUT_TEST(window_resize_req)
|
---|
| 756 | {
|
---|
| 757 | gfx_context_t *gc;
|
---|
| 758 | ds_display_t *disp;
|
---|
| 759 | ds_client_t *client;
|
---|
[9901f267] | 760 | ds_seat_t *seat;
|
---|
[e022819] | 761 | ds_window_t *wnd;
|
---|
| 762 | display_wnd_params_t params;
|
---|
| 763 | gfx_coord2_t pos;
|
---|
[b0ae23f] | 764 | sysarg_t pos_id;
|
---|
[e022819] | 765 | errno_t rc;
|
---|
| 766 |
|
---|
| 767 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 768 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 769 |
|
---|
[8aef01c] | 770 | rc = ds_display_create(gc, df_none, &disp);
|
---|
[e022819] | 771 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 772 |
|
---|
| 773 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 774 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 775 |
|
---|
[d8503fd] | 776 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[9901f267] | 777 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 778 |
|
---|
[e022819] | 779 | display_wnd_params_init(¶ms);
|
---|
| 780 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 781 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 782 |
|
---|
| 783 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 784 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 785 |
|
---|
| 786 | PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
|
---|
| 787 |
|
---|
| 788 | pos.x = 42;
|
---|
| 789 | pos.y = 43;
|
---|
[b0ae23f] | 790 | pos_id = 44;
|
---|
| 791 | ds_window_resize_req(wnd, display_wr_top_right, &pos, pos_id);
|
---|
[e022819] | 792 |
|
---|
| 793 | PCUT_ASSERT_INT_EQUALS(dsw_resizing, wnd->state);
|
---|
| 794 | PCUT_ASSERT_INT_EQUALS(display_wr_top_right, wnd->rsztype);
|
---|
| 795 | PCUT_ASSERT_INT_EQUALS(pos.x, wnd->orig_pos.x);
|
---|
| 796 | PCUT_ASSERT_INT_EQUALS(pos.y, wnd->orig_pos.y);
|
---|
[3be5366] | 797 | PCUT_ASSERT_INT_EQUALS(pos_id, wnd->orig_pos_id);
|
---|
[e022819] | 798 |
|
---|
| 799 | ds_window_destroy(wnd);
|
---|
[9901f267] | 800 | ds_seat_destroy(seat);
|
---|
[e022819] | 801 | ds_client_destroy(client);
|
---|
| 802 | ds_display_destroy(disp);
|
---|
| 803 | }
|
---|
| 804 |
|
---|
| 805 | PCUT_TEST(window_calc_resize)
|
---|
| 806 | {
|
---|
| 807 | ds_display_t *disp;
|
---|
| 808 | ds_client_t *client;
|
---|
[9e84d2c] | 809 | ds_seat_t *seat;
|
---|
[e022819] | 810 | ds_window_t *wnd;
|
---|
| 811 | display_wnd_params_t params;
|
---|
| 812 | gfx_coord2_t dresize;
|
---|
[b3825aa] | 813 | gfx_coord2_t dresizen;
|
---|
| 814 | gfx_coord2_t dresizeb;
|
---|
| 815 | gfx_coord2_t dresizebn;
|
---|
[e022819] | 816 | gfx_rect_t nrect;
|
---|
| 817 | errno_t rc;
|
---|
| 818 |
|
---|
[8aef01c] | 819 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[e022819] | 820 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 821 |
|
---|
| 822 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 823 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 824 |
|
---|
[d8503fd] | 825 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[9e84d2c] | 826 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 827 |
|
---|
[e022819] | 828 | display_wnd_params_init(¶ms);
|
---|
| 829 | params.rect.p0.x = 10;
|
---|
| 830 | params.rect.p0.y = 11;
|
---|
[b3825aa] | 831 | params.rect.p1.x = 30;
|
---|
| 832 | params.rect.p1.y = 31;
|
---|
| 833 | params.min_size.x = 2;
|
---|
| 834 | params.min_size.y = 3;
|
---|
[e022819] | 835 |
|
---|
| 836 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 837 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 838 |
|
---|
| 839 | wnd->state = dsw_resizing;
|
---|
[b3825aa] | 840 |
|
---|
[e022819] | 841 | dresize.x = 5;
|
---|
| 842 | dresize.y = 6;
|
---|
| 843 |
|
---|
[b3825aa] | 844 | dresizen.x = -5;
|
---|
| 845 | dresizen.y = -6;
|
---|
| 846 |
|
---|
| 847 | dresizeb.x = 50;
|
---|
| 848 | dresizeb.y = 60;
|
---|
| 849 |
|
---|
| 850 | dresizebn.x = -50;
|
---|
| 851 | dresizebn.y = -60;
|
---|
| 852 |
|
---|
| 853 | /* Resize top */
|
---|
[e022819] | 854 | wnd->rsztype = display_wr_top;
|
---|
[b3825aa] | 855 |
|
---|
[e022819] | 856 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 857 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 858 | PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y);
|
---|
[b3825aa] | 859 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 860 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 861 |
|
---|
| 862 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 863 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 864 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.y);
|
---|
| 865 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 866 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 867 |
|
---|
| 868 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 869 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 870 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.y);
|
---|
| 871 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 872 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 873 |
|
---|
| 874 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 875 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 876 | PCUT_ASSERT_INT_EQUALS(-49, nrect.p0.y);
|
---|
| 877 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 878 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
[e022819] | 879 |
|
---|
[b3825aa] | 880 | /* Resize top left */
|
---|
[e022819] | 881 | wnd->rsztype = display_wr_top_left;
|
---|
[b3825aa] | 882 |
|
---|
[e022819] | 883 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 884 | PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x);
|
---|
| 885 | PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y);
|
---|
[b3825aa] | 886 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 887 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 888 |
|
---|
| 889 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 890 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.x);
|
---|
| 891 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.y);
|
---|
| 892 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 893 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 894 |
|
---|
| 895 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 896 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.x);
|
---|
| 897 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.y);
|
---|
| 898 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 899 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 900 |
|
---|
| 901 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 902 | PCUT_ASSERT_INT_EQUALS(-40, nrect.p0.x);
|
---|
| 903 | PCUT_ASSERT_INT_EQUALS(-49, nrect.p0.y);
|
---|
| 904 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 905 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 906 |
|
---|
| 907 | /* Resize left */
|
---|
[e022819] | 908 | wnd->rsztype = display_wr_left;
|
---|
[b3825aa] | 909 |
|
---|
[e022819] | 910 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 911 | PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x);
|
---|
| 912 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[b3825aa] | 913 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 914 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 915 |
|
---|
| 916 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 917 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.x);
|
---|
| 918 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 919 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 920 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
[e022819] | 921 |
|
---|
[b3825aa] | 922 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 923 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.x);
|
---|
| 924 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 925 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 926 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 927 |
|
---|
| 928 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 929 | PCUT_ASSERT_INT_EQUALS(-40, nrect.p0.x);
|
---|
| 930 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 931 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 932 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 933 |
|
---|
| 934 | /* Resize bottom left */
|
---|
[e022819] | 935 | wnd->rsztype = display_wr_bottom_left;
|
---|
[b3825aa] | 936 |
|
---|
[e022819] | 937 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 938 | PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x);
|
---|
| 939 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[b3825aa] | 940 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 941 | PCUT_ASSERT_INT_EQUALS(37, nrect.p1.y);
|
---|
| 942 |
|
---|
| 943 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 944 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.x);
|
---|
| 945 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 946 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 947 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.y);
|
---|
| 948 |
|
---|
| 949 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 950 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.x);
|
---|
| 951 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 952 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 953 | PCUT_ASSERT_INT_EQUALS(91, nrect.p1.y);
|
---|
| 954 |
|
---|
| 955 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 956 | PCUT_ASSERT_INT_EQUALS(-40, nrect.p0.x);
|
---|
| 957 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 958 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 959 | PCUT_ASSERT_INT_EQUALS(14, nrect.p1.y);
|
---|
[e022819] | 960 |
|
---|
[b3825aa] | 961 | /* Resize bottom */
|
---|
[e022819] | 962 | wnd->rsztype = display_wr_bottom;
|
---|
[b3825aa] | 963 |
|
---|
[e022819] | 964 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 965 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 966 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[b3825aa] | 967 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 968 | PCUT_ASSERT_INT_EQUALS(37, nrect.p1.y);
|
---|
| 969 |
|
---|
| 970 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 971 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 972 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 973 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 974 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.y);
|
---|
| 975 |
|
---|
| 976 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 977 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 978 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 979 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 980 | PCUT_ASSERT_INT_EQUALS(91, nrect.p1.y);
|
---|
| 981 |
|
---|
| 982 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 983 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 984 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 985 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
---|
| 986 | PCUT_ASSERT_INT_EQUALS(14, nrect.p1.y);
|
---|
[e022819] | 987 |
|
---|
[b3825aa] | 988 | /* Resize bottom right */
|
---|
[e022819] | 989 | wnd->rsztype = display_wr_bottom_right;
|
---|
[b3825aa] | 990 |
|
---|
[e022819] | 991 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 992 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 993 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[b3825aa] | 994 | PCUT_ASSERT_INT_EQUALS(35, nrect.p1.x);
|
---|
| 995 | PCUT_ASSERT_INT_EQUALS(37, nrect.p1.y);
|
---|
| 996 |
|
---|
| 997 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 998 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 999 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[e022819] | 1000 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x);
|
---|
[b3825aa] | 1001 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.y);
|
---|
| 1002 |
|
---|
| 1003 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 1004 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 1005 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 1006 | PCUT_ASSERT_INT_EQUALS(80, nrect.p1.x);
|
---|
| 1007 | PCUT_ASSERT_INT_EQUALS(91, nrect.p1.y);
|
---|
[e022819] | 1008 |
|
---|
[b3825aa] | 1009 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 1010 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 1011 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 1012 | PCUT_ASSERT_INT_EQUALS(12, nrect.p1.x);
|
---|
| 1013 | PCUT_ASSERT_INT_EQUALS(14, nrect.p1.y);
|
---|
| 1014 |
|
---|
| 1015 | /* Resize right */
|
---|
[e022819] | 1016 | wnd->rsztype = display_wr_right;
|
---|
[b3825aa] | 1017 |
|
---|
[e022819] | 1018 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 1019 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 1020 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[b3825aa] | 1021 | PCUT_ASSERT_INT_EQUALS(35, nrect.p1.x);
|
---|
| 1022 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 1023 |
|
---|
| 1024 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 1025 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 1026 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
[e022819] | 1027 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x);
|
---|
[b3825aa] | 1028 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 1029 |
|
---|
| 1030 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 1031 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 1032 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 1033 | PCUT_ASSERT_INT_EQUALS(80, nrect.p1.x);
|
---|
| 1034 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 1035 |
|
---|
| 1036 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 1037 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 1038 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
---|
| 1039 | PCUT_ASSERT_INT_EQUALS(12, nrect.p1.x);
|
---|
| 1040 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
[e022819] | 1041 |
|
---|
[b3825aa] | 1042 | /* Resize top right */
|
---|
[e022819] | 1043 | wnd->rsztype = display_wr_top_right;
|
---|
[b3825aa] | 1044 |
|
---|
[e022819] | 1045 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
---|
| 1046 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 1047 | PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y);
|
---|
[b3825aa] | 1048 | PCUT_ASSERT_INT_EQUALS(35, nrect.p1.x);
|
---|
| 1049 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 1050 |
|
---|
| 1051 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
---|
| 1052 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 1053 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.y);
|
---|
[e022819] | 1054 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x);
|
---|
[b3825aa] | 1055 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 1056 |
|
---|
| 1057 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
---|
| 1058 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 1059 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.y);
|
---|
| 1060 | PCUT_ASSERT_INT_EQUALS(80, nrect.p1.x);
|
---|
| 1061 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
| 1062 |
|
---|
| 1063 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
---|
| 1064 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
---|
| 1065 | PCUT_ASSERT_INT_EQUALS(-49, nrect.p0.y);
|
---|
| 1066 | PCUT_ASSERT_INT_EQUALS(12, nrect.p1.x);
|
---|
| 1067 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
---|
[e022819] | 1068 |
|
---|
| 1069 | ds_window_destroy(wnd);
|
---|
[9e84d2c] | 1070 | ds_seat_destroy(seat);
|
---|
[e022819] | 1071 | ds_client_destroy(client);
|
---|
| 1072 | ds_display_destroy(disp);
|
---|
| 1073 | }
|
---|
| 1074 |
|
---|
[9242ad9] | 1075 | /** Test ds_window_set_cursor() */
|
---|
| 1076 | PCUT_TEST(window_set_cursor)
|
---|
| 1077 | {
|
---|
| 1078 | gfx_context_t *gc;
|
---|
| 1079 | ds_display_t *disp;
|
---|
| 1080 | ds_client_t *client;
|
---|
[9e84d2c] | 1081 | ds_seat_t *seat;
|
---|
[9242ad9] | 1082 | ds_window_t *wnd;
|
---|
| 1083 | display_wnd_params_t params;
|
---|
| 1084 | errno_t rc;
|
---|
| 1085 |
|
---|
| 1086 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 1087 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1088 |
|
---|
[8aef01c] | 1089 | rc = ds_display_create(gc, df_none, &disp);
|
---|
[9242ad9] | 1090 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1091 |
|
---|
| 1092 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 1093 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1094 |
|
---|
[d8503fd] | 1095 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[9e84d2c] | 1096 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1097 |
|
---|
[9242ad9] | 1098 | display_wnd_params_init(¶ms);
|
---|
| 1099 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 1100 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 1101 |
|
---|
| 1102 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 1103 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1104 |
|
---|
| 1105 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
---|
| 1106 |
|
---|
| 1107 | rc = ds_window_set_cursor(wnd, -1);
|
---|
| 1108 | PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
|
---|
| 1109 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
---|
| 1110 |
|
---|
[dd7df1c] | 1111 | // Check that invalid cursors cannot be set: ignore enum conversions
|
---|
| 1112 | // as we are out-of-bounds
|
---|
| 1113 | #pragma GCC diagnostic push
|
---|
| 1114 | #if defined(__GNUC__) && (__GNUC__ >= 10)
|
---|
| 1115 | #pragma GCC diagnostic ignored "-Wenum-conversion"
|
---|
| 1116 | #endif
|
---|
[9242ad9] | 1117 | rc = ds_window_set_cursor(wnd, dcurs_limit);
|
---|
| 1118 | PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
|
---|
| 1119 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
---|
| 1120 |
|
---|
| 1121 | rc = ds_window_set_cursor(wnd, dcurs_limit + 1);
|
---|
| 1122 | PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
|
---|
| 1123 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
---|
[dd7df1c] | 1124 | #pragma GCC diagnostic pop
|
---|
[9242ad9] | 1125 |
|
---|
| 1126 | rc = ds_window_set_cursor(wnd, dcurs_size_lr);
|
---|
| 1127 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1128 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_size_lr], wnd->cursor);
|
---|
| 1129 |
|
---|
| 1130 | ds_window_destroy(wnd);
|
---|
[9e84d2c] | 1131 | ds_seat_destroy(seat);
|
---|
[9242ad9] | 1132 | ds_client_destroy(client);
|
---|
| 1133 | ds_display_destroy(disp);
|
---|
| 1134 | }
|
---|
| 1135 |
|
---|
[7cc30e9] | 1136 | /** Test ds_window_set_caption() */
|
---|
| 1137 | PCUT_TEST(window_set_caption)
|
---|
| 1138 | {
|
---|
| 1139 | gfx_context_t *gc;
|
---|
| 1140 | ds_display_t *disp;
|
---|
| 1141 | ds_client_t *client;
|
---|
| 1142 | ds_seat_t *seat;
|
---|
| 1143 | ds_window_t *wnd;
|
---|
| 1144 | display_wnd_params_t params;
|
---|
| 1145 | errno_t rc;
|
---|
| 1146 |
|
---|
| 1147 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 1148 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1149 |
|
---|
| 1150 | rc = ds_display_create(gc, df_none, &disp);
|
---|
| 1151 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1152 |
|
---|
| 1153 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 1154 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1155 |
|
---|
[d8503fd] | 1156 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[7cc30e9] | 1157 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1158 |
|
---|
| 1159 | display_wnd_params_init(¶ms);
|
---|
| 1160 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 1161 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 1162 |
|
---|
| 1163 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 1164 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1165 |
|
---|
| 1166 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
---|
| 1167 |
|
---|
| 1168 | rc = ds_window_set_caption(wnd, "Hello");
|
---|
| 1169 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1170 | PCUT_ASSERT_INT_EQUALS(0, str_cmp("Hello", wnd->caption));
|
---|
| 1171 |
|
---|
| 1172 | ds_window_destroy(wnd);
|
---|
| 1173 | ds_seat_destroy(seat);
|
---|
| 1174 | ds_client_destroy(client);
|
---|
| 1175 | ds_display_destroy(disp);
|
---|
| 1176 | }
|
---|
| 1177 |
|
---|
[acd7ac2] | 1178 | /** ds_window_find_next() finds next window by flags */
|
---|
| 1179 | PCUT_TEST(window_find_next)
|
---|
[17c0f5d] | 1180 | {
|
---|
| 1181 | gfx_context_t *gc;
|
---|
| 1182 | ds_display_t *disp;
|
---|
| 1183 | ds_client_t *client;
|
---|
| 1184 | ds_seat_t *seat;
|
---|
| 1185 | ds_window_t *w0;
|
---|
| 1186 | ds_window_t *w1;
|
---|
| 1187 | ds_window_t *w2;
|
---|
| 1188 | ds_window_t *wnd;
|
---|
| 1189 | display_wnd_params_t params;
|
---|
| 1190 | errno_t rc;
|
---|
| 1191 |
|
---|
| 1192 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 1193 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1194 |
|
---|
| 1195 | rc = ds_display_create(gc, df_none, &disp);
|
---|
| 1196 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1197 |
|
---|
| 1198 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 1199 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1200 |
|
---|
[d8503fd] | 1201 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[17c0f5d] | 1202 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1203 |
|
---|
| 1204 | display_wnd_params_init(¶ms);
|
---|
| 1205 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 1206 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 1207 |
|
---|
| 1208 | rc = ds_window_create(client, ¶ms, &w0);
|
---|
| 1209 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1210 |
|
---|
| 1211 | rc = ds_window_create(client, ¶ms, &w1);
|
---|
| 1212 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1213 | w1->flags |= wndf_minimized;
|
---|
| 1214 |
|
---|
| 1215 | rc = ds_window_create(client, ¶ms, &w2);
|
---|
| 1216 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1217 | w2->flags |= wndf_system;
|
---|
| 1218 |
|
---|
[acd7ac2] | 1219 | wnd = ds_window_find_next(w0, wndf_minimized);
|
---|
[17c0f5d] | 1220 | PCUT_ASSERT_EQUALS(w1, wnd);
|
---|
| 1221 |
|
---|
[acd7ac2] | 1222 | wnd = ds_window_find_next(w0, wndf_system);
|
---|
[17c0f5d] | 1223 | PCUT_ASSERT_EQUALS(w2, wnd);
|
---|
| 1224 |
|
---|
[acd7ac2] | 1225 | wnd = ds_window_find_next(w0, wndf_maximized);
|
---|
| 1226 | PCUT_ASSERT_NULL(wnd);
|
---|
| 1227 |
|
---|
| 1228 | ds_window_destroy(w0);
|
---|
| 1229 | ds_window_destroy(w1);
|
---|
| 1230 | ds_window_destroy(w2);
|
---|
| 1231 | ds_seat_destroy(seat);
|
---|
| 1232 | ds_client_destroy(client);
|
---|
| 1233 | ds_display_destroy(disp);
|
---|
| 1234 | }
|
---|
| 1235 |
|
---|
| 1236 | /** ds_window_find_prev() finds previous window by flags */
|
---|
| 1237 | PCUT_TEST(window_find_prev)
|
---|
| 1238 | {
|
---|
| 1239 | gfx_context_t *gc;
|
---|
| 1240 | ds_display_t *disp;
|
---|
| 1241 | ds_client_t *client;
|
---|
| 1242 | ds_seat_t *seat;
|
---|
| 1243 | ds_window_t *w0;
|
---|
| 1244 | ds_window_t *w1;
|
---|
| 1245 | ds_window_t *w2;
|
---|
| 1246 | ds_window_t *wnd;
|
---|
| 1247 | display_wnd_params_t params;
|
---|
| 1248 | errno_t rc;
|
---|
| 1249 |
|
---|
| 1250 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 1251 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1252 |
|
---|
| 1253 | rc = ds_display_create(gc, df_none, &disp);
|
---|
| 1254 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1255 |
|
---|
| 1256 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 1257 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1258 |
|
---|
| 1259 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
| 1260 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1261 |
|
---|
| 1262 | display_wnd_params_init(¶ms);
|
---|
| 1263 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 1264 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 1265 |
|
---|
| 1266 | rc = ds_window_create(client, ¶ms, &w2);
|
---|
| 1267 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1268 | w2->flags |= wndf_system;
|
---|
| 1269 |
|
---|
| 1270 | rc = ds_window_create(client, ¶ms, &w1);
|
---|
| 1271 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1272 | w1->flags |= wndf_minimized;
|
---|
| 1273 |
|
---|
| 1274 | rc = ds_window_create(client, ¶ms, &w0);
|
---|
| 1275 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1276 |
|
---|
| 1277 | wnd = ds_window_find_prev(w0, wndf_minimized);
|
---|
| 1278 | PCUT_ASSERT_EQUALS(w1, wnd);
|
---|
| 1279 |
|
---|
| 1280 | wnd = ds_window_find_prev(w0, wndf_system);
|
---|
| 1281 | PCUT_ASSERT_EQUALS(w2, wnd);
|
---|
| 1282 |
|
---|
| 1283 | wnd = ds_window_find_prev(w0, wndf_maximized);
|
---|
[17c0f5d] | 1284 | PCUT_ASSERT_NULL(wnd);
|
---|
| 1285 |
|
---|
| 1286 | ds_window_destroy(w0);
|
---|
| 1287 | ds_window_destroy(w1);
|
---|
| 1288 | ds_window_destroy(w2);
|
---|
| 1289 | ds_seat_destroy(seat);
|
---|
| 1290 | ds_client_destroy(client);
|
---|
| 1291 | ds_display_destroy(disp);
|
---|
| 1292 | }
|
---|
| 1293 |
|
---|
| 1294 | /** ds_window_unfocus() switches to another window */
|
---|
| 1295 | PCUT_TEST(window_unfocus)
|
---|
| 1296 | {
|
---|
| 1297 | gfx_context_t *gc;
|
---|
| 1298 | ds_display_t *disp;
|
---|
| 1299 | ds_client_t *client;
|
---|
| 1300 | ds_seat_t *seat;
|
---|
| 1301 | ds_window_t *w0;
|
---|
| 1302 | ds_window_t *w1;
|
---|
| 1303 | display_wnd_params_t params;
|
---|
| 1304 | errno_t rc;
|
---|
| 1305 |
|
---|
| 1306 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 1307 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1308 |
|
---|
| 1309 | rc = ds_display_create(gc, df_none, &disp);
|
---|
| 1310 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1311 |
|
---|
| 1312 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 1313 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1314 |
|
---|
[d8503fd] | 1315 | rc = ds_seat_create(disp, "Alice", &seat);
|
---|
[17c0f5d] | 1316 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1317 |
|
---|
| 1318 | display_wnd_params_init(¶ms);
|
---|
| 1319 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 1320 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 1321 |
|
---|
| 1322 | rc = ds_window_create(client, ¶ms, &w1);
|
---|
| 1323 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1324 |
|
---|
| 1325 | rc = ds_window_create(client, ¶ms, &w0);
|
---|
| 1326 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1327 |
|
---|
| 1328 | PCUT_ASSERT_EQUALS(w0, seat->focus);
|
---|
| 1329 |
|
---|
| 1330 | ds_window_unfocus(w0);
|
---|
| 1331 |
|
---|
| 1332 | PCUT_ASSERT_EQUALS(w1, seat->focus);
|
---|
| 1333 |
|
---|
| 1334 | ds_window_destroy(w0);
|
---|
| 1335 | ds_window_destroy(w1);
|
---|
| 1336 | ds_seat_destroy(seat);
|
---|
| 1337 | ds_client_destroy(client);
|
---|
| 1338 | ds_display_destroy(disp);
|
---|
| 1339 | }
|
---|
| 1340 |
|
---|
[6828a56] | 1341 | /** ds_window_orig_seat() correctly compares seats */
|
---|
| 1342 | PCUT_TEST(window_orig_seat)
|
---|
| 1343 | {
|
---|
| 1344 | gfx_context_t *gc;
|
---|
| 1345 | ds_display_t *disp;
|
---|
| 1346 | ds_client_t *client;
|
---|
| 1347 | ds_seat_t *seat0;
|
---|
| 1348 | ds_seat_t *seat1;
|
---|
| 1349 | sysarg_t devid0;
|
---|
| 1350 | sysarg_t devid1;
|
---|
| 1351 | ds_idevcfg_t *cfg0;
|
---|
| 1352 | ds_idevcfg_t *cfg1;
|
---|
| 1353 | ds_window_t *wnd;
|
---|
| 1354 | display_wnd_params_t params;
|
---|
| 1355 | errno_t rc;
|
---|
| 1356 |
|
---|
| 1357 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
---|
| 1358 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1359 |
|
---|
| 1360 | rc = ds_display_create(gc, df_none, &disp);
|
---|
| 1361 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1362 |
|
---|
| 1363 | rc = ds_client_create(disp, NULL, NULL, &client);
|
---|
| 1364 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1365 |
|
---|
| 1366 | rc = ds_seat_create(disp, "Alice", &seat0);
|
---|
| 1367 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1368 |
|
---|
| 1369 | rc = ds_seat_create(disp, "Bob", &seat1);
|
---|
| 1370 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1371 |
|
---|
| 1372 | display_wnd_params_init(¶ms);
|
---|
| 1373 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 1374 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 1375 |
|
---|
| 1376 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
| 1377 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1378 |
|
---|
| 1379 | devid0 = 42;
|
---|
| 1380 | devid1 = 43;
|
---|
| 1381 |
|
---|
| 1382 | rc = ds_idevcfg_create(disp, devid0, seat0, &cfg0);
|
---|
| 1383 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1384 |
|
---|
| 1385 | rc = ds_idevcfg_create(disp, devid1, seat1, &cfg1);
|
---|
| 1386 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1387 |
|
---|
| 1388 | wnd->state = dsw_moving;
|
---|
| 1389 | wnd->orig_pos_id = devid0;
|
---|
| 1390 |
|
---|
| 1391 | PCUT_ASSERT_TRUE(ds_window_orig_seat(wnd, devid0));
|
---|
| 1392 | PCUT_ASSERT_FALSE(ds_window_orig_seat(wnd, devid1));
|
---|
| 1393 |
|
---|
| 1394 | ds_idevcfg_destroy(cfg0);
|
---|
| 1395 | ds_idevcfg_destroy(cfg1);
|
---|
| 1396 | ds_window_destroy(wnd);
|
---|
| 1397 | ds_seat_destroy(seat0);
|
---|
| 1398 | ds_seat_destroy(seat1);
|
---|
| 1399 | ds_client_destroy(client);
|
---|
| 1400 | ds_display_destroy(disp);
|
---|
| 1401 | }
|
---|
| 1402 |
|
---|
[a40ae0d] | 1403 | static errno_t dummy_set_color(void *arg, gfx_color_t *color)
|
---|
| 1404 | {
|
---|
| 1405 | return EOK;
|
---|
| 1406 | }
|
---|
| 1407 |
|
---|
| 1408 | static errno_t dummy_fill_rect(void *arg, gfx_rect_t *rect)
|
---|
| 1409 | {
|
---|
| 1410 | return EOK;
|
---|
| 1411 | }
|
---|
| 1412 |
|
---|
[bef51cf] | 1413 | PCUT_EXPORT(window);
|
---|