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