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