Changeset aefdccd in mainline for uspace/lib/ui/test/list.c


Ignore:
Timestamp:
2025-10-20T06:14:54Z (7 weeks ago)
Author:
GitHub <noreply@…>
Parents:
adbd7e1 (diff), 3e41cc4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
boba-buba <120932204+boba-buba@…> (2025-10-20 06:14:54)
git-committer:
GitHub <noreply@…> (2025-10-20 06:14:54)
Message:

Merge branch 'HelenOS:master' into ticket/packet-capture

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/test/list.c

    radbd7e1 raefdccd  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    30643064}
    30653065
     3066/** ui_list_save_pos() / ui_list_restore_pos() saves/restores position */
     3067PCUT_TEST(save_pos_restore_pos)
     3068{
     3069        ui_t *ui;
     3070        ui_window_t *window;
     3071        ui_wnd_params_t params;
     3072        ui_list_t *list;
     3073        ui_list_entry_t *a, *b;
     3074        ui_list_entry_attr_t attr;
     3075        ui_list_pos_t pos;
     3076        test_resp_t resp;
     3077        errno_t rc;
     3078
     3079        rc = ui_create_disp(NULL, &ui);
     3080        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     3081
     3082        ui_wnd_params_init(&params);
     3083        params.caption = "Test";
     3084
     3085        rc = ui_window_create(ui, &params, &window);
     3086        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     3087
     3088        rc = ui_list_create(window, true, &list);
     3089        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     3090
     3091        ui_list_set_cb(list, &test_cb, &resp);
     3092
     3093        ui_list_entry_attr_init(&attr);
     3094
     3095        attr.caption = "a";
     3096        attr.arg = (void *)2;
     3097        rc = ui_list_entry_append(list, &attr, &a);
     3098        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     3099
     3100        attr.caption = "b";
     3101        attr.arg = (void *)1;
     3102        rc = ui_list_entry_append(list, &attr, &b);
     3103        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     3104
     3105        ui_list_set_cursor(list, b);
     3106
     3107        ui_list_save_pos(list, &pos);
     3108
     3109        /* Empty and re-build list. */
     3110
     3111        ui_list_entry_destroy(a);
     3112        ui_list_entry_destroy(b);
     3113
     3114        ui_list_entry_attr_init(&attr);
     3115
     3116        attr.caption = "a";
     3117        attr.arg = (void *)2;
     3118        rc = ui_list_entry_append(list, &attr, &a);
     3119        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     3120
     3121        attr.caption = "b";
     3122        attr.arg = (void *)1;
     3123        rc = ui_list_entry_append(list, &attr, &b);
     3124        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     3125
     3126        ui_list_restore_pos(list, &pos);
     3127
     3128        PCUT_ASSERT_STR_EQUALS("b", list->cursor->caption);
     3129
     3130        ui_list_destroy(list);
     3131        ui_window_destroy(window);
     3132        ui_destroy(ui);
     3133}
     3134
    30663135static void test_list_activate_req(ui_list_t *list, void *arg)
    30673136{
Note: See TracChangeset for help on using the changeset viewer.