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