diff options
author | Ryuan Choi <ryuan.choi@gmail.com> | 2014-07-02 07:55:53 +0900 |
---|---|---|
committer | Ryuan Choi <ryuan.choi@gmail.com> | 2014-07-02 07:58:45 +0900 |
commit | 5622df6914329bca7e816aac334c2dda25d296a8 (patch) | |
tree | e9322bf9eec535a5b293b843561c7a7d6fc5e1ec /src | |
parent | 389f300d88c292dc8c5e0c5863a32f92c3aa8e9e (diff) | |
download | elementary-5622df6914329bca7e816aac334c2dda25d296a8.tar.gz |
fileselector: Make selected_set actually select the file
This patch comes from Kai Huuhko.
Added test case for selected_set/get.
@fix
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/elc_fileselector.c | 2 | ||||
-rw-r--r-- | src/tests/elm_test_fileselector.c | 61 |
2 files changed, 61 insertions, 2 deletions
diff --git a/src/lib/elc_fileselector.c b/src/lib/elc_fileselector.c index 0f6903c95..106b91039 100644 --- a/src/lib/elc_fileselector.c +++ b/src/lib/elc_fileselector.c @@ -1902,7 +1902,7 @@ _elm_fileselector_elm_interface_fileselector_selected_set(Eo *obj, Elm_Fileselec } selected = ecore_file_dir_get(path); - _populate(obj, selected, NULL, NULL); + _populate(obj, selected, NULL, path); eina_stringshare_replace(&sd->selection, path); free(selected); } diff --git a/src/tests/elm_test_fileselector.c b/src/tests/elm_test_fileselector.c index 5d0943083..e5dd0677b 100644 --- a/src/tests/elm_test_fileselector.c +++ b/src/tests/elm_test_fileselector.c @@ -27,8 +27,67 @@ START_TEST (elm_atspi_role_get) } END_TEST +static void +_directory_open_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Eina_Bool *ret = data; + *ret = EINA_TRUE; +} + +START_TEST (elm_fileselector_selected) +{ + Evas_Object *win, *fileselector; + Eina_Tmpstr *tmp_path; + Eina_Stringshare *exist, *no_exist; + FILE *fp; + char *path; + Eina_Bool selected; + + elm_init(1, NULL); + + if (!eina_file_mkdtemp("elm_test-XXXXXX", &tmp_path)) + { + /* can not test */ + ck_assert(EINA_FALSE); + return; + } + + path = strdup(tmp_path); + eina_tmpstr_del(tmp_path); + + exist = eina_stringshare_printf("%s/exist", path); + no_exist = eina_stringshare_printf("%s/no_exist", path); + fp = fopen(exist, "w"); + fclose(fp); + + win = elm_win_add(NULL, "fileselector", ELM_WIN_BASIC); + + fileselector = elm_fileselector_add(win); + evas_object_smart_callback_add(fileselector, "directory,open", _directory_open_cb, &selected); + + ck_assert(!elm_fileselector_selected_set(fileselector, no_exist)); + + selected = EINA_FALSE; + ck_assert(elm_fileselector_selected_set(fileselector, path)); + while (!selected) ecore_main_loop_iterate(); + ck_assert_str_eq(elm_fileselector_selected_get(fileselector), path); + + selected = EINA_FALSE; + ck_assert(elm_fileselector_selected_set(fileselector, exist)); + while (!selected) ecore_main_loop_iterate(); + ck_assert_str_eq(elm_fileselector_selected_get(fileselector), exist); + + eina_stringshare_del(exist); + eina_stringshare_del(no_exist); + free(path); + + elm_shutdown(); +} +END_TEST + void elm_test_fileselector(TCase *tc) { - tcase_add_test(tc, elm_atspi_role_get); + tcase_add_test(tc, elm_atspi_role_get); + tcase_add_test(tc, elm_fileselector_selected); } |