Changeset 0e6e77f in mainline for uspace/lib/display/test/display.c
- Timestamp:
- 2020-02-28T15:44:55Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a8eed5f
- Parents:
- 2a515dcd
- git-author:
- Jiri Svoboda <jiri@…> (2020-02-26 18:26:13)
- git-committer:
- Jiri Svoboda <jiri@…> (2020-02-28 15:44:55)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/display/test/display.c
r2a515dcd r0e6e77f 55 55 static errno_t test_window_create(void *, display_wnd_params_t *, sysarg_t *); 56 56 static errno_t test_window_destroy(void *, sysarg_t); 57 static errno_t test_window_resize(void *, sysarg_t, gfx_coord2_t *, 58 gfx_rect_t *); 57 59 static errno_t test_get_event(void *, sysarg_t *, display_wnd_ev_t *); 58 60 … … 62 64 .window_create = test_window_create, 63 65 .window_destroy = test_window_destroy, 66 .window_resize = test_window_resize, 64 67 .get_event = test_get_event 65 68 }; … … 88 91 gfx_rect_t create_rect; 89 92 bool window_destroy_called; 93 sysarg_t destroy_wnd_id; 94 95 bool window_resize_called; 96 gfx_coord2_t resize_offs; 97 gfx_rect_t resize_nbound; 98 sysarg_t resize_wnd_id; 99 90 100 bool get_event_called; 91 101 bool set_color_called; … … 220 230 rc = display_window_destroy(wnd); 221 231 PCUT_ASSERT_TRUE(resp.window_destroy_called); 232 PCUT_ASSERT_INT_EQUALS(wnd->id, resp.destroy_wnd_id); 222 233 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 223 234 … … 272 283 rc = display_window_destroy(wnd); 273 284 PCUT_ASSERT_TRUE(resp.window_destroy_called); 285 PCUT_ASSERT_INT_EQUALS(wnd->id, resp.destroy_wnd_id); 274 286 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 275 287 288 display_close(disp); 289 rc = loc_service_unregister(sid); 290 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 291 } 292 293 /** display_window_resize() with server returning error response works. */ 294 PCUT_TEST(window_resize_failure) 295 { 296 errno_t rc; 297 service_id_t sid; 298 display_t *disp = NULL; 299 display_wnd_params_t params; 300 display_window_t *wnd; 301 gfx_coord2_t offs; 302 gfx_rect_t nrect; 303 test_response_t resp; 304 305 async_set_fallback_port_handler(test_display_conn, &resp); 306 307 // FIXME This causes this test to be non-reentrant! 308 rc = loc_server_register(test_display_server); 309 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 310 311 rc = loc_service_register(test_display_svc, &sid); 312 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 313 314 rc = display_open(test_display_svc, &disp); 315 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 316 PCUT_ASSERT_NOT_NULL(disp); 317 318 resp.rc = EOK; 319 display_wnd_params_init(¶ms); 320 params.rect.p0.x = 0; 321 params.rect.p0.y = 0; 322 params.rect.p0.x = 100; 323 params.rect.p0.y = 100; 324 325 rc = display_window_create(disp, ¶ms, &test_display_wnd_cb, 326 (void *) &resp, &wnd); 327 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 328 PCUT_ASSERT_NOT_NULL(wnd); 329 330 resp.rc = EIO; 331 resp.window_resize_called = false; 332 offs.x = 11; 333 offs.y = 12; 334 nrect.p0.x = 13; 335 nrect.p0.y = 14; 336 nrect.p1.x = 15; 337 nrect.p1.y = 16; 338 339 rc = display_window_resize(wnd, &offs, &nrect); 340 PCUT_ASSERT_TRUE(resp.window_resize_called); 341 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 342 PCUT_ASSERT_INT_EQUALS(wnd->id, resp.resize_wnd_id); 343 PCUT_ASSERT_INT_EQUALS(offs.x, resp.resize_offs.x); 344 PCUT_ASSERT_INT_EQUALS(offs.y, resp.resize_offs.y); 345 PCUT_ASSERT_INT_EQUALS(nrect.p0.x, resp.resize_nbound.p0.x); 346 PCUT_ASSERT_INT_EQUALS(nrect.p0.y, resp.resize_nbound.p0.y); 347 PCUT_ASSERT_INT_EQUALS(nrect.p1.x, resp.resize_nbound.p1.x); 348 PCUT_ASSERT_INT_EQUALS(nrect.p1.y, resp.resize_nbound.p1.y); 349 350 display_window_destroy(wnd); 351 display_close(disp); 352 rc = loc_service_unregister(sid); 353 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 354 } 355 356 /** display_window_resize() with server returning success response works. */ 357 PCUT_TEST(window_resize_success) 358 { 359 errno_t rc; 360 service_id_t sid; 361 display_t *disp = NULL; 362 display_wnd_params_t params; 363 display_window_t *wnd; 364 gfx_coord2_t offs; 365 gfx_rect_t nrect; 366 test_response_t resp; 367 368 async_set_fallback_port_handler(test_display_conn, &resp); 369 370 // FIXME This causes this test to be non-reentrant! 371 rc = loc_server_register(test_display_server); 372 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 373 374 rc = loc_service_register(test_display_svc, &sid); 375 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 376 377 rc = display_open(test_display_svc, &disp); 378 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 379 PCUT_ASSERT_NOT_NULL(disp); 380 381 resp.rc = EOK; 382 display_wnd_params_init(¶ms); 383 params.rect.p0.x = 0; 384 params.rect.p0.y = 0; 385 params.rect.p0.x = 100; 386 params.rect.p0.y = 100; 387 388 rc = display_window_create(disp, ¶ms, &test_display_wnd_cb, 389 (void *) &resp, &wnd); 390 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 391 PCUT_ASSERT_NOT_NULL(wnd); 392 393 resp.rc = EOK; 394 resp.window_resize_called = false; 395 offs.x = 11; 396 offs.y = 12; 397 nrect.p0.x = 13; 398 nrect.p0.y = 14; 399 nrect.p1.x = 15; 400 nrect.p1.y = 16; 401 402 rc = display_window_resize(wnd, &offs, &nrect); 403 PCUT_ASSERT_TRUE(resp.window_resize_called); 404 PCUT_ASSERT_ERRNO_VAL(resp.rc, rc); 405 PCUT_ASSERT_INT_EQUALS(offs.x, resp.resize_offs.x); 406 PCUT_ASSERT_INT_EQUALS(offs.y, resp.resize_offs.y); 407 PCUT_ASSERT_INT_EQUALS(nrect.p0.x, resp.resize_nbound.p0.x); 408 PCUT_ASSERT_INT_EQUALS(nrect.p0.y, resp.resize_nbound.p0.y); 409 PCUT_ASSERT_INT_EQUALS(nrect.p1.x, resp.resize_nbound.p1.x); 410 PCUT_ASSERT_INT_EQUALS(nrect.p1.y, resp.resize_nbound.p1.y); 411 412 display_window_destroy(wnd); 276 413 display_close(disp); 277 414 rc = loc_service_unregister(sid); … … 792 929 793 930 resp->window_destroy_called = true; 931 resp->destroy_wnd_id = wnd_id; 932 return resp->rc; 933 } 934 935 static errno_t test_window_resize(void *arg, sysarg_t wnd_id, 936 gfx_coord2_t *offs, gfx_rect_t *nrect) 937 { 938 test_response_t *resp = (test_response_t *) arg; 939 940 resp->window_resize_called = true; 941 resp->resize_wnd_id = wnd_id; 942 resp->resize_offs = *offs; 943 resp->resize_nbound = *nrect; 794 944 return resp->rc; 795 945 }
Note:
See TracChangeset
for help on using the changeset viewer.