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