Changeset 29a5a99 in mainline for uspace/srv/hid/display/test/display.c
- Timestamp:
- 2022-12-04T10:42:48Z (2 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 14b4577
- Parents:
- 795c6f7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/display/test/display.c
r795c6f7 r29a5a99 601 601 } 602 602 603 /** ds_display_update_max_rect() updates maximization rectangle */ 604 PCUT_TEST(display_update_max_rect) 605 { 606 ds_display_t *disp; 607 ds_seat_t *seat; 608 ds_client_t *client; 609 ds_window_t *wnd; 610 display_wnd_params_t params; 611 errno_t rc; 612 613 rc = ds_display_create(NULL, df_none, &disp); 614 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 615 616 rc = ds_seat_create(disp, &seat); 617 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 618 619 rc = ds_client_create(disp, NULL, NULL, &client); 620 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 621 622 /* 623 * We need to set display dimensions Here we do it directly 624 * instead of adding a display device. 625 */ 626 disp->rect.p0.x = 0; 627 disp->rect.p0.y = 0; 628 disp->rect.p1.x = 500; 629 disp->rect.p1.y = 500; 630 631 /* Set maximize rectangle as well */ 632 disp->max_rect = disp->rect; 633 634 /* A panel-like window at the bottom */ 635 display_wnd_params_init(¶ms); 636 params.flags |= wndf_setpos; 637 params.pos.x = 0; 638 params.pos.y = 450; 639 params.rect.p0.x = 0; 640 params.rect.p0.y = 0; 641 params.rect.p1.x = 500; 642 params.rect.p1.y = 50; 643 644 rc = ds_window_create(client, ¶ms, &wnd); 645 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 646 647 /* 648 * At this point the maximize rect should be unaltered because 649 * the avoid flag has not been set. 650 */ 651 PCUT_ASSERT_INT_EQUALS(0, disp->max_rect.p0.x); 652 PCUT_ASSERT_INT_EQUALS(0, disp->max_rect.p0.y); 653 PCUT_ASSERT_INT_EQUALS(500, disp->max_rect.p1.x); 654 PCUT_ASSERT_INT_EQUALS(500, disp->max_rect.p1.y); 655 656 wnd->flags |= wndf_avoid; 657 658 /* Update maximize rectangle */ 659 ds_display_update_max_rect(disp); 660 661 /* Verify maximize rectangle */ 662 PCUT_ASSERT_INT_EQUALS(0, disp->max_rect.p0.x); 663 PCUT_ASSERT_INT_EQUALS(0, disp->max_rect.p0.y); 664 PCUT_ASSERT_INT_EQUALS(500, disp->max_rect.p1.x); 665 PCUT_ASSERT_INT_EQUALS(450, disp->max_rect.p1.y); 666 667 ds_window_destroy(wnd); 668 ds_client_destroy(client); 669 ds_seat_destroy(seat); 670 ds_display_destroy(disp); 671 } 672 673 /** Cropping maximization rectangle from the top */ 674 PCUT_TEST(display_crop_max_rect_top) 675 { 676 gfx_rect_t arect; 677 gfx_rect_t mrect; 678 679 arect.p0.x = 10; 680 arect.p0.y = 20; 681 arect.p1.x = 30; 682 arect.p1.y = 5; 683 684 mrect.p0.x = 10; 685 mrect.p0.y = 20; 686 mrect.p1.x = 30; 687 mrect.p1.y = 40; 688 689 ds_display_crop_max_rect(&arect, &mrect); 690 691 PCUT_ASSERT_INT_EQUALS(10, mrect.p0.x); 692 PCUT_ASSERT_INT_EQUALS(5, mrect.p0.y); 693 PCUT_ASSERT_INT_EQUALS(30, mrect.p1.x); 694 PCUT_ASSERT_INT_EQUALS(40, mrect.p1.y); 695 } 696 697 /** Cropping maximization rectangle from the bottom */ 698 PCUT_TEST(display_crop_max_rect_bottom) 699 { 700 gfx_rect_t arect; 701 gfx_rect_t mrect; 702 703 arect.p0.x = 10; 704 arect.p0.y = 35; 705 arect.p1.x = 30; 706 arect.p1.y = 40; 707 708 mrect.p0.x = 10; 709 mrect.p0.y = 20; 710 mrect.p1.x = 30; 711 mrect.p1.y = 40; 712 713 ds_display_crop_max_rect(&arect, &mrect); 714 715 PCUT_ASSERT_INT_EQUALS(10, mrect.p0.x); 716 PCUT_ASSERT_INT_EQUALS(20, mrect.p0.y); 717 PCUT_ASSERT_INT_EQUALS(30, mrect.p1.x); 718 PCUT_ASSERT_INT_EQUALS(35, mrect.p1.y); 719 } 720 721 /** Cropping maximization rectangle from the left */ 722 PCUT_TEST(display_crop_max_rect_left) 723 { 724 gfx_rect_t arect; 725 gfx_rect_t mrect; 726 727 arect.p0.x = 10; 728 arect.p0.y = 20; 729 arect.p1.x = 15; 730 arect.p1.y = 40; 731 732 mrect.p0.x = 10; 733 mrect.p0.y = 20; 734 mrect.p1.x = 30; 735 mrect.p1.y = 40; 736 737 ds_display_crop_max_rect(&arect, &mrect); 738 739 PCUT_ASSERT_INT_EQUALS(15, mrect.p0.x); 740 PCUT_ASSERT_INT_EQUALS(20, mrect.p0.y); 741 PCUT_ASSERT_INT_EQUALS(30, mrect.p1.x); 742 PCUT_ASSERT_INT_EQUALS(40, mrect.p1.y); 743 } 744 745 /** Cropping maximization rectangle from the right */ 746 PCUT_TEST(display_crop_max_rect_right) 747 { 748 gfx_rect_t arect; 749 gfx_rect_t mrect; 750 751 arect.p0.x = 25; 752 arect.p0.y = 20; 753 arect.p1.x = 30; 754 arect.p1.y = 40; 755 756 mrect.p0.x = 10; 757 mrect.p0.y = 20; 758 mrect.p1.x = 30; 759 mrect.p1.y = 40; 760 761 ds_display_crop_max_rect(&arect, &mrect); 762 763 PCUT_ASSERT_INT_EQUALS(10, mrect.p0.x); 764 PCUT_ASSERT_INT_EQUALS(20, mrect.p0.y); 765 PCUT_ASSERT_INT_EQUALS(25, mrect.p1.x); 766 PCUT_ASSERT_INT_EQUALS(40, mrect.p1.y); 767 } 768 603 769 PCUT_EXPORT(display);
Note:
See TracChangeset
for help on using the changeset viewer.