Changeset 1e4a937 in mainline for uspace/lib/display/test/display.c
- Timestamp:
- 2020-03-09T11:03:58Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e022819
- Parents:
- a2e104e
- git-author:
- Jiri Svoboda <jiri@…> (2020-03-08 10:02:08)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-03-09 11:03:58)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/display/test/display.c
ra2e104e r1e4a937 57 57 static errno_t test_window_destroy(void *, sysarg_t); 58 58 static errno_t test_window_move_req(void *, sysarg_t, gfx_coord2_t *); 59 static errno_t test_window_resize_req(void *, sysarg_t, display_wnd_rsztype_t, 60 gfx_coord2_t *); 59 61 static errno_t test_window_resize(void *, sysarg_t, gfx_coord2_t *, 60 62 gfx_rect_t *); … … 67 69 .window_destroy = test_window_destroy, 68 70 .window_move_req = test_window_move_req, 71 .window_resize_req = test_window_resize_req, 69 72 .window_resize = test_window_resize, 70 73 .get_event = test_get_event … … 100 103 sysarg_t move_req_wnd_id; 101 104 gfx_coord2_t move_req_pos; 105 106 bool window_resize_req_called; 107 sysarg_t resize_req_wnd_id; 108 display_wnd_rsztype_t resize_req_rsztype; 109 gfx_coord2_t resize_req_pos; 102 110 103 111 bool window_resize_called; … … 410 418 } 411 419 420 /** display_window_resize_req() with server returning error response works. */ 421 PCUT_TEST(window_resize_req_failure) 422 { 423 errno_t rc; 424 service_id_t sid; 425 display_t *disp = NULL; 426 display_wnd_params_t params; 427 display_window_t *wnd; 428 test_response_t resp; 429 display_wnd_rsztype_t rsztype; 430 gfx_coord2_t pos; 431 432 async_set_fallback_port_handler(test_display_conn, &resp); 433 434 // FIXME This causes this test to be non-reentrant! 435 rc = loc_server_register(test_display_server); 436 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 437 438 rc = loc_service_register(test_display_svc, &sid); 439 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 440 441 rc = display_open(test_display_svc, &disp); 442 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 443 PCUT_ASSERT_NOT_NULL(disp); 444 445 resp.rc = EOK; 446 display_wnd_params_init(¶ms); 447 params.rect.p0.x = 0; 448 params.rect.p0.y = 0; 449 params.rect.p0.x = 100; 450 params.rect.p0.y = 100; 451 452 rc = display_window_create(disp, ¶ms, &test_display_wnd_cb, 453 (void *) &resp, &wnd); 454 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 455 PCUT_ASSERT_NOT_NULL(wnd); 456 457 resp.rc = EIO; 458 resp.window_resize_req_called = false; 459 460 rsztype = display_wr_top_right; 461 pos.x = 42; 462 pos.y = 43; 463 464 rc = display_window_resize_req(wnd, rsztype, &pos); 465 PCUT_ASSERT_TRUE(resp.window_resize_req_called); 466 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 467 PCUT_ASSERT_INT_EQUALS(rsztype, resp.resize_req_rsztype); 468 PCUT_ASSERT_INT_EQUALS(wnd->id, resp.resize_req_wnd_id); 469 PCUT_ASSERT_INT_EQUALS(pos.x, resp.resize_req_pos.x); 470 PCUT_ASSERT_INT_EQUALS(pos.y, resp.resize_req_pos.y); 471 472 display_window_destroy(wnd); 473 display_close(disp); 474 rc = loc_service_unregister(sid); 475 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 476 } 477 478 /** display_window_resize_req() with server returning success response works. */ 479 PCUT_TEST(window_resize_req_success) 480 { 481 errno_t rc; 482 service_id_t sid; 483 display_t *disp = NULL; 484 display_wnd_params_t params; 485 display_window_t *wnd; 486 test_response_t resp; 487 display_wnd_rsztype_t rsztype; 488 gfx_coord2_t pos; 489 490 async_set_fallback_port_handler(test_display_conn, &resp); 491 492 // FIXME This causes this test to be non-reentrant! 493 rc = loc_server_register(test_display_server); 494 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 495 496 rc = loc_service_register(test_display_svc, &sid); 497 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 498 499 rc = display_open(test_display_svc, &disp); 500 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 501 PCUT_ASSERT_NOT_NULL(disp); 502 503 resp.rc = EOK; 504 display_wnd_params_init(¶ms); 505 params.rect.p0.x = 0; 506 params.rect.p0.y = 0; 507 params.rect.p0.x = 100; 508 params.rect.p0.y = 100; 509 510 rc = display_window_create(disp, ¶ms, &test_display_wnd_cb, 511 (void *) &resp, &wnd); 512 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 513 PCUT_ASSERT_NOT_NULL(wnd); 514 515 resp.rc = EOK; 516 resp.window_resize_req_called = false; 517 518 rsztype = display_wr_top_right; 519 pos.x = 42; 520 pos.y = 43; 521 522 rc = display_window_resize_req(wnd, rsztype, &pos); 523 PCUT_ASSERT_TRUE(resp.window_resize_req_called); 524 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 525 PCUT_ASSERT_INT_EQUALS(rsztype, resp.resize_req_rsztype); 526 PCUT_ASSERT_INT_EQUALS(wnd->id, resp.resize_req_wnd_id); 527 PCUT_ASSERT_INT_EQUALS(pos.x, resp.resize_req_pos.x); 528 PCUT_ASSERT_INT_EQUALS(pos.y, resp.resize_req_pos.y); 529 530 display_window_destroy(wnd); 531 display_close(disp); 532 rc = loc_service_unregister(sid); 533 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 534 } 535 412 536 /** display_window_resize() with server returning error response works. */ 413 537 PCUT_TEST(window_resize_failure) … … 1140 1264 } 1141 1265 1266 static errno_t test_window_resize_req(void *arg, sysarg_t wnd_id, 1267 display_wnd_rsztype_t rsztype, gfx_coord2_t *pos) 1268 { 1269 test_response_t *resp = (test_response_t *) arg; 1270 1271 resp->window_resize_req_called = true; 1272 resp->resize_req_rsztype = rsztype; 1273 resp->resize_req_wnd_id = wnd_id; 1274 resp->resize_req_pos = *pos; 1275 return resp->rc; 1276 } 1277 1142 1278 static errno_t test_window_resize(void *arg, sysarg_t wnd_id, 1143 1279 gfx_coord2_t *offs, gfx_rect_t *nrect)
Note:
See TracChangeset
for help on using the changeset viewer.