Changeset 26c90dd in mainline
- Timestamp:
- 2022-03-21T12:40:57Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d4ea1f6
- Parents:
- 1026cc4
- git-author:
- Jiri Svoboda <jiri@…> (2022-03-20 20:38:40)
- git-committer:
- Jiri Svoboda <jiri@…> (2022-03-21 12:40:57)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/scrollbar.c
r1026cc4 r26c90dd 552 552 553 553 /** Press, update and release scrollbar */ 554 PCUT_TEST( press_uodate_release)554 PCUT_TEST(thumb_press_update_release) 555 555 { 556 556 errno_t rc; … … 607 607 PCUT_ASSERT_TRUE(resp.moved); 608 608 PCUT_ASSERT_INT_EQUALS(20, scrollbar->pos); 609 610 ui_scrollbar_destroy(scrollbar); 611 ui_resource_destroy(resource); 612 613 rc = gfx_context_delete(gc); 614 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 615 } 616 617 /** Press and release up through */ 618 PCUT_TEST(up_through_press_release) 619 { 620 errno_t rc; 621 gfx_context_t *gc = NULL; 622 test_gc_t tgc; 623 ui_resource_t *resource = NULL; 624 gfx_coord2_t pos; 625 gfx_rect_t rect; 626 ui_scrollbar_t *scrollbar; 627 test_cb_resp_t resp; 628 629 memset(&tgc, 0, sizeof(tgc)); 630 rc = gfx_context_new(&ops, &tgc, &gc); 631 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 632 633 rc = ui_resource_create(gc, false, &resource); 634 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 635 PCUT_ASSERT_NOT_NULL(resource); 636 637 rc = ui_scrollbar_create(resource, &scrollbar); 638 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 639 640 rect.p0.x = 10; 641 rect.p0.y = 20; 642 rect.p1.x = 110; 643 rect.p1.y = 120; 644 ui_scrollbar_set_rect(scrollbar, &rect); 645 646 resp.page_up = false; 647 ui_scrollbar_set_cb(scrollbar, &test_scrollbar_cb, &resp); 648 649 PCUT_ASSERT_FALSE(scrollbar->up_through_held); 650 651 ui_scrollbar_up_through_press(scrollbar); 652 PCUT_ASSERT_TRUE(scrollbar->up_through_held); 653 PCUT_ASSERT_TRUE(resp.page_up); 654 655 /* Position does not matter here */ 656 pos.x = 11; 657 pos.y = 22; 658 659 ui_scrollbar_release(scrollbar, &pos); 660 PCUT_ASSERT_FALSE(scrollbar->up_through_held); 661 662 ui_scrollbar_destroy(scrollbar); 663 ui_resource_destroy(resource); 664 665 rc = gfx_context_delete(gc); 666 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 667 } 668 669 /** Press and release down through */ 670 PCUT_TEST(down_through_press_release) 671 { 672 errno_t rc; 673 gfx_context_t *gc = NULL; 674 test_gc_t tgc; 675 ui_resource_t *resource = NULL; 676 gfx_coord2_t pos; 677 gfx_rect_t rect; 678 ui_scrollbar_t *scrollbar; 679 test_cb_resp_t resp; 680 681 memset(&tgc, 0, sizeof(tgc)); 682 rc = gfx_context_new(&ops, &tgc, &gc); 683 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 684 685 rc = ui_resource_create(gc, false, &resource); 686 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 687 PCUT_ASSERT_NOT_NULL(resource); 688 689 rc = ui_scrollbar_create(resource, &scrollbar); 690 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 691 692 rect.p0.x = 10; 693 rect.p0.y = 20; 694 rect.p1.x = 110; 695 rect.p1.y = 120; 696 ui_scrollbar_set_rect(scrollbar, &rect); 697 698 resp.page_down = false; 699 ui_scrollbar_set_cb(scrollbar, &test_scrollbar_cb, &resp); 700 701 PCUT_ASSERT_FALSE(scrollbar->down_through_held); 702 703 ui_scrollbar_down_through_press(scrollbar); 704 PCUT_ASSERT_TRUE(scrollbar->down_through_held); 705 PCUT_ASSERT_TRUE(resp.page_down); 706 707 /* Position does not matter here */ 708 pos.x = 11; 709 pos.y = 22; 710 711 ui_scrollbar_release(scrollbar, &pos); 712 PCUT_ASSERT_FALSE(scrollbar->down_through_held); 609 713 610 714 ui_scrollbar_destroy(scrollbar); … … 921 1025 claim = ui_scrollbar_pos_event(scrollbar, &event); 922 1026 PCUT_ASSERT_TRUE(scrollbar->btn_up->held); 1027 PCUT_ASSERT_EQUALS(ui_claimed, claim); 1028 1029 ui_scrollbar_destroy(scrollbar); 1030 ui_resource_destroy(resource); 1031 1032 rc = gfx_context_delete(gc); 1033 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1034 } 1035 1036 /** ui_scrollbar_pos_event() detects up through press/release */ 1037 PCUT_TEST(pos_event_press_release_up_through) 1038 { 1039 errno_t rc; 1040 gfx_context_t *gc = NULL; 1041 test_gc_t tgc; 1042 ui_resource_t *resource = NULL; 1043 ui_scrollbar_t *scrollbar; 1044 ui_evclaim_t claim; 1045 pos_event_t event; 1046 gfx_rect_t rect; 1047 1048 memset(&tgc, 0, sizeof(tgc)); 1049 rc = gfx_context_new(&ops, &tgc, &gc); 1050 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1051 1052 rc = ui_resource_create(gc, false, &resource); 1053 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1054 PCUT_ASSERT_NOT_NULL(resource); 1055 1056 rc = ui_scrollbar_create(resource, &scrollbar); 1057 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1058 1059 PCUT_ASSERT_FALSE(scrollbar->up_through_held); 1060 1061 rect.p0.x = 20; 1062 rect.p0.y = 10; 1063 rect.p1.x = 100; 1064 rect.p1.y = 30; 1065 ui_scrollbar_set_rect(scrollbar, &rect); 1066 1067 /* Need to move thumb so that up through can be accessed */ 1068 ui_scrollbar_set_pos(scrollbar, 42); 1069 1070 /* Press inside up through is claimed and depresses it */ 1071 event.type = POS_PRESS; 1072 event.hpos = 50; 1073 event.vpos = 20; 1074 claim = ui_scrollbar_pos_event(scrollbar, &event); 1075 PCUT_ASSERT_TRUE(scrollbar->up_through_held); 1076 PCUT_ASSERT_EQUALS(ui_claimed, claim); 1077 1078 /* Release outside (or anywhere) is claimed and relases up through */ 1079 event.type = POS_RELEASE; 1080 event.hpos = 41; 1081 event.vpos = 32; 1082 claim = ui_scrollbar_pos_event(scrollbar, &event); 1083 PCUT_ASSERT_FALSE(scrollbar->up_through_held); 1084 PCUT_ASSERT_EQUALS(ui_claimed, claim); 1085 1086 ui_scrollbar_destroy(scrollbar); 1087 ui_resource_destroy(resource); 1088 1089 rc = gfx_context_delete(gc); 1090 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1091 } 1092 1093 /** ui_scrollbar_pos_event() detects down through press/release */ 1094 PCUT_TEST(pos_event_press_release_down_through) 1095 { 1096 errno_t rc; 1097 gfx_context_t *gc = NULL; 1098 test_gc_t tgc; 1099 ui_resource_t *resource = NULL; 1100 ui_scrollbar_t *scrollbar; 1101 ui_evclaim_t claim; 1102 pos_event_t event; 1103 gfx_rect_t rect; 1104 1105 memset(&tgc, 0, sizeof(tgc)); 1106 rc = gfx_context_new(&ops, &tgc, &gc); 1107 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1108 1109 rc = ui_resource_create(gc, false, &resource); 1110 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1111 PCUT_ASSERT_NOT_NULL(resource); 1112 1113 rc = ui_scrollbar_create(resource, &scrollbar); 1114 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1115 1116 PCUT_ASSERT_FALSE(scrollbar->up_through_held); 1117 1118 rect.p0.x = 20; 1119 rect.p0.y = 10; 1120 rect.p1.x = 100; 1121 rect.p1.y = 30; 1122 ui_scrollbar_set_rect(scrollbar, &rect); 1123 1124 /* Press inside down through is claimed and depresses it */ 1125 event.type = POS_PRESS; 1126 event.hpos = 70; 1127 event.vpos = 20; 1128 claim = ui_scrollbar_pos_event(scrollbar, &event); 1129 PCUT_ASSERT_TRUE(scrollbar->down_through_held); 1130 PCUT_ASSERT_EQUALS(ui_claimed, claim); 1131 1132 /* Release outside (or anywhere) is claimed and relases up through */ 1133 event.type = POS_RELEASE; 1134 event.hpos = 41; 1135 event.vpos = 32; 1136 claim = ui_scrollbar_pos_event(scrollbar, &event); 1137 PCUT_ASSERT_FALSE(scrollbar->down_through_held); 923 1138 PCUT_ASSERT_EQUALS(ui_claimed, claim); 924 1139
Note:
See TracChangeset
for help on using the changeset viewer.