Ignore:
File:
1 edited

Legend:

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

    r84d29a2 r95fc538  
    3636PCUT_TEST_SUITE(tbarcfg);
    3737
    38 /** Creating, opening and closing taskbar configuration */
    39 PCUT_TEST(create_open_close)
     38/** Opening and closing taskbar configuration */
     39PCUT_TEST(open_close)
    4040{
    4141        errno_t rc;
    4242        tbarcfg_t *tbcfg;
    43         char fname[L_tmpnam], *p;
     43        FILE *f;
     44        int rv;
    4445
    45         p = tmpnam(fname);
    46         PCUT_ASSERT_NOT_NULL(p);
     46        f = fopen("/tmp/test", "wt");
     47        PCUT_ASSERT_NOT_NULL(f);
    4748
    48         /* Create new repository */
    49         rc = tbarcfg_create(fname, &tbcfg);
     49        rv = fputs("[sif](){[entries](){}}", f);
     50        PCUT_ASSERT_TRUE(rv >= 0);
     51
     52        rv = fclose(f);
     53        PCUT_ASSERT_INT_EQUALS(0, rv);
     54
     55        rc = tbarcfg_open("/tmp/test", &tbcfg);
    5056        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    5157
    5258        tbarcfg_close(tbcfg);
    53 
    54         /* Re-open the repository */
    55 
    56         rc = tbarcfg_open(fname, &tbcfg);
    57         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    58 
    59         tbarcfg_close(tbcfg);
    60         remove(fname);
    6159}
    6260
     
    6664        errno_t rc;
    6765        tbarcfg_t *tbcfg;
    68         char fname[L_tmpnam], *p;
    6966        smenu_entry_t *e;
     67        FILE *f;
     68        int rv;
    7069
    71         p = tmpnam(fname);
    72         PCUT_ASSERT_NOT_NULL(p);
     70        f = fopen("/tmp/test", "wt");
     71        PCUT_ASSERT_NOT_NULL(f);
    7372
    74         rc = tbarcfg_create(fname, &tbcfg);
    75         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     73        rv = fputs("[sif](){[entries](){"
     74            "[entry]([caption]=[A][cmd]=[a]){}"
     75            "[entry]([caption]=[B][cmd]=[b]){}"
     76            "}}", f);
     77        PCUT_ASSERT_TRUE(rv >= 0);
    7678
    77         rc = smenu_entry_create(tbcfg, "A", "a");
    78         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     79        rv = fclose(f);
     80        PCUT_ASSERT_INT_EQUALS(0, rv);
    7981
    80         rc = smenu_entry_create(tbcfg, "B", "b");
     82        rc = tbarcfg_open("/tmp/test", &tbcfg);
    8183        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    8284
     
    8991
    9092        tbarcfg_close(tbcfg);
    91         remove(fname);
    9293}
    9394
     
    9798        errno_t rc;
    9899        tbarcfg_t *tbcfg;
    99         char fname[L_tmpnam], *p;
    100100        smenu_entry_t *e;
    101101        const char *caption;
    102102        const char *cmd;
     103        FILE *f;
     104        int rv;
    103105
    104         p = tmpnam(fname);
    105         PCUT_ASSERT_NOT_NULL(p);
     106        f = fopen("/tmp/test", "wt");
     107        PCUT_ASSERT_NOT_NULL(f);
    106108
    107         rc = tbarcfg_create(fname, &tbcfg);
    108         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     109        rv = fputs("[sif](){[entries](){"
     110            "[entry]([caption]=[A][cmd]=[a]){}"
     111            "}}", f);
     112        PCUT_ASSERT_TRUE(rv >= 0);
    109113
    110         rc = smenu_entry_create(tbcfg, "A", "a");
     114        rv = fclose(f);
     115        PCUT_ASSERT_INT_EQUALS(0, rv);
     116
     117        rc = tbarcfg_open("/tmp/test", &tbcfg);
    111118        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    112119
     
    120127
    121128        tbarcfg_close(tbcfg);
    122         remove(fname);
    123 }
    124 
    125 /** Setting menu entry properties */
    126 PCUT_TEST(set_caption_cmd)
    127 {
    128         errno_t rc;
    129         tbarcfg_t *tbcfg;
    130         char fname[L_tmpnam], *p;
    131         smenu_entry_t *e;
    132         const char *caption;
    133         const char *cmd;
    134 
    135         p = tmpnam(fname);
    136         PCUT_ASSERT_NOT_NULL(p);
    137 
    138         rc = tbarcfg_create(fname, &tbcfg);
    139         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    140 
    141         rc = smenu_entry_create(tbcfg, "A", "a");
    142         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    143 
    144         e = tbarcfg_smenu_first(tbcfg);
    145         PCUT_ASSERT_NOT_NULL(e);
    146 
    147         caption = smenu_entry_get_caption(e);
    148         PCUT_ASSERT_STR_EQUALS("A", caption);
    149         cmd = smenu_entry_get_cmd(e);
    150         PCUT_ASSERT_STR_EQUALS("a", cmd);
    151 
    152         /* Set properties */
    153         rc = smenu_entry_set_caption(e, "B");
    154         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    155         rc = smenu_entry_set_cmd(e, "b");
    156         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    157 
    158         rc = smenu_entry_save(e);
    159         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    160 
    161         /* Check that properties have been set */
    162         caption = smenu_entry_get_caption(e);
    163         PCUT_ASSERT_STR_EQUALS("B", caption);
    164         cmd = smenu_entry_get_cmd(e);
    165         PCUT_ASSERT_STR_EQUALS("b", cmd);
    166 
    167         tbarcfg_close(tbcfg);
    168 
    169         /* Re-open repository */
    170 
    171         rc = tbarcfg_open(fname, &tbcfg);
    172         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    173 
    174         e = tbarcfg_smenu_first(tbcfg);
    175         PCUT_ASSERT_NOT_NULL(e);
    176 
    177         /* Check that new values of properties have persisted */
    178         caption = smenu_entry_get_caption(e);
    179         PCUT_ASSERT_STR_EQUALS("B", caption);
    180         cmd = smenu_entry_get_cmd(e);
    181         PCUT_ASSERT_STR_EQUALS("b", cmd);
    182 
    183         tbarcfg_close(tbcfg);
    184         remove(fname);
    185 }
    186 
    187 /** Create start menu entry */
    188 PCUT_TEST(entry_create)
    189 {
    190         errno_t rc;
    191         tbarcfg_t *tbcfg;
    192         char fname[L_tmpnam], *p;
    193         smenu_entry_t *e;
    194         const char *caption;
    195         const char *cmd;
    196 
    197         p = tmpnam(fname);
    198         PCUT_ASSERT_NOT_NULL(p);
    199 
    200         rc = tbarcfg_create(fname, &tbcfg);
    201         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    202 
    203         rc = smenu_entry_create(tbcfg, "A", "a");
    204         PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    205 
    206         e = tbarcfg_smenu_first(tbcfg);
    207         PCUT_ASSERT_NOT_NULL(e);
    208 
    209         caption = smenu_entry_get_caption(e);
    210         PCUT_ASSERT_STR_EQUALS("A", caption);
    211         cmd = smenu_entry_get_cmd(e);
    212         PCUT_ASSERT_STR_EQUALS("a", cmd);
    213 
    214         tbarcfg_close(tbcfg);
    215         remove(fname);
    216129}
    217130
Note: See TracChangeset for help on using the changeset viewer.