Changeset 9468680 in mainline for uspace/app/nav/test/panel.c


Ignore:
Timestamp:
2021-10-19T19:48:40Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Children:
bdb2a72f
Parents:
516c160
Message:

When moving up a dir, seek to the directory just exited

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/nav/test/panel.c

    r516c160 r9468680  
    471471        rv = remove(p);
    472472        PCUT_ASSERT_INT_EQUALS(0, rv);
     473
    473474        free(fname);
     475}
     476
     477/** When moving to parent directory from a subdir, we seek to the
     478 * coresponding entry
     479 */
     480PCUT_TEST(read_dir_up)
     481{
     482        panel_t *panel;
     483        char buf[L_tmpnam];
     484        char *subdir_a;
     485        char *subdir_b;
     486        char *subdir_c;
     487        char *p;
     488        errno_t rc;
     489        int rv;
     490
     491        /* Create name for temporary directory */
     492        p = tmpnam(buf);
     493        PCUT_ASSERT_NOT_NULL(p);
     494
     495        /* Create temporary directory */
     496        rc = vfs_link_path(p, KIND_DIRECTORY, NULL);
     497        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     498
     499        /* Create some subdirectories */
     500
     501        rv = asprintf(&subdir_a, "%s/%s", p, "a");
     502        PCUT_ASSERT_TRUE(rv >= 0);
     503        rc = vfs_link_path(subdir_a, KIND_DIRECTORY, NULL);
     504        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     505
     506        rv = asprintf(&subdir_b, "%s/%s", p, "b");
     507        PCUT_ASSERT_TRUE(rv >= 0);
     508        rc = vfs_link_path(subdir_b, KIND_DIRECTORY, NULL);
     509        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     510
     511        rv = asprintf(&subdir_c, "%s/%s", p, "c");
     512        PCUT_ASSERT_TRUE(rv >= 0);
     513        rc = vfs_link_path(subdir_c, KIND_DIRECTORY, NULL);
     514        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     515
     516        rc = panel_create(NULL, true, &panel);
     517        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     518
     519        /* Start in subdirectory "b" */
     520        rc = panel_read_dir(panel, subdir_b);
     521        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     522
     523        /* Now go up (into p) */
     524
     525        rc = panel_read_dir(panel, "..");
     526        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     527
     528        PCUT_ASSERT_NOT_NULL(panel->cursor);
     529        PCUT_ASSERT_STR_EQUALS("b", panel->cursor->name);
     530
     531        panel_destroy(panel);
     532
     533        rv = remove(subdir_a);
     534        PCUT_ASSERT_INT_EQUALS(0, rv);
     535
     536        rv = remove(subdir_b);
     537        PCUT_ASSERT_INT_EQUALS(0, rv);
     538
     539        rv = remove(subdir_c);
     540        PCUT_ASSERT_INT_EQUALS(0, rv);
     541
     542        rv = remove(p);
     543        PCUT_ASSERT_INT_EQUALS(0, rv);
     544
     545        free(subdir_a);
     546        free(subdir_b);
     547        free(subdir_c);
    474548}
    475549
     
    594668        /* Add another entry */
    595669        attr.name = "b";
    596         attr.size= 2;
     670        attr.size = 2;
    597671        rc = panel_entry_append(panel, &attr);
    598672        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
Note: See TracChangeset for help on using the changeset viewer.