Changeset 37087c8 in mainline


Ignore:
Timestamp:
2023-04-19T16:21:36Z (13 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
97d3d9d
Parents:
c0757e1f
Message:

Fill in unimplemented UI list tests

File:
1 edited

Legend:

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

    rc0757e1f r37087c8  
    119119}
    120120
    121 //XXX
     121/** ui_list_get_cb_arg() returns the callback argument */
    122122PCUT_TEST(get_cb_arg)
    123123{
     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(&params);
     136        params.caption = "Test";
     137
     138        rc = ui_window_create(ui, &params, &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);
    124151}
    125152
     
    756783}
    757784
    758 //XXX TODO
     785/** ui_list_set_cursor() sets list cursor position */
    759786PCUT_TEST(set_cursor)
    760787{
     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(&params);
     801        params.caption = "Test";
     802
     803        rc = ui_window_create(ui, &params, &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);
    761843}
    762844
     
    914996}
    915997
    916 //XXX
     998/** ui_list_entry_get_list() returns the containing list */
    917999PCUT_TEST(entry_get_list)
    9181000{
     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(&params);
     1014        params.caption = "Test";
     1015
     1016        rc = ui_window_create(ui, &params, &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);
    9191039}
    9201040
Note: See TracChangeset for help on using the changeset viewer.