| 1 | /*
|
|---|
| 2 | * Copyright (c) 2023 Jiri Svoboda
|
|---|
| 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 |
|
|---|
| 29 | #include <disp_srv.h>
|
|---|
| 30 | #include <errno.h>
|
|---|
| 31 | #include <gfx/context.h>
|
|---|
| 32 | #include <pcut/pcut.h>
|
|---|
| 33 | #include <stdio.h>
|
|---|
| 34 | #include <str.h>
|
|---|
| 35 |
|
|---|
| 36 | #include "../client.h"
|
|---|
| 37 | #include "../display.h"
|
|---|
| 38 | #include "../seat.h"
|
|---|
| 39 | #include "../window.h"
|
|---|
| 40 |
|
|---|
| 41 | PCUT_INIT;
|
|---|
| 42 |
|
|---|
| 43 | PCUT_TEST_SUITE(window);
|
|---|
| 44 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 69 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 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 |
|
|---|
| 102 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 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 |
|
|---|
| 131 | /** Test ds_window_resize(). */
|
|---|
| 132 | PCUT_TEST(window_resize)
|
|---|
| 133 | {
|
|---|
| 134 | ds_display_t *disp;
|
|---|
| 135 | ds_client_t *client;
|
|---|
| 136 | ds_seat_t *seat;
|
|---|
| 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 |
|
|---|
| 143 | rc = ds_display_create(NULL, df_none, &disp);
|
|---|
| 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 |
|
|---|
| 149 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 150 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 151 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 196 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 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 |
|
|---|
| 237 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 279 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 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 |
|
|---|
| 316 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 354 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 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 |
|
|---|
| 394 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 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 |
|
|---|
| 415 | ds_window_destroy(wnd);
|
|---|
| 416 | ds_seat_destroy(seat);
|
|---|
| 417 | ds_client_destroy(client);
|
|---|
| 418 | ds_display_destroy(disp);
|
|---|
| 419 | }
|
|---|
| 420 |
|
|---|
| 421 | /** Test ds_window_get_ctx(). */
|
|---|
| 422 | PCUT_TEST(window_get_ctx)
|
|---|
| 423 | {
|
|---|
| 424 | ds_display_t *disp;
|
|---|
| 425 | ds_client_t *client;
|
|---|
| 426 | ds_seat_t *seat;
|
|---|
| 427 | ds_window_t *wnd;
|
|---|
| 428 | display_wnd_params_t params;
|
|---|
| 429 | gfx_context_t *gc;
|
|---|
| 430 | errno_t rc;
|
|---|
| 431 |
|
|---|
| 432 | rc = ds_display_create(NULL, df_none, &disp);
|
|---|
| 433 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 434 |
|
|---|
| 435 | rc = ds_client_create(disp, NULL, NULL, &client);
|
|---|
| 436 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 437 |
|
|---|
| 438 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 439 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 440 |
|
|---|
| 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);
|
|---|
| 446 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 447 |
|
|---|
| 448 | gc = ds_window_get_ctx(wnd);
|
|---|
| 449 | PCUT_ASSERT_NOT_NULL(gc);
|
|---|
| 450 |
|
|---|
| 451 | ds_window_destroy(wnd);
|
|---|
| 452 | ds_seat_destroy(seat);
|
|---|
| 453 | ds_client_destroy(client);
|
|---|
| 454 | ds_display_destroy(disp);
|
|---|
| 455 | }
|
|---|
| 456 |
|
|---|
| 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 |
|
|---|
| 473 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 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 |
|
|---|
| 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;
|
|---|
| 501 | ds_seat_t *seat;
|
|---|
| 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 |
|
|---|
| 512 | rc = ds_display_create(gc, df_none, &disp);
|
|---|
| 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 |
|
|---|
| 518 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 519 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 520 |
|
|---|
| 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 |
|
|---|
| 528 | /* New window gets focused event */
|
|---|
| 529 | rc = ds_client_get_event(client, &rwindow, &revent);
|
|---|
| 530 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 531 |
|
|---|
| 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);
|
|---|
| 547 | ds_seat_destroy(seat);
|
|---|
| 548 | ds_client_destroy(client);
|
|---|
| 549 | ds_display_destroy(disp);
|
|---|
| 550 | }
|
|---|
| 551 |
|
|---|
| 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;
|
|---|
| 558 | ds_seat_t *seat;
|
|---|
| 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 |
|
|---|
| 567 | rc = ds_display_create(gc, df_none, &disp);
|
|---|
| 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 |
|
|---|
| 573 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 574 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 575 |
|
|---|
| 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 |
|
|---|
| 585 | wnd->dpos.x = 10;
|
|---|
| 586 | wnd->dpos.y = 10;
|
|---|
| 587 |
|
|---|
| 588 | event.type = POS_PRESS;
|
|---|
| 589 | event.btn_num = 2;
|
|---|
| 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);
|
|---|
| 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);
|
|---|
| 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);
|
|---|
| 616 | PCUT_ASSERT_INT_EQUALS(13, wnd->dpos.x);
|
|---|
| 617 | PCUT_ASSERT_INT_EQUALS(14, wnd->dpos.y);
|
|---|
| 618 |
|
|---|
| 619 | ds_window_destroy(wnd);
|
|---|
| 620 | ds_seat_destroy(seat);
|
|---|
| 621 | ds_client_destroy(client);
|
|---|
| 622 | ds_display_destroy(disp);
|
|---|
| 623 | }
|
|---|
| 624 |
|
|---|
| 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 |
|
|---|
| 645 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 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 |
|
|---|
| 684 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 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 |
|
|---|
| 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;
|
|---|
| 709 | ds_seat_t *seat;
|
|---|
| 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 |
|
|---|
| 718 | rc = ds_display_create(gc, df_none, &disp);
|
|---|
| 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 |
|
|---|
| 724 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 725 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 726 |
|
|---|
| 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);
|
|---|
| 743 |
|
|---|
| 744 | ds_window_destroy(wnd);
|
|---|
| 745 | ds_seat_destroy(seat);
|
|---|
| 746 | ds_client_destroy(client);
|
|---|
| 747 | ds_display_destroy(disp);
|
|---|
| 748 | }
|
|---|
| 749 |
|
|---|
| 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;
|
|---|
| 756 | ds_seat_t *seat;
|
|---|
| 757 | ds_window_t *wnd;
|
|---|
| 758 | display_wnd_params_t params;
|
|---|
| 759 | gfx_coord2_t pos;
|
|---|
| 760 | sysarg_t pos_id;
|
|---|
| 761 | errno_t rc;
|
|---|
| 762 |
|
|---|
| 763 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
|---|
| 764 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 765 |
|
|---|
| 766 | rc = ds_display_create(gc, df_none, &disp);
|
|---|
| 767 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 768 |
|
|---|
| 769 | rc = ds_client_create(disp, NULL, NULL, &client);
|
|---|
| 770 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 771 |
|
|---|
| 772 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 773 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 774 |
|
|---|
| 775 | display_wnd_params_init(¶ms);
|
|---|
| 776 | params.rect.p0.x = params.rect.p0.y = 0;
|
|---|
| 777 | params.rect.p1.x = params.rect.p1.y = 1;
|
|---|
| 778 |
|
|---|
| 779 | rc = ds_window_create(client, ¶ms, &wnd);
|
|---|
| 780 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 781 |
|
|---|
| 782 | PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state);
|
|---|
| 783 |
|
|---|
| 784 | pos.x = 42;
|
|---|
| 785 | pos.y = 43;
|
|---|
| 786 | pos_id = 44;
|
|---|
| 787 | ds_window_resize_req(wnd, display_wr_top_right, &pos, pos_id);
|
|---|
| 788 |
|
|---|
| 789 | PCUT_ASSERT_INT_EQUALS(dsw_resizing, wnd->state);
|
|---|
| 790 | PCUT_ASSERT_INT_EQUALS(display_wr_top_right, wnd->rsztype);
|
|---|
| 791 | PCUT_ASSERT_INT_EQUALS(pos.x, wnd->orig_pos.x);
|
|---|
| 792 | PCUT_ASSERT_INT_EQUALS(pos.y, wnd->orig_pos.y);
|
|---|
| 793 |
|
|---|
| 794 | ds_window_destroy(wnd);
|
|---|
| 795 | ds_seat_destroy(seat);
|
|---|
| 796 | ds_client_destroy(client);
|
|---|
| 797 | ds_display_destroy(disp);
|
|---|
| 798 | }
|
|---|
| 799 |
|
|---|
| 800 | PCUT_TEST(window_calc_resize)
|
|---|
| 801 | {
|
|---|
| 802 | ds_display_t *disp;
|
|---|
| 803 | ds_client_t *client;
|
|---|
| 804 | ds_seat_t *seat;
|
|---|
| 805 | ds_window_t *wnd;
|
|---|
| 806 | display_wnd_params_t params;
|
|---|
| 807 | gfx_coord2_t dresize;
|
|---|
| 808 | gfx_coord2_t dresizen;
|
|---|
| 809 | gfx_coord2_t dresizeb;
|
|---|
| 810 | gfx_coord2_t dresizebn;
|
|---|
| 811 | gfx_rect_t nrect;
|
|---|
| 812 | errno_t rc;
|
|---|
| 813 |
|
|---|
| 814 | rc = ds_display_create(NULL, df_none, &disp);
|
|---|
| 815 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 816 |
|
|---|
| 817 | rc = ds_client_create(disp, NULL, NULL, &client);
|
|---|
| 818 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 819 |
|
|---|
| 820 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 821 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 822 |
|
|---|
| 823 | display_wnd_params_init(¶ms);
|
|---|
| 824 | params.rect.p0.x = 10;
|
|---|
| 825 | params.rect.p0.y = 11;
|
|---|
| 826 | params.rect.p1.x = 30;
|
|---|
| 827 | params.rect.p1.y = 31;
|
|---|
| 828 | params.min_size.x = 2;
|
|---|
| 829 | params.min_size.y = 3;
|
|---|
| 830 |
|
|---|
| 831 | rc = ds_window_create(client, ¶ms, &wnd);
|
|---|
| 832 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 833 |
|
|---|
| 834 | wnd->state = dsw_resizing;
|
|---|
| 835 |
|
|---|
| 836 | dresize.x = 5;
|
|---|
| 837 | dresize.y = 6;
|
|---|
| 838 |
|
|---|
| 839 | dresizen.x = -5;
|
|---|
| 840 | dresizen.y = -6;
|
|---|
| 841 |
|
|---|
| 842 | dresizeb.x = 50;
|
|---|
| 843 | dresizeb.y = 60;
|
|---|
| 844 |
|
|---|
| 845 | dresizebn.x = -50;
|
|---|
| 846 | dresizebn.y = -60;
|
|---|
| 847 |
|
|---|
| 848 | /* Resize top */
|
|---|
| 849 | wnd->rsztype = display_wr_top;
|
|---|
| 850 |
|
|---|
| 851 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
|---|
| 852 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 853 | PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y);
|
|---|
| 854 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 855 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 856 |
|
|---|
| 857 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
|---|
| 858 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 859 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.y);
|
|---|
| 860 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 861 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 862 |
|
|---|
| 863 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
|---|
| 864 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 865 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.y);
|
|---|
| 866 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 867 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 868 |
|
|---|
| 869 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
|---|
| 870 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 871 | PCUT_ASSERT_INT_EQUALS(-49, nrect.p0.y);
|
|---|
| 872 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 873 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 874 |
|
|---|
| 875 | /* Resize top left */
|
|---|
| 876 | wnd->rsztype = display_wr_top_left;
|
|---|
| 877 |
|
|---|
| 878 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
|---|
| 879 | PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x);
|
|---|
| 880 | PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y);
|
|---|
| 881 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 882 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 883 |
|
|---|
| 884 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
|---|
| 885 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.x);
|
|---|
| 886 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.y);
|
|---|
| 887 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 888 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 889 |
|
|---|
| 890 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
|---|
| 891 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.x);
|
|---|
| 892 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.y);
|
|---|
| 893 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 894 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 895 |
|
|---|
| 896 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
|---|
| 897 | PCUT_ASSERT_INT_EQUALS(-40, nrect.p0.x);
|
|---|
| 898 | PCUT_ASSERT_INT_EQUALS(-49, nrect.p0.y);
|
|---|
| 899 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 900 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 901 |
|
|---|
| 902 | /* Resize left */
|
|---|
| 903 | wnd->rsztype = display_wr_left;
|
|---|
| 904 |
|
|---|
| 905 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
|---|
| 906 | PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x);
|
|---|
| 907 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 908 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 909 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 910 |
|
|---|
| 911 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
|---|
| 912 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.x);
|
|---|
| 913 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 914 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 915 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 916 |
|
|---|
| 917 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
|---|
| 918 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.x);
|
|---|
| 919 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 920 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 921 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 922 |
|
|---|
| 923 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
|---|
| 924 | PCUT_ASSERT_INT_EQUALS(-40, nrect.p0.x);
|
|---|
| 925 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 926 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 927 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 928 |
|
|---|
| 929 | /* Resize bottom left */
|
|---|
| 930 | wnd->rsztype = display_wr_bottom_left;
|
|---|
| 931 |
|
|---|
| 932 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
|---|
| 933 | PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x);
|
|---|
| 934 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 935 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 936 | PCUT_ASSERT_INT_EQUALS(37, nrect.p1.y);
|
|---|
| 937 |
|
|---|
| 938 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
|---|
| 939 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.x);
|
|---|
| 940 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 941 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 942 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.y);
|
|---|
| 943 |
|
|---|
| 944 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
|---|
| 945 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.x);
|
|---|
| 946 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 947 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 948 | PCUT_ASSERT_INT_EQUALS(91, nrect.p1.y);
|
|---|
| 949 |
|
|---|
| 950 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
|---|
| 951 | PCUT_ASSERT_INT_EQUALS(-40, nrect.p0.x);
|
|---|
| 952 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 953 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 954 | PCUT_ASSERT_INT_EQUALS(14, nrect.p1.y);
|
|---|
| 955 |
|
|---|
| 956 | /* Resize bottom */
|
|---|
| 957 | wnd->rsztype = display_wr_bottom;
|
|---|
| 958 |
|
|---|
| 959 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
|---|
| 960 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 961 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 962 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 963 | PCUT_ASSERT_INT_EQUALS(37, nrect.p1.y);
|
|---|
| 964 |
|
|---|
| 965 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
|---|
| 966 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 967 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 968 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 969 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.y);
|
|---|
| 970 |
|
|---|
| 971 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
|---|
| 972 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 973 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 974 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 975 | PCUT_ASSERT_INT_EQUALS(91, nrect.p1.y);
|
|---|
| 976 |
|
|---|
| 977 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
|---|
| 978 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 979 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 980 | PCUT_ASSERT_INT_EQUALS(30, nrect.p1.x);
|
|---|
| 981 | PCUT_ASSERT_INT_EQUALS(14, nrect.p1.y);
|
|---|
| 982 |
|
|---|
| 983 | /* Resize bottom right */
|
|---|
| 984 | wnd->rsztype = display_wr_bottom_right;
|
|---|
| 985 |
|
|---|
| 986 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
|---|
| 987 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 988 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 989 | PCUT_ASSERT_INT_EQUALS(35, nrect.p1.x);
|
|---|
| 990 | PCUT_ASSERT_INT_EQUALS(37, nrect.p1.y);
|
|---|
| 991 |
|
|---|
| 992 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
|---|
| 993 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 994 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 995 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x);
|
|---|
| 996 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.y);
|
|---|
| 997 |
|
|---|
| 998 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
|---|
| 999 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 1000 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 1001 | PCUT_ASSERT_INT_EQUALS(80, nrect.p1.x);
|
|---|
| 1002 | PCUT_ASSERT_INT_EQUALS(91, nrect.p1.y);
|
|---|
| 1003 |
|
|---|
| 1004 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
|---|
| 1005 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 1006 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 1007 | PCUT_ASSERT_INT_EQUALS(12, nrect.p1.x);
|
|---|
| 1008 | PCUT_ASSERT_INT_EQUALS(14, nrect.p1.y);
|
|---|
| 1009 |
|
|---|
| 1010 | /* Resize right */
|
|---|
| 1011 | wnd->rsztype = display_wr_right;
|
|---|
| 1012 |
|
|---|
| 1013 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
|---|
| 1014 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 1015 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 1016 | PCUT_ASSERT_INT_EQUALS(35, nrect.p1.x);
|
|---|
| 1017 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 1018 |
|
|---|
| 1019 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
|---|
| 1020 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 1021 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 1022 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x);
|
|---|
| 1023 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 1024 |
|
|---|
| 1025 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
|---|
| 1026 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 1027 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 1028 | PCUT_ASSERT_INT_EQUALS(80, nrect.p1.x);
|
|---|
| 1029 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 1030 |
|
|---|
| 1031 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
|---|
| 1032 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 1033 | PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y);
|
|---|
| 1034 | PCUT_ASSERT_INT_EQUALS(12, nrect.p1.x);
|
|---|
| 1035 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 1036 |
|
|---|
| 1037 | /* Resize top right */
|
|---|
| 1038 | wnd->rsztype = display_wr_top_right;
|
|---|
| 1039 |
|
|---|
| 1040 | ds_window_calc_resize(wnd, &dresize, &nrect);
|
|---|
| 1041 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 1042 | PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y);
|
|---|
| 1043 | PCUT_ASSERT_INT_EQUALS(35, nrect.p1.x);
|
|---|
| 1044 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 1045 |
|
|---|
| 1046 | ds_window_calc_resize(wnd, &dresizen, &nrect);
|
|---|
| 1047 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 1048 | PCUT_ASSERT_INT_EQUALS(5, nrect.p0.y);
|
|---|
| 1049 | PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x);
|
|---|
| 1050 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 1051 |
|
|---|
| 1052 | ds_window_calc_resize(wnd, &dresizeb, &nrect);
|
|---|
| 1053 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 1054 | PCUT_ASSERT_INT_EQUALS(28, nrect.p0.y);
|
|---|
| 1055 | PCUT_ASSERT_INT_EQUALS(80, nrect.p1.x);
|
|---|
| 1056 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 1057 |
|
|---|
| 1058 | ds_window_calc_resize(wnd, &dresizebn, &nrect);
|
|---|
| 1059 | PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x);
|
|---|
| 1060 | PCUT_ASSERT_INT_EQUALS(-49, nrect.p0.y);
|
|---|
| 1061 | PCUT_ASSERT_INT_EQUALS(12, nrect.p1.x);
|
|---|
| 1062 | PCUT_ASSERT_INT_EQUALS(31, nrect.p1.y);
|
|---|
| 1063 |
|
|---|
| 1064 | ds_window_destroy(wnd);
|
|---|
| 1065 | ds_seat_destroy(seat);
|
|---|
| 1066 | ds_client_destroy(client);
|
|---|
| 1067 | ds_display_destroy(disp);
|
|---|
| 1068 | }
|
|---|
| 1069 |
|
|---|
| 1070 | /** Test ds_window_set_cursor() */
|
|---|
| 1071 | PCUT_TEST(window_set_cursor)
|
|---|
| 1072 | {
|
|---|
| 1073 | gfx_context_t *gc;
|
|---|
| 1074 | ds_display_t *disp;
|
|---|
| 1075 | ds_client_t *client;
|
|---|
| 1076 | ds_seat_t *seat;
|
|---|
| 1077 | ds_window_t *wnd;
|
|---|
| 1078 | display_wnd_params_t params;
|
|---|
| 1079 | errno_t rc;
|
|---|
| 1080 |
|
|---|
| 1081 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
|---|
| 1082 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1083 |
|
|---|
| 1084 | rc = ds_display_create(gc, df_none, &disp);
|
|---|
| 1085 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1086 |
|
|---|
| 1087 | rc = ds_client_create(disp, NULL, NULL, &client);
|
|---|
| 1088 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1089 |
|
|---|
| 1090 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 1091 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1092 |
|
|---|
| 1093 | display_wnd_params_init(¶ms);
|
|---|
| 1094 | params.rect.p0.x = params.rect.p0.y = 0;
|
|---|
| 1095 | params.rect.p1.x = params.rect.p1.y = 1;
|
|---|
| 1096 |
|
|---|
| 1097 | rc = ds_window_create(client, ¶ms, &wnd);
|
|---|
| 1098 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1099 |
|
|---|
| 1100 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
|---|
| 1101 |
|
|---|
| 1102 | rc = ds_window_set_cursor(wnd, -1);
|
|---|
| 1103 | PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
|
|---|
| 1104 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
|---|
| 1105 |
|
|---|
| 1106 | rc = ds_window_set_cursor(wnd, dcurs_limit);
|
|---|
| 1107 | PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
|
|---|
| 1108 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
|---|
| 1109 |
|
|---|
| 1110 | rc = ds_window_set_cursor(wnd, dcurs_limit + 1);
|
|---|
| 1111 | PCUT_ASSERT_ERRNO_VAL(EINVAL, rc);
|
|---|
| 1112 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
|---|
| 1113 |
|
|---|
| 1114 | rc = ds_window_set_cursor(wnd, dcurs_size_lr);
|
|---|
| 1115 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1116 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_size_lr], wnd->cursor);
|
|---|
| 1117 |
|
|---|
| 1118 | ds_window_destroy(wnd);
|
|---|
| 1119 | ds_seat_destroy(seat);
|
|---|
| 1120 | ds_client_destroy(client);
|
|---|
| 1121 | ds_display_destroy(disp);
|
|---|
| 1122 | }
|
|---|
| 1123 |
|
|---|
| 1124 | /** Test ds_window_set_caption() */
|
|---|
| 1125 | PCUT_TEST(window_set_caption)
|
|---|
| 1126 | {
|
|---|
| 1127 | gfx_context_t *gc;
|
|---|
| 1128 | ds_display_t *disp;
|
|---|
| 1129 | ds_client_t *client;
|
|---|
| 1130 | ds_seat_t *seat;
|
|---|
| 1131 | ds_window_t *wnd;
|
|---|
| 1132 | display_wnd_params_t params;
|
|---|
| 1133 | errno_t rc;
|
|---|
| 1134 |
|
|---|
| 1135 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
|---|
| 1136 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1137 |
|
|---|
| 1138 | rc = ds_display_create(gc, df_none, &disp);
|
|---|
| 1139 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1140 |
|
|---|
| 1141 | rc = ds_client_create(disp, NULL, NULL, &client);
|
|---|
| 1142 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1143 |
|
|---|
| 1144 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 1145 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1146 |
|
|---|
| 1147 | display_wnd_params_init(¶ms);
|
|---|
| 1148 | params.rect.p0.x = params.rect.p0.y = 0;
|
|---|
| 1149 | params.rect.p1.x = params.rect.p1.y = 1;
|
|---|
| 1150 |
|
|---|
| 1151 | rc = ds_window_create(client, ¶ms, &wnd);
|
|---|
| 1152 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1153 |
|
|---|
| 1154 | PCUT_ASSERT_EQUALS(wnd->display->cursor[dcurs_arrow], wnd->cursor);
|
|---|
| 1155 |
|
|---|
| 1156 | rc = ds_window_set_caption(wnd, "Hello");
|
|---|
| 1157 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1158 | PCUT_ASSERT_INT_EQUALS(0, str_cmp("Hello", wnd->caption));
|
|---|
| 1159 |
|
|---|
| 1160 | ds_window_destroy(wnd);
|
|---|
| 1161 | ds_seat_destroy(seat);
|
|---|
| 1162 | ds_client_destroy(client);
|
|---|
| 1163 | ds_display_destroy(disp);
|
|---|
| 1164 | }
|
|---|
| 1165 |
|
|---|
| 1166 | /** ds_window_find_alt() finds alternate window by flags */
|
|---|
| 1167 | PCUT_TEST(window_find_alt)
|
|---|
| 1168 | {
|
|---|
| 1169 | gfx_context_t *gc;
|
|---|
| 1170 | ds_display_t *disp;
|
|---|
| 1171 | ds_client_t *client;
|
|---|
| 1172 | ds_seat_t *seat;
|
|---|
| 1173 | ds_window_t *w0;
|
|---|
| 1174 | ds_window_t *w1;
|
|---|
| 1175 | ds_window_t *w2;
|
|---|
| 1176 | ds_window_t *wnd;
|
|---|
| 1177 | display_wnd_params_t params;
|
|---|
| 1178 | errno_t rc;
|
|---|
| 1179 |
|
|---|
| 1180 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
|---|
| 1181 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1182 |
|
|---|
| 1183 | rc = ds_display_create(gc, df_none, &disp);
|
|---|
| 1184 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1185 |
|
|---|
| 1186 | rc = ds_client_create(disp, NULL, NULL, &client);
|
|---|
| 1187 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1188 |
|
|---|
| 1189 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 1190 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1191 |
|
|---|
| 1192 | display_wnd_params_init(¶ms);
|
|---|
| 1193 | params.rect.p0.x = params.rect.p0.y = 0;
|
|---|
| 1194 | params.rect.p1.x = params.rect.p1.y = 1;
|
|---|
| 1195 |
|
|---|
| 1196 | rc = ds_window_create(client, ¶ms, &w0);
|
|---|
| 1197 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1198 |
|
|---|
| 1199 | rc = ds_window_create(client, ¶ms, &w1);
|
|---|
| 1200 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1201 | w1->flags |= wndf_minimized;
|
|---|
| 1202 |
|
|---|
| 1203 | rc = ds_window_create(client, ¶ms, &w2);
|
|---|
| 1204 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1205 | w2->flags |= wndf_system;
|
|---|
| 1206 |
|
|---|
| 1207 | wnd = ds_window_find_alt(w0, wndf_minimized);
|
|---|
| 1208 | PCUT_ASSERT_EQUALS(w1, wnd);
|
|---|
| 1209 |
|
|---|
| 1210 | wnd = ds_window_find_alt(w0, wndf_system);
|
|---|
| 1211 | PCUT_ASSERT_EQUALS(w2, wnd);
|
|---|
| 1212 |
|
|---|
| 1213 | wnd = ds_window_find_alt(w0, wndf_maximized);
|
|---|
| 1214 | PCUT_ASSERT_NULL(wnd);
|
|---|
| 1215 |
|
|---|
| 1216 | ds_window_destroy(w0);
|
|---|
| 1217 | ds_window_destroy(w1);
|
|---|
| 1218 | ds_window_destroy(w2);
|
|---|
| 1219 | ds_seat_destroy(seat);
|
|---|
| 1220 | ds_client_destroy(client);
|
|---|
| 1221 | ds_display_destroy(disp);
|
|---|
| 1222 | }
|
|---|
| 1223 |
|
|---|
| 1224 | /** ds_window_unfocus() switches to another window */
|
|---|
| 1225 | PCUT_TEST(window_unfocus)
|
|---|
| 1226 | {
|
|---|
| 1227 | gfx_context_t *gc;
|
|---|
| 1228 | ds_display_t *disp;
|
|---|
| 1229 | ds_client_t *client;
|
|---|
| 1230 | ds_seat_t *seat;
|
|---|
| 1231 | ds_window_t *w0;
|
|---|
| 1232 | ds_window_t *w1;
|
|---|
| 1233 | display_wnd_params_t params;
|
|---|
| 1234 | errno_t rc;
|
|---|
| 1235 |
|
|---|
| 1236 | rc = gfx_context_new(&dummy_ops, NULL, &gc);
|
|---|
| 1237 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1238 |
|
|---|
| 1239 | rc = ds_display_create(gc, df_none, &disp);
|
|---|
| 1240 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1241 |
|
|---|
| 1242 | rc = ds_client_create(disp, NULL, NULL, &client);
|
|---|
| 1243 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1244 |
|
|---|
| 1245 | rc = ds_seat_create(disp, "Alice", &seat);
|
|---|
| 1246 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1247 |
|
|---|
| 1248 | display_wnd_params_init(¶ms);
|
|---|
| 1249 | params.rect.p0.x = params.rect.p0.y = 0;
|
|---|
| 1250 | params.rect.p1.x = params.rect.p1.y = 1;
|
|---|
| 1251 |
|
|---|
| 1252 | rc = ds_window_create(client, ¶ms, &w1);
|
|---|
| 1253 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1254 |
|
|---|
| 1255 | rc = ds_window_create(client, ¶ms, &w0);
|
|---|
| 1256 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1257 |
|
|---|
| 1258 | PCUT_ASSERT_EQUALS(w0, seat->focus);
|
|---|
| 1259 |
|
|---|
| 1260 | ds_window_unfocus(w0);
|
|---|
| 1261 |
|
|---|
| 1262 | PCUT_ASSERT_EQUALS(w1, seat->focus);
|
|---|
| 1263 |
|
|---|
| 1264 | ds_window_destroy(w0);
|
|---|
| 1265 | ds_window_destroy(w1);
|
|---|
| 1266 | ds_seat_destroy(seat);
|
|---|
| 1267 | ds_client_destroy(client);
|
|---|
| 1268 | ds_display_destroy(disp);
|
|---|
| 1269 | }
|
|---|
| 1270 |
|
|---|
| 1271 | static errno_t dummy_set_color(void *arg, gfx_color_t *color)
|
|---|
| 1272 | {
|
|---|
| 1273 | return EOK;
|
|---|
| 1274 | }
|
|---|
| 1275 |
|
|---|
| 1276 | static errno_t dummy_fill_rect(void *arg, gfx_rect_t *rect)
|
|---|
| 1277 | {
|
|---|
| 1278 | return EOK;
|
|---|
| 1279 | }
|
|---|
| 1280 |
|
|---|
| 1281 | PCUT_EXPORT(window);
|
|---|