[c8cf261] | 1 | /*
|
---|
| 2 | * Copyright (c) 2019 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 |
|
---|
[3434233] | 29 | #include <disp_srv.h>
|
---|
[6af4b4f] | 30 | #include <errno.h>
|
---|
| 31 | #include <pcut/pcut.h>
|
---|
| 32 | #include <str.h>
|
---|
[c8cf261] | 33 |
|
---|
[b3c185b6] | 34 | #include "../client.h"
|
---|
[6af4b4f] | 35 | #include "../display.h"
|
---|
[cf32dbd] | 36 | #include "../seat.h"
|
---|
[b2d1df3] | 37 | #include "../window.h"
|
---|
[c8cf261] | 38 |
|
---|
[6af4b4f] | 39 | PCUT_INIT;
|
---|
[c8cf261] | 40 |
|
---|
[6af4b4f] | 41 | PCUT_TEST_SUITE(display);
|
---|
[c8cf261] | 42 |
|
---|
[be15256] | 43 | static void test_ds_ev_pending(void *);
|
---|
| 44 |
|
---|
| 45 | static ds_client_cb_t test_ds_client_cb = {
|
---|
| 46 | .ev_pending = test_ds_ev_pending
|
---|
| 47 | };
|
---|
| 48 |
|
---|
| 49 | static void test_ds_ev_pending(void *arg)
|
---|
| 50 | {
|
---|
[b2d1df3] | 51 | bool *called_cb = (bool *) arg;
|
---|
| 52 | *called_cb = true;
|
---|
| 53 | }
|
---|
[be15256] | 54 |
|
---|
[6af4b4f] | 55 | /** Display creation and destruction. */
|
---|
[bef51cf] | 56 | PCUT_TEST(display_create_destroy)
|
---|
[6af4b4f] | 57 | {
|
---|
| 58 | ds_display_t *disp;
|
---|
| 59 | errno_t rc;
|
---|
[c8cf261] | 60 |
|
---|
[8aef01c] | 61 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[6af4b4f] | 62 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 63 |
|
---|
| 64 | ds_display_destroy(disp);
|
---|
| 65 | }
|
---|
| 66 |
|
---|
[b3c185b6] | 67 | /** Basic client operation. */
|
---|
| 68 | PCUT_TEST(display_client)
|
---|
[bef51cf] | 69 | {
|
---|
| 70 | ds_display_t *disp;
|
---|
[b3c185b6] | 71 | ds_client_t *client;
|
---|
| 72 | ds_client_t *c0, *c1;
|
---|
[bef51cf] | 73 | errno_t rc;
|
---|
| 74 |
|
---|
[8aef01c] | 75 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[bef51cf] | 76 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 77 |
|
---|
[be15256] | 78 | rc = ds_client_create(disp, &test_ds_client_cb, NULL, &client);
|
---|
[bef51cf] | 79 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 80 |
|
---|
[b3c185b6] | 81 | c0 = ds_display_first_client(disp);
|
---|
| 82 | PCUT_ASSERT_EQUALS(c0, client);
|
---|
[bef51cf] | 83 |
|
---|
[b3c185b6] | 84 | c1 = ds_display_next_client(c0);
|
---|
| 85 | PCUT_ASSERT_NULL(c1);
|
---|
[bef51cf] | 86 |
|
---|
[b3c185b6] | 87 | ds_client_destroy(client);
|
---|
[bef51cf] | 88 | ds_display_destroy(disp);
|
---|
| 89 | }
|
---|
| 90 |
|
---|
[b2d1df3] | 91 | /** Test ds_display_find_window(). */
|
---|
| 92 | PCUT_TEST(display_find_window)
|
---|
| 93 | {
|
---|
| 94 | ds_display_t *disp;
|
---|
| 95 | ds_client_t *client;
|
---|
[b4b4dafe] | 96 | ds_seat_t *seat;
|
---|
[b2d1df3] | 97 | ds_window_t *w0;
|
---|
| 98 | ds_window_t *w1;
|
---|
| 99 | ds_window_t *wnd;
|
---|
[3434233] | 100 | display_wnd_params_t params;
|
---|
[b4b4dafe] | 101 | bool called_cb = false;
|
---|
[b2d1df3] | 102 | errno_t rc;
|
---|
| 103 |
|
---|
[8aef01c] | 104 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[b2d1df3] | 105 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 106 |
|
---|
[b4b4dafe] | 107 | rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
|
---|
| 108 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 109 |
|
---|
| 110 | rc = ds_seat_create(disp, &seat);
|
---|
[b2d1df3] | 111 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 112 |
|
---|
[3434233] | 113 | display_wnd_params_init(¶ms);
|
---|
| 114 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 115 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 116 |
|
---|
| 117 | rc = ds_window_create(client, ¶ms, &w1);
|
---|
[b2d1df3] | 118 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 119 |
|
---|
[3434233] | 120 | rc = ds_window_create(client, ¶ms, &w0);
|
---|
[b2d1df3] | 121 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 122 |
|
---|
[bd1f9a6d] | 123 | wnd = ds_display_first_window(disp);
|
---|
| 124 | PCUT_ASSERT_EQUALS(w0, wnd);
|
---|
| 125 |
|
---|
| 126 | wnd = ds_display_next_window(wnd);
|
---|
| 127 | PCUT_ASSERT_EQUALS(w1, wnd);
|
---|
| 128 |
|
---|
| 129 | wnd = ds_display_next_window(wnd);
|
---|
| 130 | PCUT_ASSERT_NULL(wnd);
|
---|
| 131 |
|
---|
[2012fe0] | 132 | wnd = ds_display_last_window(disp);
|
---|
| 133 | PCUT_ASSERT_EQUALS(w1, wnd);
|
---|
| 134 |
|
---|
| 135 | wnd = ds_display_prev_window(wnd);
|
---|
| 136 | PCUT_ASSERT_EQUALS(w0, wnd);
|
---|
| 137 |
|
---|
| 138 | wnd = ds_display_prev_window(wnd);
|
---|
| 139 | PCUT_ASSERT_NULL(wnd);
|
---|
| 140 |
|
---|
[b2d1df3] | 141 | wnd = ds_display_find_window(disp, w0->id);
|
---|
| 142 | PCUT_ASSERT_EQUALS(w0, wnd);
|
---|
| 143 |
|
---|
| 144 | wnd = ds_display_find_window(disp, w1->id);
|
---|
| 145 | PCUT_ASSERT_EQUALS(w1, wnd);
|
---|
| 146 |
|
---|
| 147 | wnd = ds_display_find_window(disp, 0);
|
---|
| 148 | PCUT_ASSERT_NULL(wnd);
|
---|
| 149 |
|
---|
[bd1f9a6d] | 150 | wnd = ds_display_find_window(disp, w0->id + 1);
|
---|
[b2d1df3] | 151 | PCUT_ASSERT_NULL(wnd);
|
---|
| 152 |
|
---|
[648e2ac] | 153 | ds_window_destroy(w0);
|
---|
| 154 | ds_window_destroy(w1);
|
---|
[b4b4dafe] | 155 | ds_seat_destroy(seat);
|
---|
[b2d1df3] | 156 | ds_client_destroy(client);
|
---|
| 157 | ds_display_destroy(disp);
|
---|
| 158 | }
|
---|
| 159 |
|
---|
[24cf391a] | 160 | /** Test ds_display_window_by_pos(). */
|
---|
| 161 | PCUT_TEST(display_window_by_pos)
|
---|
| 162 | {
|
---|
| 163 | ds_display_t *disp;
|
---|
| 164 | ds_client_t *client;
|
---|
[b4b4dafe] | 165 | ds_seat_t *seat;
|
---|
[24cf391a] | 166 | ds_window_t *w0;
|
---|
| 167 | ds_window_t *w1;
|
---|
| 168 | ds_window_t *wnd;
|
---|
[3434233] | 169 | display_wnd_params_t params;
|
---|
[24cf391a] | 170 | gfx_coord2_t pos;
|
---|
[b4b4dafe] | 171 | bool called_cb = false;
|
---|
[24cf391a] | 172 | errno_t rc;
|
---|
| 173 |
|
---|
[8aef01c] | 174 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[24cf391a] | 175 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 176 |
|
---|
[b4b4dafe] | 177 | rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
|
---|
| 178 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 179 |
|
---|
| 180 | rc = ds_seat_create(disp, &seat);
|
---|
[24cf391a] | 181 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 182 |
|
---|
[3434233] | 183 | display_wnd_params_init(¶ms);
|
---|
| 184 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 185 | params.rect.p1.x = params.rect.p1.y = 100;
|
---|
| 186 |
|
---|
| 187 | rc = ds_window_create(client, ¶ms, &w0);
|
---|
[24cf391a] | 188 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 189 |
|
---|
[3434233] | 190 | rc = ds_window_create(client, ¶ms, &w1);
|
---|
[24cf391a] | 191 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 192 |
|
---|
| 193 | w0->dpos.x = 10;
|
---|
| 194 | w0->dpos.y = 10;
|
---|
| 195 |
|
---|
| 196 | w1->dpos.x = 400;
|
---|
| 197 | w1->dpos.y = 400;
|
---|
| 198 |
|
---|
| 199 | pos.x = 10;
|
---|
| 200 | pos.y = 10;
|
---|
| 201 | wnd = ds_display_window_by_pos(disp, &pos);
|
---|
| 202 | PCUT_ASSERT_EQUALS(w0, wnd);
|
---|
| 203 |
|
---|
| 204 | pos.x = 400;
|
---|
| 205 | pos.y = 400;
|
---|
| 206 | wnd = ds_display_window_by_pos(disp, &pos);
|
---|
| 207 | PCUT_ASSERT_EQUALS(w1, wnd);
|
---|
| 208 |
|
---|
| 209 | ds_window_destroy(w0);
|
---|
| 210 | ds_window_destroy(w1);
|
---|
[b4b4dafe] | 211 | ds_seat_destroy(seat);
|
---|
[24cf391a] | 212 | ds_client_destroy(client);
|
---|
| 213 | ds_display_destroy(disp);
|
---|
| 214 | }
|
---|
| 215 |
|
---|
[cf32dbd] | 216 | /** Basic seat operation. */
|
---|
| 217 | PCUT_TEST(display_seat)
|
---|
| 218 | {
|
---|
| 219 | ds_display_t *disp;
|
---|
| 220 | ds_seat_t *seat;
|
---|
| 221 | ds_seat_t *s0, *s1;
|
---|
| 222 | errno_t rc;
|
---|
| 223 |
|
---|
[8aef01c] | 224 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[cf32dbd] | 225 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 226 |
|
---|
| 227 | rc = ds_seat_create(disp, &seat);
|
---|
| 228 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 229 |
|
---|
| 230 | s0 = ds_display_first_seat(disp);
|
---|
| 231 | PCUT_ASSERT_EQUALS(s0, seat);
|
---|
| 232 |
|
---|
| 233 | s1 = ds_display_next_seat(s0);
|
---|
| 234 | PCUT_ASSERT_NULL(s1);
|
---|
| 235 |
|
---|
| 236 | ds_seat_destroy(seat);
|
---|
| 237 | ds_display_destroy(disp);
|
---|
| 238 | }
|
---|
| 239 |
|
---|
[24cf391a] | 240 | /** Test ds_display_post_kbd_event() delivers event to client callback.
|
---|
| 241 | */
|
---|
[b2d1df3] | 242 | PCUT_TEST(display_post_kbd_event)
|
---|
| 243 | {
|
---|
| 244 | ds_display_t *disp;
|
---|
[cf32dbd] | 245 | ds_seat_t *seat;
|
---|
[b2d1df3] | 246 | ds_client_t *client;
|
---|
| 247 | ds_window_t *wnd;
|
---|
[3434233] | 248 | display_wnd_params_t params;
|
---|
[b2d1df3] | 249 | kbd_event_t event;
|
---|
[24cf391a] | 250 | bool called_cb = false;
|
---|
[b2d1df3] | 251 | errno_t rc;
|
---|
| 252 |
|
---|
[8aef01c] | 253 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[b2d1df3] | 254 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 255 |
|
---|
[cf32dbd] | 256 | rc = ds_seat_create(disp, &seat);
|
---|
| 257 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 258 |
|
---|
[b2d1df3] | 259 | rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
|
---|
| 260 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 261 |
|
---|
[3434233] | 262 | display_wnd_params_init(¶ms);
|
---|
| 263 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 264 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 265 |
|
---|
| 266 | rc = ds_window_create(client, ¶ms, &wnd);
|
---|
[b2d1df3] | 267 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 268 |
|
---|
[94635b30] | 269 | ds_seat_set_focus(seat, wnd);
|
---|
| 270 |
|
---|
[b2d1df3] | 271 | event.type = KEY_PRESS;
|
---|
| 272 | event.key = KC_ENTER;
|
---|
| 273 | event.mods = 0;
|
---|
| 274 | event.c = L'\0';
|
---|
| 275 |
|
---|
[0e6e77f] | 276 | called_cb = false;
|
---|
[b2d1df3] | 277 |
|
---|
| 278 | rc = ds_display_post_kbd_event(disp, &event);
|
---|
| 279 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 280 | PCUT_ASSERT_TRUE(called_cb);
|
---|
| 281 |
|
---|
[648e2ac] | 282 | ds_window_destroy(wnd);
|
---|
[b2d1df3] | 283 | ds_client_destroy(client);
|
---|
[cf32dbd] | 284 | ds_seat_destroy(seat);
|
---|
[b2d1df3] | 285 | ds_display_destroy(disp);
|
---|
| 286 | }
|
---|
| 287 |
|
---|
[24cf391a] | 288 | /** Test ds_display_post_kbd_event() with Alt-Tab switches focus.
|
---|
| 289 | */
|
---|
| 290 | PCUT_TEST(display_post_kbd_event_alt_tab)
|
---|
| 291 | {
|
---|
| 292 | ds_display_t *disp;
|
---|
| 293 | ds_seat_t *seat;
|
---|
| 294 | ds_client_t *client;
|
---|
| 295 | ds_window_t *w0, *w1;
|
---|
[3434233] | 296 | display_wnd_params_t params;
|
---|
[24cf391a] | 297 | kbd_event_t event;
|
---|
| 298 | bool called_cb = false;
|
---|
| 299 | errno_t rc;
|
---|
| 300 |
|
---|
[8aef01c] | 301 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[24cf391a] | 302 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 303 |
|
---|
| 304 | rc = ds_seat_create(disp, &seat);
|
---|
| 305 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 306 |
|
---|
| 307 | rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
|
---|
| 308 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 309 |
|
---|
[3434233] | 310 | display_wnd_params_init(¶ms);
|
---|
| 311 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 312 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 313 |
|
---|
| 314 | rc = ds_window_create(client, ¶ms, &w0);
|
---|
[24cf391a] | 315 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 316 |
|
---|
[3434233] | 317 | rc = ds_window_create(client, ¶ms, &w1);
|
---|
[24cf391a] | 318 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 319 |
|
---|
| 320 | ds_seat_set_focus(seat, w0);
|
---|
| 321 |
|
---|
| 322 | event.type = KEY_PRESS;
|
---|
| 323 | event.key = KC_TAB;
|
---|
| 324 | event.mods = KM_ALT;
|
---|
| 325 | event.c = L'\0';
|
---|
| 326 |
|
---|
[0e6e77f] | 327 | called_cb = false;
|
---|
[24cf391a] | 328 |
|
---|
| 329 | rc = ds_display_post_kbd_event(disp, &event);
|
---|
| 330 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[0e6e77f] | 331 |
|
---|
| 332 | /* Got gocus/unfocus events */
|
---|
| 333 | PCUT_ASSERT_TRUE(called_cb);
|
---|
[24cf391a] | 334 |
|
---|
| 335 | /* Next window should be focused */
|
---|
| 336 | PCUT_ASSERT_EQUALS(w1, seat->focus);
|
---|
| 337 |
|
---|
[0e6e77f] | 338 | called_cb = false;
|
---|
| 339 |
|
---|
[24cf391a] | 340 | rc = ds_display_post_kbd_event(disp, &event);
|
---|
| 341 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[0e6e77f] | 342 |
|
---|
| 343 | /* Got gocus/unfocus events */
|
---|
| 344 | PCUT_ASSERT_TRUE(called_cb);
|
---|
[24cf391a] | 345 |
|
---|
| 346 | /* Focus should be back to the first window */
|
---|
| 347 | PCUT_ASSERT_EQUALS(w0, seat->focus);
|
---|
| 348 |
|
---|
| 349 | ds_window_destroy(w0);
|
---|
| 350 | ds_window_destroy(w1);
|
---|
| 351 | ds_client_destroy(client);
|
---|
| 352 | ds_seat_destroy(seat);
|
---|
| 353 | ds_display_destroy(disp);
|
---|
| 354 | }
|
---|
| 355 |
|
---|
[4fbdc3d] | 356 | /** Test ds_display_post_ptd_event() with click on window switches focus
|
---|
[24cf391a] | 357 | */
|
---|
[4fbdc3d] | 358 | PCUT_TEST(display_post_ptd_event_wnd_switch)
|
---|
[24cf391a] | 359 | {
|
---|
| 360 | ds_display_t *disp;
|
---|
| 361 | ds_seat_t *seat;
|
---|
| 362 | ds_client_t *client;
|
---|
| 363 | ds_window_t *w0, *w1;
|
---|
[3434233] | 364 | display_wnd_params_t params;
|
---|
[4fbdc3d] | 365 | ptd_event_t event;
|
---|
[24cf391a] | 366 | bool called_cb = false;
|
---|
| 367 | errno_t rc;
|
---|
| 368 |
|
---|
[8aef01c] | 369 | rc = ds_display_create(NULL, df_none, &disp);
|
---|
[24cf391a] | 370 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 371 |
|
---|
| 372 | rc = ds_seat_create(disp, &seat);
|
---|
| 373 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 374 |
|
---|
| 375 | rc = ds_client_create(disp, &test_ds_client_cb, &called_cb, &client);
|
---|
| 376 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 377 |
|
---|
[0e6e77f] | 378 | /*
|
---|
| 379 | * For PTD_MOVE to work we need to set display dimensions (as pointer
|
---|
| 380 | * move is clipped to the display rectangle. Here we do it directly
|
---|
| 381 | * instead of adding a display device.
|
---|
| 382 | */
|
---|
| 383 | disp->rect.p0.x = 0;
|
---|
| 384 | disp->rect.p0.y = 0;
|
---|
| 385 | disp->rect.p1.x = 500;
|
---|
| 386 | disp->rect.p1.y = 500;
|
---|
| 387 |
|
---|
[3434233] | 388 | display_wnd_params_init(¶ms);
|
---|
| 389 | params.rect.p0.x = params.rect.p0.y = 0;
|
---|
| 390 | params.rect.p1.x = params.rect.p1.y = 1;
|
---|
| 391 |
|
---|
| 392 | rc = ds_window_create(client, ¶ms, &w0);
|
---|
[24cf391a] | 393 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 394 |
|
---|
[3434233] | 395 | rc = ds_window_create(client, ¶ms, &w1);
|
---|
[24cf391a] | 396 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 397 |
|
---|
| 398 | w0->dpos.x = 10;
|
---|
| 399 | w0->dpos.y = 10;
|
---|
| 400 |
|
---|
| 401 | w1->dpos.x = 400;
|
---|
| 402 | w1->dpos.y = 400;
|
---|
| 403 |
|
---|
[4fbdc3d] | 404 | ds_seat_set_focus(seat, w0);
|
---|
[24cf391a] | 405 |
|
---|
[4fbdc3d] | 406 | event.type = PTD_MOVE;
|
---|
| 407 | event.dmove.x = 400;
|
---|
| 408 | event.dmove.y = 400;
|
---|
| 409 | rc = ds_display_post_ptd_event(disp, &event);
|
---|
| 410 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[24cf391a] | 411 |
|
---|
[4fbdc3d] | 412 | event.type = PTD_PRESS;
|
---|
| 413 | event.btn_num = 1;
|
---|
| 414 | rc = ds_display_post_ptd_event(disp, &event);
|
---|
[24cf391a] | 415 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 416 |
|
---|
| 417 | PCUT_ASSERT_EQUALS(w1, seat->focus);
|
---|
| 418 |
|
---|
[f5191b4] | 419 | event.type = PTD_RELEASE;
|
---|
| 420 | event.btn_num = 1;
|
---|
| 421 | rc = ds_display_post_ptd_event(disp, &event);
|
---|
| 422 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 423 |
|
---|
[4fbdc3d] | 424 | event.type = PTD_MOVE;
|
---|
[a40ae0d] | 425 | event.dmove.x = -400 + 10;
|
---|
| 426 | event.dmove.y = -400 + 10;
|
---|
[4fbdc3d] | 427 | rc = ds_display_post_ptd_event(disp, &event);
|
---|
| 428 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 429 |
|
---|
| 430 | event.type = PTD_PRESS;
|
---|
| 431 | event.btn_num = 1;
|
---|
| 432 | rc = ds_display_post_ptd_event(disp, &event);
|
---|
[24cf391a] | 433 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 434 |
|
---|
| 435 | PCUT_ASSERT_EQUALS(w0, seat->focus);
|
---|
| 436 |
|
---|
| 437 | ds_window_destroy(w0);
|
---|
| 438 | ds_window_destroy(w1);
|
---|
| 439 | ds_client_destroy(client);
|
---|
| 440 | ds_seat_destroy(seat);
|
---|
| 441 | ds_display_destroy(disp);
|
---|
| 442 | }
|
---|
| 443 |
|
---|
[6af4b4f] | 444 | PCUT_EXPORT(display);
|
---|