Changeset 806d761 in mainline for uspace/lib/tbarcfg/test/tbarcfg.c


Ignore:
Timestamp:
2024-02-07T23:44:59Z (4 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
242e3c3
Parents:
74cb6610
Message:

Start menu should have 'open in terminal' functionality

Makes it easier for the user and if we are running in console mode,
we correctly start the application, instead of failing to start a
terminal.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/tbarcfg/test/tbarcfg.c

    r74cb6610 r806d761  
    11/*
    2  * Copyright (c) 2023 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    7676        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    7777
    78         rc = smenu_entry_create(tbcfg, "A", "a", &e1);
     78        rc = smenu_entry_create(tbcfg, "A", "a", false, &e1);
    7979        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    8080        PCUT_ASSERT_NOT_NULL(e1);
    8181
    82         rc = smenu_entry_create(tbcfg, "B", "b", &e2);
     82        rc = smenu_entry_create(tbcfg, "B", "b", false, &e2);
    8383        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    8484        PCUT_ASSERT_NOT_NULL(e2);
    8585
    8686        /* Create entry without getting a pointer to it */
    87         rc = smenu_entry_create(tbcfg, "C", "c", NULL);
     87        rc = smenu_entry_create(tbcfg, "C", "c", false, NULL);
    8888        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    8989
     
    102102
    103103/** Getting menu entry properties */
    104 PCUT_TEST(get_caption_cmd)
     104PCUT_TEST(get_caption_cmd_term)
    105105{
    106106        errno_t rc;
     
    110110        const char *caption;
    111111        const char *cmd;
    112 
    113         p = tmpnam(fname);
    114         PCUT_ASSERT_NOT_NULL(p);
    115 
    116         rc = tbarcfg_create(fname, &tbcfg);
    117         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    118 
    119         rc = smenu_entry_create(tbcfg, "A", "a", &e);
     112        bool terminal;
     113
     114        p = tmpnam(fname);
     115        PCUT_ASSERT_NOT_NULL(p);
     116
     117        rc = tbarcfg_create(fname, &tbcfg);
     118        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     119
     120        rc = smenu_entry_create(tbcfg, "A", "a", false, &e);
    120121        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    121122
     
    124125        cmd = smenu_entry_get_cmd(e);
    125126        PCUT_ASSERT_STR_EQUALS("a", cmd);
     127        terminal = smenu_entry_get_terminal(e);
     128        PCUT_ASSERT_FALSE(terminal);
    126129
    127130        tbarcfg_close(tbcfg);
     
    130133
    131134/** Setting menu entry properties */
    132 PCUT_TEST(set_caption_cmd)
     135PCUT_TEST(set_caption_cmd_term)
    133136{
    134137        errno_t rc;
     
    138141        const char *caption;
    139142        const char *cmd;
    140 
    141         p = tmpnam(fname);
    142         PCUT_ASSERT_NOT_NULL(p);
    143 
    144         rc = tbarcfg_create(fname, &tbcfg);
    145         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    146 
    147         rc = smenu_entry_create(tbcfg, "A", "a", &e);
     143        bool terminal;
     144
     145        p = tmpnam(fname);
     146        PCUT_ASSERT_NOT_NULL(p);
     147
     148        rc = tbarcfg_create(fname, &tbcfg);
     149        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     150
     151        rc = smenu_entry_create(tbcfg, "A", "a", false, &e);
    148152        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    149153
     
    152156        cmd = smenu_entry_get_cmd(e);
    153157        PCUT_ASSERT_STR_EQUALS("a", cmd);
     158        terminal = smenu_entry_get_terminal(e);
     159        PCUT_ASSERT_FALSE(terminal);
    154160
    155161        /* Set properties */
     
    158164        rc = smenu_entry_set_cmd(e, "b");
    159165        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     166        smenu_entry_set_terminal(e, true);
    160167
    161168        rc = smenu_entry_save(e);
     
    167174        cmd = smenu_entry_get_cmd(e);
    168175        PCUT_ASSERT_STR_EQUALS("b", cmd);
     176        terminal = smenu_entry_get_terminal(e);
     177        PCUT_ASSERT_TRUE(terminal);
    169178
    170179        tbarcfg_close(tbcfg);
     
    197206        const char *caption;
    198207        const char *cmd;
    199 
    200         p = tmpnam(fname);
    201         PCUT_ASSERT_NOT_NULL(p);
    202 
    203         rc = tbarcfg_create(fname, &tbcfg);
    204         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    205 
    206         rc = smenu_entry_create(tbcfg, "A", "a", &e);
     208        bool terminal;
     209
     210        p = tmpnam(fname);
     211        PCUT_ASSERT_NOT_NULL(p);
     212
     213        rc = tbarcfg_create(fname, &tbcfg);
     214        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     215
     216        rc = smenu_entry_create(tbcfg, "A", "a", false, &e);
    207217        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    208218        PCUT_ASSERT_NOT_NULL(e);
     
    212222        cmd = smenu_entry_get_cmd(e);
    213223        PCUT_ASSERT_STR_EQUALS("a", cmd);
     224        terminal = smenu_entry_get_terminal(e);
     225        PCUT_ASSERT_FALSE(terminal);
     226
     227        smenu_entry_destroy(e);
     228
     229        rc = smenu_entry_create(tbcfg, "B", "b", true, &e);
     230        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     231        PCUT_ASSERT_NOT_NULL(e);
     232
     233        caption = smenu_entry_get_caption(e);
     234        PCUT_ASSERT_STR_EQUALS("B", caption);
     235        cmd = smenu_entry_get_cmd(e);
     236        PCUT_ASSERT_STR_EQUALS("b", cmd);
     237        terminal = smenu_entry_get_terminal(e);
     238        PCUT_ASSERT_TRUE(terminal);
     239
     240        smenu_entry_destroy(e);
    214241
    215242        tbarcfg_close(tbcfg);
     
    231258        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    232259
    233         rc = smenu_entry_create(tbcfg, "A", "a", &e);
     260        rc = smenu_entry_create(tbcfg, "A", "a", false, &e);
    234261        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    235262
Note: See TracChangeset for help on using the changeset viewer.