Changeset e022819 in mainline for uspace/srv/hid/display/test/window.c
- Timestamp:
- 2020-03-14T00:30:53Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 03c8081
- Parents:
- 1e4a937
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/test/window.c
r1e4a937 re022819 281 281 } 282 282 283 /** Test ds_window_resize_req() */ 284 PCUT_TEST(window_resize_req) 285 { 286 gfx_context_t *gc; 287 ds_display_t *disp; 288 ds_client_t *client; 289 ds_window_t *wnd; 290 display_wnd_params_t params; 291 gfx_coord2_t pos; 292 errno_t rc; 293 294 rc = gfx_context_new(&dummy_ops, NULL, &gc); 295 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 296 297 rc = ds_display_create(gc, &disp); 298 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 299 300 rc = ds_client_create(disp, NULL, NULL, &client); 301 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 302 303 display_wnd_params_init(¶ms); 304 params.rect.p0.x = params.rect.p0.y = 0; 305 params.rect.p1.x = params.rect.p1.y = 1; 306 307 rc = ds_window_create(client, ¶ms, &wnd); 308 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 309 310 PCUT_ASSERT_INT_EQUALS(dsw_idle, wnd->state); 311 312 pos.x = 42; 313 pos.y = 43; 314 ds_window_resize_req(wnd, display_wr_top_right, &pos); 315 316 PCUT_ASSERT_INT_EQUALS(dsw_resizing, wnd->state); 317 PCUT_ASSERT_INT_EQUALS(display_wr_top_right, wnd->rsztype); 318 PCUT_ASSERT_INT_EQUALS(pos.x, wnd->orig_pos.x); 319 PCUT_ASSERT_INT_EQUALS(pos.y, wnd->orig_pos.y); 320 321 ds_window_destroy(wnd); 322 ds_client_destroy(client); 323 ds_display_destroy(disp); 324 } 325 326 PCUT_TEST(window_calc_resize) 327 { 328 ds_display_t *disp; 329 ds_client_t *client; 330 ds_window_t *wnd; 331 display_wnd_params_t params; 332 gfx_coord2_t dresize; 333 gfx_rect_t nrect; 334 errno_t rc; 335 336 rc = ds_display_create(NULL, &disp); 337 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 338 339 rc = ds_client_create(disp, NULL, NULL, &client); 340 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 341 342 display_wnd_params_init(¶ms); 343 params.rect.p0.x = 10; 344 params.rect.p0.y = 11; 345 params.rect.p1.x = 20; 346 params.rect.p1.y = 21; 347 348 rc = ds_window_create(client, ¶ms, &wnd); 349 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 350 351 wnd->state = dsw_resizing; 352 dresize.x = 5; 353 dresize.y = 6; 354 355 wnd->rsztype = display_wr_top; 356 ds_window_calc_resize(wnd, &dresize, &nrect); 357 PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x); 358 PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y); 359 PCUT_ASSERT_INT_EQUALS(20, nrect.p1.x); 360 PCUT_ASSERT_INT_EQUALS(21, nrect.p1.y); 361 362 wnd->rsztype = display_wr_top_left; 363 ds_window_calc_resize(wnd, &dresize, &nrect); 364 PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x); 365 PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y); 366 PCUT_ASSERT_INT_EQUALS(20, nrect.p1.x); 367 PCUT_ASSERT_INT_EQUALS(21, nrect.p1.y); 368 369 wnd->rsztype = display_wr_left; 370 ds_window_calc_resize(wnd, &dresize, &nrect); 371 PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x); 372 PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y); 373 PCUT_ASSERT_INT_EQUALS(20, nrect.p1.x); 374 PCUT_ASSERT_INT_EQUALS(21, nrect.p1.y); 375 376 wnd->rsztype = display_wr_bottom_left; 377 ds_window_calc_resize(wnd, &dresize, &nrect); 378 PCUT_ASSERT_INT_EQUALS(15, nrect.p0.x); 379 PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y); 380 PCUT_ASSERT_INT_EQUALS(20, nrect.p1.x); 381 PCUT_ASSERT_INT_EQUALS(27, nrect.p1.y); 382 383 wnd->rsztype = display_wr_bottom; 384 ds_window_calc_resize(wnd, &dresize, &nrect); 385 PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x); 386 PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y); 387 PCUT_ASSERT_INT_EQUALS(20, nrect.p1.x); 388 PCUT_ASSERT_INT_EQUALS(27, nrect.p1.y); 389 390 wnd->rsztype = display_wr_bottom_right; 391 ds_window_calc_resize(wnd, &dresize, &nrect); 392 PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x); 393 PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y); 394 PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x); 395 PCUT_ASSERT_INT_EQUALS(27, nrect.p1.y); 396 397 wnd->rsztype = display_wr_right; 398 ds_window_calc_resize(wnd, &dresize, &nrect); 399 PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x); 400 PCUT_ASSERT_INT_EQUALS(11, nrect.p0.y); 401 PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x); 402 PCUT_ASSERT_INT_EQUALS(21, nrect.p1.y); 403 404 wnd->rsztype = display_wr_top_right; 405 ds_window_calc_resize(wnd, &dresize, &nrect); 406 PCUT_ASSERT_INT_EQUALS(10, nrect.p0.x); 407 PCUT_ASSERT_INT_EQUALS(17, nrect.p0.y); 408 PCUT_ASSERT_INT_EQUALS(25, nrect.p1.x); 409 PCUT_ASSERT_INT_EQUALS(21, nrect.p1.y); 410 411 ds_window_destroy(wnd); 412 ds_client_destroy(client); 413 ds_display_destroy(disp); 414 } 415 283 416 static errno_t dummy_set_color(void *arg, gfx_color_t *color) 284 417 {
Note:
See TracChangeset
for help on using the changeset viewer.