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