| 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 |
|
|---|
| 29 | #include <async.h>
|
|---|
| 30 | #include <errno.h>
|
|---|
| 31 | #include <display.h>
|
|---|
| 32 | #include <disp_srv.h>
|
|---|
| 33 | #include <fibril_synch.h>
|
|---|
| 34 | #include <gfx/color.h>
|
|---|
| 35 | #include <gfx/context.h>
|
|---|
| 36 | #include <gfx/render.h>
|
|---|
| 37 | #include <ipcgfx/server.h>
|
|---|
| 38 | #include <loc.h>
|
|---|
| 39 | #include <pcut/pcut.h>
|
|---|
| 40 |
|
|---|
| 41 | PCUT_INIT;
|
|---|
| 42 |
|
|---|
| 43 | PCUT_TEST_SUITE(display);
|
|---|
| 44 |
|
|---|
| 45 | static const char *test_display_server = "test-display";
|
|---|
| 46 | static const char *test_display_svc = "test/display";
|
|---|
| 47 |
|
|---|
| 48 | static void test_display_conn(ipc_call_t *, void *);
|
|---|
| 49 |
|
|---|
| 50 | static void test_close_event(void *);
|
|---|
| 51 | static void test_focus_event(void *);
|
|---|
| 52 | static void test_kbd_event(void *, kbd_event_t *);
|
|---|
| 53 | static void test_pos_event(void *, pos_event_t *);
|
|---|
| 54 | static void test_unfocus_event(void *);
|
|---|
| 55 |
|
|---|
| 56 | static errno_t test_window_create(void *, display_wnd_params_t *, sysarg_t *);
|
|---|
| 57 | static errno_t test_window_destroy(void *, sysarg_t);
|
|---|
| 58 | static errno_t test_window_move_req(void *, sysarg_t, gfx_coord2_t *);
|
|---|
| 59 | static errno_t test_window_move(void *, sysarg_t, gfx_coord2_t *);
|
|---|
| 60 | static errno_t test_window_resize_req(void *, sysarg_t, display_wnd_rsztype_t,
|
|---|
| 61 | gfx_coord2_t *);
|
|---|
| 62 | static errno_t test_window_resize(void *, sysarg_t, gfx_coord2_t *,
|
|---|
| 63 | gfx_rect_t *);
|
|---|
| 64 | static errno_t test_window_set_cursor(void *, sysarg_t, display_stock_cursor_t);
|
|---|
| 65 | static errno_t test_get_event(void *, sysarg_t *, display_wnd_ev_t *);
|
|---|
| 66 | static errno_t test_get_info(void *, display_info_t *);
|
|---|
| 67 |
|
|---|
| 68 | static errno_t test_gc_set_color(void *, gfx_color_t *);
|
|---|
| 69 |
|
|---|
| 70 | static display_ops_t test_display_srv_ops = {
|
|---|
| 71 | .window_create = test_window_create,
|
|---|
| 72 | .window_destroy = test_window_destroy,
|
|---|
| 73 | .window_move_req = test_window_move_req,
|
|---|
| 74 | .window_move = test_window_move,
|
|---|
| 75 | .window_resize_req = test_window_resize_req,
|
|---|
| 76 | .window_resize = test_window_resize,
|
|---|
| 77 | .window_set_cursor = test_window_set_cursor,
|
|---|
| 78 | .get_event = test_get_event,
|
|---|
| 79 | .get_info = test_get_info
|
|---|
| 80 | };
|
|---|
| 81 |
|
|---|
| 82 | static display_wnd_cb_t test_display_wnd_cb = {
|
|---|
| 83 | .close_event = test_close_event,
|
|---|
| 84 | .focus_event = test_focus_event,
|
|---|
| 85 | .kbd_event = test_kbd_event,
|
|---|
| 86 | .pos_event = test_pos_event,
|
|---|
| 87 | .unfocus_event = test_unfocus_event
|
|---|
| 88 | };
|
|---|
| 89 |
|
|---|
| 90 | static gfx_context_ops_t test_gc_ops = {
|
|---|
| 91 | .set_color = test_gc_set_color
|
|---|
| 92 | };
|
|---|
| 93 |
|
|---|
| 94 | /** Describes to the server how to respond to our request and pass tracking
|
|---|
| 95 | * data back to the client.
|
|---|
| 96 | */
|
|---|
| 97 | typedef struct {
|
|---|
| 98 | errno_t rc;
|
|---|
| 99 | sysarg_t wnd_id;
|
|---|
| 100 | display_wnd_ev_t event;
|
|---|
| 101 | display_wnd_ev_t revent;
|
|---|
| 102 | int event_cnt;
|
|---|
| 103 | bool window_create_called;
|
|---|
| 104 | gfx_rect_t create_rect;
|
|---|
| 105 | gfx_coord2_t create_min_size;
|
|---|
| 106 | bool window_destroy_called;
|
|---|
| 107 | sysarg_t destroy_wnd_id;
|
|---|
| 108 |
|
|---|
| 109 | bool window_move_req_called;
|
|---|
| 110 | sysarg_t move_req_wnd_id;
|
|---|
| 111 | gfx_coord2_t move_req_pos;
|
|---|
| 112 |
|
|---|
| 113 | bool window_move_called;
|
|---|
| 114 | sysarg_t move_wnd_id;
|
|---|
| 115 | gfx_coord2_t move_dpos;
|
|---|
| 116 |
|
|---|
| 117 | bool window_resize_req_called;
|
|---|
| 118 | sysarg_t resize_req_wnd_id;
|
|---|
| 119 | display_wnd_rsztype_t resize_req_rsztype;
|
|---|
| 120 | gfx_coord2_t resize_req_pos;
|
|---|
| 121 |
|
|---|
| 122 | bool window_resize_called;
|
|---|
| 123 | gfx_coord2_t resize_offs;
|
|---|
| 124 | gfx_rect_t resize_nbound;
|
|---|
| 125 | sysarg_t resize_wnd_id;
|
|---|
| 126 |
|
|---|
| 127 | bool window_set_cursor_called;
|
|---|
| 128 | sysarg_t set_cursor_wnd_id;
|
|---|
| 129 | display_stock_cursor_t set_cursor_cursor;
|
|---|
| 130 |
|
|---|
| 131 | bool get_event_called;
|
|---|
| 132 |
|
|---|
| 133 | bool get_info_called;
|
|---|
| 134 | gfx_rect_t get_info_rect;
|
|---|
| 135 |
|
|---|
| 136 | bool set_color_called;
|
|---|
| 137 | bool close_event_called;
|
|---|
| 138 | bool focus_event_called;
|
|---|
| 139 | bool kbd_event_called;
|
|---|
| 140 | bool pos_event_called;
|
|---|
| 141 | bool unfocus_event_called;
|
|---|
| 142 | fibril_condvar_t event_cv;
|
|---|
| 143 | fibril_mutex_t event_lock;
|
|---|
| 144 | display_srv_t *srv;
|
|---|
| 145 | } test_response_t;
|
|---|
| 146 |
|
|---|
| 147 | /** display_open(), display_close() work for valid display service */
|
|---|
| 148 | PCUT_TEST(open_close)
|
|---|
| 149 | {
|
|---|
| 150 | errno_t rc;
|
|---|
| 151 | service_id_t sid;
|
|---|
| 152 | display_t *disp = NULL;
|
|---|
| 153 | test_response_t resp;
|
|---|
| 154 |
|
|---|
| 155 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 156 |
|
|---|
| 157 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 158 | rc = loc_server_register(test_display_server);
|
|---|
| 159 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 160 |
|
|---|
| 161 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 162 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 163 |
|
|---|
| 164 | rc = display_open(test_display_svc, &disp);
|
|---|
| 165 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 166 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 167 |
|
|---|
| 168 | display_close(disp);
|
|---|
| 169 | rc = loc_service_unregister(sid);
|
|---|
| 170 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | /** display_window_create() with server returning error response works */
|
|---|
| 174 | PCUT_TEST(window_create_failure)
|
|---|
| 175 | {
|
|---|
| 176 | errno_t rc;
|
|---|
| 177 | service_id_t sid;
|
|---|
| 178 | display_t *disp = NULL;
|
|---|
| 179 | display_wnd_params_t params;
|
|---|
| 180 | display_window_t *wnd;
|
|---|
| 181 | test_response_t resp;
|
|---|
| 182 |
|
|---|
| 183 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 184 |
|
|---|
| 185 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 186 | rc = loc_server_register(test_display_server);
|
|---|
| 187 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 188 |
|
|---|
| 189 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 190 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 191 |
|
|---|
| 192 | rc = display_open(test_display_svc, &disp);
|
|---|
| 193 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 194 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 195 |
|
|---|
| 196 | wnd = NULL;
|
|---|
| 197 | resp.rc = ENOMEM;
|
|---|
| 198 | resp.window_create_called = false;
|
|---|
| 199 | display_wnd_params_init(¶ms);
|
|---|
| 200 | params.rect.p0.x = 0;
|
|---|
| 201 | params.rect.p0.y = 0;
|
|---|
| 202 | params.rect.p0.x = 100;
|
|---|
| 203 | params.rect.p0.y = 100;
|
|---|
| 204 | params.min_size.x = 11;
|
|---|
| 205 | params.min_size.y = 12;
|
|---|
| 206 |
|
|---|
| 207 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 208 | (void *) &resp, &wnd);
|
|---|
| 209 | PCUT_ASSERT_TRUE(resp.window_create_called);
|
|---|
| 210 | PCUT_ASSERT_EQUALS(params.rect.p0.x, resp.create_rect.p0.x);
|
|---|
| 211 | PCUT_ASSERT_EQUALS(params.rect.p0.y, resp.create_rect.p0.y);
|
|---|
| 212 | PCUT_ASSERT_EQUALS(params.rect.p1.x, resp.create_rect.p1.x);
|
|---|
| 213 | PCUT_ASSERT_EQUALS(params.rect.p1.y, resp.create_rect.p1.y);
|
|---|
| 214 | PCUT_ASSERT_EQUALS(params.min_size.x, resp.create_min_size.x);
|
|---|
| 215 | PCUT_ASSERT_EQUALS(params.min_size.y, resp.create_min_size.y);
|
|---|
| 216 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
|---|
| 217 | PCUT_ASSERT_NULL(wnd);
|
|---|
| 218 |
|
|---|
| 219 | display_close(disp);
|
|---|
| 220 | rc = loc_service_unregister(sid);
|
|---|
| 221 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | /** display_window_create() and display_window_destroy() with success
|
|---|
| 225 | *
|
|---|
| 226 | * with server returning success,
|
|---|
| 227 | */
|
|---|
| 228 | PCUT_TEST(window_create_destroy_success)
|
|---|
| 229 | {
|
|---|
| 230 | errno_t rc;
|
|---|
| 231 | service_id_t sid;
|
|---|
| 232 | display_t *disp = NULL;
|
|---|
| 233 | display_wnd_params_t params;
|
|---|
| 234 | display_window_t *wnd;
|
|---|
| 235 | test_response_t resp;
|
|---|
| 236 |
|
|---|
| 237 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 238 |
|
|---|
| 239 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 240 | rc = loc_server_register(test_display_server);
|
|---|
| 241 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 242 |
|
|---|
| 243 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 244 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 245 |
|
|---|
| 246 | rc = display_open(test_display_svc, &disp);
|
|---|
| 247 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 248 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 249 |
|
|---|
| 250 | wnd = NULL;
|
|---|
| 251 | resp.rc = EOK;
|
|---|
| 252 | resp.window_create_called = false;
|
|---|
| 253 | display_wnd_params_init(¶ms);
|
|---|
| 254 | params.rect.p0.x = 0;
|
|---|
| 255 | params.rect.p0.y = 0;
|
|---|
| 256 | params.rect.p0.x = 100;
|
|---|
| 257 | params.rect.p0.y = 100;
|
|---|
| 258 |
|
|---|
| 259 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 260 | (void *) &resp, &wnd);
|
|---|
| 261 | PCUT_ASSERT_TRUE(resp.window_create_called);
|
|---|
| 262 | PCUT_ASSERT_EQUALS(params.rect.p0.x, resp.create_rect.p0.x);
|
|---|
| 263 | PCUT_ASSERT_EQUALS(params.rect.p0.y, resp.create_rect.p0.y);
|
|---|
| 264 | PCUT_ASSERT_EQUALS(params.rect.p1.x, resp.create_rect.p1.x);
|
|---|
| 265 | PCUT_ASSERT_EQUALS(params.rect.p1.y, resp.create_rect.p1.y);
|
|---|
| 266 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 267 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 268 |
|
|---|
| 269 | resp.window_destroy_called = false;
|
|---|
| 270 | rc = display_window_destroy(wnd);
|
|---|
| 271 | PCUT_ASSERT_TRUE(resp.window_destroy_called);
|
|---|
| 272 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.destroy_wnd_id);
|
|---|
| 273 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 274 |
|
|---|
| 275 | display_close(disp);
|
|---|
| 276 | rc = loc_service_unregister(sid);
|
|---|
| 277 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 278 | }
|
|---|
| 279 |
|
|---|
| 280 | /** display_window_create() with server returning error response works. */
|
|---|
| 281 | PCUT_TEST(window_destroy_failure)
|
|---|
| 282 | {
|
|---|
| 283 | errno_t rc;
|
|---|
| 284 | service_id_t sid;
|
|---|
| 285 | display_t *disp = NULL;
|
|---|
| 286 | display_wnd_params_t params;
|
|---|
| 287 | display_window_t *wnd;
|
|---|
| 288 | test_response_t resp;
|
|---|
| 289 |
|
|---|
| 290 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 291 |
|
|---|
| 292 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 293 | rc = loc_server_register(test_display_server);
|
|---|
| 294 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 295 |
|
|---|
| 296 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 297 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 298 |
|
|---|
| 299 | rc = display_open(test_display_svc, &disp);
|
|---|
| 300 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 301 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 302 |
|
|---|
| 303 | resp.rc = EOK;
|
|---|
| 304 | resp.window_create_called = false;
|
|---|
| 305 | display_wnd_params_init(¶ms);
|
|---|
| 306 | params.rect.p0.x = 0;
|
|---|
| 307 | params.rect.p0.y = 0;
|
|---|
| 308 | params.rect.p0.x = 100;
|
|---|
| 309 | params.rect.p0.y = 100;
|
|---|
| 310 |
|
|---|
| 311 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 312 | (void *) &resp, &wnd);
|
|---|
| 313 | PCUT_ASSERT_TRUE(resp.window_create_called);
|
|---|
| 314 | PCUT_ASSERT_EQUALS(params.rect.p0.x, resp.create_rect.p0.x);
|
|---|
| 315 | PCUT_ASSERT_EQUALS(params.rect.p0.y, resp.create_rect.p0.y);
|
|---|
| 316 | PCUT_ASSERT_EQUALS(params.rect.p1.x, resp.create_rect.p1.x);
|
|---|
| 317 | PCUT_ASSERT_EQUALS(params.rect.p1.y, resp.create_rect.p1.y);
|
|---|
| 318 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 319 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 320 |
|
|---|
| 321 | resp.rc = EIO;
|
|---|
| 322 | resp.window_destroy_called = false;
|
|---|
| 323 | rc = display_window_destroy(wnd);
|
|---|
| 324 | PCUT_ASSERT_TRUE(resp.window_destroy_called);
|
|---|
| 325 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.destroy_wnd_id);
|
|---|
| 326 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
|---|
| 327 |
|
|---|
| 328 | display_close(disp);
|
|---|
| 329 | rc = loc_service_unregister(sid);
|
|---|
| 330 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 331 | }
|
|---|
| 332 |
|
|---|
| 333 | /** display_window_destroy() can handle NULL argument */
|
|---|
| 334 | PCUT_TEST(window_destroy_null)
|
|---|
| 335 | {
|
|---|
| 336 | display_window_destroy(NULL);
|
|---|
| 337 | }
|
|---|
| 338 |
|
|---|
| 339 | /** display_window_move_req() with server returning error response works. */
|
|---|
| 340 | PCUT_TEST(window_move_req_failure)
|
|---|
| 341 | {
|
|---|
| 342 | errno_t rc;
|
|---|
| 343 | service_id_t sid;
|
|---|
| 344 | display_t *disp = NULL;
|
|---|
| 345 | display_wnd_params_t params;
|
|---|
| 346 | display_window_t *wnd;
|
|---|
| 347 | test_response_t resp;
|
|---|
| 348 | gfx_coord2_t pos;
|
|---|
| 349 |
|
|---|
| 350 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 351 |
|
|---|
| 352 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 353 | rc = loc_server_register(test_display_server);
|
|---|
| 354 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 355 |
|
|---|
| 356 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 357 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 358 |
|
|---|
| 359 | rc = display_open(test_display_svc, &disp);
|
|---|
| 360 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 361 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 362 |
|
|---|
| 363 | resp.rc = EOK;
|
|---|
| 364 | display_wnd_params_init(¶ms);
|
|---|
| 365 | params.rect.p0.x = 0;
|
|---|
| 366 | params.rect.p0.y = 0;
|
|---|
| 367 | params.rect.p0.x = 100;
|
|---|
| 368 | params.rect.p0.y = 100;
|
|---|
| 369 |
|
|---|
| 370 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 371 | (void *) &resp, &wnd);
|
|---|
| 372 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 373 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 374 |
|
|---|
| 375 | resp.rc = EIO;
|
|---|
| 376 | resp.window_move_req_called = false;
|
|---|
| 377 |
|
|---|
| 378 | pos.x = 42;
|
|---|
| 379 | pos.y = 43;
|
|---|
| 380 |
|
|---|
| 381 | rc = display_window_move_req(wnd, &pos);
|
|---|
| 382 | PCUT_ASSERT_TRUE(resp.window_move_req_called);
|
|---|
| 383 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
|---|
| 384 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.move_req_wnd_id);
|
|---|
| 385 | PCUT_ASSERT_INT_EQUALS(pos.x, resp.move_req_pos.x);
|
|---|
| 386 | PCUT_ASSERT_INT_EQUALS(pos.y, resp.move_req_pos.y);
|
|---|
| 387 |
|
|---|
| 388 | display_window_destroy(wnd);
|
|---|
| 389 | display_close(disp);
|
|---|
| 390 | rc = loc_service_unregister(sid);
|
|---|
| 391 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 392 | }
|
|---|
| 393 |
|
|---|
| 394 | /** display_window_move_req() with server returning success response works. */
|
|---|
| 395 | PCUT_TEST(window_move_req_success)
|
|---|
| 396 | {
|
|---|
| 397 | errno_t rc;
|
|---|
| 398 | service_id_t sid;
|
|---|
| 399 | display_t *disp = NULL;
|
|---|
| 400 | display_wnd_params_t params;
|
|---|
| 401 | display_window_t *wnd;
|
|---|
| 402 | test_response_t resp;
|
|---|
| 403 | gfx_coord2_t pos;
|
|---|
| 404 |
|
|---|
| 405 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 406 |
|
|---|
| 407 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 408 | rc = loc_server_register(test_display_server);
|
|---|
| 409 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 410 |
|
|---|
| 411 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 412 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 413 |
|
|---|
| 414 | rc = display_open(test_display_svc, &disp);
|
|---|
| 415 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 416 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 417 |
|
|---|
| 418 | resp.rc = EOK;
|
|---|
| 419 | display_wnd_params_init(¶ms);
|
|---|
| 420 | params.rect.p0.x = 0;
|
|---|
| 421 | params.rect.p0.y = 0;
|
|---|
| 422 | params.rect.p0.x = 100;
|
|---|
| 423 | params.rect.p0.y = 100;
|
|---|
| 424 |
|
|---|
| 425 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 426 | (void *) &resp, &wnd);
|
|---|
| 427 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 428 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 429 |
|
|---|
| 430 | resp.rc = EOK;
|
|---|
| 431 | resp.window_move_req_called = false;
|
|---|
| 432 |
|
|---|
| 433 | pos.x = 42;
|
|---|
| 434 | pos.y = 43;
|
|---|
| 435 |
|
|---|
| 436 | rc = display_window_move_req(wnd, &pos);
|
|---|
| 437 | PCUT_ASSERT_TRUE(resp.window_move_req_called);
|
|---|
| 438 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
|---|
| 439 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.move_req_wnd_id);
|
|---|
| 440 | PCUT_ASSERT_INT_EQUALS(pos.x, resp.move_req_pos.x);
|
|---|
| 441 | PCUT_ASSERT_INT_EQUALS(pos.y, resp.move_req_pos.y);
|
|---|
| 442 |
|
|---|
| 443 | display_window_destroy(wnd);
|
|---|
| 444 | display_close(disp);
|
|---|
| 445 | rc = loc_service_unregister(sid);
|
|---|
| 446 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| 449 | /** display_window_move() with server returning error response works. */
|
|---|
| 450 | PCUT_TEST(window_move_failure)
|
|---|
| 451 | {
|
|---|
| 452 | errno_t rc;
|
|---|
| 453 | service_id_t sid;
|
|---|
| 454 | display_t *disp = NULL;
|
|---|
| 455 | display_wnd_params_t params;
|
|---|
| 456 | display_window_t *wnd;
|
|---|
| 457 | gfx_coord2_t dpos;
|
|---|
| 458 | test_response_t resp;
|
|---|
| 459 |
|
|---|
| 460 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 461 |
|
|---|
| 462 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 463 | rc = loc_server_register(test_display_server);
|
|---|
| 464 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 465 |
|
|---|
| 466 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 467 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 468 |
|
|---|
| 469 | rc = display_open(test_display_svc, &disp);
|
|---|
| 470 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 471 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 472 |
|
|---|
| 473 | resp.rc = EOK;
|
|---|
| 474 | display_wnd_params_init(¶ms);
|
|---|
| 475 | params.rect.p0.x = 0;
|
|---|
| 476 | params.rect.p0.y = 0;
|
|---|
| 477 | params.rect.p0.x = 100;
|
|---|
| 478 | params.rect.p0.y = 100;
|
|---|
| 479 |
|
|---|
| 480 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 481 | (void *) &resp, &wnd);
|
|---|
| 482 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 483 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 484 |
|
|---|
| 485 | resp.rc = EIO;
|
|---|
| 486 | resp.window_move_called = false;
|
|---|
| 487 | dpos.x = 11;
|
|---|
| 488 | dpos.y = 12;
|
|---|
| 489 |
|
|---|
| 490 | rc = display_window_move(wnd, &dpos);
|
|---|
| 491 | PCUT_ASSERT_TRUE(resp.window_move_called);
|
|---|
| 492 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
|---|
| 493 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.move_wnd_id);
|
|---|
| 494 | PCUT_ASSERT_INT_EQUALS(dpos.x, resp.move_dpos.x);
|
|---|
| 495 | PCUT_ASSERT_INT_EQUALS(dpos.y, resp.move_dpos.y);
|
|---|
| 496 |
|
|---|
| 497 | display_window_destroy(wnd);
|
|---|
| 498 | display_close(disp);
|
|---|
| 499 | rc = loc_service_unregister(sid);
|
|---|
| 500 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | /** display_window_move() with server returning success response works. */
|
|---|
| 504 | PCUT_TEST(window_move_success)
|
|---|
| 505 | {
|
|---|
| 506 | errno_t rc;
|
|---|
| 507 | service_id_t sid;
|
|---|
| 508 | display_t *disp = NULL;
|
|---|
| 509 | display_wnd_params_t params;
|
|---|
| 510 | display_window_t *wnd;
|
|---|
| 511 | gfx_coord2_t dpos;
|
|---|
| 512 | test_response_t resp;
|
|---|
| 513 |
|
|---|
| 514 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 515 |
|
|---|
| 516 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 517 | rc = loc_server_register(test_display_server);
|
|---|
| 518 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 519 |
|
|---|
| 520 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 521 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 522 |
|
|---|
| 523 | rc = display_open(test_display_svc, &disp);
|
|---|
| 524 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 525 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 526 |
|
|---|
| 527 | resp.rc = EOK;
|
|---|
| 528 | display_wnd_params_init(¶ms);
|
|---|
| 529 | params.rect.p0.x = 0;
|
|---|
| 530 | params.rect.p0.y = 0;
|
|---|
| 531 | params.rect.p0.x = 100;
|
|---|
| 532 | params.rect.p0.y = 100;
|
|---|
| 533 |
|
|---|
| 534 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 535 | (void *) &resp, &wnd);
|
|---|
| 536 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 537 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 538 |
|
|---|
| 539 | resp.rc = EOK;
|
|---|
| 540 | resp.window_move_called = false;
|
|---|
| 541 | dpos.x = 11;
|
|---|
| 542 | dpos.y = 12;
|
|---|
| 543 |
|
|---|
| 544 | rc = display_window_move(wnd, &dpos);
|
|---|
| 545 | PCUT_ASSERT_TRUE(resp.window_move_called);
|
|---|
| 546 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
|---|
| 547 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.move_wnd_id);
|
|---|
| 548 | PCUT_ASSERT_INT_EQUALS(dpos.x, resp.move_dpos.x);
|
|---|
| 549 | PCUT_ASSERT_INT_EQUALS(dpos.y, resp.move_dpos.y);
|
|---|
| 550 |
|
|---|
| 551 | display_window_destroy(wnd);
|
|---|
| 552 | display_close(disp);
|
|---|
| 553 | rc = loc_service_unregister(sid);
|
|---|
| 554 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 555 | }
|
|---|
| 556 |
|
|---|
| 557 | /** display_window_resize_req() with server returning error response works. */
|
|---|
| 558 | PCUT_TEST(window_resize_req_failure)
|
|---|
| 559 | {
|
|---|
| 560 | errno_t rc;
|
|---|
| 561 | service_id_t sid;
|
|---|
| 562 | display_t *disp = NULL;
|
|---|
| 563 | display_wnd_params_t params;
|
|---|
| 564 | display_window_t *wnd;
|
|---|
| 565 | test_response_t resp;
|
|---|
| 566 | display_wnd_rsztype_t rsztype;
|
|---|
| 567 | gfx_coord2_t pos;
|
|---|
| 568 |
|
|---|
| 569 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 570 |
|
|---|
| 571 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 572 | rc = loc_server_register(test_display_server);
|
|---|
| 573 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 574 |
|
|---|
| 575 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 576 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 577 |
|
|---|
| 578 | rc = display_open(test_display_svc, &disp);
|
|---|
| 579 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 580 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 581 |
|
|---|
| 582 | resp.rc = EOK;
|
|---|
| 583 | display_wnd_params_init(¶ms);
|
|---|
| 584 | params.rect.p0.x = 0;
|
|---|
| 585 | params.rect.p0.y = 0;
|
|---|
| 586 | params.rect.p0.x = 100;
|
|---|
| 587 | params.rect.p0.y = 100;
|
|---|
| 588 |
|
|---|
| 589 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 590 | (void *) &resp, &wnd);
|
|---|
| 591 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 592 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 593 |
|
|---|
| 594 | resp.rc = EIO;
|
|---|
| 595 | resp.window_resize_req_called = false;
|
|---|
| 596 |
|
|---|
| 597 | rsztype = display_wr_top_right;
|
|---|
| 598 | pos.x = 42;
|
|---|
| 599 | pos.y = 43;
|
|---|
| 600 |
|
|---|
| 601 | rc = display_window_resize_req(wnd, rsztype, &pos);
|
|---|
| 602 | PCUT_ASSERT_TRUE(resp.window_resize_req_called);
|
|---|
| 603 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
|---|
| 604 | PCUT_ASSERT_INT_EQUALS(rsztype, resp.resize_req_rsztype);
|
|---|
| 605 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.resize_req_wnd_id);
|
|---|
| 606 | PCUT_ASSERT_INT_EQUALS(pos.x, resp.resize_req_pos.x);
|
|---|
| 607 | PCUT_ASSERT_INT_EQUALS(pos.y, resp.resize_req_pos.y);
|
|---|
| 608 |
|
|---|
| 609 | display_window_destroy(wnd);
|
|---|
| 610 | display_close(disp);
|
|---|
| 611 | rc = loc_service_unregister(sid);
|
|---|
| 612 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 613 | }
|
|---|
| 614 |
|
|---|
| 615 | /** display_window_resize_req() with server returning success response works. */
|
|---|
| 616 | PCUT_TEST(window_resize_req_success)
|
|---|
| 617 | {
|
|---|
| 618 | errno_t rc;
|
|---|
| 619 | service_id_t sid;
|
|---|
| 620 | display_t *disp = NULL;
|
|---|
| 621 | display_wnd_params_t params;
|
|---|
| 622 | display_window_t *wnd;
|
|---|
| 623 | test_response_t resp;
|
|---|
| 624 | display_wnd_rsztype_t rsztype;
|
|---|
| 625 | gfx_coord2_t pos;
|
|---|
| 626 |
|
|---|
| 627 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 628 |
|
|---|
| 629 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 630 | rc = loc_server_register(test_display_server);
|
|---|
| 631 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 632 |
|
|---|
| 633 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 634 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 635 |
|
|---|
| 636 | rc = display_open(test_display_svc, &disp);
|
|---|
| 637 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 638 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 639 |
|
|---|
| 640 | resp.rc = EOK;
|
|---|
| 641 | display_wnd_params_init(¶ms);
|
|---|
| 642 | params.rect.p0.x = 0;
|
|---|
| 643 | params.rect.p0.y = 0;
|
|---|
| 644 | params.rect.p0.x = 100;
|
|---|
| 645 | params.rect.p0.y = 100;
|
|---|
| 646 |
|
|---|
| 647 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 648 | (void *) &resp, &wnd);
|
|---|
| 649 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 650 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 651 |
|
|---|
| 652 | resp.rc = EOK;
|
|---|
| 653 | resp.window_resize_req_called = false;
|
|---|
| 654 |
|
|---|
| 655 | rsztype = display_wr_top_right;
|
|---|
| 656 | pos.x = 42;
|
|---|
| 657 | pos.y = 43;
|
|---|
| 658 |
|
|---|
| 659 | rc = display_window_resize_req(wnd, rsztype, &pos);
|
|---|
| 660 | PCUT_ASSERT_TRUE(resp.window_resize_req_called);
|
|---|
| 661 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
|---|
| 662 | PCUT_ASSERT_INT_EQUALS(rsztype, resp.resize_req_rsztype);
|
|---|
| 663 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.resize_req_wnd_id);
|
|---|
| 664 | PCUT_ASSERT_INT_EQUALS(pos.x, resp.resize_req_pos.x);
|
|---|
| 665 | PCUT_ASSERT_INT_EQUALS(pos.y, resp.resize_req_pos.y);
|
|---|
| 666 |
|
|---|
| 667 | display_window_destroy(wnd);
|
|---|
| 668 | display_close(disp);
|
|---|
| 669 | rc = loc_service_unregister(sid);
|
|---|
| 670 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 671 | }
|
|---|
| 672 |
|
|---|
| 673 | /** display_window_resize() with server returning error response works. */
|
|---|
| 674 | PCUT_TEST(window_resize_failure)
|
|---|
| 675 | {
|
|---|
| 676 | errno_t rc;
|
|---|
| 677 | service_id_t sid;
|
|---|
| 678 | display_t *disp = NULL;
|
|---|
| 679 | display_wnd_params_t params;
|
|---|
| 680 | display_window_t *wnd;
|
|---|
| 681 | gfx_coord2_t offs;
|
|---|
| 682 | gfx_rect_t nrect;
|
|---|
| 683 | test_response_t resp;
|
|---|
| 684 |
|
|---|
| 685 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 686 |
|
|---|
| 687 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 688 | rc = loc_server_register(test_display_server);
|
|---|
| 689 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 690 |
|
|---|
| 691 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 692 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 693 |
|
|---|
| 694 | rc = display_open(test_display_svc, &disp);
|
|---|
| 695 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 696 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 697 |
|
|---|
| 698 | resp.rc = EOK;
|
|---|
| 699 | display_wnd_params_init(¶ms);
|
|---|
| 700 | params.rect.p0.x = 0;
|
|---|
| 701 | params.rect.p0.y = 0;
|
|---|
| 702 | params.rect.p0.x = 100;
|
|---|
| 703 | params.rect.p0.y = 100;
|
|---|
| 704 |
|
|---|
| 705 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 706 | (void *) &resp, &wnd);
|
|---|
| 707 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 708 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 709 |
|
|---|
| 710 | resp.rc = EIO;
|
|---|
| 711 | resp.window_resize_called = false;
|
|---|
| 712 | offs.x = 11;
|
|---|
| 713 | offs.y = 12;
|
|---|
| 714 | nrect.p0.x = 13;
|
|---|
| 715 | nrect.p0.y = 14;
|
|---|
| 716 | nrect.p1.x = 15;
|
|---|
| 717 | nrect.p1.y = 16;
|
|---|
| 718 |
|
|---|
| 719 | rc = display_window_resize(wnd, &offs, &nrect);
|
|---|
| 720 | PCUT_ASSERT_TRUE(resp.window_resize_called);
|
|---|
| 721 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
|---|
| 722 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.resize_wnd_id);
|
|---|
| 723 | PCUT_ASSERT_INT_EQUALS(offs.x, resp.resize_offs.x);
|
|---|
| 724 | PCUT_ASSERT_INT_EQUALS(offs.y, resp.resize_offs.y);
|
|---|
| 725 | PCUT_ASSERT_INT_EQUALS(nrect.p0.x, resp.resize_nbound.p0.x);
|
|---|
| 726 | PCUT_ASSERT_INT_EQUALS(nrect.p0.y, resp.resize_nbound.p0.y);
|
|---|
| 727 | PCUT_ASSERT_INT_EQUALS(nrect.p1.x, resp.resize_nbound.p1.x);
|
|---|
| 728 | PCUT_ASSERT_INT_EQUALS(nrect.p1.y, resp.resize_nbound.p1.y);
|
|---|
| 729 |
|
|---|
| 730 | display_window_destroy(wnd);
|
|---|
| 731 | display_close(disp);
|
|---|
| 732 | rc = loc_service_unregister(sid);
|
|---|
| 733 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 734 | }
|
|---|
| 735 |
|
|---|
| 736 | /** display_window_resize() with server returning success response works. */
|
|---|
| 737 | PCUT_TEST(window_resize_success)
|
|---|
| 738 | {
|
|---|
| 739 | errno_t rc;
|
|---|
| 740 | service_id_t sid;
|
|---|
| 741 | display_t *disp = NULL;
|
|---|
| 742 | display_wnd_params_t params;
|
|---|
| 743 | display_window_t *wnd;
|
|---|
| 744 | gfx_coord2_t offs;
|
|---|
| 745 | gfx_rect_t nrect;
|
|---|
| 746 | test_response_t resp;
|
|---|
| 747 |
|
|---|
| 748 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 749 |
|
|---|
| 750 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 751 | rc = loc_server_register(test_display_server);
|
|---|
| 752 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 753 |
|
|---|
| 754 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 755 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 756 |
|
|---|
| 757 | rc = display_open(test_display_svc, &disp);
|
|---|
| 758 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 759 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 760 |
|
|---|
| 761 | resp.rc = EOK;
|
|---|
| 762 | display_wnd_params_init(¶ms);
|
|---|
| 763 | params.rect.p0.x = 0;
|
|---|
| 764 | params.rect.p0.y = 0;
|
|---|
| 765 | params.rect.p0.x = 100;
|
|---|
| 766 | params.rect.p0.y = 100;
|
|---|
| 767 |
|
|---|
| 768 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 769 | (void *) &resp, &wnd);
|
|---|
| 770 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 771 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 772 |
|
|---|
| 773 | resp.rc = EOK;
|
|---|
| 774 | resp.window_resize_called = false;
|
|---|
| 775 | offs.x = 11;
|
|---|
| 776 | offs.y = 12;
|
|---|
| 777 | nrect.p0.x = 13;
|
|---|
| 778 | nrect.p0.y = 14;
|
|---|
| 779 | nrect.p1.x = 15;
|
|---|
| 780 | nrect.p1.y = 16;
|
|---|
| 781 |
|
|---|
| 782 | rc = display_window_resize(wnd, &offs, &nrect);
|
|---|
| 783 | PCUT_ASSERT_TRUE(resp.window_resize_called);
|
|---|
| 784 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
|---|
| 785 | PCUT_ASSERT_INT_EQUALS(offs.x, resp.resize_offs.x);
|
|---|
| 786 | PCUT_ASSERT_INT_EQUALS(offs.y, resp.resize_offs.y);
|
|---|
| 787 | PCUT_ASSERT_INT_EQUALS(nrect.p0.x, resp.resize_nbound.p0.x);
|
|---|
| 788 | PCUT_ASSERT_INT_EQUALS(nrect.p0.y, resp.resize_nbound.p0.y);
|
|---|
| 789 | PCUT_ASSERT_INT_EQUALS(nrect.p1.x, resp.resize_nbound.p1.x);
|
|---|
| 790 | PCUT_ASSERT_INT_EQUALS(nrect.p1.y, resp.resize_nbound.p1.y);
|
|---|
| 791 |
|
|---|
| 792 | display_window_destroy(wnd);
|
|---|
| 793 | display_close(disp);
|
|---|
| 794 | rc = loc_service_unregister(sid);
|
|---|
| 795 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 796 | }
|
|---|
| 797 |
|
|---|
| 798 | /** display_window_set_cursor() with server returning error response works. */
|
|---|
| 799 | PCUT_TEST(window_set_cursor_failure)
|
|---|
| 800 | {
|
|---|
| 801 | errno_t rc;
|
|---|
| 802 | service_id_t sid;
|
|---|
| 803 | display_t *disp = NULL;
|
|---|
| 804 | display_wnd_params_t params;
|
|---|
| 805 | display_window_t *wnd;
|
|---|
| 806 | test_response_t resp;
|
|---|
| 807 |
|
|---|
| 808 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 809 |
|
|---|
| 810 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 811 | rc = loc_server_register(test_display_server);
|
|---|
| 812 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 813 |
|
|---|
| 814 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 815 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 816 |
|
|---|
| 817 | rc = display_open(test_display_svc, &disp);
|
|---|
| 818 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 819 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 820 |
|
|---|
| 821 | resp.rc = EOK;
|
|---|
| 822 | display_wnd_params_init(¶ms);
|
|---|
| 823 | params.rect.p0.x = 0;
|
|---|
| 824 | params.rect.p0.y = 0;
|
|---|
| 825 | params.rect.p0.x = 100;
|
|---|
| 826 | params.rect.p0.y = 100;
|
|---|
| 827 |
|
|---|
| 828 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 829 | (void *) &resp, &wnd);
|
|---|
| 830 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 831 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 832 |
|
|---|
| 833 | resp.rc = EIO;
|
|---|
| 834 | resp.window_set_cursor_called = false;
|
|---|
| 835 |
|
|---|
| 836 | rc = display_window_set_cursor(wnd, dcurs_size_ud);
|
|---|
| 837 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.set_cursor_wnd_id);
|
|---|
| 838 | PCUT_ASSERT_TRUE(resp.window_set_cursor_called);
|
|---|
| 839 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
|---|
| 840 | PCUT_ASSERT_INT_EQUALS(dcurs_size_ud, resp.set_cursor_cursor);
|
|---|
| 841 |
|
|---|
| 842 | display_window_destroy(wnd);
|
|---|
| 843 | display_close(disp);
|
|---|
| 844 | rc = loc_service_unregister(sid);
|
|---|
| 845 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 846 | }
|
|---|
| 847 |
|
|---|
| 848 | /** display_window_set_cursor() with server returning success response works. */
|
|---|
| 849 | PCUT_TEST(window_set_cursor_success)
|
|---|
| 850 | {
|
|---|
| 851 | errno_t rc;
|
|---|
| 852 | service_id_t sid;
|
|---|
| 853 | display_t *disp = NULL;
|
|---|
| 854 | display_wnd_params_t params;
|
|---|
| 855 | display_window_t *wnd;
|
|---|
| 856 | test_response_t resp;
|
|---|
| 857 |
|
|---|
| 858 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 859 |
|
|---|
| 860 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 861 | rc = loc_server_register(test_display_server);
|
|---|
| 862 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 863 |
|
|---|
| 864 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 865 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 866 |
|
|---|
| 867 | rc = display_open(test_display_svc, &disp);
|
|---|
| 868 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 869 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 870 |
|
|---|
| 871 | resp.rc = EOK;
|
|---|
| 872 | display_wnd_params_init(¶ms);
|
|---|
| 873 | params.rect.p0.x = 0;
|
|---|
| 874 | params.rect.p0.y = 0;
|
|---|
| 875 | params.rect.p0.x = 100;
|
|---|
| 876 | params.rect.p0.y = 100;
|
|---|
| 877 |
|
|---|
| 878 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 879 | (void *) &resp, &wnd);
|
|---|
| 880 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 881 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 882 |
|
|---|
| 883 | resp.rc = EOK;
|
|---|
| 884 | resp.window_set_cursor_called = false;
|
|---|
| 885 |
|
|---|
| 886 | rc = display_window_set_cursor(wnd, dcurs_size_ud);
|
|---|
| 887 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.set_cursor_wnd_id);
|
|---|
| 888 | PCUT_ASSERT_TRUE(resp.window_set_cursor_called);
|
|---|
| 889 | PCUT_ASSERT_ERRNO_VAL(resp.rc, EOK);
|
|---|
| 890 | PCUT_ASSERT_INT_EQUALS(dcurs_size_ud, resp.set_cursor_cursor);
|
|---|
| 891 |
|
|---|
| 892 | display_window_destroy(wnd);
|
|---|
| 893 | display_close(disp);
|
|---|
| 894 | rc = loc_service_unregister(sid);
|
|---|
| 895 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 896 | }
|
|---|
| 897 |
|
|---|
| 898 | /** display_window_get_gc with server returning failure */
|
|---|
| 899 | PCUT_TEST(window_get_gc_failure)
|
|---|
| 900 | {
|
|---|
| 901 | errno_t rc;
|
|---|
| 902 | service_id_t sid;
|
|---|
| 903 | display_t *disp = NULL;
|
|---|
| 904 | display_wnd_params_t params;
|
|---|
| 905 | display_window_t *wnd;
|
|---|
| 906 | test_response_t resp;
|
|---|
| 907 | gfx_context_t *gc;
|
|---|
| 908 |
|
|---|
| 909 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 910 |
|
|---|
| 911 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 912 | rc = loc_server_register(test_display_server);
|
|---|
| 913 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 914 |
|
|---|
| 915 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 916 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 917 |
|
|---|
| 918 | rc = display_open(test_display_svc, &disp);
|
|---|
| 919 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 920 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 921 |
|
|---|
| 922 | wnd = NULL;
|
|---|
| 923 | resp.rc = EOK;
|
|---|
| 924 | display_wnd_params_init(¶ms);
|
|---|
| 925 | params.rect.p0.x = 0;
|
|---|
| 926 | params.rect.p0.y = 0;
|
|---|
| 927 | params.rect.p0.x = 100;
|
|---|
| 928 | params.rect.p0.y = 100;
|
|---|
| 929 |
|
|---|
| 930 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 931 | (void *) &resp, &wnd);
|
|---|
| 932 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 933 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 934 |
|
|---|
| 935 | gc = NULL;
|
|---|
| 936 | resp.rc = ENOMEM;
|
|---|
| 937 | rc = display_window_get_gc(wnd, &gc);
|
|---|
| 938 | /* async_connect_me_to() does not return specific error */
|
|---|
| 939 | PCUT_ASSERT_ERRNO_VAL(EIO, rc);
|
|---|
| 940 | PCUT_ASSERT_NULL(gc);
|
|---|
| 941 |
|
|---|
| 942 | resp.rc = EOK;
|
|---|
| 943 | rc = display_window_destroy(wnd);
|
|---|
| 944 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 945 |
|
|---|
| 946 | display_close(disp);
|
|---|
| 947 | rc = loc_service_unregister(sid);
|
|---|
| 948 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 949 | }
|
|---|
| 950 |
|
|---|
| 951 | /** display_window_get_gc with server returning success */
|
|---|
| 952 | PCUT_TEST(window_get_gc_success)
|
|---|
| 953 | {
|
|---|
| 954 | errno_t rc;
|
|---|
| 955 | service_id_t sid;
|
|---|
| 956 | display_t *disp = NULL;
|
|---|
| 957 | display_wnd_params_t params;
|
|---|
| 958 | display_window_t *wnd;
|
|---|
| 959 | test_response_t resp;
|
|---|
| 960 | gfx_context_t *gc;
|
|---|
| 961 | gfx_color_t *color;
|
|---|
| 962 |
|
|---|
| 963 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 964 |
|
|---|
| 965 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 966 | rc = loc_server_register(test_display_server);
|
|---|
| 967 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 968 |
|
|---|
| 969 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 970 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 971 |
|
|---|
| 972 | rc = display_open(test_display_svc, &disp);
|
|---|
| 973 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 974 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 975 |
|
|---|
| 976 | wnd = NULL;
|
|---|
| 977 | resp.rc = EOK;
|
|---|
| 978 | display_wnd_params_init(¶ms);
|
|---|
| 979 | params.rect.p0.x = 0;
|
|---|
| 980 | params.rect.p0.y = 0;
|
|---|
| 981 | params.rect.p0.x = 100;
|
|---|
| 982 | params.rect.p0.y = 100;
|
|---|
| 983 |
|
|---|
| 984 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 985 | (void *) &resp, &wnd);
|
|---|
| 986 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 987 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 988 |
|
|---|
| 989 | gc = NULL;
|
|---|
| 990 | rc = display_window_get_gc(wnd, &gc);
|
|---|
| 991 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 992 | PCUT_ASSERT_NOT_NULL(gc);
|
|---|
| 993 |
|
|---|
| 994 | rc = gfx_color_new_rgb_i16(0, 0, 0, &color);
|
|---|
| 995 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 996 |
|
|---|
| 997 | resp.set_color_called = false;
|
|---|
| 998 | rc = gfx_set_color(gc, color);
|
|---|
| 999 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1000 | PCUT_ASSERT_TRUE(resp.set_color_called);
|
|---|
| 1001 |
|
|---|
| 1002 | gfx_color_delete(color);
|
|---|
| 1003 |
|
|---|
| 1004 | rc = display_window_destroy(wnd);
|
|---|
| 1005 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1006 |
|
|---|
| 1007 | display_close(disp);
|
|---|
| 1008 | rc = loc_service_unregister(sid);
|
|---|
| 1009 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1010 | }
|
|---|
| 1011 |
|
|---|
| 1012 | /** Close event can be delivered from server to client callback function */
|
|---|
| 1013 | PCUT_TEST(close_event_deliver)
|
|---|
| 1014 | {
|
|---|
| 1015 | errno_t rc;
|
|---|
| 1016 | service_id_t sid;
|
|---|
| 1017 | display_t *disp = NULL;
|
|---|
| 1018 | display_wnd_params_t params;
|
|---|
| 1019 | display_window_t *wnd;
|
|---|
| 1020 | test_response_t resp;
|
|---|
| 1021 |
|
|---|
| 1022 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 1023 |
|
|---|
| 1024 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 1025 | rc = loc_server_register(test_display_server);
|
|---|
| 1026 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1027 |
|
|---|
| 1028 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 1029 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1030 |
|
|---|
| 1031 | rc = display_open(test_display_svc, &disp);
|
|---|
| 1032 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1033 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 1034 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
|---|
| 1035 |
|
|---|
| 1036 | wnd = NULL;
|
|---|
| 1037 | resp.rc = EOK;
|
|---|
| 1038 | display_wnd_params_init(¶ms);
|
|---|
| 1039 | params.rect.p0.x = 0;
|
|---|
| 1040 | params.rect.p0.y = 0;
|
|---|
| 1041 | params.rect.p0.x = 100;
|
|---|
| 1042 | params.rect.p0.y = 100;
|
|---|
| 1043 |
|
|---|
| 1044 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 1045 | (void *) &resp, &wnd);
|
|---|
| 1046 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1047 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 1048 |
|
|---|
| 1049 | resp.event_cnt = 1;
|
|---|
| 1050 | resp.event.etype = wev_close;
|
|---|
| 1051 | resp.wnd_id = wnd->id;
|
|---|
| 1052 | resp.close_event_called = false;
|
|---|
| 1053 | fibril_mutex_initialize(&resp.event_lock);
|
|---|
| 1054 | fibril_condvar_initialize(&resp.event_cv);
|
|---|
| 1055 | display_srv_ev_pending(resp.srv);
|
|---|
| 1056 |
|
|---|
| 1057 | /* Wait for the event handler to be called. */
|
|---|
| 1058 | fibril_mutex_lock(&resp.event_lock);
|
|---|
| 1059 | while (!resp.close_event_called) {
|
|---|
| 1060 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
|---|
| 1061 | }
|
|---|
| 1062 | fibril_mutex_unlock(&resp.event_lock);
|
|---|
| 1063 |
|
|---|
| 1064 | /* Verify that the event was delivered correctly */
|
|---|
| 1065 | PCUT_ASSERT_INT_EQUALS(resp.event.etype,
|
|---|
| 1066 | resp.revent.etype);
|
|---|
| 1067 |
|
|---|
| 1068 | rc = display_window_destroy(wnd);
|
|---|
| 1069 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1070 |
|
|---|
| 1071 | display_close(disp);
|
|---|
| 1072 |
|
|---|
| 1073 | rc = loc_service_unregister(sid);
|
|---|
| 1074 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1075 | }
|
|---|
| 1076 |
|
|---|
| 1077 | /** Focus event can be delivered from server to client callback function */
|
|---|
| 1078 | PCUT_TEST(focus_event_deliver)
|
|---|
| 1079 | {
|
|---|
| 1080 | errno_t rc;
|
|---|
| 1081 | service_id_t sid;
|
|---|
| 1082 | display_t *disp = NULL;
|
|---|
| 1083 | display_wnd_params_t params;
|
|---|
| 1084 | display_window_t *wnd;
|
|---|
| 1085 | test_response_t resp;
|
|---|
| 1086 |
|
|---|
| 1087 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 1088 |
|
|---|
| 1089 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 1090 | rc = loc_server_register(test_display_server);
|
|---|
| 1091 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1092 |
|
|---|
| 1093 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 1094 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1095 |
|
|---|
| 1096 | rc = display_open(test_display_svc, &disp);
|
|---|
| 1097 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1098 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 1099 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
|---|
| 1100 |
|
|---|
| 1101 | wnd = NULL;
|
|---|
| 1102 | resp.rc = EOK;
|
|---|
| 1103 | display_wnd_params_init(¶ms);
|
|---|
| 1104 | params.rect.p0.x = 0;
|
|---|
| 1105 | params.rect.p0.y = 0;
|
|---|
| 1106 | params.rect.p0.x = 100;
|
|---|
| 1107 | params.rect.p0.y = 100;
|
|---|
| 1108 |
|
|---|
| 1109 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 1110 | (void *) &resp, &wnd);
|
|---|
| 1111 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1112 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 1113 |
|
|---|
| 1114 | resp.event_cnt = 1;
|
|---|
| 1115 | resp.event.etype = wev_focus;
|
|---|
| 1116 | resp.wnd_id = wnd->id;
|
|---|
| 1117 | resp.focus_event_called = false;
|
|---|
| 1118 | fibril_mutex_initialize(&resp.event_lock);
|
|---|
| 1119 | fibril_condvar_initialize(&resp.event_cv);
|
|---|
| 1120 | display_srv_ev_pending(resp.srv);
|
|---|
| 1121 |
|
|---|
| 1122 | /* Wait for the event handler to be called. */
|
|---|
| 1123 | fibril_mutex_lock(&resp.event_lock);
|
|---|
| 1124 | while (!resp.focus_event_called) {
|
|---|
| 1125 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
|---|
| 1126 | }
|
|---|
| 1127 | fibril_mutex_unlock(&resp.event_lock);
|
|---|
| 1128 |
|
|---|
| 1129 | /* Verify that the event was delivered correctly */
|
|---|
| 1130 | PCUT_ASSERT_INT_EQUALS(resp.event.etype,
|
|---|
| 1131 | resp.revent.etype);
|
|---|
| 1132 |
|
|---|
| 1133 | rc = display_window_destroy(wnd);
|
|---|
| 1134 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1135 |
|
|---|
| 1136 | display_close(disp);
|
|---|
| 1137 |
|
|---|
| 1138 | rc = loc_service_unregister(sid);
|
|---|
| 1139 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1140 | }
|
|---|
| 1141 |
|
|---|
| 1142 | /** Keyboard event can be delivered from server to client callback function */
|
|---|
| 1143 | PCUT_TEST(kbd_event_deliver)
|
|---|
| 1144 | {
|
|---|
| 1145 | errno_t rc;
|
|---|
| 1146 | service_id_t sid;
|
|---|
| 1147 | display_t *disp = NULL;
|
|---|
| 1148 | display_wnd_params_t params;
|
|---|
| 1149 | display_window_t *wnd;
|
|---|
| 1150 | test_response_t resp;
|
|---|
| 1151 |
|
|---|
| 1152 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 1153 |
|
|---|
| 1154 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 1155 | rc = loc_server_register(test_display_server);
|
|---|
| 1156 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1157 |
|
|---|
| 1158 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 1159 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1160 |
|
|---|
| 1161 | rc = display_open(test_display_svc, &disp);
|
|---|
| 1162 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1163 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 1164 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
|---|
| 1165 |
|
|---|
| 1166 | wnd = NULL;
|
|---|
| 1167 | resp.rc = EOK;
|
|---|
| 1168 | display_wnd_params_init(¶ms);
|
|---|
| 1169 | params.rect.p0.x = 0;
|
|---|
| 1170 | params.rect.p0.y = 0;
|
|---|
| 1171 | params.rect.p0.x = 100;
|
|---|
| 1172 | params.rect.p0.y = 100;
|
|---|
| 1173 |
|
|---|
| 1174 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 1175 | (void *) &resp, &wnd);
|
|---|
| 1176 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1177 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 1178 |
|
|---|
| 1179 | resp.event_cnt = 1;
|
|---|
| 1180 | resp.event.etype = wev_kbd;
|
|---|
| 1181 | resp.event.ev.kbd.type = KEY_PRESS;
|
|---|
| 1182 | resp.event.ev.kbd.key = KC_ENTER;
|
|---|
| 1183 | resp.event.ev.kbd.mods = 0;
|
|---|
| 1184 | resp.event.ev.kbd.c = L'\0';
|
|---|
| 1185 | resp.wnd_id = wnd->id;
|
|---|
| 1186 | resp.kbd_event_called = false;
|
|---|
| 1187 | fibril_mutex_initialize(&resp.event_lock);
|
|---|
| 1188 | fibril_condvar_initialize(&resp.event_cv);
|
|---|
| 1189 | display_srv_ev_pending(resp.srv);
|
|---|
| 1190 |
|
|---|
| 1191 | /* Wait for the event handler to be called. */
|
|---|
| 1192 | fibril_mutex_lock(&resp.event_lock);
|
|---|
| 1193 | while (!resp.kbd_event_called) {
|
|---|
| 1194 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
|---|
| 1195 | }
|
|---|
| 1196 | fibril_mutex_unlock(&resp.event_lock);
|
|---|
| 1197 |
|
|---|
| 1198 | /* Verify that the event was delivered correctly */
|
|---|
| 1199 | PCUT_ASSERT_INT_EQUALS(resp.event.etype,
|
|---|
| 1200 | resp.revent.etype);
|
|---|
| 1201 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.kbd.type,
|
|---|
| 1202 | resp.revent.ev.kbd.type);
|
|---|
| 1203 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.kbd.key,
|
|---|
| 1204 | resp.revent.ev.kbd.key);
|
|---|
| 1205 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.kbd.mods,
|
|---|
| 1206 | resp.revent.ev.kbd.mods);
|
|---|
| 1207 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.kbd.c,
|
|---|
| 1208 | resp.revent.ev.kbd.c);
|
|---|
| 1209 |
|
|---|
| 1210 | rc = display_window_destroy(wnd);
|
|---|
| 1211 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1212 |
|
|---|
| 1213 | display_close(disp);
|
|---|
| 1214 |
|
|---|
| 1215 | rc = loc_service_unregister(sid);
|
|---|
| 1216 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1217 | }
|
|---|
| 1218 |
|
|---|
| 1219 | /** Position event can be delivered from server to client callback function */
|
|---|
| 1220 | PCUT_TEST(pos_event_deliver)
|
|---|
| 1221 | {
|
|---|
| 1222 | errno_t rc;
|
|---|
| 1223 | service_id_t sid;
|
|---|
| 1224 | display_t *disp = NULL;
|
|---|
| 1225 | display_wnd_params_t params;
|
|---|
| 1226 | display_window_t *wnd;
|
|---|
| 1227 | test_response_t resp;
|
|---|
| 1228 |
|
|---|
| 1229 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 1230 |
|
|---|
| 1231 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 1232 | rc = loc_server_register(test_display_server);
|
|---|
| 1233 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1234 |
|
|---|
| 1235 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 1236 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1237 |
|
|---|
| 1238 | rc = display_open(test_display_svc, &disp);
|
|---|
| 1239 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1240 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 1241 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
|---|
| 1242 |
|
|---|
| 1243 | wnd = NULL;
|
|---|
| 1244 | resp.rc = EOK;
|
|---|
| 1245 | display_wnd_params_init(¶ms);
|
|---|
| 1246 | params.rect.p0.x = 0;
|
|---|
| 1247 | params.rect.p0.y = 0;
|
|---|
| 1248 | params.rect.p0.x = 100;
|
|---|
| 1249 | params.rect.p0.y = 100;
|
|---|
| 1250 |
|
|---|
| 1251 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 1252 | (void *) &resp, &wnd);
|
|---|
| 1253 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1254 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 1255 |
|
|---|
| 1256 | resp.event_cnt = 1;
|
|---|
| 1257 | resp.event.etype = wev_pos;
|
|---|
| 1258 | resp.event.ev.pos.type = POS_PRESS;
|
|---|
| 1259 | resp.event.ev.pos.btn_num = 1;
|
|---|
| 1260 | resp.event.ev.pos.hpos = 2;
|
|---|
| 1261 | resp.event.ev.pos.vpos = 3;
|
|---|
| 1262 | resp.wnd_id = wnd->id;
|
|---|
| 1263 | resp.pos_event_called = false;
|
|---|
| 1264 | fibril_mutex_initialize(&resp.event_lock);
|
|---|
| 1265 | fibril_condvar_initialize(&resp.event_cv);
|
|---|
| 1266 | display_srv_ev_pending(resp.srv);
|
|---|
| 1267 |
|
|---|
| 1268 | /* Wait for the event handler to be called. */
|
|---|
| 1269 | fibril_mutex_lock(&resp.event_lock);
|
|---|
| 1270 | while (!resp.pos_event_called) {
|
|---|
| 1271 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
|---|
| 1272 | }
|
|---|
| 1273 | fibril_mutex_unlock(&resp.event_lock);
|
|---|
| 1274 |
|
|---|
| 1275 | /* Verify that the event was delivered correctly */
|
|---|
| 1276 | PCUT_ASSERT_INT_EQUALS(resp.event.etype,
|
|---|
| 1277 | resp.revent.etype);
|
|---|
| 1278 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.pos.type,
|
|---|
| 1279 | resp.revent.ev.pos.type);
|
|---|
| 1280 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.pos.btn_num,
|
|---|
| 1281 | resp.revent.ev.pos.btn_num);
|
|---|
| 1282 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.pos.hpos,
|
|---|
| 1283 | resp.revent.ev.pos.hpos);
|
|---|
| 1284 | PCUT_ASSERT_INT_EQUALS(resp.event.ev.pos.vpos,
|
|---|
| 1285 | resp.revent.ev.pos.vpos);
|
|---|
| 1286 |
|
|---|
| 1287 | rc = display_window_destroy(wnd);
|
|---|
| 1288 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1289 |
|
|---|
| 1290 | display_close(disp);
|
|---|
| 1291 |
|
|---|
| 1292 | rc = loc_service_unregister(sid);
|
|---|
| 1293 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1294 | }
|
|---|
| 1295 |
|
|---|
| 1296 | /** Unfocus event can be delivered from server to client callback function */
|
|---|
| 1297 | PCUT_TEST(unfocus_event_deliver)
|
|---|
| 1298 | {
|
|---|
| 1299 | errno_t rc;
|
|---|
| 1300 | service_id_t sid;
|
|---|
| 1301 | display_t *disp = NULL;
|
|---|
| 1302 | display_wnd_params_t params;
|
|---|
| 1303 | display_window_t *wnd;
|
|---|
| 1304 | test_response_t resp;
|
|---|
| 1305 |
|
|---|
| 1306 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 1307 |
|
|---|
| 1308 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 1309 | rc = loc_server_register(test_display_server);
|
|---|
| 1310 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1311 |
|
|---|
| 1312 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 1313 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1314 |
|
|---|
| 1315 | rc = display_open(test_display_svc, &disp);
|
|---|
| 1316 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1317 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 1318 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
|---|
| 1319 |
|
|---|
| 1320 | wnd = NULL;
|
|---|
| 1321 | resp.rc = EOK;
|
|---|
| 1322 | display_wnd_params_init(¶ms);
|
|---|
| 1323 | params.rect.p0.x = 0;
|
|---|
| 1324 | params.rect.p0.y = 0;
|
|---|
| 1325 | params.rect.p0.x = 100;
|
|---|
| 1326 | params.rect.p0.y = 100;
|
|---|
| 1327 |
|
|---|
| 1328 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
|---|
| 1329 | (void *) &resp, &wnd);
|
|---|
| 1330 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1331 | PCUT_ASSERT_NOT_NULL(wnd);
|
|---|
| 1332 |
|
|---|
| 1333 | resp.event_cnt = 1;
|
|---|
| 1334 | resp.event.etype = wev_unfocus;
|
|---|
| 1335 | resp.wnd_id = wnd->id;
|
|---|
| 1336 | resp.unfocus_event_called = false;
|
|---|
| 1337 | fibril_mutex_initialize(&resp.event_lock);
|
|---|
| 1338 | fibril_condvar_initialize(&resp.event_cv);
|
|---|
| 1339 | display_srv_ev_pending(resp.srv);
|
|---|
| 1340 |
|
|---|
| 1341 | /* Wait for the event handler to be called. */
|
|---|
| 1342 | fibril_mutex_lock(&resp.event_lock);
|
|---|
| 1343 | while (!resp.unfocus_event_called) {
|
|---|
| 1344 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
|---|
| 1345 | }
|
|---|
| 1346 | fibril_mutex_unlock(&resp.event_lock);
|
|---|
| 1347 |
|
|---|
| 1348 | /* Verify that the event was delivered correctly */
|
|---|
| 1349 | PCUT_ASSERT_INT_EQUALS(resp.event.etype,
|
|---|
| 1350 | resp.revent.etype);
|
|---|
| 1351 |
|
|---|
| 1352 | rc = display_window_destroy(wnd);
|
|---|
| 1353 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1354 |
|
|---|
| 1355 | display_close(disp);
|
|---|
| 1356 |
|
|---|
| 1357 | rc = loc_service_unregister(sid);
|
|---|
| 1358 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1359 | }
|
|---|
| 1360 |
|
|---|
| 1361 | /** display_get_info() with server returning failure response works. */
|
|---|
| 1362 | PCUT_TEST(get_info_failure)
|
|---|
| 1363 | {
|
|---|
| 1364 | errno_t rc;
|
|---|
| 1365 | service_id_t sid;
|
|---|
| 1366 | display_t *disp = NULL;
|
|---|
| 1367 | display_info_t info;
|
|---|
| 1368 | test_response_t resp;
|
|---|
| 1369 |
|
|---|
| 1370 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 1371 |
|
|---|
| 1372 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 1373 | rc = loc_server_register(test_display_server);
|
|---|
| 1374 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1375 |
|
|---|
| 1376 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 1377 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1378 |
|
|---|
| 1379 | rc = display_open(test_display_svc, &disp);
|
|---|
| 1380 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1381 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 1382 |
|
|---|
| 1383 | resp.rc = ENOMEM;
|
|---|
| 1384 | resp.get_info_called = false;
|
|---|
| 1385 |
|
|---|
| 1386 | rc = display_get_info(disp, &info);
|
|---|
| 1387 | PCUT_ASSERT_TRUE(resp.get_info_called);
|
|---|
| 1388 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
|---|
| 1389 |
|
|---|
| 1390 | display_close(disp);
|
|---|
| 1391 | rc = loc_service_unregister(sid);
|
|---|
| 1392 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1393 | }
|
|---|
| 1394 |
|
|---|
| 1395 | /** display_get_info() with server returning success response works. */
|
|---|
| 1396 | PCUT_TEST(get_info_success)
|
|---|
| 1397 | {
|
|---|
| 1398 | errno_t rc;
|
|---|
| 1399 | service_id_t sid;
|
|---|
| 1400 | display_t *disp = NULL;
|
|---|
| 1401 | display_info_t info;
|
|---|
| 1402 | test_response_t resp;
|
|---|
| 1403 |
|
|---|
| 1404 | async_set_fallback_port_handler(test_display_conn, &resp);
|
|---|
| 1405 |
|
|---|
| 1406 | // FIXME This causes this test to be non-reentrant!
|
|---|
| 1407 | rc = loc_server_register(test_display_server);
|
|---|
| 1408 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1409 |
|
|---|
| 1410 | rc = loc_service_register(test_display_svc, &sid);
|
|---|
| 1411 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1412 |
|
|---|
| 1413 | rc = display_open(test_display_svc, &disp);
|
|---|
| 1414 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1415 | PCUT_ASSERT_NOT_NULL(disp);
|
|---|
| 1416 |
|
|---|
| 1417 | resp.rc = EOK;
|
|---|
| 1418 | resp.get_info_called = false;
|
|---|
| 1419 | resp.get_info_rect.p0.x = 10;
|
|---|
| 1420 | resp.get_info_rect.p0.y = 11;
|
|---|
| 1421 | resp.get_info_rect.p1.x = 20;
|
|---|
| 1422 | resp.get_info_rect.p1.y = 21;
|
|---|
| 1423 |
|
|---|
| 1424 | rc = display_get_info(disp, &info);
|
|---|
| 1425 | PCUT_ASSERT_TRUE(resp.get_info_called);
|
|---|
| 1426 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
|---|
| 1427 | PCUT_ASSERT_INT_EQUALS(resp.get_info_rect.p0.x, info.rect.p0.x);
|
|---|
| 1428 | PCUT_ASSERT_INT_EQUALS(resp.get_info_rect.p0.y, info.rect.p0.y);
|
|---|
| 1429 | PCUT_ASSERT_INT_EQUALS(resp.get_info_rect.p1.x, info.rect.p1.x);
|
|---|
| 1430 | PCUT_ASSERT_INT_EQUALS(resp.get_info_rect.p1.y, info.rect.p1.y);
|
|---|
| 1431 |
|
|---|
| 1432 | display_close(disp);
|
|---|
| 1433 | rc = loc_service_unregister(sid);
|
|---|
| 1434 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
|---|
| 1435 | }
|
|---|
| 1436 |
|
|---|
| 1437 | /** Test display service connection.
|
|---|
| 1438 | *
|
|---|
| 1439 | * This is very similar to connection handler in the display server.
|
|---|
| 1440 | * XXX This should be folded into display_srv, if possible
|
|---|
| 1441 | */
|
|---|
| 1442 | static void test_display_conn(ipc_call_t *icall, void *arg)
|
|---|
| 1443 | {
|
|---|
| 1444 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1445 | display_srv_t srv;
|
|---|
| 1446 | sysarg_t wnd_id;
|
|---|
| 1447 | sysarg_t svc_id;
|
|---|
| 1448 | gfx_context_t *gc;
|
|---|
| 1449 | errno_t rc;
|
|---|
| 1450 |
|
|---|
| 1451 | svc_id = ipc_get_arg2(icall);
|
|---|
| 1452 | wnd_id = ipc_get_arg3(icall);
|
|---|
| 1453 |
|
|---|
| 1454 | if (svc_id != 0) {
|
|---|
| 1455 | /* Set up protocol structure */
|
|---|
| 1456 | display_srv_initialize(&srv);
|
|---|
| 1457 | srv.ops = &test_display_srv_ops;
|
|---|
| 1458 | srv.arg = arg;
|
|---|
| 1459 | resp->srv = &srv;
|
|---|
| 1460 |
|
|---|
| 1461 | /* Handle connection */
|
|---|
| 1462 | display_conn(icall, &srv);
|
|---|
| 1463 |
|
|---|
| 1464 | resp->srv = NULL;
|
|---|
| 1465 | } else {
|
|---|
| 1466 | (void) wnd_id;
|
|---|
| 1467 |
|
|---|
| 1468 | if (resp->rc != EOK) {
|
|---|
| 1469 | async_answer_0(icall, resp->rc);
|
|---|
| 1470 | return;
|
|---|
| 1471 | }
|
|---|
| 1472 |
|
|---|
| 1473 | rc = gfx_context_new(&test_gc_ops, arg, &gc);
|
|---|
| 1474 | if (rc != EOK) {
|
|---|
| 1475 | async_answer_0(icall, ENOMEM);
|
|---|
| 1476 | return;
|
|---|
| 1477 | }
|
|---|
| 1478 |
|
|---|
| 1479 | /* Window GC connection */
|
|---|
| 1480 | gc_conn(icall, gc);
|
|---|
| 1481 | }
|
|---|
| 1482 | }
|
|---|
| 1483 |
|
|---|
| 1484 | static void test_close_event(void *arg)
|
|---|
| 1485 | {
|
|---|
| 1486 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1487 |
|
|---|
| 1488 | resp->revent.etype = wev_close;
|
|---|
| 1489 |
|
|---|
| 1490 | fibril_mutex_lock(&resp->event_lock);
|
|---|
| 1491 | resp->close_event_called = true;
|
|---|
| 1492 | fibril_condvar_broadcast(&resp->event_cv);
|
|---|
| 1493 | fibril_mutex_unlock(&resp->event_lock);
|
|---|
| 1494 | }
|
|---|
| 1495 |
|
|---|
| 1496 | static void test_focus_event(void *arg)
|
|---|
| 1497 | {
|
|---|
| 1498 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1499 |
|
|---|
| 1500 | resp->revent.etype = wev_focus;
|
|---|
| 1501 |
|
|---|
| 1502 | fibril_mutex_lock(&resp->event_lock);
|
|---|
| 1503 | resp->focus_event_called = true;
|
|---|
| 1504 | fibril_condvar_broadcast(&resp->event_cv);
|
|---|
| 1505 | fibril_mutex_unlock(&resp->event_lock);
|
|---|
| 1506 | }
|
|---|
| 1507 |
|
|---|
| 1508 | static void test_kbd_event(void *arg, kbd_event_t *event)
|
|---|
| 1509 | {
|
|---|
| 1510 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1511 |
|
|---|
| 1512 | resp->revent.etype = wev_kbd;
|
|---|
| 1513 | resp->revent.ev.kbd = *event;
|
|---|
| 1514 |
|
|---|
| 1515 | fibril_mutex_lock(&resp->event_lock);
|
|---|
| 1516 | resp->kbd_event_called = true;
|
|---|
| 1517 | fibril_condvar_broadcast(&resp->event_cv);
|
|---|
| 1518 | fibril_mutex_unlock(&resp->event_lock);
|
|---|
| 1519 | }
|
|---|
| 1520 |
|
|---|
| 1521 | static void test_pos_event(void *arg, pos_event_t *event)
|
|---|
| 1522 | {
|
|---|
| 1523 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1524 |
|
|---|
| 1525 | resp->revent.etype = wev_pos;
|
|---|
| 1526 | resp->revent.ev.pos = *event;
|
|---|
| 1527 |
|
|---|
| 1528 | fibril_mutex_lock(&resp->event_lock);
|
|---|
| 1529 | resp->pos_event_called = true;
|
|---|
| 1530 | fibril_condvar_broadcast(&resp->event_cv);
|
|---|
| 1531 | fibril_mutex_unlock(&resp->event_lock);
|
|---|
| 1532 | }
|
|---|
| 1533 |
|
|---|
| 1534 | static void test_unfocus_event(void *arg)
|
|---|
| 1535 | {
|
|---|
| 1536 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1537 |
|
|---|
| 1538 | resp->revent.etype = wev_unfocus;
|
|---|
| 1539 |
|
|---|
| 1540 | fibril_mutex_lock(&resp->event_lock);
|
|---|
| 1541 | resp->unfocus_event_called = true;
|
|---|
| 1542 | fibril_condvar_broadcast(&resp->event_cv);
|
|---|
| 1543 | fibril_mutex_unlock(&resp->event_lock);
|
|---|
| 1544 | }
|
|---|
| 1545 |
|
|---|
| 1546 | static errno_t test_window_create(void *arg, display_wnd_params_t *params,
|
|---|
| 1547 | sysarg_t *rwnd_id)
|
|---|
| 1548 | {
|
|---|
| 1549 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1550 |
|
|---|
| 1551 | resp->window_create_called = true;
|
|---|
| 1552 | resp->create_rect = params->rect;
|
|---|
| 1553 | resp->create_min_size = params->min_size;
|
|---|
| 1554 | if (resp->rc == EOK)
|
|---|
| 1555 | *rwnd_id = resp->wnd_id;
|
|---|
| 1556 |
|
|---|
| 1557 | return resp->rc;
|
|---|
| 1558 | }
|
|---|
| 1559 |
|
|---|
| 1560 | static errno_t test_window_destroy(void *arg, sysarg_t wnd_id)
|
|---|
| 1561 | {
|
|---|
| 1562 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1563 |
|
|---|
| 1564 | resp->window_destroy_called = true;
|
|---|
| 1565 | resp->destroy_wnd_id = wnd_id;
|
|---|
| 1566 | return resp->rc;
|
|---|
| 1567 | }
|
|---|
| 1568 |
|
|---|
| 1569 | static errno_t test_window_move_req(void *arg, sysarg_t wnd_id,
|
|---|
| 1570 | gfx_coord2_t *pos)
|
|---|
| 1571 | {
|
|---|
| 1572 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1573 |
|
|---|
| 1574 | resp->window_move_req_called = true;
|
|---|
| 1575 | resp->move_req_wnd_id = wnd_id;
|
|---|
| 1576 | resp->move_req_pos = *pos;
|
|---|
| 1577 | return resp->rc;
|
|---|
| 1578 | }
|
|---|
| 1579 |
|
|---|
| 1580 | static errno_t test_window_move(void *arg, sysarg_t wnd_id, gfx_coord2_t *dpos)
|
|---|
| 1581 | {
|
|---|
| 1582 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1583 |
|
|---|
| 1584 | resp->window_move_called = true;
|
|---|
| 1585 | resp->move_wnd_id = wnd_id;
|
|---|
| 1586 | resp->move_dpos = *dpos;
|
|---|
| 1587 | return resp->rc;
|
|---|
| 1588 | }
|
|---|
| 1589 |
|
|---|
| 1590 | static errno_t test_window_resize_req(void *arg, sysarg_t wnd_id,
|
|---|
| 1591 | display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
|
|---|
| 1592 | {
|
|---|
| 1593 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1594 |
|
|---|
| 1595 | resp->window_resize_req_called = true;
|
|---|
| 1596 | resp->resize_req_rsztype = rsztype;
|
|---|
| 1597 | resp->resize_req_wnd_id = wnd_id;
|
|---|
| 1598 | resp->resize_req_pos = *pos;
|
|---|
| 1599 | return resp->rc;
|
|---|
| 1600 | }
|
|---|
| 1601 |
|
|---|
| 1602 | static errno_t test_window_resize(void *arg, sysarg_t wnd_id,
|
|---|
| 1603 | gfx_coord2_t *offs, gfx_rect_t *nrect)
|
|---|
| 1604 | {
|
|---|
| 1605 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1606 |
|
|---|
| 1607 | resp->window_resize_called = true;
|
|---|
| 1608 | resp->resize_wnd_id = wnd_id;
|
|---|
| 1609 | resp->resize_offs = *offs;
|
|---|
| 1610 | resp->resize_nbound = *nrect;
|
|---|
| 1611 | return resp->rc;
|
|---|
| 1612 | }
|
|---|
| 1613 |
|
|---|
| 1614 | static errno_t test_window_set_cursor(void *arg, sysarg_t wnd_id,
|
|---|
| 1615 | display_stock_cursor_t cursor)
|
|---|
| 1616 | {
|
|---|
| 1617 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1618 |
|
|---|
| 1619 | resp->window_set_cursor_called = true;
|
|---|
| 1620 | resp->set_cursor_wnd_id = wnd_id;
|
|---|
| 1621 | resp->set_cursor_cursor = cursor;
|
|---|
| 1622 |
|
|---|
| 1623 | return resp->rc;
|
|---|
| 1624 | }
|
|---|
| 1625 |
|
|---|
| 1626 | static errno_t test_get_event(void *arg, sysarg_t *wnd_id,
|
|---|
| 1627 | display_wnd_ev_t *event)
|
|---|
| 1628 | {
|
|---|
| 1629 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1630 |
|
|---|
| 1631 | resp->get_event_called = true;
|
|---|
| 1632 | if (resp->event_cnt > 0) {
|
|---|
| 1633 | --resp->event_cnt;
|
|---|
| 1634 | *wnd_id = resp->wnd_id;
|
|---|
| 1635 | *event = resp->event;
|
|---|
| 1636 | return EOK;
|
|---|
| 1637 | }
|
|---|
| 1638 |
|
|---|
| 1639 | return ENOENT;
|
|---|
| 1640 | }
|
|---|
| 1641 |
|
|---|
| 1642 | static errno_t test_get_info(void *arg, display_info_t *info)
|
|---|
| 1643 | {
|
|---|
| 1644 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1645 |
|
|---|
| 1646 | resp->get_info_called = true;
|
|---|
| 1647 | info->rect = resp->get_info_rect;
|
|---|
| 1648 |
|
|---|
| 1649 | return resp->rc;
|
|---|
| 1650 | }
|
|---|
| 1651 |
|
|---|
| 1652 | static errno_t test_gc_set_color(void *arg, gfx_color_t *color)
|
|---|
| 1653 | {
|
|---|
| 1654 | test_response_t *resp = (test_response_t *) arg;
|
|---|
| 1655 |
|
|---|
| 1656 | resp->set_color_called = true;
|
|---|
| 1657 | return resp->rc;
|
|---|
| 1658 | }
|
|---|
| 1659 |
|
|---|
| 1660 | PCUT_EXPORT(display);
|
|---|