2014-06-10 19:07:15 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2017-11-05 23:18:42 -08:00
|
|
|
#define EFL_ACCESS_BETA
|
2017-10-18 18:13:54 -07:00
|
|
|
#define EFL_ACCESS_PROTECTED
|
2014-06-10 19:07:15 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_suite.h"
|
|
|
|
|
2014-09-30 04:10:22 -07:00
|
|
|
static Evas_Object *win, *genlist;
|
|
|
|
static Elm_Gen_Item_Class itc;
|
2014-09-30 10:48:22 -07:00
|
|
|
static Eo *current;
|
|
|
|
static int counter;
|
2017-10-18 18:13:54 -07:00
|
|
|
static Efl_Access_Event_Children_Changed_Data ev_data;
|
2015-10-02 07:44:19 -07:00
|
|
|
Evas_Object *content;
|
|
|
|
|
2018-02-14 12:04:24 -08:00
|
|
|
START_TEST (elm_genlist_legacy_type_check)
|
|
|
|
{
|
|
|
|
Evas_Object *win, *genlist;
|
|
|
|
const char *type;
|
|
|
|
|
2018-03-06 06:43:06 -08:00
|
|
|
char *args[] = { "exe" };
|
|
|
|
elm_init(1, args);
|
2018-02-14 12:04:24 -08:00
|
|
|
win = elm_win_add(NULL, "genlist", ELM_WIN_BASIC);
|
|
|
|
|
|
|
|
genlist = elm_genlist_add(win);
|
|
|
|
|
|
|
|
type = elm_object_widget_type_get(genlist);
|
|
|
|
ck_assert(type != NULL);
|
|
|
|
ck_assert(!strcmp(type, "Elm_Genlist"));
|
|
|
|
|
|
|
|
type = evas_object_type_get(genlist);
|
|
|
|
ck_assert(type != NULL);
|
|
|
|
ck_assert(!strcmp(type, "elm_genlist"));
|
|
|
|
|
|
|
|
elm_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
2014-06-10 19:07:15 -07:00
|
|
|
|
2014-09-30 04:10:22 -07:00
|
|
|
void test_init(void)
|
2014-06-10 19:07:15 -07:00
|
|
|
{
|
2018-03-06 06:43:06 -08:00
|
|
|
char *args[] = { "exe" };
|
|
|
|
elm_init(1, args);
|
2015-04-06 01:22:58 -07:00
|
|
|
elm_config_atspi_mode_set(EINA_TRUE);
|
2014-06-10 19:07:15 -07:00
|
|
|
win = elm_win_add(NULL, "genlist", ELM_WIN_BASIC);
|
|
|
|
genlist = elm_genlist_add(win);
|
2014-09-30 04:10:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST (elm_atspi_role_get)
|
|
|
|
{
|
|
|
|
test_init();
|
|
|
|
|
2017-10-18 18:13:54 -07:00
|
|
|
Efl_Access_Role role;
|
2014-09-30 04:10:22 -07:00
|
|
|
|
2017-10-18 18:13:54 -07:00
|
|
|
role = efl_access_role_get(genlist);
|
2014-06-10 19:07:15 -07:00
|
|
|
|
2017-10-18 18:13:54 -07:00
|
|
|
ck_assert(role == EFL_ACCESS_ROLE_LIST);
|
2014-06-10 19:07:15 -07:00
|
|
|
|
|
|
|
elm_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-09-30 04:10:22 -07:00
|
|
|
START_TEST(elm_atspi_children_get1)
|
|
|
|
{
|
|
|
|
test_init();
|
|
|
|
Eina_List *children;
|
|
|
|
Elm_Object_Item *it[3];
|
|
|
|
|
2017-10-18 18:13:54 -07:00
|
|
|
children = efl_access_children_get(genlist);
|
2014-09-30 04:10:22 -07:00
|
|
|
ck_assert(children == NULL);
|
|
|
|
|
|
|
|
it[0] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
2015-04-06 01:22:58 -07:00
|
|
|
it[1] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
|
|
|
it[2] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
2014-09-30 04:10:22 -07:00
|
|
|
|
2017-10-18 18:13:54 -07:00
|
|
|
children = efl_access_children_get(genlist);
|
2014-09-30 04:10:22 -07:00
|
|
|
ck_assert(eina_list_count(children) == 3);
|
|
|
|
ck_assert(eina_list_nth(children, 0) == it[0]);
|
|
|
|
ck_assert(eina_list_nth(children, 1) == it[1]);
|
|
|
|
ck_assert(eina_list_nth(children, 2) == it[2]);
|
|
|
|
|
|
|
|
eina_list_free(children);
|
|
|
|
|
|
|
|
elm_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST(elm_atspi_children_get2)
|
|
|
|
{
|
|
|
|
test_init();
|
|
|
|
Eina_List *children;
|
|
|
|
Elm_Object_Item *it[3];
|
|
|
|
|
|
|
|
it[0] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
|
|
|
it[1] = elm_genlist_item_prepend(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
|
|
|
|
it[2] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
|
|
|
|
|
2017-10-18 18:13:54 -07:00
|
|
|
children = efl_access_children_get(genlist);
|
2014-09-30 04:10:22 -07:00
|
|
|
ck_assert(eina_list_nth(children, 1) == it[0]);
|
|
|
|
ck_assert(eina_list_nth(children, 0) == it[1]);
|
|
|
|
ck_assert(eina_list_nth(children, 2) == it[2]);
|
|
|
|
|
|
|
|
elm_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2016-06-20 07:31:31 -07:00
|
|
|
static void
|
2016-08-30 05:34:10 -07:00
|
|
|
_children_changed_cb(void *data EINA_UNUSED, const Efl_Event *event)
|
2014-09-30 10:48:22 -07:00
|
|
|
{
|
2017-10-18 18:13:54 -07:00
|
|
|
if (event->desc != EFL_ACCESS_EVENT_CHILDREN_CHANGED)
|
2016-06-20 07:31:31 -07:00
|
|
|
return;
|
2015-09-03 05:07:23 -07:00
|
|
|
|
2017-10-18 18:13:54 -07:00
|
|
|
ev_data = *(Efl_Access_Event_Children_Changed_Data*)event->info;
|
2016-05-18 08:17:36 -07:00
|
|
|
current = event->object;
|
2014-09-30 10:48:22 -07:00
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(elm_atspi_children_events_add)
|
|
|
|
{
|
|
|
|
test_init();
|
|
|
|
|
|
|
|
current = NULL;
|
|
|
|
counter = 0;
|
|
|
|
|
|
|
|
Elm_Object_Item *it[3];
|
|
|
|
|
2017-10-18 18:13:54 -07:00
|
|
|
efl_access_event_handler_add(EFL_ACCESS_MIXIN, _children_changed_cb, NULL);
|
2014-09-30 10:48:22 -07:00
|
|
|
|
|
|
|
it[0] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
|
|
|
ck_assert(genlist == current);
|
|
|
|
ck_assert(counter == 1);
|
|
|
|
ck_assert(ev_data.is_added == EINA_TRUE);
|
|
|
|
ck_assert(ev_data.child == it[0]);
|
|
|
|
|
|
|
|
it[1] = elm_genlist_item_prepend(genlist, &itc, it[0], NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
|
|
|
|
ck_assert(genlist == current);
|
2015-04-06 01:22:58 -07:00
|
|
|
ck_assert(counter == 2);
|
2014-09-30 10:48:22 -07:00
|
|
|
ck_assert(ev_data.is_added == EINA_TRUE);
|
2015-04-06 01:22:58 -07:00
|
|
|
ck_assert(ev_data.child == it[1]);
|
2014-09-30 10:48:22 -07:00
|
|
|
|
|
|
|
it[2] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
|
|
|
|
ck_assert(genlist == current);
|
2015-04-06 01:22:58 -07:00
|
|
|
ck_assert(counter == 3);
|
2014-09-30 10:48:22 -07:00
|
|
|
ck_assert(ev_data.is_added == EINA_TRUE);
|
|
|
|
ck_assert(ev_data.child == it[2]);
|
|
|
|
|
|
|
|
elm_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST(elm_atspi_children_events_del1)
|
|
|
|
{
|
|
|
|
test_init();
|
|
|
|
|
|
|
|
current = NULL;
|
|
|
|
counter = 0;
|
|
|
|
|
|
|
|
Elm_Object_Item *it[3];
|
|
|
|
|
|
|
|
it[0] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
2015-04-06 01:22:58 -07:00
|
|
|
it[1] = elm_genlist_item_prepend(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
2014-09-30 10:48:22 -07:00
|
|
|
it[2] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
|
|
|
|
|
2017-10-18 18:13:54 -07:00
|
|
|
efl_access_event_handler_add(EFL_ACCESS_MIXIN, _children_changed_cb, NULL);
|
2015-04-06 01:22:58 -07:00
|
|
|
|
2014-09-30 10:48:22 -07:00
|
|
|
elm_object_item_del(it[0]);
|
|
|
|
ck_assert(genlist == current);
|
2015-04-06 01:22:58 -07:00
|
|
|
ck_assert(counter == 1);
|
2014-09-30 10:48:22 -07:00
|
|
|
ck_assert(ev_data.is_added == EINA_FALSE);
|
2015-04-06 01:22:58 -07:00
|
|
|
ck_assert(ev_data.child == it[0]);
|
2014-09-30 10:48:22 -07:00
|
|
|
|
|
|
|
elm_object_item_del(it[2]);
|
|
|
|
ck_assert(genlist == current);
|
2015-04-06 01:22:58 -07:00
|
|
|
ck_assert(counter == 2);
|
2014-09-30 10:48:22 -07:00
|
|
|
ck_assert(ev_data.is_added == EINA_FALSE);
|
|
|
|
ck_assert(ev_data.child == it[2]);
|
|
|
|
|
|
|
|
elm_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST(elm_atspi_children_events_del2)
|
|
|
|
{
|
|
|
|
test_init();
|
|
|
|
|
2015-04-06 01:22:58 -07:00
|
|
|
Elm_Object_Item *it;
|
2014-09-30 10:48:22 -07:00
|
|
|
current = NULL;
|
|
|
|
counter = 0;
|
|
|
|
|
2015-04-06 01:22:58 -07:00
|
|
|
it = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
2014-09-30 10:48:22 -07:00
|
|
|
|
2017-10-18 18:13:54 -07:00
|
|
|
efl_access_event_handler_add(EFL_ACCESS_MIXIN, _children_changed_cb, NULL);
|
2014-09-30 10:48:22 -07:00
|
|
|
elm_genlist_clear(genlist);
|
|
|
|
|
|
|
|
ck_assert(genlist == current);
|
2015-04-06 01:22:58 -07:00
|
|
|
ck_assert(counter == 1);
|
2014-09-30 10:48:22 -07:00
|
|
|
ck_assert(ev_data.is_added == EINA_FALSE);
|
2015-04-06 01:22:58 -07:00
|
|
|
ck_assert(ev_data.child == it);
|
2014-09-30 10:48:22 -07:00
|
|
|
|
|
|
|
elm_shutdown();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2014-06-10 19:07:15 -07:00
|
|
|
void elm_test_genlist(TCase *tc)
|
|
|
|
{
|
2018-02-14 12:04:24 -08:00
|
|
|
tcase_add_test(tc, elm_genlist_legacy_type_check);
|
2014-09-30 04:10:22 -07:00
|
|
|
tcase_add_test(tc, elm_atspi_role_get);
|
|
|
|
tcase_add_test(tc, elm_atspi_children_get1);
|
|
|
|
tcase_add_test(tc, elm_atspi_children_get2);
|
2014-09-30 10:48:22 -07:00
|
|
|
tcase_add_test(tc, elm_atspi_children_events_add);
|
|
|
|
tcase_add_test(tc, elm_atspi_children_events_del1);
|
|
|
|
tcase_add_test(tc, elm_atspi_children_events_del2);
|
2014-06-10 19:07:15 -07:00
|
|
|
}
|