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