Changes in uspace/lib/ui/test/list.c [5e758e4:28ca31ed] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/test/list.c
r5e758e4 r28ca31ed 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 904 904 } 905 905 906 /** ui_list_entry_move_up() moves entry up */ 907 PCUT_TEST(entry_move_up) 908 { 909 ui_t *ui; 910 ui_window_t *window; 911 ui_wnd_params_t params; 912 ui_list_t *list; 913 ui_list_entry_attr_t attr; 914 ui_list_entry_t *e1, *e2, *e3; 915 ui_list_entry_t *e; 916 errno_t rc; 917 918 rc = ui_create_disp(NULL, &ui); 919 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 920 921 ui_wnd_params_init(¶ms); 922 params.caption = "Test"; 923 924 rc = ui_window_create(ui, ¶ms, &window); 925 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 926 927 rc = ui_list_create(window, true, &list); 928 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 929 930 ui_list_entry_attr_init(&attr); 931 932 /* Create entries */ 933 934 attr.caption = "a"; 935 attr.arg = (void *)1; 936 rc = ui_list_entry_append(list, &attr, &e1); 937 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 938 939 attr.caption = "b"; 940 attr.arg = (void *)2; 941 rc = ui_list_entry_append(list, &attr, &e2); 942 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 943 944 attr.caption = "c"; 945 attr.arg = (void *)3; 946 rc = ui_list_entry_append(list, &attr, &e3); 947 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 948 949 e = ui_list_first(list); 950 PCUT_ASSERT_EQUALS(e1, e); 951 952 /* Moving first entry up should have no effect */ 953 ui_list_entry_move_up(e1); 954 955 e = ui_list_first(list); 956 PCUT_ASSERT_EQUALS(e1, e); 957 958 e = ui_list_next(e); 959 PCUT_ASSERT_EQUALS(e2, e); 960 961 e = ui_list_next(e); 962 PCUT_ASSERT_EQUALS(e3, e); 963 964 e = ui_list_next(e); 965 PCUT_ASSERT_NULL(e); 966 967 /* Move second entry up */ 968 ui_list_entry_move_up(e2); 969 970 e = ui_list_first(list); 971 PCUT_ASSERT_EQUALS(e2, e); 972 973 e = ui_list_next(e); 974 PCUT_ASSERT_EQUALS(e1, e); 975 976 e = ui_list_next(e); 977 PCUT_ASSERT_EQUALS(e3, e); 978 979 e = ui_list_next(e); 980 PCUT_ASSERT_NULL(e); 981 982 ui_list_destroy(list); 983 ui_window_destroy(window); 984 ui_destroy(ui); 985 } 986 987 /** ui_list_entry_move_down() moves entry down */ 988 PCUT_TEST(entry_move_down) 989 { 990 ui_t *ui; 991 ui_window_t *window; 992 ui_wnd_params_t params; 993 ui_list_t *list; 994 ui_list_entry_attr_t attr; 995 ui_list_entry_t *e1, *e2, *e3; 996 ui_list_entry_t *e; 997 errno_t rc; 998 999 rc = ui_create_disp(NULL, &ui); 1000 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1001 1002 ui_wnd_params_init(¶ms); 1003 params.caption = "Test"; 1004 1005 rc = ui_window_create(ui, ¶ms, &window); 1006 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1007 1008 rc = ui_list_create(window, true, &list); 1009 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1010 1011 ui_list_entry_attr_init(&attr); 1012 1013 /* Create entries */ 1014 1015 attr.caption = "a"; 1016 attr.arg = (void *)1; 1017 rc = ui_list_entry_append(list, &attr, &e1); 1018 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1019 1020 attr.caption = "b"; 1021 attr.arg = (void *)2; 1022 rc = ui_list_entry_append(list, &attr, &e2); 1023 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1024 1025 attr.caption = "c"; 1026 attr.arg = (void *)3; 1027 rc = ui_list_entry_append(list, &attr, &e3); 1028 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 1029 1030 e = ui_list_first(list); 1031 PCUT_ASSERT_EQUALS(e1, e); 1032 1033 /* Moving last entry down should have no effect */ 1034 ui_list_entry_move_down(e3); 1035 1036 e = ui_list_first(list); 1037 PCUT_ASSERT_EQUALS(e1, e); 1038 1039 e = ui_list_next(e); 1040 PCUT_ASSERT_EQUALS(e2, e); 1041 1042 e = ui_list_next(e); 1043 PCUT_ASSERT_EQUALS(e3, e); 1044 1045 e = ui_list_next(e); 1046 PCUT_ASSERT_NULL(e); 1047 1048 /* Move second-to-last entry down */ 1049 ui_list_entry_move_down(e2); 1050 1051 e = ui_list_first(list); 1052 PCUT_ASSERT_EQUALS(e1, e); 1053 1054 e = ui_list_next(e); 1055 PCUT_ASSERT_EQUALS(e3, e); 1056 1057 e = ui_list_next(e); 1058 PCUT_ASSERT_EQUALS(e2, e); 1059 1060 e = ui_list_next(e); 1061 PCUT_ASSERT_NULL(e); 1062 1063 ui_list_destroy(list); 1064 ui_window_destroy(window); 1065 ui_destroy(ui); 1066 } 1067 906 1068 /** ui_list_entry_delete() deletes entry */ 907 1069 PCUT_TEST(entry_delete)
Note:
See TracChangeset
for help on using the changeset viewer.