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