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