[959b7ec] | 1 | /*
|
---|
| 2 | * Copyright (c) 2019 Jiri Svoboda
|
---|
| 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>
|
---|
| 40 |
|
---|
| 41 | PCUT_INIT;
|
---|
| 42 |
|
---|
| 43 | PCUT_TEST_SUITE(display);
|
---|
| 44 |
|
---|
| 45 | static const char *test_display_server = "test-display";
|
---|
| 46 | static const char *test_display_svc = "test/display";
|
---|
| 47 |
|
---|
| 48 | static void test_display_conn(ipc_call_t *, void *);
|
---|
[b0a94854] | 49 |
|
---|
| 50 | static void test_focus_event(void *);
|
---|
[bfddc62] | 51 | static void test_kbd_event(void *, kbd_event_t *);
|
---|
[f7fb2b21] | 52 | static void test_pos_event(void *, pos_event_t *);
|
---|
[b0a94854] | 53 | static void test_unfocus_event(void *);
|
---|
[959b7ec] | 54 |
|
---|
[4d9c807] | 55 | static errno_t test_window_create(void *, display_wnd_params_t *, sysarg_t *);
|
---|
[bfddc62] | 56 | static errno_t test_window_destroy(void *, sysarg_t);
|
---|
| 57 | static errno_t test_get_event(void *, sysarg_t *, display_wnd_ev_t *);
|
---|
| 58 |
|
---|
| 59 | static errno_t test_gc_set_color(void *, gfx_color_t *);
|
---|
| 60 |
|
---|
| 61 | static display_ops_t test_display_srv_ops = {
|
---|
| 62 | .window_create = test_window_create,
|
---|
| 63 | .window_destroy = test_window_destroy,
|
---|
| 64 | .get_event = test_get_event
|
---|
| 65 | };
|
---|
| 66 |
|
---|
| 67 | static display_wnd_cb_t test_display_wnd_cb = {
|
---|
[b0a94854] | 68 | .focus_event = test_focus_event,
|
---|
[f7fb2b21] | 69 | .kbd_event = test_kbd_event,
|
---|
[b0a94854] | 70 | .pos_event = test_pos_event,
|
---|
| 71 | .unfocus_event = test_unfocus_event
|
---|
[bfddc62] | 72 | };
|
---|
| 73 |
|
---|
| 74 | static gfx_context_ops_t test_gc_ops = {
|
---|
| 75 | .set_color = test_gc_set_color
|
---|
| 76 | };
|
---|
| 77 |
|
---|
| 78 | /** Describes to the server how to respond to our request and pass tracking
|
---|
| 79 | * data back to the client.
|
---|
| 80 | */
|
---|
| 81 | typedef struct {
|
---|
| 82 | errno_t rc;
|
---|
| 83 | sysarg_t wnd_id;
|
---|
| 84 | display_wnd_ev_t event;
|
---|
[b093a62] | 85 | display_wnd_ev_t revent;
|
---|
| 86 | int event_cnt;
|
---|
[bfddc62] | 87 | bool window_create_called;
|
---|
[4d9c807] | 88 | gfx_rect_t create_rect;
|
---|
[bfddc62] | 89 | bool window_destroy_called;
|
---|
| 90 | bool get_event_called;
|
---|
| 91 | bool set_color_called;
|
---|
[b0a94854] | 92 | bool focus_event_called;
|
---|
[b093a62] | 93 | bool kbd_event_called;
|
---|
[f7fb2b21] | 94 | bool pos_event_called;
|
---|
[b0a94854] | 95 | bool unfocus_event_called;
|
---|
[f7fb2b21] | 96 | fibril_condvar_t event_cv;
|
---|
| 97 | fibril_mutex_t event_lock;
|
---|
[dcac756] | 98 | display_srv_t *srv;
|
---|
[bfddc62] | 99 | } test_response_t;
|
---|
[959b7ec] | 100 |
|
---|
| 101 | /** display_open(), display_close() work for valid display service */
|
---|
| 102 | PCUT_TEST(open_close)
|
---|
| 103 | {
|
---|
| 104 | errno_t rc;
|
---|
| 105 | service_id_t sid;
|
---|
| 106 | display_t *disp = NULL;
|
---|
[dcac756] | 107 | test_response_t resp;
|
---|
[959b7ec] | 108 |
|
---|
[dcac756] | 109 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
[959b7ec] | 110 |
|
---|
[38e4f42] | 111 | // FIXME This causes this test to be non-reentrant!
|
---|
[959b7ec] | 112 | rc = loc_server_register(test_display_server);
|
---|
| 113 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 114 |
|
---|
| 115 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 116 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 117 |
|
---|
| 118 | rc = display_open(test_display_svc, &disp);
|
---|
| 119 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 120 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 121 |
|
---|
| 122 | display_close(disp);
|
---|
| 123 | rc = loc_service_unregister(sid);
|
---|
| 124 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | /** display_window_create() with server returning error response works */
|
---|
| 128 | PCUT_TEST(window_create_failure)
|
---|
| 129 | {
|
---|
[bfddc62] | 130 | errno_t rc;
|
---|
| 131 | service_id_t sid;
|
---|
| 132 | display_t *disp = NULL;
|
---|
[4d9c807] | 133 | display_wnd_params_t params;
|
---|
[bfddc62] | 134 | display_window_t *wnd;
|
---|
| 135 | test_response_t resp;
|
---|
| 136 |
|
---|
| 137 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 138 |
|
---|
[38e4f42] | 139 | // FIXME This causes this test to be non-reentrant!
|
---|
[bfddc62] | 140 | rc = loc_server_register(test_display_server);
|
---|
| 141 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 142 |
|
---|
| 143 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 144 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 145 |
|
---|
| 146 | rc = display_open(test_display_svc, &disp);
|
---|
| 147 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 148 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 149 |
|
---|
| 150 | wnd = NULL;
|
---|
| 151 | resp.rc = ENOMEM;
|
---|
| 152 | resp.window_create_called = false;
|
---|
[4d9c807] | 153 | display_wnd_params_init(¶ms);
|
---|
| 154 | params.rect.p0.x = 0;
|
---|
| 155 | params.rect.p0.y = 0;
|
---|
| 156 | params.rect.p0.x = 100;
|
---|
| 157 | params.rect.p0.y = 100;
|
---|
| 158 |
|
---|
| 159 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 160 | (void *) &resp, &wnd);
|
---|
[bfddc62] | 161 | PCUT_ASSERT_TRUE(resp.window_create_called);
|
---|
[4d9c807] | 162 | PCUT_ASSERT_EQUALS(params.rect.p0.x, resp.create_rect.p0.x);
|
---|
| 163 | PCUT_ASSERT_EQUALS(params.rect.p0.y, resp.create_rect.p0.y);
|
---|
| 164 | PCUT_ASSERT_EQUALS(params.rect.p1.x, resp.create_rect.p1.x);
|
---|
| 165 | PCUT_ASSERT_EQUALS(params.rect.p1.y, resp.create_rect.p1.y);
|
---|
[bfddc62] | 166 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
| 167 | PCUT_ASSERT_NULL(wnd);
|
---|
| 168 |
|
---|
| 169 | display_close(disp);
|
---|
| 170 | rc = loc_service_unregister(sid);
|
---|
| 171 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[959b7ec] | 172 | }
|
---|
| 173 |
|
---|
[bfddc62] | 174 | /** display_window_create() and display_window_destroy() with success
|
---|
| 175 | *
|
---|
| 176 | * with server returning success,
|
---|
| 177 | */
|
---|
| 178 | PCUT_TEST(window_create_destroy_success)
|
---|
[959b7ec] | 179 | {
|
---|
[bfddc62] | 180 | errno_t rc;
|
---|
| 181 | service_id_t sid;
|
---|
| 182 | display_t *disp = NULL;
|
---|
[4d9c807] | 183 | display_wnd_params_t params;
|
---|
[bfddc62] | 184 | display_window_t *wnd;
|
---|
| 185 | test_response_t resp;
|
---|
| 186 |
|
---|
| 187 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 188 |
|
---|
[38e4f42] | 189 | // FIXME This causes this test to be non-reentrant!
|
---|
[bfddc62] | 190 | rc = loc_server_register(test_display_server);
|
---|
| 191 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 192 |
|
---|
| 193 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 194 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 195 |
|
---|
| 196 | rc = display_open(test_display_svc, &disp);
|
---|
| 197 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 198 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 199 |
|
---|
| 200 | wnd = NULL;
|
---|
| 201 | resp.rc = EOK;
|
---|
| 202 | resp.window_create_called = false;
|
---|
[4d9c807] | 203 | display_wnd_params_init(¶ms);
|
---|
| 204 | params.rect.p0.x = 0;
|
---|
| 205 | params.rect.p0.y = 0;
|
---|
| 206 | params.rect.p0.x = 100;
|
---|
| 207 | params.rect.p0.y = 100;
|
---|
| 208 |
|
---|
| 209 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 210 | (void *) &resp, &wnd);
|
---|
[bfddc62] | 211 | PCUT_ASSERT_TRUE(resp.window_create_called);
|
---|
[4d9c807] | 212 | PCUT_ASSERT_EQUALS(params.rect.p0.x, resp.create_rect.p0.x);
|
---|
| 213 | PCUT_ASSERT_EQUALS(params.rect.p0.y, resp.create_rect.p0.y);
|
---|
| 214 | PCUT_ASSERT_EQUALS(params.rect.p1.x, resp.create_rect.p1.x);
|
---|
| 215 | PCUT_ASSERT_EQUALS(params.rect.p1.y, resp.create_rect.p1.y);
|
---|
[bfddc62] | 216 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 217 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 218 |
|
---|
| 219 | resp.window_destroy_called = false;
|
---|
| 220 | rc = display_window_destroy(wnd);
|
---|
| 221 | PCUT_ASSERT_TRUE(resp.window_destroy_called);
|
---|
| 222 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 223 |
|
---|
| 224 | display_close(disp);
|
---|
| 225 | rc = loc_service_unregister(sid);
|
---|
| 226 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[959b7ec] | 227 | }
|
---|
| 228 |
|
---|
[bfddc62] | 229 | /** display_window_create() with server returning error response works. */
|
---|
[959b7ec] | 230 | PCUT_TEST(window_destroy_failure)
|
---|
| 231 | {
|
---|
[bfddc62] | 232 | errno_t rc;
|
---|
| 233 | service_id_t sid;
|
---|
| 234 | display_t *disp = NULL;
|
---|
[4d9c807] | 235 | display_wnd_params_t params;
|
---|
[bfddc62] | 236 | display_window_t *wnd;
|
---|
| 237 | test_response_t resp;
|
---|
[959b7ec] | 238 |
|
---|
[bfddc62] | 239 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 240 |
|
---|
[38e4f42] | 241 | // FIXME This causes this test to be non-reentrant!
|
---|
[bfddc62] | 242 | rc = loc_server_register(test_display_server);
|
---|
| 243 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 244 |
|
---|
| 245 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 246 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 247 |
|
---|
| 248 | rc = display_open(test_display_svc, &disp);
|
---|
| 249 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 250 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 251 |
|
---|
| 252 | resp.rc = EOK;
|
---|
| 253 | resp.window_create_called = false;
|
---|
[4d9c807] | 254 | display_wnd_params_init(¶ms);
|
---|
| 255 | params.rect.p0.x = 0;
|
---|
| 256 | params.rect.p0.y = 0;
|
---|
| 257 | params.rect.p0.x = 100;
|
---|
| 258 | params.rect.p0.y = 100;
|
---|
| 259 |
|
---|
| 260 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 261 | (void *) &resp, &wnd);
|
---|
[bfddc62] | 262 | PCUT_ASSERT_TRUE(resp.window_create_called);
|
---|
[4d9c807] | 263 | PCUT_ASSERT_EQUALS(params.rect.p0.x, resp.create_rect.p0.x);
|
---|
| 264 | PCUT_ASSERT_EQUALS(params.rect.p0.y, resp.create_rect.p0.y);
|
---|
| 265 | PCUT_ASSERT_EQUALS(params.rect.p1.x, resp.create_rect.p1.x);
|
---|
| 266 | PCUT_ASSERT_EQUALS(params.rect.p1.y, resp.create_rect.p1.y);
|
---|
[bfddc62] | 267 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 268 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 269 |
|
---|
| 270 | resp.rc = EIO;
|
---|
| 271 | resp.window_destroy_called = false;
|
---|
| 272 | rc = display_window_destroy(wnd);
|
---|
| 273 | PCUT_ASSERT_TRUE(resp.window_destroy_called);
|
---|
| 274 | PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
|
---|
| 275 |
|
---|
| 276 | display_close(disp);
|
---|
| 277 | rc = loc_service_unregister(sid);
|
---|
| 278 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[959b7ec] | 279 | }
|
---|
| 280 |
|
---|
| 281 | /** display_window_get_gc with server returning failure */
|
---|
| 282 | PCUT_TEST(window_get_gc_failure)
|
---|
| 283 | {
|
---|
[bfddc62] | 284 | errno_t rc;
|
---|
| 285 | service_id_t sid;
|
---|
| 286 | display_t *disp = NULL;
|
---|
[4d9c807] | 287 | display_wnd_params_t params;
|
---|
[bfddc62] | 288 | display_window_t *wnd;
|
---|
| 289 | test_response_t resp;
|
---|
| 290 | gfx_context_t *gc;
|
---|
| 291 |
|
---|
| 292 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 293 |
|
---|
[38e4f42] | 294 | // FIXME This causes this test to be non-reentrant!
|
---|
[bfddc62] | 295 | rc = loc_server_register(test_display_server);
|
---|
| 296 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 297 |
|
---|
| 298 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 299 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 300 |
|
---|
| 301 | rc = display_open(test_display_svc, &disp);
|
---|
| 302 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 303 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 304 |
|
---|
| 305 | wnd = NULL;
|
---|
| 306 | resp.rc = EOK;
|
---|
[4d9c807] | 307 | display_wnd_params_init(¶ms);
|
---|
| 308 | params.rect.p0.x = 0;
|
---|
| 309 | params.rect.p0.y = 0;
|
---|
| 310 | params.rect.p0.x = 100;
|
---|
| 311 | params.rect.p0.y = 100;
|
---|
| 312 |
|
---|
| 313 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 314 | (void *) &resp, &wnd);
|
---|
[bfddc62] | 315 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 316 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 317 |
|
---|
| 318 | gc = NULL;
|
---|
| 319 | resp.rc = ENOMEM;
|
---|
| 320 | rc = display_window_get_gc(wnd, &gc);
|
---|
| 321 | /* async_connect_me_to() does not return specific error */
|
---|
| 322 | PCUT_ASSERT_ERRNO_VAL(EIO, rc);
|
---|
| 323 | PCUT_ASSERT_NULL(gc);
|
---|
| 324 |
|
---|
| 325 | resp.rc = EOK;
|
---|
| 326 | rc = display_window_destroy(wnd);
|
---|
| 327 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 328 |
|
---|
| 329 | display_close(disp);
|
---|
| 330 | rc = loc_service_unregister(sid);
|
---|
| 331 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[959b7ec] | 332 | }
|
---|
| 333 |
|
---|
| 334 | /** display_window_get_gc with server returning success */
|
---|
| 335 | PCUT_TEST(window_get_gc_success)
|
---|
| 336 | {
|
---|
[bfddc62] | 337 | errno_t rc;
|
---|
| 338 | service_id_t sid;
|
---|
| 339 | display_t *disp = NULL;
|
---|
[4d9c807] | 340 | display_wnd_params_t params;
|
---|
[bfddc62] | 341 | display_window_t *wnd;
|
---|
| 342 | test_response_t resp;
|
---|
| 343 | gfx_context_t *gc;
|
---|
| 344 | gfx_color_t *color;
|
---|
| 345 |
|
---|
| 346 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 347 |
|
---|
[38e4f42] | 348 | // FIXME This causes this test to be non-reentrant!
|
---|
[bfddc62] | 349 | rc = loc_server_register(test_display_server);
|
---|
| 350 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 351 |
|
---|
| 352 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 353 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 354 |
|
---|
| 355 | rc = display_open(test_display_svc, &disp);
|
---|
| 356 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 357 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 358 |
|
---|
| 359 | wnd = NULL;
|
---|
| 360 | resp.rc = EOK;
|
---|
[4d9c807] | 361 | display_wnd_params_init(¶ms);
|
---|
| 362 | params.rect.p0.x = 0;
|
---|
| 363 | params.rect.p0.y = 0;
|
---|
| 364 | params.rect.p0.x = 100;
|
---|
| 365 | params.rect.p0.y = 100;
|
---|
| 366 |
|
---|
| 367 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 368 | (void *) &resp, &wnd);
|
---|
[bfddc62] | 369 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 370 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 371 |
|
---|
| 372 | gc = NULL;
|
---|
| 373 | rc = display_window_get_gc(wnd, &gc);
|
---|
| 374 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 375 | PCUT_ASSERT_NOT_NULL(gc);
|
---|
| 376 |
|
---|
| 377 | rc = gfx_color_new_rgb_i16(0, 0, 0, &color);
|
---|
| 378 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 379 |
|
---|
| 380 | resp.set_color_called = false;
|
---|
| 381 | rc = gfx_set_color(gc, color);
|
---|
| 382 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 383 | PCUT_ASSERT_TRUE(resp.set_color_called);
|
---|
| 384 |
|
---|
| 385 | gfx_color_delete(color);
|
---|
| 386 |
|
---|
| 387 | rc = display_window_destroy(wnd);
|
---|
| 388 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 389 |
|
---|
| 390 | display_close(disp);
|
---|
| 391 | rc = loc_service_unregister(sid);
|
---|
| 392 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
[959b7ec] | 393 | }
|
---|
| 394 |
|
---|
[b0a94854] | 395 | /** Focus event can be delivered from server to client callback function */
|
---|
| 396 | PCUT_TEST(focus_event_deliver)
|
---|
| 397 | {
|
---|
| 398 | errno_t rc;
|
---|
| 399 | service_id_t sid;
|
---|
| 400 | display_t *disp = NULL;
|
---|
| 401 | display_wnd_params_t params;
|
---|
| 402 | display_window_t *wnd;
|
---|
| 403 | test_response_t resp;
|
---|
| 404 |
|
---|
| 405 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 406 |
|
---|
| 407 | // FIXME This causes this test to be non-reentrant!
|
---|
| 408 | rc = loc_server_register(test_display_server);
|
---|
| 409 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 410 |
|
---|
| 411 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 412 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 413 |
|
---|
| 414 | rc = display_open(test_display_svc, &disp);
|
---|
| 415 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 416 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 417 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
| 418 |
|
---|
| 419 | wnd = NULL;
|
---|
| 420 | resp.rc = EOK;
|
---|
| 421 | display_wnd_params_init(¶ms);
|
---|
| 422 | params.rect.p0.x = 0;
|
---|
| 423 | params.rect.p0.y = 0;
|
---|
| 424 | params.rect.p0.x = 100;
|
---|
| 425 | params.rect.p0.y = 100;
|
---|
| 426 |
|
---|
| 427 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 428 | (void *) &resp, &wnd);
|
---|
| 429 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 430 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 431 |
|
---|
| 432 | resp.event_cnt = 1;
|
---|
| 433 | resp.event.etype = wev_focus;
|
---|
| 434 | resp.wnd_id = wnd->id;
|
---|
| 435 | resp.focus_event_called = false;
|
---|
| 436 | fibril_mutex_initialize(&resp.event_lock);
|
---|
| 437 | fibril_condvar_initialize(&resp.event_cv);
|
---|
| 438 | display_srv_ev_pending(resp.srv);
|
---|
| 439 |
|
---|
| 440 | /* Wait for the event handler to be called. */
|
---|
| 441 | fibril_mutex_lock(&resp.event_lock);
|
---|
| 442 | while (!resp.focus_event_called) {
|
---|
| 443 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
| 444 | }
|
---|
| 445 | fibril_mutex_unlock(&resp.event_lock);
|
---|
| 446 |
|
---|
| 447 | /* Verify that the event was delivered correctly */
|
---|
| 448 | PCUT_ASSERT_EQUALS(resp.event.etype,
|
---|
| 449 | resp.revent.etype);
|
---|
| 450 |
|
---|
| 451 | rc = display_window_destroy(wnd);
|
---|
| 452 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 453 |
|
---|
| 454 | display_close(disp);
|
---|
| 455 |
|
---|
| 456 | rc = loc_service_unregister(sid);
|
---|
| 457 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 458 | }
|
---|
| 459 |
|
---|
[dcac756] | 460 | /** Keyboard event can be delivered from server to client callback function */
|
---|
| 461 | PCUT_TEST(kbd_event_deliver)
|
---|
| 462 | {
|
---|
| 463 | errno_t rc;
|
---|
| 464 | service_id_t sid;
|
---|
| 465 | display_t *disp = NULL;
|
---|
[4d9c807] | 466 | display_wnd_params_t params;
|
---|
[dcac756] | 467 | display_window_t *wnd;
|
---|
| 468 | test_response_t resp;
|
---|
| 469 |
|
---|
| 470 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 471 |
|
---|
| 472 | // FIXME This causes this test to be non-reentrant!
|
---|
| 473 | rc = loc_server_register(test_display_server);
|
---|
| 474 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 475 |
|
---|
| 476 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 477 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 478 |
|
---|
| 479 | rc = display_open(test_display_svc, &disp);
|
---|
| 480 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 481 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 482 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
| 483 |
|
---|
| 484 | wnd = NULL;
|
---|
| 485 | resp.rc = EOK;
|
---|
[4d9c807] | 486 | display_wnd_params_init(¶ms);
|
---|
| 487 | params.rect.p0.x = 0;
|
---|
| 488 | params.rect.p0.y = 0;
|
---|
| 489 | params.rect.p0.x = 100;
|
---|
| 490 | params.rect.p0.y = 100;
|
---|
| 491 |
|
---|
| 492 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 493 | (void *) &resp, &wnd);
|
---|
[dcac756] | 494 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 495 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 496 |
|
---|
[b093a62] | 497 | resp.event_cnt = 1;
|
---|
[f7fb2b21] | 498 | resp.event.etype = wev_kbd;
|
---|
| 499 | resp.event.ev.kbd.type = KEY_PRESS;
|
---|
| 500 | resp.event.ev.kbd.key = KC_ENTER;
|
---|
| 501 | resp.event.ev.kbd.mods = 0;
|
---|
| 502 | resp.event.ev.kbd.c = L'\0';
|
---|
[b093a62] | 503 | resp.wnd_id = wnd->id;
|
---|
| 504 | resp.kbd_event_called = false;
|
---|
[f7fb2b21] | 505 | fibril_mutex_initialize(&resp.event_lock);
|
---|
| 506 | fibril_condvar_initialize(&resp.event_cv);
|
---|
[dcac756] | 507 | display_srv_ev_pending(resp.srv);
|
---|
| 508 |
|
---|
[b093a62] | 509 | /* Wait for the event handler to be called. */
|
---|
[f7fb2b21] | 510 | fibril_mutex_lock(&resp.event_lock);
|
---|
[b093a62] | 511 | while (!resp.kbd_event_called) {
|
---|
[f7fb2b21] | 512 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
[b093a62] | 513 | }
|
---|
[f7fb2b21] | 514 | fibril_mutex_unlock(&resp.event_lock);
|
---|
[b093a62] | 515 |
|
---|
| 516 | /* Verify that the event was delivered correctly */
|
---|
[f7fb2b21] | 517 | PCUT_ASSERT_EQUALS(resp.event.etype,
|
---|
| 518 | resp.revent.etype);
|
---|
| 519 | PCUT_ASSERT_EQUALS(resp.event.ev.kbd.type,
|
---|
| 520 | resp.revent.ev.kbd.type);
|
---|
| 521 | PCUT_ASSERT_EQUALS(resp.event.ev.kbd.key,
|
---|
| 522 | resp.revent.ev.kbd.key);
|
---|
| 523 | PCUT_ASSERT_EQUALS(resp.event.ev.kbd.mods,
|
---|
| 524 | resp.revent.ev.kbd.mods);
|
---|
| 525 | PCUT_ASSERT_EQUALS(resp.event.ev.kbd.c,
|
---|
| 526 | resp.revent.ev.kbd.c);
|
---|
| 527 |
|
---|
| 528 | rc = display_window_destroy(wnd);
|
---|
| 529 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 530 |
|
---|
| 531 | display_close(disp);
|
---|
| 532 |
|
---|
| 533 | rc = loc_service_unregister(sid);
|
---|
| 534 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 535 | }
|
---|
| 536 |
|
---|
| 537 | /** Position event can be delivered from server to client callback function */
|
---|
| 538 | PCUT_TEST(pos_event_deliver)
|
---|
| 539 | {
|
---|
| 540 | errno_t rc;
|
---|
| 541 | service_id_t sid;
|
---|
| 542 | display_t *disp = NULL;
|
---|
| 543 | display_wnd_params_t params;
|
---|
| 544 | display_window_t *wnd;
|
---|
| 545 | test_response_t resp;
|
---|
| 546 |
|
---|
| 547 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 548 |
|
---|
| 549 | // FIXME This causes this test to be non-reentrant!
|
---|
| 550 | rc = loc_server_register(test_display_server);
|
---|
| 551 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 552 |
|
---|
| 553 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 554 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 555 |
|
---|
| 556 | rc = display_open(test_display_svc, &disp);
|
---|
| 557 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 558 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 559 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
| 560 |
|
---|
| 561 | wnd = NULL;
|
---|
| 562 | resp.rc = EOK;
|
---|
| 563 | display_wnd_params_init(¶ms);
|
---|
| 564 | params.rect.p0.x = 0;
|
---|
| 565 | params.rect.p0.y = 0;
|
---|
| 566 | params.rect.p0.x = 100;
|
---|
| 567 | params.rect.p0.y = 100;
|
---|
| 568 |
|
---|
| 569 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 570 | (void *) &resp, &wnd);
|
---|
| 571 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 572 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 573 |
|
---|
| 574 | resp.event_cnt = 1;
|
---|
| 575 | resp.event.etype = wev_pos;
|
---|
| 576 | resp.event.ev.pos.type = POS_PRESS;
|
---|
| 577 | resp.event.ev.pos.btn_num = 1;
|
---|
| 578 | resp.event.ev.pos.hpos = 2;
|
---|
| 579 | resp.event.ev.pos.vpos = 3;
|
---|
| 580 | resp.wnd_id = wnd->id;
|
---|
| 581 | resp.pos_event_called = false;
|
---|
| 582 | fibril_mutex_initialize(&resp.event_lock);
|
---|
| 583 | fibril_condvar_initialize(&resp.event_cv);
|
---|
| 584 | display_srv_ev_pending(resp.srv);
|
---|
| 585 |
|
---|
| 586 | /* Wait for the event handler to be called. */
|
---|
| 587 | fibril_mutex_lock(&resp.event_lock);
|
---|
| 588 | while (!resp.pos_event_called) {
|
---|
| 589 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
| 590 | }
|
---|
| 591 | fibril_mutex_unlock(&resp.event_lock);
|
---|
| 592 |
|
---|
| 593 | /* Verify that the event was delivered correctly */
|
---|
| 594 | PCUT_ASSERT_EQUALS(resp.event.etype,
|
---|
| 595 | resp.revent.etype);
|
---|
| 596 | PCUT_ASSERT_EQUALS(resp.event.ev.pos.type,
|
---|
| 597 | resp.revent.ev.pos.type);
|
---|
| 598 | PCUT_ASSERT_EQUALS(resp.event.ev.pos.btn_num,
|
---|
| 599 | resp.revent.ev.pos.btn_num);
|
---|
| 600 | PCUT_ASSERT_EQUALS(resp.event.ev.pos.hpos,
|
---|
| 601 | resp.revent.ev.pos.hpos);
|
---|
| 602 | PCUT_ASSERT_EQUALS(resp.event.ev.pos.vpos,
|
---|
| 603 | resp.revent.ev.pos.vpos);
|
---|
[b093a62] | 604 |
|
---|
[dcac756] | 605 | rc = display_window_destroy(wnd);
|
---|
| 606 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 607 |
|
---|
| 608 | display_close(disp);
|
---|
[b093a62] | 609 |
|
---|
[dcac756] | 610 | rc = loc_service_unregister(sid);
|
---|
| 611 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 612 | }
|
---|
| 613 |
|
---|
[b0a94854] | 614 | /** Unfocus event can be delivered from server to client callback function */
|
---|
| 615 | PCUT_TEST(unfocus_event_deliver)
|
---|
| 616 | {
|
---|
| 617 | errno_t rc;
|
---|
| 618 | service_id_t sid;
|
---|
| 619 | display_t *disp = NULL;
|
---|
| 620 | display_wnd_params_t params;
|
---|
| 621 | display_window_t *wnd;
|
---|
| 622 | test_response_t resp;
|
---|
| 623 |
|
---|
| 624 | async_set_fallback_port_handler(test_display_conn, &resp);
|
---|
| 625 |
|
---|
| 626 | // FIXME This causes this test to be non-reentrant!
|
---|
| 627 | rc = loc_server_register(test_display_server);
|
---|
| 628 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 629 |
|
---|
| 630 | rc = loc_service_register(test_display_svc, &sid);
|
---|
| 631 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 632 |
|
---|
| 633 | rc = display_open(test_display_svc, &disp);
|
---|
| 634 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 635 | PCUT_ASSERT_NOT_NULL(disp);
|
---|
| 636 | PCUT_ASSERT_NOT_NULL(resp.srv);
|
---|
| 637 |
|
---|
| 638 | wnd = NULL;
|
---|
| 639 | resp.rc = EOK;
|
---|
| 640 | display_wnd_params_init(¶ms);
|
---|
| 641 | params.rect.p0.x = 0;
|
---|
| 642 | params.rect.p0.y = 0;
|
---|
| 643 | params.rect.p0.x = 100;
|
---|
| 644 | params.rect.p0.y = 100;
|
---|
| 645 |
|
---|
| 646 | rc = display_window_create(disp, ¶ms, &test_display_wnd_cb,
|
---|
| 647 | (void *) &resp, &wnd);
|
---|
| 648 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 649 | PCUT_ASSERT_NOT_NULL(wnd);
|
---|
| 650 |
|
---|
| 651 | resp.event_cnt = 1;
|
---|
| 652 | resp.event.etype = wev_unfocus;
|
---|
| 653 | resp.wnd_id = wnd->id;
|
---|
| 654 | resp.focus_event_called = false;
|
---|
| 655 | fibril_mutex_initialize(&resp.event_lock);
|
---|
| 656 | fibril_condvar_initialize(&resp.event_cv);
|
---|
| 657 | display_srv_ev_pending(resp.srv);
|
---|
| 658 |
|
---|
| 659 | /* Wait for the event handler to be called. */
|
---|
| 660 | fibril_mutex_lock(&resp.event_lock);
|
---|
| 661 | while (!resp.unfocus_event_called) {
|
---|
| 662 | fibril_condvar_wait(&resp.event_cv, &resp.event_lock);
|
---|
| 663 | }
|
---|
| 664 | fibril_mutex_unlock(&resp.event_lock);
|
---|
| 665 |
|
---|
| 666 | /* Verify that the event was delivered correctly */
|
---|
| 667 | PCUT_ASSERT_EQUALS(resp.event.etype,
|
---|
| 668 | resp.revent.etype);
|
---|
| 669 |
|
---|
| 670 | rc = display_window_destroy(wnd);
|
---|
| 671 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 672 |
|
---|
| 673 | display_close(disp);
|
---|
| 674 |
|
---|
| 675 | rc = loc_service_unregister(sid);
|
---|
| 676 | PCUT_ASSERT_ERRNO_VAL(EOK, rc);
|
---|
| 677 | }
|
---|
| 678 |
|
---|
[38e4f42] | 679 | /** Test display service connection.
|
---|
| 680 | *
|
---|
| 681 | * This is very similar to connection handler in the display server.
|
---|
| 682 | * XXX This should be folded into display_srv, if possible
|
---|
| 683 | */
|
---|
[959b7ec] | 684 | static void test_display_conn(ipc_call_t *icall, void *arg)
|
---|
| 685 | {
|
---|
[bfddc62] | 686 | test_response_t *resp = (test_response_t *) arg;
|
---|
[959b7ec] | 687 | display_srv_t srv;
|
---|
[bfddc62] | 688 | sysarg_t wnd_id;
|
---|
| 689 | sysarg_t svc_id;
|
---|
| 690 | gfx_context_t *gc;
|
---|
| 691 | errno_t rc;
|
---|
| 692 |
|
---|
| 693 | svc_id = ipc_get_arg2(icall);
|
---|
| 694 | wnd_id = ipc_get_arg3(icall);
|
---|
| 695 |
|
---|
| 696 | if (svc_id != 0) {
|
---|
| 697 | /* Set up protocol structure */
|
---|
| 698 | display_srv_initialize(&srv);
|
---|
| 699 | srv.ops = &test_display_srv_ops;
|
---|
| 700 | srv.arg = arg;
|
---|
[dcac756] | 701 | resp->srv = &srv;
|
---|
[bfddc62] | 702 |
|
---|
| 703 | /* Handle connection */
|
---|
| 704 | display_conn(icall, &srv);
|
---|
[dcac756] | 705 |
|
---|
| 706 | resp->srv = NULL;
|
---|
[bfddc62] | 707 | } else {
|
---|
| 708 | (void) wnd_id;
|
---|
| 709 |
|
---|
| 710 | if (resp->rc != EOK) {
|
---|
| 711 | async_answer_0(icall, resp->rc);
|
---|
| 712 | return;
|
---|
| 713 | }
|
---|
| 714 |
|
---|
| 715 | rc = gfx_context_new(&test_gc_ops, arg, &gc);
|
---|
| 716 | if (rc != EOK) {
|
---|
| 717 | async_answer_0(icall, ENOMEM);
|
---|
| 718 | return;
|
---|
| 719 | }
|
---|
| 720 |
|
---|
| 721 | /* Window GC connection */
|
---|
| 722 | gc_conn(icall, gc);
|
---|
| 723 | }
|
---|
| 724 | }
|
---|
[959b7ec] | 725 |
|
---|
[b0a94854] | 726 | static void test_focus_event(void *arg)
|
---|
| 727 | {
|
---|
| 728 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 729 |
|
---|
| 730 | resp->revent.etype = wev_focus;
|
---|
| 731 |
|
---|
| 732 | fibril_mutex_lock(&resp->event_lock);
|
---|
| 733 | resp->focus_event_called = true;
|
---|
| 734 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
| 735 | fibril_mutex_unlock(&resp->event_lock);
|
---|
| 736 | }
|
---|
| 737 |
|
---|
[bfddc62] | 738 | static void test_kbd_event(void *arg, kbd_event_t *event)
|
---|
| 739 | {
|
---|
[b093a62] | 740 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 741 |
|
---|
[f7fb2b21] | 742 | resp->revent.etype = wev_kbd;
|
---|
| 743 | resp->revent.ev.kbd = *event;
|
---|
[b093a62] | 744 |
|
---|
[f7fb2b21] | 745 | fibril_mutex_lock(&resp->event_lock);
|
---|
[b093a62] | 746 | resp->kbd_event_called = true;
|
---|
[f7fb2b21] | 747 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
| 748 | fibril_mutex_unlock(&resp->event_lock);
|
---|
| 749 | }
|
---|
| 750 |
|
---|
| 751 | static void test_pos_event(void *arg, pos_event_t *event)
|
---|
| 752 | {
|
---|
| 753 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 754 |
|
---|
| 755 | resp->revent.etype = wev_pos;
|
---|
| 756 | resp->revent.ev.pos = *event;
|
---|
| 757 |
|
---|
| 758 | fibril_mutex_lock(&resp->event_lock);
|
---|
| 759 | resp->pos_event_called = true;
|
---|
| 760 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
[b0a94854] | 761 | fibril_mutex_unlock(&resp->event_lock);
|
---|
| 762 | }
|
---|
| 763 |
|
---|
| 764 | static void test_unfocus_event(void *arg)
|
---|
| 765 | {
|
---|
| 766 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 767 |
|
---|
| 768 | resp->revent.etype = wev_unfocus;
|
---|
| 769 |
|
---|
| 770 | fibril_mutex_lock(&resp->event_lock);
|
---|
| 771 | resp->unfocus_event_called = true;
|
---|
| 772 | fibril_condvar_broadcast(&resp->event_cv);
|
---|
[f7fb2b21] | 773 | fibril_mutex_unlock(&resp->event_lock);
|
---|
[bfddc62] | 774 | }
|
---|
| 775 |
|
---|
[4d9c807] | 776 | static errno_t test_window_create(void *arg, display_wnd_params_t *params,
|
---|
| 777 | sysarg_t *rwnd_id)
|
---|
[bfddc62] | 778 | {
|
---|
| 779 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 780 |
|
---|
| 781 | resp->window_create_called = true;
|
---|
[4d9c807] | 782 | resp->create_rect = params->rect;
|
---|
[bfddc62] | 783 | if (resp->rc == EOK)
|
---|
| 784 | *rwnd_id = resp->wnd_id;
|
---|
[959b7ec] | 785 |
|
---|
[bfddc62] | 786 | return resp->rc;
|
---|
[959b7ec] | 787 | }
|
---|
| 788 |
|
---|
[bfddc62] | 789 | static errno_t test_window_destroy(void *arg, sysarg_t wnd_id)
|
---|
| 790 | {
|
---|
| 791 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 792 |
|
---|
| 793 | resp->window_destroy_called = true;
|
---|
| 794 | return resp->rc;
|
---|
| 795 | }
|
---|
| 796 |
|
---|
| 797 | static errno_t test_get_event(void *arg, sysarg_t *wnd_id, display_wnd_ev_t *event)
|
---|
| 798 | {
|
---|
| 799 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 800 |
|
---|
| 801 | resp->get_event_called = true;
|
---|
[b093a62] | 802 | if (resp->event_cnt > 0) {
|
---|
| 803 | --resp->event_cnt;
|
---|
[bfddc62] | 804 | *wnd_id = resp->wnd_id;
|
---|
| 805 | *event = resp->event;
|
---|
[b093a62] | 806 | return EOK;
|
---|
[bfddc62] | 807 | }
|
---|
| 808 |
|
---|
[b093a62] | 809 | return ENOENT;
|
---|
[bfddc62] | 810 | }
|
---|
| 811 |
|
---|
| 812 | static errno_t test_gc_set_color(void *arg, gfx_color_t *color)
|
---|
| 813 | {
|
---|
| 814 | test_response_t *resp = (test_response_t *) arg;
|
---|
| 815 |
|
---|
| 816 | resp->set_color_called = true;
|
---|
| 817 | return resp->rc;
|
---|
| 818 | }
|
---|
| 819 |
|
---|
[959b7ec] | 820 | PCUT_EXPORT(display);
|
---|