Changeset b093a62 in mainline
- Timestamp:
- 2019-11-11T13:04:25Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 84876aa4
- Parents:
- da412547
- git-author:
- Jiri Svoboda <jiri@…> (2019-11-10 18:04:14)
- git-committer:
- Jiri Svoboda <jiri@…> (2019-11-11 13:04:25)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/display/test/display.c
rda412547 rb093a62 31 31 #include <display.h> 32 32 #include <disp_srv.h> 33 #include <fibril_synch.h> 33 34 #include <gfx/color.h> 34 35 #include <gfx/context.h> … … 75 76 sysarg_t wnd_id; 76 77 display_wnd_ev_t event; 78 display_wnd_ev_t revent; 79 int event_cnt; 77 80 bool window_create_called; 78 81 bool window_destroy_called; 79 82 bool get_event_called; 80 83 bool set_color_called; 84 bool kbd_event_called; 85 fibril_condvar_t kbd_event_cv; 86 fibril_mutex_t kbd_event_lock; 81 87 display_srv_t *srv; 82 88 } test_response_t; … … 325 331 326 332 /** Keyboard event can be delivered from server to client callback function */ 327 #include <stdio.h>328 333 PCUT_TEST(kbd_event_deliver) 329 334 { … … 351 356 wnd = NULL; 352 357 resp.rc = EOK; 353 rc = display_window_create(disp, &test_display_wnd_cb, NULL, &wnd); 358 rc = display_window_create(disp, &test_display_wnd_cb, (void *) &resp, 359 &wnd); 354 360 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 355 361 PCUT_ASSERT_NOT_NULL(wnd); 356 362 357 printf(" ** call display_window_get_gc\n");358 363 gc = NULL; 359 364 rc = display_window_get_gc(wnd, &gc); … … 361 366 PCUT_ASSERT_NOT_NULL(gc); 362 367 363 printf(" ** call display_srv_ev_pending\n"); 368 resp.event_cnt = 1; 369 resp.event.kbd_event.type = KEY_PRESS; 370 resp.event.kbd_event.key = KC_ENTER; 371 resp.event.kbd_event.mods = 0; 372 resp.event.kbd_event.c = L'\0'; 373 resp.wnd_id = wnd->id; 374 resp.kbd_event_called = false; 375 fibril_mutex_initialize(&resp.kbd_event_lock); 376 fibril_condvar_initialize(&resp.kbd_event_cv); 364 377 display_srv_ev_pending(resp.srv); 365 378 366 printf(" ** call display_window_destroy\n"); 379 /* Wait for the event handler to be called. */ 380 fibril_mutex_lock(&resp.kbd_event_lock); 381 while (!resp.kbd_event_called) { 382 fibril_condvar_wait(&resp.kbd_event_cv, &resp.kbd_event_lock); 383 } 384 fibril_mutex_unlock(&resp.kbd_event_lock); 385 386 /* Verify that the event was delivered correctly */ 387 PCUT_ASSERT_EQUALS(resp.event.kbd_event.type, 388 resp.revent.kbd_event.type); 389 PCUT_ASSERT_EQUALS(resp.event.kbd_event.key, 390 resp.revent.kbd_event.key); 391 PCUT_ASSERT_EQUALS(resp.event.kbd_event.mods, 392 resp.revent.kbd_event.mods); 393 PCUT_ASSERT_EQUALS(resp.event.kbd_event.c, 394 resp.revent.kbd_event.c); 395 367 396 rc = display_window_destroy(wnd); 368 397 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 369 398 370 printf(" ** call display_close\n"); 371 display_close(disp); 372 printf(" ** call loc_service_unregister\n"); 399 display_close(disp); 400 373 401 rc = loc_service_unregister(sid); 374 402 PCUT_ASSERT_ERRNO_VAL(EOK, rc); … … 424 452 static void test_kbd_event(void *arg, kbd_event_t *event) 425 453 { 454 test_response_t *resp = (test_response_t *) arg; 455 456 resp->revent.kbd_event = *event; 457 458 fibril_mutex_lock(&resp->kbd_event_lock); 459 resp->kbd_event_called = true; 460 fibril_condvar_broadcast(&resp->kbd_event_cv); 461 fibril_mutex_unlock(&resp->kbd_event_lock); 426 462 } 427 463 … … 450 486 451 487 resp->get_event_called = true; 452 if (resp->rc == EOK) { 488 if (resp->event_cnt > 0) { 489 --resp->event_cnt; 453 490 *wnd_id = resp->wnd_id; 454 491 *event = resp->event; 492 return EOK; 455 493 } 456 494 457 return resp->rc;495 return ENOENT; 458 496 } 459 497
Note:
See TracChangeset
for help on using the changeset viewer.