2014-06-10 19:07:15 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2018-04-03 04:27:30 -07:00
|
|
|
#define EFL_ACCESS_OBJECT_BETA
|
2014-06-10 19:07:15 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_suite.h"
|
|
|
|
|
2019-04-02 11:50:43 -07:00
|
|
|
|
|
|
|
EFL_START_TEST(elm_fileselector_legacy_type_check)
|
|
|
|
{
|
|
|
|
Evas_Object *win, *fileselector;
|
|
|
|
const char *type;
|
|
|
|
|
|
|
|
win = win_add(NULL, "fileselector", ELM_WIN_BASIC);
|
|
|
|
|
|
|
|
fileselector = elm_fileselector_add(win);
|
|
|
|
|
|
|
|
type = elm_object_widget_type_get(fileselector);
|
|
|
|
ck_assert(type != NULL);
|
|
|
|
ck_assert(!strcmp(type, "Elm_Fileselector"));
|
|
|
|
|
|
|
|
type = evas_object_type_get(fileselector);
|
|
|
|
ck_assert(type != NULL);
|
|
|
|
ck_assert(!strcmp(type, "elm_fileselector"));
|
|
|
|
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
|
|
|
EFL_START_TEST(elm_atspi_role_get)
|
|
|
|
{
|
|
|
|
Evas_Object *win, *fileselector;
|
|
|
|
Efl_Access_Role role;
|
|
|
|
|
|
|
|
win = win_add(NULL, "fileselector", ELM_WIN_BASIC);
|
|
|
|
|
|
|
|
fileselector = elm_fileselector_add(win);
|
|
|
|
role = efl_access_object_role_get(fileselector);
|
|
|
|
|
|
|
|
ck_assert(role == EFL_ACCESS_ROLE_FILE_CHOOSER);
|
|
|
|
|
|
|
|
}
|
|
|
|
EFL_END_TEST
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
2018-08-06 11:26:08 -07:00
|
|
|
static Eina_Bool
|
|
|
|
timer_expired_cb(void *user_data)
|
|
|
|
{
|
|
|
|
Eina_Bool *did_timeout = user_data;
|
|
|
|
|
|
|
|
*did_timeout = EINA_TRUE;
|
|
|
|
ecore_main_loop_quit();
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
idler_done_cb(void *user_data)
|
|
|
|
{
|
|
|
|
Eina_Bool *done = user_data;
|
|
|
|
|
|
|
|
if (*done) ecore_main_loop_quit();
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
fileselector_test_helper_wait_flag(double in, Eina_Bool *done)
|
|
|
|
{
|
|
|
|
Eina_Bool did_timeout = EINA_FALSE;
|
|
|
|
Ecore_Timer *tm;
|
|
|
|
Ecore_Idle_Enterer *idle;
|
|
|
|
|
|
|
|
tm = ecore_timer_add(in, timer_expired_cb, &did_timeout);
|
|
|
|
idle = ecore_idle_enterer_add(idler_done_cb, done);
|
|
|
|
|
|
|
|
ecore_main_loop_begin();
|
|
|
|
|
|
|
|
ecore_idle_enterer_del(idle);
|
|
|
|
ecore_timer_del(tm);
|
|
|
|
|
|
|
|
return !did_timeout;
|
|
|
|
}
|
|
|
|
|
2014-07-01 15:55:53 -07:00
|
|
|
static void
|
2016-09-14 16:45:16 -07:00
|
|
|
_ready_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2014-07-01 15:55:53 -07:00
|
|
|
{
|
|
|
|
Eina_Bool *ret = data;
|
|
|
|
*ret = EINA_TRUE;
|
2019-03-27 14:24:57 -07:00
|
|
|
|
|
|
|
ecore_main_loop_quit();
|
2014-07-01 15:55:53 -07:00
|
|
|
}
|
|
|
|
|
2019-04-02 11:50:43 -07:00
|
|
|
|
2019-01-28 10:42:56 -08:00
|
|
|
EFL_START_TEST(elm_fileselector_selected)
|
2014-07-01 15:55:53 -07:00
|
|
|
{
|
|
|
|
Evas_Object *win, *fileselector;
|
|
|
|
Eina_Tmpstr *tmp_path;
|
|
|
|
Eina_Stringshare *exist, *no_exist;
|
|
|
|
FILE *fp;
|
|
|
|
char *path;
|
2016-09-14 16:45:16 -07:00
|
|
|
Eina_Bool open, selected;
|
2014-07-01 15:55:53 -07:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2018-04-27 05:59:04 -07:00
|
|
|
win = win_add(NULL, "fileselector", ELM_WIN_BASIC);
|
2014-07-01 15:55:53 -07:00
|
|
|
|
|
|
|
fileselector = elm_fileselector_add(win);
|
2016-09-14 16:45:16 -07:00
|
|
|
evas_object_smart_callback_add(fileselector, "directory,open", _ready_cb, &open);
|
2014-07-01 15:55:53 -07:00
|
|
|
|
|
|
|
ck_assert(!elm_fileselector_selected_set(fileselector, no_exist));
|
|
|
|
|
2016-09-14 16:45:16 -07:00
|
|
|
open = EINA_FALSE;
|
2014-07-01 15:55:53 -07:00
|
|
|
ck_assert(elm_fileselector_selected_set(fileselector, path));
|
2018-08-06 11:26:08 -07:00
|
|
|
ck_assert(fileselector_test_helper_wait_flag(10, &open));
|
2014-07-16 07:17:31 -07:00
|
|
|
|
2014-07-01 15:55:53 -07:00
|
|
|
ck_assert_str_eq(elm_fileselector_selected_get(fileselector), path);
|
|
|
|
|
2019-03-27 14:24:57 -07:00
|
|
|
evas_object_smart_callback_del(fileselector, "directory,open", _ready_cb);
|
|
|
|
evas_object_smart_callback_add(fileselector, "selected", _ready_cb, &selected);
|
|
|
|
|
2019-03-28 12:44:31 -07:00
|
|
|
selected = EINA_FALSE;
|
2014-07-01 15:55:53 -07:00
|
|
|
ck_assert(elm_fileselector_selected_set(fileselector, exist));
|
2018-08-06 11:26:08 -07:00
|
|
|
ck_assert(fileselector_test_helper_wait_flag(10, &selected));
|
elc_filselector: solve the mysterium of sometimes failing tests
so after a phone call, two days of debugging, tears, crying etc. etc. we
finally came to a point of enlightenment! *Someone* (bu5hm4n) moved
gengrid and genlist events from eo back to smart events, so we can work
arround legacy borks and event-name collisions, at this point he did not
knew that some widgets (fileselector) already relied on those *lovely*
events. Hence this broke theoretically the testsuite, however, the
fileselector testsuite is ultimatily buggy, and the wait function does
not return false when it timeouts, (i don't know why not). So this break
was never discovered.
Additionally there is a second issue. it appears, that when we
immidiatly quit the mainloop after we have got the selected callback,
that then genlist decides to forget about the sd->selected pointer, and
NULLs that one out. Which then results in the fact that
elm_fileselector_selected_get ends up returning invalid paths.
Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D8488
2019-03-27 13:15:53 -07:00
|
|
|
ck_assert(selected == EINA_TRUE);
|
2019-03-27 14:24:57 -07:00
|
|
|
|
2014-07-01 15:55:53 -07:00
|
|
|
ck_assert_str_eq(elm_fileselector_selected_get(fileselector), exist);
|
|
|
|
|
|
|
|
eina_stringshare_del(exist);
|
|
|
|
eina_stringshare_del(no_exist);
|
|
|
|
free(path);
|
|
|
|
|
|
|
|
}
|
2018-03-26 11:19:28 -07:00
|
|
|
EFL_END_TEST
|
2014-07-01 15:55:53 -07:00
|
|
|
|
2019-04-02 11:50:43 -07:00
|
|
|
#endif
|
|
|
|
|
2014-06-10 19:07:15 -07:00
|
|
|
void elm_test_fileselector(TCase *tc)
|
|
|
|
{
|
2018-02-14 12:04:24 -08:00
|
|
|
tcase_add_test(tc, elm_fileselector_legacy_type_check);
|
2014-07-01 15:55:53 -07:00
|
|
|
tcase_add_test(tc, elm_atspi_role_get);
|
2019-04-02 11:50:43 -07:00
|
|
|
//FIXME this should be reenabled when issues on travis are fixed with this.
|
|
|
|
//tcase_add_test(tc, elm_fileselector_selected);
|
2014-06-10 19:07:15 -07:00
|
|
|
}
|
|
|
|
|