Changes in uspace/lib/ui/test/list.c [5e758e4:7cf5ddb] in mainline
- File:
-
- 1 edited
-
uspace/lib/ui/test/list.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/list.c
r5e758e4 r7cf5ddb 119 119 } 120 120 121 /** ui_list_get_cb_arg() returns the callback argument */122 PCUT_TEST(get_cb_arg)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);151 }152 153 121 /** ui_list_entry_height() gives the correct height */ 154 122 PCUT_TEST(entry_height) … … 783 751 } 784 752 785 /** ui_list_set_cursor() sets list cursor position */786 PCUT_TEST(set_cursor)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);843 }844 845 753 /** ui_list_entry_attr_init() initializes entry attribute structure */ 846 754 PCUT_TEST(entry_attr_init) … … 990 898 arg = ui_list_entry_get_arg(entry); 991 899 PCUT_ASSERT_EQUALS(attr.arg, arg); 992 993 ui_list_destroy(list);994 ui_window_destroy(window);995 ui_destroy(ui);996 }997 998 /** ui_list_entry_get_list() returns the containing list */999 PCUT_TEST(entry_get_list)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);1039 }1040 1041 /** ui_list_entry_set_caption() sets entry captino */1042 PCUT_TEST(entry_set_caption)1043 {1044 ui_t *ui;1045 ui_window_t *window;1046 ui_wnd_params_t params;1047 ui_list_t *list;1048 ui_list_entry_attr_t attr;1049 ui_list_entry_t *entry;1050 errno_t rc;1051 1052 rc = ui_create_disp(NULL, &ui);1053 PCUT_ASSERT_ERRNO_VAL(EOK, rc);1054 1055 ui_wnd_params_init(¶ms);1056 params.caption = "Test";1057 1058 rc = ui_window_create(ui, ¶ms, &window);1059 PCUT_ASSERT_ERRNO_VAL(EOK, rc);1060 1061 rc = ui_list_create(window, true, &list);1062 PCUT_ASSERT_ERRNO_VAL(EOK, rc);1063 1064 ui_list_entry_attr_init(&attr);1065 1066 /* Append entry and get pointer to it */1067 attr.caption = "a";1068 attr.arg = (void *)1;1069 entry = NULL;1070 rc = ui_list_entry_append(list, &attr, &entry);1071 PCUT_ASSERT_ERRNO_VAL(EOK, rc);1072 PCUT_ASSERT_NOT_NULL(entry);1073 1074 /* Change caption */1075 rc = ui_list_entry_set_caption(entry, "b");1076 PCUT_ASSERT_ERRNO_VAL(EOK, rc);1077 PCUT_ASSERT_STR_EQUALS("b", entry->caption);1078 900 1079 901 ui_list_destroy(list);
Note:
See TracChangeset
for help on using the changeset viewer.
