mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
improve top_dir of file browser
This commit is contained in:
parent
6186653d09
commit
bdf0bdd61f
@ -63,6 +63,7 @@ static ret_t on_file_open(void* ctx, event_t* e) {
|
||||
emitter_on(EMITTER(chooser), EVT_DONE, tk_on_choose_file_result, ctx);
|
||||
|
||||
file_chooser_set_init_dir(chooser, "src");
|
||||
file_chooser_set_top_dir(chooser, "./");
|
||||
file_chooser_set_filter(chooser, ".c.h.cpp.inc");
|
||||
|
||||
return file_chooser_choose_file_for_open(chooser);
|
||||
|
@ -107,6 +107,7 @@ ret_t file_browser_set_cwd(file_browser_t* fb, const char* cwd) {
|
||||
return_value_if_fail(path_abs(cwd, path, MAX_PATH) == RET_OK, RET_BAD_PARAMS);
|
||||
path_normalize(path, fb->cwd, MAX_PATH);
|
||||
}
|
||||
path_remove_last_slash(fb->cwd);
|
||||
|
||||
file_browser_refresh(fb);
|
||||
|
||||
|
@ -367,3 +367,21 @@ TEST(FileBrowser, top_dir) {
|
||||
|
||||
file_browser_destroy(fb);
|
||||
}
|
||||
|
||||
TEST(FileBrowser, top_dir1) {
|
||||
char cwd[MAX_PATH + 1];
|
||||
file_browser_t* fb = file_browser_create(os_fs());
|
||||
|
||||
fs_get_cwd(os_fs(), cwd);
|
||||
|
||||
ASSERT_EQ(file_browser_set_cwd(fb, "./"), RET_OK);
|
||||
ASSERT_EQ(file_browser_set_top_dir(fb, "./"), RET_OK);
|
||||
ASSERT_STREQ(fb->top_dir, cwd);
|
||||
|
||||
ASSERT_NE(file_browser_up(fb), RET_OK);
|
||||
ASSERT_EQ(file_browser_enter(fb, "src"), RET_OK);
|
||||
ASSERT_EQ(file_browser_up(fb), RET_OK);
|
||||
ASSERT_NE(file_browser_up(fb), RET_OK);
|
||||
|
||||
file_browser_destroy(fb);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user