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