[959b7ec] | 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>
|
---|
[b093a62] | 33 | #include <fibril_synch.h>
|
---|
[bfddc62] | 34 | #include <gfx/color.h>
|
---|
| 35 | #include <gfx/context.h>
|
---|
| 36 | #include <gfx/render.h>
|
---|
| 37 | #include <ipcgfx/server.h>
|
---|
[959b7ec] | 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 *);
|
---|
[b0a94854] | 49 |
|
---|
[338d0935] | 50 | static void test_close_event(void *);
|
---|
[b0a94854] | 51 | static void test_focus_event(void *);
|
---|
[bfddc62] | 52 | static void test_kbd_event(void *, kbd_event_t *);
|
---|
[f7fb2b21] | 53 | static void test_pos_event(void *, pos_event_t *);
|
---|
[b0a94854] | 54 | static void test_unfocus_event(void *);
|
---|
[959b7ec] | 55 |
|
---|
[4d9c807] | 56 | static errno_t test_window_create(void *, display_wnd_params_t *, sysarg_t *);
|
---|
[bfddc62] | 57 | static errno_t test_window_destroy(void *, sysarg_t);
|
---|
[a2e104e] | 58 | static errno_t test_window_move_req(void *, sysarg_t, gfx_coord2_t *);
|
---|
[1e4a937] | 59 | static errno_t test_window_resize_req(void *, sysarg_t, display_wnd_rsztype_t,
|
---|
| 60 | gfx_coord2_t *);
|
---|
[0e6e77f] | 61 | static errno_t test_window_resize(void *, sysarg_t, gfx_coord2_t *,
|
---|
| 62 | gfx_rect_t *);
|
---|
[bfddc62] | 63 | static errno_t test_get_event(void *, sysarg_t *, display_wnd_ev_t *);
|
---|
| 64 |
|
---|
| 65 | static errno_t test_gc_set_color(void *, gfx_color_t *);
|
---|
| 66 |
|
---|
| 67 | static display_ops_t test_display_srv_ops = {
|
---|
| 68 | .window_create = test_window_create,
|
---|
| 69 | .window_destroy = test_window_destroy,
|
---|
[a2e104e] | 70 | .window_move_req = test_window_move_req,
|
---|
[1e4a937] | 71 | .window_resize_req = test_window_resize_req,
|
---|
[0e6e77f] | 72 | .window_resize = test_window_resize,
|
---|
[bfddc62] | 73 | .get_event = test_get_event
|
---|
| 74 | };
|
---|
| 75 |
|
---|
| 76 | static display_wnd_cb_t test_display_wnd_cb = {
|
---|
[338d0935] | 77 | .close_event = test_close_event,
|
---|
[b0a94854] | 78 | .focus_event = test_focus_event,
|
---|
[f7fb2b21] | 79 | .kbd_event = test_kbd_event,
|
---|
[b0a94854] | 80 | .pos_event = test_pos_event,
|
---|
| 81 | .unfocus_event = test_unfocus_event
|
---|
[bfddc62] | 82 | };
|
---|
| 83 |
|
---|
| 84 | static gfx_context_ops_t test_gc_ops = {
|
---|
| 85 | .set_color = test_gc_set_color
|
---|
| 86 | };
|
---|
| 87 |
|
---|
| 88 | /** Describes to the server how to respond to our request and pass tracking
|
---|
| 89 | * data back to the client.
|
---|
| 90 | */
|
---|
| 91 | typedef struct {
|
---|
| 92 | errno_t rc;
|
---|
| 93 | sysarg_t wnd_id;
|
---|
| 94 | display_wnd_ev_t event;
|
---|
[b093a62] | 95 | display_wnd_ev_t revent;
|
---|
| 96 | int event_cnt;
|
---|
[bfddc62] | 97 | bool window_create_called;
|
---|
[4d9c807] | 98 | gfx_rect_t create_rect;
|
---|
[bfddc62] | 99 | bool window_destroy_called;
|
---|
[0e6e77f] | 100 | sysarg_t destroy_wnd_id;
|
---|
| 101 |
|
---|
[a2e104e] | 102 | bool window_move_req_called;
|
---|
| 103 | sysarg_t move_req_wnd_id;
|
---|
| 104 | gfx_coord2_t move_req_pos;
|
---|
| 105 |
|
---|
[1e4a937] | 106 | bool window_resize_req_called;
|
---|
| 107 | sysarg_t resize_req_wnd_id;
|
---|
| 108 | display_wnd_rsztype_t resize_req_rsztype;
|
---|
| 109 | gfx_coord2_t resize_req_pos;
|
---|
| 110 |
|
---|
[0e6e77f] | 111 | bool window_resize_called;
|
---|
| 112 | gfx_coord2_t resize_offs;
|
---|
| 113 | gfx_rect_t resize_nbound;
|
---|
| 114 | sysarg_t resize_wnd_id;
|
---|
| 115 |
|
---|
[bfddc62] | 116 | bool get_event_called;
|
---|
| 117 | bool set_color_called;
|
---|
[338d0935] | 118 | bool close_event_called;
|
---|
[b0a94854] | 119 | bool focus_event_called;
|
---|
[b093a62] | 120 | bool kbd_event_called;
|
---|
[f7fb2b21] | 121 | bool pos_event_called;
|
---|
[b0a94854] | 122 | bool unfocus_event_called;
|
---|
[f7fb2b21] | 123 | fibril_condvar_t event_cv;
|
---|
| 124 | fibril_mutex_t event_lock;
|
---|
[dcac756] | 125 | display_srv_t *srv;
|
---|
[bfddc62] | 126 | } test_response_t;
|
---|
[959b7ec] | 127 |
|
---|
| 128 | /** display_open(), display_close() work for valid display service */
|
---|
| 129 | PCUT_TEST(open_close)
|
---|
| 130 | {
|
---|
| 131 | errno_t rc;
|
---|
| 132 | service_id_t sid;
|
---|
| 133 | display_t *disp = NULL;
|
---|
[dcac756] | 134 | test_response_t resp;
|
---|
[959b7ec] | 135 |
|
---|
[dcac756] | 136 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
[959b7ec] | 137 |
|
---|
[38e4f42] | 138 | // FIXME This causes this test to be non-reentrant!
|
---|
[959b7ec] | 139 | rc = loc_server_register(test_display_server);
|
---|
| 140 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 141 |
|
---|
| 142 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 143 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 144 |
|
---|
| 145 | rc = display_open(test_display_svc, &disp);
|
---|
| 146 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 147 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 148 |
|
---|
| 149 | display_close(disp);
|
---|
| 150 | rc = loc_service_unregister(sid);
|
---|
| 151 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | /** display_window_create() with server returning error response works */
|
---|
| 155 | PCUT_TEST(window_create_failure)
|
---|
| 156 | {
|
---|
[bfddc62] | 157 | errno_t rc;
|
---|
| 158 | service_id_t sid;
|
---|
| 159 | display_t *disp = NULL;
|
---|
[4d9c807] | 160 | display_wnd_params_t params;
|
---|
[bfddc62] | 161 | display_window_t *wnd;
|
---|
| 162 | test_response_t resp;
|
---|
| 163 |
|
---|
| 164 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 165 |
|
---|
[38e4f42] | 166 | // FIXME This causes this test to be non-reentrant!
|
---|
[bfddc62] | 167 | rc = loc_server_register(test_display_server);
|
---|
| 168 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 169 |
|
---|
| 170 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 171 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 172 |
|
---|
| 173 | rc = display_open(test_display_svc, &disp);
|
---|
| 174 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 175 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 176 |
|
---|
| 177 | wnd = NULL;
|
---|
| 178 | resp.rc = ENOMEM;
|
---|
| 179 | resp.window_create_called = false;
|
---|
[4d9c807] | 180 | display_wnd_params_init(¶ms);
|
---|
| 181 | params.rect.p0.x = 0;
|
---|
| 182 | params.rect.p0.y = 0;
|
---|
| 183 | params.rect.p0.x = 100;
|
---|
| 184 | params.rect.p0.y = 100;
|
---|
| 185 |
|
---|
| 186 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 187 | (void *) &resp, &wnd);
|
---|
[bfddc62] | 188 | PCUT_ASSERT_TRUE(resp.window_create_called);
|
---|
[4d9c807] | 189 | PCUT_ASSERT_EQUALS(params.rect.p0.x, resp.create_rect.p0.x);
|
---|
| 190 | PCUT_ASSERT_EQUALS(params.rect.p0.y, resp.create_rect.p0.y);
|
---|
| 191 | PCUT_ASSERT_EQUALS(params.rect.p1.x, resp.create_rect.p1.x);
|
---|
| 192 | PCUT_ASSERT_EQUALS(params.rect.p1.y, resp.create_rect.p1.y);
|
---|
[bfddc62] | 193 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
| 194 | PCUT_ASSERT_NULL(wnd);
|
---|
| 195 |
|
---|
| 196 | display_close(disp);
|
---|
| 197 | rc = loc_service_unregister(sid);
|
---|
| 198 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[959b7ec] | 199 | }
|
---|
| 200 |
|
---|
[bfddc62] | 201 | /** display_window_create() and display_window_destroy() with success
|
---|
| 202 | *
|
---|
| 203 | * with server returning success,
|
---|
| 204 | */
|
---|
| 205 | PCUT_TEST(window_create_destroy_success)
|
---|
[959b7ec] | 206 | {
|
---|
[bfddc62] | 207 | errno_t rc;
|
---|
| 208 | service_id_t sid;
|
---|
| 209 | display_t *disp = NULL;
|
---|
[4d9c807] | 210 | display_wnd_params_t params;
|
---|
[bfddc62] | 211 | display_window_t *wnd;
|
---|
| 212 | test_response_t resp;
|
---|
| 213 |
|
---|
| 214 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 215 |
|
---|
[38e4f42] | 216 | // FIXME This causes this test to be non-reentrant!
|
---|
[bfddc62] | 217 | rc = loc_server_register(test_display_server);
|
---|
| 218 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 219 |
|
---|
| 220 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 221 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 222 |
|
---|
| 223 | rc = display_open(test_display_svc, &disp);
|
---|
| 224 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 225 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 226 |
|
---|
| 227 | wnd = NULL;
|
---|
| 228 | resp.rc = EOK;
|
---|
| 229 | resp.window_create_called = false;
|
---|
[4d9c807] | 230 | display_wnd_params_init(¶ms);
|
---|
| 231 | params.rect.p0.x = 0;
|
---|
| 232 | params.rect.p0.y = 0;
|
---|
| 233 | params.rect.p0.x = 100;
|
---|
| 234 | params.rect.p0.y = 100;
|
---|
| 235 |
|
---|
| 236 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 237 | (void *) &resp, &wnd);
|
---|
[bfddc62] | 238 | PCUT_ASSERT_TRUE(resp.window_create_called);
|
---|
[4d9c807] | 239 | PCUT_ASSERT_EQUALS(params.rect.p0.x, resp.create_rect.p0.x);
|
---|
| 240 | PCUT_ASSERT_EQUALS(params.rect.p0.y, resp.create_rect.p0.y);
|
---|
| 241 | PCUT_ASSERT_EQUALS(params.rect.p1.x, resp.create_rect.p1.x);
|
---|
| 242 | PCUT_ASSERT_EQUALS(params.rect.p1.y, resp.create_rect.p1.y);
|
---|
[bfddc62] | 243 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 244 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 245 |
|
---|
| 246 | resp.window_destroy_called = false;
|
---|
| 247 | rc = display_window_destroy(wnd);
|
---|
| 248 | PCUT_ASSERT_TRUE(resp.window_destroy_called);
|
---|
[0e6e77f] | 249 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.destroy_wnd_id);
|
---|
[bfddc62] | 250 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 251 |
|
---|
| 252 | display_close(disp);
|
---|
| 253 | rc = loc_service_unregister(sid);
|
---|
| 254 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[959b7ec] | 255 | }
|
---|
| 256 |
|
---|
[bfddc62] | 257 | /** display_window_create() with server returning error response works. */
|
---|
[959b7ec] | 258 | PCUT_TEST(window_destroy_failure)
|
---|
| 259 | {
|
---|
[bfddc62] | 260 | errno_t rc;
|
---|
| 261 | service_id_t sid;
|
---|
| 262 | display_t *disp = NULL;
|
---|
[4d9c807] | 263 | display_wnd_params_t params;
|
---|
[bfddc62] | 264 | display_window_t *wnd;
|
---|
| 265 | test_response_t resp;
|
---|
[959b7ec] | 266 |
|
---|
[bfddc62] | 267 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 268 |
|
---|
[38e4f42] | 269 | // FIXME This causes this test to be non-reentrant!
|
---|
[bfddc62] | 270 | rc = loc_server_register(test_display_server);
|
---|
| 271 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 272 |
|
---|
| 273 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 274 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 275 |
|
---|
| 276 | rc = display_open(test_display_svc, &disp);
|
---|
| 277 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 278 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 279 |
|
---|
| 280 | resp.rc = EOK;
|
---|
| 281 | resp.window_create_called = false;
|
---|
[4d9c807] | 282 | display_wnd_params_init(¶ms);
|
---|
| 283 | params.rect.p0.x = 0;
|
---|
| 284 | params.rect.p0.y = 0;
|
---|
| 285 | params.rect.p0.x = 100;
|
---|
| 286 | params.rect.p0.y = 100;
|
---|
| 287 |
|
---|
| 288 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 289 | (void *) &resp, &wnd);
|
---|
[bfddc62] | 290 | PCUT_ASSERT_TRUE(resp.window_create_called);
|
---|
[4d9c807] | 291 | PCUT_ASSERT_EQUALS(params.rect.p0.x, resp.create_rect.p0.x);
|
---|
| 292 | PCUT_ASSERT_EQUALS(params.rect.p0.y, resp.create_rect.p0.y);
|
---|
| 293 | PCUT_ASSERT_EQUALS(params.rect.p1.x, resp.create_rect.p1.x);
|
---|
| 294 | PCUT_ASSERT_EQUALS(params.rect.p1.y, resp.create_rect.p1.y);
|
---|
[bfddc62] | 295 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 296 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 297 |
|
---|
| 298 | resp.rc = EIO;
|
---|
| 299 | resp.window_destroy_called = false;
|
---|
| 300 | rc = display_window_destroy(wnd);
|
---|
| 301 | PCUT_ASSERT_TRUE(resp.window_destroy_called);
|
---|
[0e6e77f] | 302 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.destroy_wnd_id);
|
---|
| 303 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
| 304 |
|
---|
| 305 | display_close(disp);
|
---|
| 306 | rc = loc_service_unregister(sid);
|
---|
| 307 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 308 | }
|
---|
| 309 |
|
---|
[a2e104e] | 310 | /** display_window_move_req() with server returning error response works. */
|
---|
| 311 | PCUT_TEST(window_move_req_failure)
|
---|
| 312 | {
|
---|
| 313 | errno_t rc;
|
---|
| 314 | service_id_t sid;
|
---|
| 315 | display_t *disp = NULL;
|
---|
| 316 | display_wnd_params_t params;
|
---|
| 317 | display_window_t *wnd;
|
---|
| 318 | test_response_t resp;
|
---|
| 319 | gfx_coord2_t pos;
|
---|
| 320 |
|
---|
| 321 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 322 |
|
---|
| 323 | // FIXME This causes this test to be non-reentrant!
|
---|
| 324 | rc = loc_server_register(test_display_server);
|
---|
| 325 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 326 |
|
---|
| 327 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 328 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 329 |
|
---|
| 330 | rc = display_open(test_display_svc, &disp);
|
---|
| 331 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 332 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 333 |
|
---|
| 334 | resp.rc = EOK;
|
---|
| 335 | display_wnd_params_init(¶ms);
|
---|
| 336 | params.rect.p0.x = 0;
|
---|
| 337 | params.rect.p0.y = 0;
|
---|
| 338 | params.rect.p0.x = 100;
|
---|
| 339 | params.rect.p0.y = 100;
|
---|
| 340 |
|
---|
| 341 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 342 | (void *) &resp, &wnd);
|
---|
| 343 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 344 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 345 |
|
---|
| 346 | resp.rc = EIO;
|
---|
| 347 | resp.window_move_req_called = false;
|
---|
| 348 |
|
---|
| 349 | pos.x = 42;
|
---|
| 350 | pos.y = 43;
|
---|
| 351 |
|
---|
| 352 | rc = display_window_move_req(wnd, &pos);
|
---|
| 353 | PCUT_ASSERT_TRUE(resp.window_move_req_called);
|
---|
| 354 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
| 355 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.move_req_wnd_id);
|
---|
| 356 | PCUT_ASSERT_INT_EQUALS(pos.x, resp.move_req_pos.x);
|
---|
| 357 | PCUT_ASSERT_INT_EQUALS(pos.y, resp.move_req_pos.y);
|
---|
| 358 |
|
---|
| 359 | display_window_destroy(wnd);
|
---|
| 360 | display_close(disp);
|
---|
| 361 | rc = loc_service_unregister(sid);
|
---|
| 362 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 363 | }
|
---|
| 364 |
|
---|
| 365 | /** display_window_move_req() with server returning success response works. */
|
---|
| 366 | PCUT_TEST(window_move_req_success)
|
---|
| 367 | {
|
---|
| 368 | errno_t rc;
|
---|
| 369 | service_id_t sid;
|
---|
| 370 | display_t *disp = NULL;
|
---|
| 371 | display_wnd_params_t params;
|
---|
| 372 | display_window_t *wnd;
|
---|
| 373 | test_response_t resp;
|
---|
| 374 | gfx_coord2_t pos;
|
---|
| 375 |
|
---|
| 376 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 377 |
|
---|
| 378 | // FIXME This causes this test to be non-reentrant!
|
---|
| 379 | rc = loc_server_register(test_display_server);
|
---|
| 380 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 381 |
|
---|
| 382 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 383 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 384 |
|
---|
| 385 | rc = display_open(test_display_svc, &disp);
|
---|
| 386 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 387 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 388 |
|
---|
| 389 | resp.rc = EOK;
|
---|
| 390 | display_wnd_params_init(¶ms);
|
---|
| 391 | params.rect.p0.x = 0;
|
---|
| 392 | params.rect.p0.y = 0;
|
---|
| 393 | params.rect.p0.x = 100;
|
---|
| 394 | params.rect.p0.y = 100;
|
---|
| 395 |
|
---|
| 396 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 397 | (void *) &resp, &wnd);
|
---|
| 398 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 399 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 400 |
|
---|
| 401 | resp.rc = EOK;
|
---|
| 402 | resp.window_move_req_called = false;
|
---|
| 403 |
|
---|
| 404 | pos.x = 42;
|
---|
| 405 | pos.y = 43;
|
---|
| 406 |
|
---|
| 407 | rc = display_window_move_req(wnd, &pos);
|
---|
| 408 | PCUT_ASSERT_TRUE(resp.window_move_req_called);
|
---|
| 409 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
| 410 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.move_req_wnd_id);
|
---|
| 411 | PCUT_ASSERT_INT_EQUALS(pos.x, resp.move_req_pos.x);
|
---|
| 412 | PCUT_ASSERT_INT_EQUALS(pos.y, resp.move_req_pos.y);
|
---|
| 413 |
|
---|
| 414 | display_window_destroy(wnd);
|
---|
| 415 | display_close(disp);
|
---|
| 416 | rc = loc_service_unregister(sid);
|
---|
| 417 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 418 | }
|
---|
| 419 |
|
---|
[1e4a937] | 420 | /** display_window_resize_req() with server returning error response works. */
|
---|
| 421 | PCUT_TEST(window_resize_req_failure)
|
---|
| 422 | {
|
---|
| 423 | errno_t rc;
|
---|
| 424 | service_id_t sid;
|
---|
| 425 | display_t *disp = NULL;
|
---|
| 426 | display_wnd_params_t params;
|
---|
| 427 | display_window_t *wnd;
|
---|
| 428 | test_response_t resp;
|
---|
| 429 | display_wnd_rsztype_t rsztype;
|
---|
| 430 | gfx_coord2_t pos;
|
---|
| 431 |
|
---|
| 432 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 433 |
|
---|
| 434 | // FIXME This causes this test to be non-reentrant!
|
---|
| 435 | rc = loc_server_register(test_display_server);
|
---|
| 436 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 437 |
|
---|
| 438 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 439 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 440 |
|
---|
| 441 | rc = display_open(test_display_svc, &disp);
|
---|
| 442 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 443 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 444 |
|
---|
| 445 | resp.rc = EOK;
|
---|
| 446 | display_wnd_params_init(¶ms);
|
---|
| 447 | params.rect.p0.x = 0;
|
---|
| 448 | params.rect.p0.y = 0;
|
---|
| 449 | params.rect.p0.x = 100;
|
---|
| 450 | params.rect.p0.y = 100;
|
---|
| 451 |
|
---|
| 452 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 453 | (void *) &resp, &wnd);
|
---|
| 454 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 455 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 456 |
|
---|
| 457 | resp.rc = EIO;
|
---|
| 458 | resp.window_resize_req_called = false;
|
---|
| 459 |
|
---|
| 460 | rsztype = display_wr_top_right;
|
---|
| 461 | pos.x = 42;
|
---|
| 462 | pos.y = 43;
|
---|
| 463 |
|
---|
| 464 | rc = display_window_resize_req(wnd, rsztype, &pos);
|
---|
| 465 | PCUT_ASSERT_TRUE(resp.window_resize_req_called);
|
---|
| 466 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
| 467 | PCUT_ASSERT_INT_EQUALS(rsztype, resp.resize_req_rsztype);
|
---|
| 468 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.resize_req_wnd_id);
|
---|
| 469 | PCUT_ASSERT_INT_EQUALS(pos.x, resp.resize_req_pos.x);
|
---|
| 470 | PCUT_ASSERT_INT_EQUALS(pos.y, resp.resize_req_pos.y);
|
---|
| 471 |
|
---|
| 472 | display_window_destroy(wnd);
|
---|
| 473 | display_close(disp);
|
---|
| 474 | rc = loc_service_unregister(sid);
|
---|
| 475 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 476 | }
|
---|
| 477 |
|
---|
| 478 | /** display_window_resize_req() with server returning success response works. */
|
---|
| 479 | PCUT_TEST(window_resize_req_success)
|
---|
| 480 | {
|
---|
| 481 | errno_t rc;
|
---|
| 482 | service_id_t sid;
|
---|
| 483 | display_t *disp = NULL;
|
---|
| 484 | display_wnd_params_t params;
|
---|
| 485 | display_window_t *wnd;
|
---|
| 486 | test_response_t resp;
|
---|
| 487 | display_wnd_rsztype_t rsztype;
|
---|
| 488 | gfx_coord2_t pos;
|
---|
| 489 |
|
---|
| 490 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 491 |
|
---|
| 492 | // FIXME This causes this test to be non-reentrant!
|
---|
| 493 | rc = loc_server_register(test_display_server);
|
---|
| 494 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 495 |
|
---|
| 496 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 497 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 498 |
|
---|
| 499 | rc = display_open(test_display_svc, &disp);
|
---|
| 500 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 501 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 502 |
|
---|
| 503 | resp.rc = EOK;
|
---|
| 504 | display_wnd_params_init(¶ms);
|
---|
| 505 | params.rect.p0.x = 0;
|
---|
| 506 | params.rect.p0.y = 0;
|
---|
| 507 | params.rect.p0.x = 100;
|
---|
| 508 | params.rect.p0.y = 100;
|
---|
| 509 |
|
---|
| 510 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 511 | (void *) &resp, &wnd);
|
---|
| 512 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 513 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 514 |
|
---|
| 515 | resp.rc = EOK;
|
---|
| 516 | resp.window_resize_req_called = false;
|
---|
| 517 |
|
---|
| 518 | rsztype = display_wr_top_right;
|
---|
| 519 | pos.x = 42;
|
---|
| 520 | pos.y = 43;
|
---|
| 521 |
|
---|
| 522 | rc = display_window_resize_req(wnd, rsztype, &pos);
|
---|
| 523 | PCUT_ASSERT_TRUE(resp.window_resize_req_called);
|
---|
| 524 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
| 525 | PCUT_ASSERT_INT_EQUALS(rsztype, resp.resize_req_rsztype);
|
---|
| 526 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.resize_req_wnd_id);
|
---|
| 527 | PCUT_ASSERT_INT_EQUALS(pos.x, resp.resize_req_pos.x);
|
---|
| 528 | PCUT_ASSERT_INT_EQUALS(pos.y, resp.resize_req_pos.y);
|
---|
| 529 |
|
---|
| 530 | display_window_destroy(wnd);
|
---|
| 531 | display_close(disp);
|
---|
| 532 | rc = loc_service_unregister(sid);
|
---|
| 533 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 534 | }
|
---|
| 535 |
|
---|
[0e6e77f] | 536 | /** display_window_resize() with server returning error response works. */
|
---|
| 537 | PCUT_TEST(window_resize_failure)
|
---|
| 538 | {
|
---|
| 539 | errno_t rc;
|
---|
| 540 | service_id_t sid;
|
---|
| 541 | display_t *disp = NULL;
|
---|
| 542 | display_wnd_params_t params;
|
---|
| 543 | display_window_t *wnd;
|
---|
| 544 | gfx_coord2_t offs;
|
---|
| 545 | gfx_rect_t nrect;
|
---|
| 546 | test_response_t resp;
|
---|
| 547 |
|
---|
| 548 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 549 |
|
---|
| 550 | // FIXME This causes this test to be non-reentrant!
|
---|
| 551 | rc = loc_server_register(test_display_server);
|
---|
| 552 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 553 |
|
---|
| 554 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 555 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 556 |
|
---|
| 557 | rc = display_open(test_display_svc, &disp);
|
---|
| 558 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 559 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 560 |
|
---|
| 561 | resp.rc = EOK;
|
---|
| 562 | display_wnd_params_init(¶ms);
|
---|
| 563 | params.rect.p0.x = 0;
|
---|
| 564 | params.rect.p0.y = 0;
|
---|
| 565 | params.rect.p0.x = 100;
|
---|
| 566 | params.rect.p0.y = 100;
|
---|
| 567 |
|
---|
| 568 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 569 | (void *) &resp, &wnd);
|
---|
| 570 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 571 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 572 |
|
---|
| 573 | resp.rc = EIO;
|
---|
| 574 | resp.window_resize_called = false;
|
---|
| 575 | offs.x = 11;
|
---|
| 576 | offs.y = 12;
|
---|
| 577 | nrect.p0.x = 13;
|
---|
| 578 | nrect.p0.y = 14;
|
---|
| 579 | nrect.p1.x = 15;
|
---|
| 580 | nrect.p1.y = 16;
|
---|
| 581 |
|
---|
| 582 | rc = display_window_resize(wnd, &offs, &nrect);
|
---|
| 583 | PCUT_ASSERT_TRUE(resp.window_resize_called);
|
---|
[bfddc62] | 584 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
[0e6e77f] | 585 | PCUT_ASSERT_INT_EQUALS(wnd->id, resp.resize_wnd_id);
|
---|
| 586 | PCUT_ASSERT_INT_EQUALS(offs.x, resp.resize_offs.x);
|
---|
| 587 | PCUT_ASSERT_INT_EQUALS(offs.y, resp.resize_offs.y);
|
---|
| 588 | PCUT_ASSERT_INT_EQUALS(nrect.p0.x, resp.resize_nbound.p0.x);
|
---|
| 589 | PCUT_ASSERT_INT_EQUALS(nrect.p0.y, resp.resize_nbound.p0.y);
|
---|
| 590 | PCUT_ASSERT_INT_EQUALS(nrect.p1.x, resp.resize_nbound.p1.x);
|
---|
| 591 | PCUT_ASSERT_INT_EQUALS(nrect.p1.y, resp.resize_nbound.p1.y);
|
---|
| 592 |
|
---|
| 593 | display_window_destroy(wnd);
|
---|
| 594 | display_close(disp);
|
---|
| 595 | rc = loc_service_unregister(sid);
|
---|
| 596 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 597 | }
|
---|
| 598 |
|
---|
| 599 | /** display_window_resize() with server returning success response works. */
|
---|
| 600 | PCUT_TEST(window_resize_success)
|
---|
| 601 | {
|
---|
| 602 | errno_t rc;
|
---|
| 603 | service_id_t sid;
|
---|
| 604 | display_t *disp = NULL;
|
---|
| 605 | display_wnd_params_t params;
|
---|
| 606 | display_window_t *wnd;
|
---|
| 607 | gfx_coord2_t offs;
|
---|
| 608 | gfx_rect_t nrect;
|
---|
| 609 | test_response_t resp;
|
---|
| 610 |
|
---|
| 611 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 612 |
|
---|
| 613 | // FIXME This causes this test to be non-reentrant!
|
---|
| 614 | rc = loc_server_register(test_display_server);
|
---|
| 615 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 616 |
|
---|
| 617 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 618 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 619 |
|
---|
| 620 | rc = display_open(test_display_svc, &disp);
|
---|
| 621 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 622 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 623 |
|
---|
| 624 | resp.rc = EOK;
|
---|
| 625 | display_wnd_params_init(¶ms);
|
---|
| 626 | params.rect.p0.x = 0;
|
---|
| 627 | params.rect.p0.y = 0;
|
---|
| 628 | params.rect.p0.x = 100;
|
---|
| 629 | params.rect.p0.y = 100;
|
---|
| 630 |
|
---|
| 631 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 632 | (void *) &resp, &wnd);
|
---|
| 633 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 634 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
[bfddc62] | 635 |
|
---|
[0e6e77f] | 636 | resp.rc = EOK;
|
---|
| 637 | resp.window_resize_called = false;
|
---|
| 638 | offs.x = 11;
|
---|
| 639 | offs.y = 12;
|
---|
| 640 | nrect.p0.x = 13;
|
---|
| 641 | nrect.p0.y = 14;
|
---|
| 642 | nrect.p1.x = 15;
|
---|
| 643 | nrect.p1.y = 16;
|
---|
| 644 |
|
---|
| 645 | rc = display_window_resize(wnd, &offs, &nrect);
|
---|
| 646 | PCUT_ASSERT_TRUE(resp.window_resize_called);
|
---|
| 647 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
| 648 | PCUT_ASSERT_INT_EQUALS(offs.x, resp.resize_offs.x);
|
---|
| 649 | PCUT_ASSERT_INT_EQUALS(offs.y, resp.resize_offs.y);
|
---|
| 650 | PCUT_ASSERT_INT_EQUALS(nrect.p0.x, resp.resize_nbound.p0.x);
|
---|
| 651 | PCUT_ASSERT_INT_EQUALS(nrect.p0.y, resp.resize_nbound.p0.y);
|
---|
| 652 | PCUT_ASSERT_INT_EQUALS(nrect.p1.x, resp.resize_nbound.p1.x);
|
---|
| 653 | PCUT_ASSERT_INT_EQUALS(nrect.p1.y, resp.resize_nbound.p1.y);
|
---|
| 654 |
|
---|
| 655 | display_window_destroy(wnd);
|
---|
[bfddc62] | 656 | display_close(disp);
|
---|
| 657 | rc = loc_service_unregister(sid);
|
---|
| 658 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[959b7ec] | 659 | }
|
---|
| 660 |
|
---|
| 661 | /** display_window_get_gc with server returning failure */
|
---|
| 662 | PCUT_TEST(window_get_gc_failure)
|
---|
| 663 | {
|
---|
[bfddc62] | 664 | errno_t rc;
|
---|
| 665 | service_id_t sid;
|
---|
| 666 | display_t *disp = NULL;
|
---|
[4d9c807] | 667 | display_wnd_params_t params;
|
---|
[bfddc62] | 668 | display_window_t *wnd;
|
---|
| 669 | test_response_t resp;
|
---|
| 670 | gfx_context_t *gc;
|
---|
| 671 |
|
---|
| 672 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 673 |
|
---|
[38e4f42] | 674 | // FIXME This causes this test to be non-reentrant!
|
---|
[bfddc62] | 675 | rc = loc_server_register(test_display_server);
|
---|
| 676 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 677 |
|
---|
| 678 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 679 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 680 |
|
---|
| 681 | rc = display_open(test_display_svc, &disp);
|
---|
| 682 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 683 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 684 |
|
---|
| 685 | wnd = NULL;
|
---|
| 686 | resp.rc = EOK;
|
---|
[4d9c807] | 687 | display_wnd_params_init(¶ms);
|
---|
| 688 | params.rect.p0.x = 0;
|
---|
| 689 | params.rect.p0.y = 0;
|
---|
| 690 | params.rect.p0.x = 100;
|
---|
| 691 | params.rect.p0.y = 100;
|
---|
| 692 |
|
---|
| 693 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 694 | (void *) &resp, &wnd);
|
---|
[bfddc62] | 695 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 696 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 697 |
|
---|
| 698 | gc = NULL;
|
---|
| 699 | resp.rc = ENOMEM;
|
---|
| 700 | rc = display_window_get_gc(wnd, &gc);
|
---|
| 701 | /* async_connect_me_to() does not return specific error */
|
---|
| 702 | PCUT_ASSERT_ERRNO_VAL(EIO, rc);
|
---|
| 703 | PCUT_ASSERT_NULL(gc);
|
---|
| 704 |
|
---|
| 705 | resp.rc = EOK;
|
---|
| 706 | rc = display_window_destroy(wnd);
|
---|
| 707 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 708 |
|
---|
| 709 | display_close(disp);
|
---|
| 710 | rc = loc_service_unregister(sid);
|
---|
| 711 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[959b7ec] | 712 | }
|
---|
| 713 |
|
---|
| 714 | /** display_window_get_gc with server returning success */
|
---|
| 715 | PCUT_TEST(window_get_gc_success)
|
---|
| 716 | {
|
---|
[bfddc62] | 717 | errno_t rc;
|
---|
| 718 | service_id_t sid;
|
---|
| 719 | display_t *disp = NULL;
|
---|
[4d9c807] | 720 | display_wnd_params_t params;
|
---|
[bfddc62] | 721 | display_window_t *wnd;
|
---|
| 722 | test_response_t resp;
|
---|
| 723 | gfx_context_t *gc;
|
---|
| 724 | gfx_color_t *color;
|
---|
| 725 |
|
---|
| 726 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 727 |
|
---|
[38e4f42] | 728 | // FIXME This causes this test to be non-reentrant!
|
---|
[bfddc62] | 729 | rc = loc_server_register(test_display_server);
|
---|
| 730 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 731 |
|
---|
| 732 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 733 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 734 |
|
---|
| 735 | rc = display_open(test_display_svc, &disp);
|
---|
| 736 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 737 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 738 |
|
---|
| 739 | wnd = NULL;
|
---|
| 740 | resp.rc = EOK;
|
---|
[4d9c807] | 741 | display_wnd_params_init(¶ms);
|
---|
| 742 | params.rect.p0.x = 0;
|
---|
| 743 | params.rect.p0.y = 0;
|
---|
| 744 | params.rect.p0.x = 100;
|
---|
| 745 | params.rect.p0.y = 100;
|
---|
| 746 |
|
---|
| 747 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 748 | (void *) &resp, &wnd);
|
---|
[bfddc62] | 749 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 750 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 751 |
|
---|
| 752 | gc = NULL;
|
---|
| 753 | rc = display_window_get_gc(wnd, &gc);
|
---|
| 754 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 755 | PCUT_ASSERT_NOT_NULL(gc);
|
---|
| 756 |
|
---|
| 757 | rc = gfx_color_new_rgb_i16(0, 0, 0, &color);
|
---|
| 758 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 759 |
|
---|
| 760 | resp.set_color_called = false;
|
---|
| 761 | rc = gfx_set_color(gc, color);
|
---|
| 762 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 763 | PCUT_ASSERT_TRUE(resp.set_color_called);
|
---|
| 764 |
|
---|
| 765 | gfx_color_delete(color);
|
---|
| 766 |
|
---|
| 767 | rc = display_window_destroy(wnd);
|
---|
| 768 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 769 |
|
---|
| 770 | display_close(disp);
|
---|
| 771 | rc = loc_service_unregister(sid);
|
---|
| 772 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[959b7ec] | 773 | }
|
---|
| 774 |
|
---|
[338d0935] | 775 | /** Close event can be delivered from server to client callback function */
|
---|
| 776 | PCUT_TEST(close_event_deliver)
|
---|
| 777 | {
|
---|
| 778 | errno_t rc;
|
---|
| 779 | service_id_t sid;
|
---|
| 780 | display_t *disp = NULL;
|
---|
| 781 | display_wnd_params_t params;
|
---|
| 782 | display_window_t *wnd;
|
---|
| 783 | test_response_t resp;
|
---|
| 784 |
|
---|
| 785 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 786 |
|
---|
| 787 | // FIXME This causes this test to be non-reentrant!
|
---|
| 788 | rc = loc_server_register(test_display_server);
|
---|
| 789 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 790 |
|
---|
| 791 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 792 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 793 |
|
---|
| 794 | rc = display_open(test_display_svc, &disp);
|
---|
| 795 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 796 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 797 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
| 798 |
|
---|
| 799 | wnd = NULL;
|
---|
| 800 | resp.rc = EOK;
|
---|
| 801 | display_wnd_params_init(¶ms);
|
---|
| 802 | params.rect.p0.x = 0;
|
---|
| 803 | params.rect.p0.y = 0;
|
---|
| 804 | params.rect.p0.x = 100;
|
---|
| 805 | params.rect.p0.y = 100;
|
---|
| 806 |
|
---|
| 807 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 808 | (void *) &resp, &wnd);
|
---|
| 809 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 810 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 811 |
|
---|
| 812 | resp.event_cnt = 1;
|
---|
| 813 | resp.event.etype = wev_close;
|
---|
| 814 | resp.wnd_id = wnd->id;
|
---|
| 815 | resp.close_event_called = false;
|
---|
| 816 | fibril_mutex_initialize(&resp.event_lock);
|
---|
| 817 | fibril_condvar_initialize(&resp.event_cv);
|
---|
| 818 | display_srv_ev_pending(resp.srv);
|
---|
| 819 |
|
---|
| 820 | /* Wait for the event handler to be called. */
|
---|
| 821 | fibril_mutex_lock(&resp.event_lock);
|
---|
| 822 | while (!resp.close_event_called) {
|
---|
| 823 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
| 824 | }
|
---|
| 825 | fibril_mutex_unlock(&resp.event_lock);
|
---|
| 826 |
|
---|
| 827 | /* Verify that the event was delivered correctly */
|
---|
| 828 | PCUT_ASSERT_EQUALS(resp.event.etype,
|
---|
| 829 | resp.revent.etype);
|
---|
| 830 |
|
---|
| 831 | rc = display_window_destroy(wnd);
|
---|
| 832 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 833 |
|
---|
| 834 | display_close(disp);
|
---|
| 835 |
|
---|
| 836 | rc = loc_service_unregister(sid);
|
---|
| 837 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 838 | }
|
---|
| 839 |
|
---|
[b0a94854] | 840 | /** Focus event can be delivered from server to client callback function */
|
---|
| 841 | PCUT_TEST(focus_event_deliver)
|
---|
| 842 | {
|
---|
| 843 | errno_t rc;
|
---|
| 844 | service_id_t sid;
|
---|
| 845 | display_t *disp = NULL;
|
---|
| 846 | display_wnd_params_t params;
|
---|
| 847 | display_window_t *wnd;
|
---|
| 848 | test_response_t resp;
|
---|
| 849 |
|
---|
| 850 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 851 |
|
---|
| 852 | // FIXME This causes this test to be non-reentrant!
|
---|
| 853 | rc = loc_server_register(test_display_server);
|
---|
| 854 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 855 |
|
---|
| 856 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 857 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 858 |
|
---|
| 859 | rc = display_open(test_display_svc, &disp);
|
---|
| 860 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 861 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 862 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
| 863 |
|
---|
| 864 | wnd = NULL;
|
---|
| 865 | resp.rc = EOK;
|
---|
| 866 | display_wnd_params_init(¶ms);
|
---|
| 867 | params.rect.p0.x = 0;
|
---|
| 868 | params.rect.p0.y = 0;
|
---|
| 869 | params.rect.p0.x = 100;
|
---|
| 870 | params.rect.p0.y = 100;
|
---|
| 871 |
|
---|
| 872 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 873 | (void *) &resp, &wnd);
|
---|
| 874 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 875 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 876 |
|
---|
| 877 | resp.event_cnt = 1;
|
---|
| 878 | resp.event.etype = wev_focus;
|
---|
| 879 | resp.wnd_id = wnd->id;
|
---|
| 880 | resp.focus_event_called = false;
|
---|
| 881 | fibril_mutex_initialize(&resp.event_lock);
|
---|
| 882 | fibril_condvar_initialize(&resp.event_cv);
|
---|
| 883 | display_srv_ev_pending(resp.srv);
|
---|
| 884 |
|
---|
| 885 | /* Wait for the event handler to be called. */
|
---|
| 886 | fibril_mutex_lock(&resp.event_lock);
|
---|
| 887 | while (!resp.focus_event_called) {
|
---|
| 888 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
| 889 | }
|
---|
| 890 | fibril_mutex_unlock(&resp.event_lock);
|
---|
| 891 |
|
---|
| 892 | /* Verify that the event was delivered correctly */
|
---|
| 893 | PCUT_ASSERT_EQUALS(resp.event.etype,
|
---|
| 894 | resp.revent.etype);
|
---|
| 895 |
|
---|
| 896 | rc = display_window_destroy(wnd);
|
---|
| 897 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 898 |
|
---|
| 899 | display_close(disp);
|
---|
| 900 |
|
---|
| 901 | rc = loc_service_unregister(sid);
|
---|
| 902 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 903 | }
|
---|
| 904 |
|
---|
[dcac756] | 905 | /** Keyboard event can be delivered from server to client callback function */
|
---|
| 906 | PCUT_TEST(kbd_event_deliver)
|
---|
| 907 | {
|
---|
| 908 | errno_t rc;
|
---|
| 909 | service_id_t sid;
|
---|
| 910 | display_t *disp = NULL;
|
---|
[4d9c807] | 911 | display_wnd_params_t params;
|
---|
[dcac756] | 912 | display_window_t *wnd;
|
---|
| 913 | test_response_t resp;
|
---|
| 914 |
|
---|
| 915 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 916 |
|
---|
| 917 | // FIXME This causes this test to be non-reentrant!
|
---|
| 918 | rc = loc_server_register(test_display_server);
|
---|
| 919 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 920 |
|
---|
| 921 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 922 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 923 |
|
---|
| 924 | rc = display_open(test_display_svc, &disp);
|
---|
| 925 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 926 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 927 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
| 928 |
|
---|
| 929 | wnd = NULL;
|
---|
| 930 | resp.rc = EOK;
|
---|
[4d9c807] | 931 | display_wnd_params_init(¶ms);
|
---|
| 932 | params.rect.p0.x = 0;
|
---|
| 933 | params.rect.p0.y = 0;
|
---|
| 934 | params.rect.p0.x = 100;
|
---|
| 935 | params.rect.p0.y = 100;
|
---|
| 936 |
|
---|
| 937 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 938 | (void *) &resp, &wnd);
|
---|
[dcac756] | 939 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 940 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 941 |
|
---|
[b093a62] | 942 | resp.event_cnt = 1;
|
---|
[f7fb2b21] | 943 | resp.event.etype = wev_kbd;
|
---|
| 944 | resp.event.ev.kbd.type = KEY_PRESS;
|
---|
| 945 | resp.event.ev.kbd.key = KC_ENTER;
|
---|
| 946 | resp.event.ev.kbd.mods = 0;
|
---|
| 947 | resp.event.ev.kbd.c = L'\0';
|
---|
[b093a62] | 948 | resp.wnd_id = wnd->id;
|
---|
| 949 | resp.kbd_event_called = false;
|
---|
[f7fb2b21] | 950 | fibril_mutex_initialize(&resp.event_lock);
|
---|
| 951 | fibril_condvar_initialize(&resp.event_cv);
|
---|
[dcac756] | 952 | display_srv_ev_pending(resp.srv);
|
---|
| 953 |
|
---|
[b093a62] | 954 | /* Wait for the event handler to be called. */
|
---|
[f7fb2b21] | 955 | fibril_mutex_lock(&resp.event_lock);
|
---|
[b093a62] | 956 | while (!resp.kbd_event_called) {
|
---|
[f7fb2b21] | 957 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
[b093a62] | 958 | }
|
---|
[f7fb2b21] | 959 | fibril_mutex_unlock(&resp.event_lock);
|
---|
[b093a62] | 960 |
|
---|
| 961 | /* Verify that the event was delivered correctly */
|
---|
[f7fb2b21] | 962 | PCUT_ASSERT_EQUALS(resp.event.etype,
|
---|
| 963 | resp.revent.etype);
|
---|
| 964 | PCUT_ASSERT_EQUALS(resp.event.ev.kbd.type,
|
---|
| 965 | resp.revent.ev.kbd.type);
|
---|
| 966 | PCUT_ASSERT_EQUALS(resp.event.ev.kbd.key,
|
---|
| 967 | resp.revent.ev.kbd.key);
|
---|
| 968 | PCUT_ASSERT_EQUALS(resp.event.ev.kbd.mods,
|
---|
| 969 | resp.revent.ev.kbd.mods);
|
---|
| 970 | PCUT_ASSERT_EQUALS(resp.event.ev.kbd.c,
|
---|
| 971 | resp.revent.ev.kbd.c);
|
---|
| 972 |
|
---|
| 973 | rc = display_window_destroy(wnd);
|
---|
| 974 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 975 |
|
---|
| 976 | display_close(disp);
|
---|
| 977 |
|
---|
| 978 | rc = loc_service_unregister(sid);
|
---|
| 979 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 980 | }
|
---|
| 981 |
|
---|
| 982 | /** Position event can be delivered from server to client callback function */
|
---|
| 983 | PCUT_TEST(pos_event_deliver)
|
---|
| 984 | {
|
---|
| 985 | errno_t rc;
|
---|
| 986 | service_id_t sid;
|
---|
| 987 | display_t *disp = NULL;
|
---|
| 988 | display_wnd_params_t params;
|
---|
| 989 | display_window_t *wnd;
|
---|
| 990 | test_response_t resp;
|
---|
| 991 |
|
---|
| 992 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 993 |
|
---|
| 994 | // FIXME This causes this test to be non-reentrant!
|
---|
| 995 | rc = loc_server_register(test_display_server);
|
---|
| 996 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 997 |
|
---|
| 998 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 999 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1000 |
|
---|
| 1001 | rc = display_open(test_display_svc, &disp);
|
---|
| 1002 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1003 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 1004 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
| 1005 |
|
---|
| 1006 | wnd = NULL;
|
---|
| 1007 | resp.rc = EOK;
|
---|
| 1008 | display_wnd_params_init(¶ms);
|
---|
| 1009 | params.rect.p0.x = 0;
|
---|
| 1010 | params.rect.p0.y = 0;
|
---|
| 1011 | params.rect.p0.x = 100;
|
---|
| 1012 | params.rect.p0.y = 100;
|
---|
| 1013 |
|
---|
| 1014 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 1015 | (void *) &resp, &wnd);
|
---|
| 1016 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1017 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 1018 |
|
---|
| 1019 | resp.event_cnt = 1;
|
---|
| 1020 | resp.event.etype = wev_pos;
|
---|
| 1021 | resp.event.ev.pos.type = POS_PRESS;
|
---|
| 1022 | resp.event.ev.pos.btn_num = 1;
|
---|
| 1023 | resp.event.ev.pos.hpos = 2;
|
---|
| 1024 | resp.event.ev.pos.vpos = 3;
|
---|
| 1025 | resp.wnd_id = wnd->id;
|
---|
| 1026 | resp.pos_event_called = false;
|
---|
| 1027 | fibril_mutex_initialize(&resp.event_lock);
|
---|
| 1028 | fibril_condvar_initialize(&resp.event_cv);
|
---|
| 1029 | display_srv_ev_pending(resp.srv);
|
---|
| 1030 |
|
---|
| 1031 | /* Wait for the event handler to be called. */
|
---|
| 1032 | fibril_mutex_lock(&resp.event_lock);
|
---|
| 1033 | while (!resp.pos_event_called) {
|
---|
| 1034 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
| 1035 | }
|
---|
| 1036 | fibril_mutex_unlock(&resp.event_lock);
|
---|
| 1037 |
|
---|
| 1038 | /* Verify that the event was delivered correctly */
|
---|
| 1039 | PCUT_ASSERT_EQUALS(resp.event.etype,
|
---|
| 1040 | resp.revent.etype);
|
---|
| 1041 | PCUT_ASSERT_EQUALS(resp.event.ev.pos.type,
|
---|
| 1042 | resp.revent.ev.pos.type);
|
---|
| 1043 | PCUT_ASSERT_EQUALS(resp.event.ev.pos.btn_num,
|
---|
| 1044 | resp.revent.ev.pos.btn_num);
|
---|
| 1045 | PCUT_ASSERT_EQUALS(resp.event.ev.pos.hpos,
|
---|
| 1046 | resp.revent.ev.pos.hpos);
|
---|
| 1047 | PCUT_ASSERT_EQUALS(resp.event.ev.pos.vpos,
|
---|
| 1048 | resp.revent.ev.pos.vpos);
|
---|
[b093a62] | 1049 |
|
---|
[dcac756] | 1050 | rc = display_window_destroy(wnd);
|
---|
| 1051 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1052 |
|
---|
| 1053 | display_close(disp);
|
---|
[b093a62] | 1054 |
|
---|
[dcac756] | 1055 | rc = loc_service_unregister(sid);
|
---|
| 1056 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1057 | }
|
---|
| 1058 |
|
---|
[b0a94854] | 1059 | /** Unfocus event can be delivered from server to client callback function */
|
---|
| 1060 | PCUT_TEST(unfocus_event_deliver)
|
---|
| 1061 | {
|
---|
| 1062 | errno_t rc;
|
---|
| 1063 | service_id_t sid;
|
---|
| 1064 | display_t *disp = NULL;
|
---|
| 1065 | display_wnd_params_t params;
|
---|
| 1066 | display_window_t *wnd;
|
---|
| 1067 | test_response_t resp;
|
---|
| 1068 |
|
---|
| 1069 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 1070 |
|
---|
| 1071 | // FIXME This causes this test to be non-reentrant!
|
---|
| 1072 | rc = loc_server_register(test_display_server);
|
---|
| 1073 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1074 |
|
---|
| 1075 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 1076 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1077 |
|
---|
| 1078 | rc = display_open(test_display_svc, &disp);
|
---|
| 1079 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1080 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 1081 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
| 1082 |
|
---|
| 1083 | wnd = NULL;
|
---|
| 1084 | resp.rc = EOK;
|
---|
| 1085 | display_wnd_params_init(¶ms);
|
---|
| 1086 | params.rect.p0.x = 0;
|
---|
| 1087 | params.rect.p0.y = 0;
|
---|
| 1088 | params.rect.p0.x = 100;
|
---|
| 1089 | params.rect.p0.y = 100;
|
---|
| 1090 |
|
---|
| 1091 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 1092 | (void *) &resp, &wnd);
|
---|
| 1093 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1094 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 1095 |
|
---|
| 1096 | resp.event_cnt = 1;
|
---|
| 1097 | resp.event.etype = wev_unfocus;
|
---|
| 1098 | resp.wnd_id = wnd->id;
|
---|
| 1099 | resp.focus_event_called = false;
|
---|
| 1100 | fibril_mutex_initialize(&resp.event_lock);
|
---|
| 1101 | fibril_condvar_initialize(&resp.event_cv);
|
---|
| 1102 | display_srv_ev_pending(resp.srv);
|
---|
| 1103 |
|
---|
| 1104 | /* Wait for the event handler to be called. */
|
---|
| 1105 | fibril_mutex_lock(&resp.event_lock);
|
---|
| 1106 | while (!resp.unfocus_event_called) {
|
---|
| 1107 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
| 1108 | }
|
---|
| 1109 | fibril_mutex_unlock(&resp.event_lock);
|
---|
| 1110 |
|
---|
| 1111 | /* Verify that the event was delivered correctly */
|
---|
| 1112 | PCUT_ASSERT_EQUALS(resp.event.etype,
|
---|
| 1113 | resp.revent.etype);
|
---|
| 1114 |
|
---|
| 1115 | rc = display_window_destroy(wnd);
|
---|
| 1116 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1117 |
|
---|
| 1118 | display_close(disp);
|
---|
| 1119 |
|
---|
| 1120 | rc = loc_service_unregister(sid);
|
---|
| 1121 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 1122 | }
|
---|
| 1123 |
|
---|
[38e4f42] | 1124 | /** Test display service connection.
|
---|
| 1125 | *
|
---|
| 1126 | * This is very similar to connection handler in the display server.
|
---|
| 1127 | * XXX This should be folded into display_srv, if possible
|
---|
| 1128 | */
|
---|
[959b7ec] | 1129 | static void test_display_conn(ipc_call_t *icall, void *arg)
|
---|
| 1130 | {
|
---|
[bfddc62] | 1131 | test_response_t *resp = (test_response_t *) arg;
|
---|
[959b7ec] | 1132 | display_srv_t srv;
|
---|
[bfddc62] | 1133 | sysarg_t wnd_id;
|
---|
| 1134 | sysarg_t svc_id;
|
---|
| 1135 | gfx_context_t *gc;
|
---|
| 1136 | errno_t rc;
|
---|
| 1137 |
|
---|
| 1138 | svc_id = ipc_get_arg2(icall);
|
---|
| 1139 | wnd_id = ipc_get_arg3(icall);
|
---|
| 1140 |
|
---|
| 1141 | if (svc_id != 0) {
|
---|
| 1142 | /* Set up protocol structure */
|
---|
| 1143 | display_srv_initialize(&srv);
|
---|
| 1144 | srv.ops = &test_display_srv_ops;
|
---|
| 1145 | srv.arg = arg;
|
---|
[dcac756] | 1146 | resp->srv = &srv;
|
---|
[bfddc62] | 1147 |
|
---|
| 1148 | /* Handle connection */
|
---|
| 1149 | display_conn(icall, &srv);
|
---|
[dcac756] | 1150 |
|
---|
| 1151 | resp->srv = NULL;
|
---|
[bfddc62] | 1152 | } else {
|
---|
| 1153 | (void) wnd_id;
|
---|
| 1154 |
|
---|
| 1155 | if (resp->rc != EOK) {
|
---|
| 1156 | async_answer_0(icall, resp->rc);
|
---|
| 1157 | return;
|
---|
| 1158 | }
|
---|
| 1159 |
|
---|
| 1160 | rc = gfx_context_new(&test_gc_ops, arg, &gc);
|
---|
| 1161 | if (rc != EOK) {
|
---|
| 1162 | async_answer_0(icall, ENOMEM);
|
---|
| 1163 | return;
|
---|
| 1164 | }
|
---|
| 1165 |
|
---|
| 1166 | /* Window GC connection */
|
---|
| 1167 | gc_conn(icall, gc);
|
---|
| 1168 | }
|
---|
| 1169 | }
|
---|
[959b7ec] | 1170 |
|
---|
[338d0935] | 1171 | static void test_close_event(void *arg)
|
---|
| 1172 | {
|
---|
| 1173 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 1174 |
|
---|
| 1175 | resp->revent.etype = wev_close;
|
---|
| 1176 |
|
---|
| 1177 | fibril_mutex_lock(&resp->event_lock);
|
---|
| 1178 | resp->close_event_called = true;
|
---|
| 1179 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
| 1180 | fibril_mutex_unlock(&resp->event_lock);
|
---|
| 1181 | }
|
---|
| 1182 |
|
---|
[b0a94854] | 1183 | static void test_focus_event(void *arg)
|
---|
| 1184 | {
|
---|
| 1185 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 1186 |
|
---|
| 1187 | resp->revent.etype = wev_focus;
|
---|
| 1188 |
|
---|
| 1189 | fibril_mutex_lock(&resp->event_lock);
|
---|
| 1190 | resp->focus_event_called = true;
|
---|
| 1191 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
| 1192 | fibril_mutex_unlock(&resp->event_lock);
|
---|
| 1193 | }
|
---|
| 1194 |
|
---|
[bfddc62] | 1195 | static void test_kbd_event(void *arg, kbd_event_t *event)
|
---|
| 1196 | {
|
---|
[b093a62] | 1197 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 1198 |
|
---|
[f7fb2b21] | 1199 | resp->revent.etype = wev_kbd;
|
---|
| 1200 | resp->revent.ev.kbd = *event;
|
---|
[b093a62] | 1201 |
|
---|
[f7fb2b21] | 1202 | fibril_mutex_lock(&resp->event_lock);
|
---|
[b093a62] | 1203 | resp->kbd_event_called = true;
|
---|
[f7fb2b21] | 1204 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
| 1205 | fibril_mutex_unlock(&resp->event_lock);
|
---|
| 1206 | }
|
---|
| 1207 |
|
---|
| 1208 | static void test_pos_event(void *arg, pos_event_t *event)
|
---|
| 1209 | {
|
---|
| 1210 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 1211 |
|
---|
| 1212 | resp->revent.etype = wev_pos;
|
---|
| 1213 | resp->revent.ev.pos = *event;
|
---|
| 1214 |
|
---|
| 1215 | fibril_mutex_lock(&resp->event_lock);
|
---|
| 1216 | resp->pos_event_called = true;
|
---|
| 1217 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
[b0a94854] | 1218 | fibril_mutex_unlock(&resp->event_lock);
|
---|
| 1219 | }
|
---|
| 1220 |
|
---|
| 1221 | static void test_unfocus_event(void *arg)
|
---|
| 1222 | {
|
---|
| 1223 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 1224 |
|
---|
| 1225 | resp->revent.etype = wev_unfocus;
|
---|
| 1226 |
|
---|
| 1227 | fibril_mutex_lock(&resp->event_lock);
|
---|
| 1228 | resp->unfocus_event_called = true;
|
---|
| 1229 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
[f7fb2b21] | 1230 | fibril_mutex_unlock(&resp->event_lock);
|
---|
[bfddc62] | 1231 | }
|
---|
| 1232 |
|
---|
[4d9c807] | 1233 | static errno_t test_window_create(void *arg, display_wnd_params_t *params,
|
---|
| 1234 | sysarg_t *rwnd_id)
|
---|
[bfddc62] | 1235 | {
|
---|
| 1236 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 1237 |
|
---|
| 1238 | resp->window_create_called = true;
|
---|
[4d9c807] | 1239 | resp->create_rect = params->rect;
|
---|
[bfddc62] | 1240 | if (resp->rc == EOK)
|
---|
| 1241 | *rwnd_id = resp->wnd_id;
|
---|
[959b7ec] | 1242 |
|
---|
[bfddc62] | 1243 | return resp->rc;
|
---|
[959b7ec] | 1244 | }
|
---|
| 1245 |
|
---|
[bfddc62] | 1246 | static errno_t test_window_destroy(void *arg, sysarg_t wnd_id)
|
---|
| 1247 | {
|
---|
| 1248 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 1249 |
|
---|
| 1250 | resp->window_destroy_called = true;
|
---|
[0e6e77f] | 1251 | resp->destroy_wnd_id = wnd_id;
|
---|
| 1252 | return resp->rc;
|
---|
| 1253 | }
|
---|
| 1254 |
|
---|
[a2e104e] | 1255 | static errno_t test_window_move_req(void *arg, sysarg_t wnd_id,
|
---|
| 1256 | gfx_coord2_t *pos)
|
---|
| 1257 | {
|
---|
| 1258 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 1259 |
|
---|
| 1260 | resp->window_move_req_called = true;
|
---|
| 1261 | resp->move_req_wnd_id = wnd_id;
|
---|
| 1262 | resp->move_req_pos = *pos;
|
---|
| 1263 | return resp->rc;
|
---|
| 1264 | }
|
---|
| 1265 |
|
---|
[1e4a937] | 1266 | static errno_t test_window_resize_req(void *arg, sysarg_t wnd_id,
|
---|
| 1267 | display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
|
---|
| 1268 | {
|
---|
| 1269 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 1270 |
|
---|
| 1271 | resp->window_resize_req_called = true;
|
---|
| 1272 | resp->resize_req_rsztype = rsztype;
|
---|
| 1273 | resp->resize_req_wnd_id = wnd_id;
|
---|
| 1274 | resp->resize_req_pos = *pos;
|
---|
| 1275 | return resp->rc;
|
---|
| 1276 | }
|
---|
| 1277 |
|
---|
[0e6e77f] | 1278 | static errno_t test_window_resize(void *arg, sysarg_t wnd_id,
|
---|
| 1279 | gfx_coord2_t *offs, gfx_rect_t *nrect)
|
---|
| 1280 | {
|
---|
| 1281 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 1282 |
|
---|
| 1283 | resp->window_resize_called = true;
|
---|
| 1284 | resp->resize_wnd_id = wnd_id;
|
---|
| 1285 | resp->resize_offs = *offs;
|
---|
| 1286 | resp->resize_nbound = *nrect;
|
---|
[bfddc62] | 1287 | return resp->rc;
|
---|
| 1288 | }
|
---|
| 1289 |
|
---|
| 1290 | static errno_t test_get_event(void *arg, sysarg_t *wnd_id, display_wnd_ev_t *event)
|
---|
| 1291 | {
|
---|
| 1292 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 1293 |
|
---|
| 1294 | resp->get_event_called = true;
|
---|
[b093a62] | 1295 | if (resp->event_cnt > 0) {
|
---|
| 1296 | --resp->event_cnt;
|
---|
[bfddc62] | 1297 | *wnd_id = resp->wnd_id;
|
---|
| 1298 | *event = resp->event;
|
---|
[b093a62] | 1299 | return EOK;
|
---|
[bfddc62] | 1300 | }
|
---|
| 1301 |
|
---|
[b093a62] | 1302 | return ENOENT;
|
---|
[bfddc62] | 1303 | }
|
---|
| 1304 |
|
---|
| 1305 | static errno_t test_gc_set_color(void *arg, gfx_color_t *color)
|
---|
| 1306 | {
|
---|
| 1307 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 1308 |
|
---|
| 1309 | resp->set_color_called = true;
|
---|
| 1310 | return resp->rc;
|
---|
| 1311 | }
|
---|
| 1312 |
|
---|
[959b7ec] | 1313 | PCUT_EXPORT(display);
|
---|