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