forked from enlightenment/efl
fileselector: Make selected_set actually select the file
This patch comes from Kai Huuhko. Added test case for selected_set/get. @fix
This commit is contained in:
parent
f56f430abd
commit
9f61c65296
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -27,8 +27,67 @@ START_TEST (elm_atspi_role_get)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
void elm_test_fileselector(TCase *tc)
|
||||
static void
|
||||
_directory_open_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
tcase_add_test(tc, elm_atspi_role_get);
|
||||
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_fileselector_selected);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue