Changeset 37087c8 in mainline for uspace/lib/ui/test/list.c
- Timestamp:
- 2023-04-19T16:21:36Z (20 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 97d3d9d
- Parents:
- c0757e1f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/list.c
rc0757e1f r37087c8 119 119 } 120 120 121 / /XXX121 /** ui_list_get_cb_arg() returns the callback argument */ 122 122 PCUT_TEST(get_cb_arg) 123 123 { 124 ui_t *ui; 125 ui_window_t *window; 126 ui_wnd_params_t params; 127 ui_list_t *list; 128 errno_t rc; 129 test_resp_t resp; 130 void *arg; 131 132 rc = ui_create_disp(NULL, &ui); 133 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 134 135 ui_wnd_params_init(¶ms); 136 params.caption = "Test"; 137 138 rc = ui_window_create(ui, ¶ms, &window); 139 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 140 141 rc = ui_list_create(window, true, &list); 142 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 143 144 ui_list_set_cb(list, &test_cb, &resp); 145 arg = ui_list_get_cb_arg(list); 146 PCUT_ASSERT_EQUALS((void *)&resp, arg); 147 148 ui_list_destroy(list); 149 ui_window_destroy(window); 150 ui_destroy(ui); 124 151 } 125 152 … … 756 783 } 757 784 758 / /XXX TODO785 /** ui_list_set_cursor() sets list cursor position */ 759 786 PCUT_TEST(set_cursor) 760 787 { 788 ui_t *ui; 789 ui_window_t *window; 790 ui_wnd_params_t params; 791 ui_list_t *list; 792 ui_list_entry_attr_t attr; 793 ui_list_entry_t *e1; 794 ui_list_entry_t *e2; 795 errno_t rc; 796 797 rc = ui_create_disp(NULL, &ui); 798 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 799 800 ui_wnd_params_init(¶ms); 801 params.caption = "Test"; 802 803 rc = ui_window_create(ui, ¶ms, &window); 804 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 805 806 rc = ui_list_create(window, true, &list); 807 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 808 809 ui_list_entry_attr_init(&attr); 810 811 /* Append entry and get pointer to it */ 812 attr.caption = "a"; 813 attr.arg = (void *)1; 814 rc = ui_list_entry_append(list, &attr, &e1); 815 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 816 PCUT_ASSERT_NOT_NULL(e1); 817 818 /* Append entry and get pointer to it */ 819 attr.caption = "b"; 820 attr.arg = (void *)2; 821 rc = ui_list_entry_append(list, &attr, &e2); 822 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 823 PCUT_ASSERT_NOT_NULL(e2); 824 825 /* Append entry */ 826 attr.caption = "c"; 827 attr.arg = (void *)3; 828 rc = ui_list_entry_append(list, &attr, NULL); 829 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 830 831 /* Cursor should be at the first entry */ 832 PCUT_ASSERT_EQUALS(e1, list->cursor); 833 PCUT_ASSERT_INT_EQUALS(0, list->cursor_idx); 834 835 /* Set cursor to the second entry */ 836 ui_list_set_cursor(list, e2); 837 PCUT_ASSERT_EQUALS(e2, list->cursor); 838 PCUT_ASSERT_INT_EQUALS(1, list->cursor_idx); 839 840 ui_list_destroy(list); 841 ui_window_destroy(window); 842 ui_destroy(ui); 761 843 } 762 844 … … 914 996 } 915 997 916 / /XXX998 /** ui_list_entry_get_list() returns the containing list */ 917 999 PCUT_TEST(entry_get_list) 918 1000 { 1001 ui_t *ui; 1002 ui_window_t *window; 1003 ui_wnd_params_t params; 1004 ui_list_t *list; 1005 ui_list_t *elist; 1006 ui_list_entry_attr_t attr; 1007 ui_list_entry_t *entry; 1008 errno_t rc; 1009 1010 rc = ui_create_disp(NULL, &ui); 1011 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1012 1013 ui_wnd_params_init(¶ms); 1014 params.caption = "Test"; 1015 1016 rc = ui_window_create(ui, ¶ms, &window); 1017 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1018 1019 rc = ui_list_create(window, true, &list); 1020 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1021 1022 ui_list_entry_attr_init(&attr); 1023 1024 /* Append entry and get pointer to it */ 1025 attr.caption = "a"; 1026 attr.arg = (void *)1; 1027 entry = NULL; 1028 rc = ui_list_entry_append(list, &attr, &entry); 1029 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1030 PCUT_ASSERT_NOT_NULL(entry); 1031 1032 /* Get the containing list */ 1033 elist = ui_list_entry_get_list(entry); 1034 PCUT_ASSERT_EQUALS(list, elist); 1035 1036 ui_list_destroy(list); 1037 ui_window_destroy(window); 1038 ui_destroy(ui); 919 1039 } 920 1040
Note:
See TracChangeset
for help on using the changeset viewer.