summaryrefslogtreecommitdiff
path: root/src/tests/elm_test_genlist.c
diff options
context:
space:
mode:
authorLukasz Stanislawski <l.stanislaws@samsung.com>2014-09-30 19:48:22 +0200
committerLukasz Stanislawski <lukasz.stanislawski@gmail.com>2015-04-06 10:24:57 +0200
commitc1d05e6b457d216b1f1a0f7053920cb3586bfff1 (patch)
tree624ca18f245ef478d9204aaae9f6d330781b3d61 /src/tests/elm_test_genlist.c
parentf5f3184df8ad5d38f9ba18f33d3dd37100910ff1 (diff)
downloadelementary-c1d05e6b457d216b1f1a0f7053920cb3586bfff1.tar.gz
atspi: implement add/del callbacks. Add genlist item tests
Diffstat (limited to 'src/tests/elm_test_genlist.c')
-rw-r--r--src/tests/elm_test_genlist.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/src/tests/elm_test_genlist.c b/src/tests/elm_test_genlist.c
index 1dd313541..007ee1715 100644
--- a/src/tests/elm_test_genlist.c
+++ b/src/tests/elm_test_genlist.c
@@ -8,6 +8,9 @@
static Evas_Object *win, *genlist;
static Elm_Gen_Item_Class itc;
+static Eo *current;
+static int counter;
+static Elm_Atspi_Event_Children_Changed_Data ev_data;
void test_init(void)
{
@@ -84,9 +87,110 @@ START_TEST(elm_atspi_children_get2)
}
END_TEST
+static Eina_Bool
+_children_changed_cb(void *data EINA_UNUSED, Eo *obj EINA_UNUSED,
+ const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ ev_data = *(Elm_Atspi_Event_Children_Changed_Data*)event_info;
+ current = obj;
+ counter++;
+
+ return EINA_TRUE;
+}
+
+START_TEST(elm_atspi_children_events_add)
+{
+ test_init();
+
+ current = NULL;
+ counter = 0;
+
+ Elm_Object_Item *it[3];
+
+ eo_do(genlist, eo_event_callback_add(ELM_INTERFACE_ATSPI_ACCESSIBLE_EVENT_CHILDREN_CHANGED, _children_changed_cb, NULL));
+
+ 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);
+ ck_assert(counter == 1);
+ ck_assert(ev_data.is_added == EINA_TRUE);
+ ck_assert(ev_data.child == it[0]);
+
+ it[2] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
+ ck_assert(genlist == current);
+ ck_assert(counter == 2);
+ 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];
+
+ eo_do(genlist, eo_event_callback_add(ELM_INTERFACE_ATSPI_ACCESSIBLE_EVENT_CHILDREN_CHANGED, _children_changed_cb, NULL));
+
+ it[0] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ it[1] = elm_genlist_item_prepend(genlist, &itc, it[0], NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ it[2] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
+
+ elm_object_item_del(it[0]);
+ ck_assert(genlist == current);
+ ck_assert(counter == 3);
+ ck_assert(ev_data.is_added == EINA_FALSE);
+ ck_assert(ev_data.child == it[1]);
+
+ elm_object_item_del(it[2]);
+ ck_assert(genlist == current);
+ ck_assert(counter == 4);
+ 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();
+
+ Elm_Object_Item *it[3];
+ current = NULL;
+ counter = 0;
+
+ 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_NONE, NULL, NULL);
+ it[2] = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
+
+ elm_genlist_clear(genlist);
+
+ ck_assert(genlist == current);
+ ck_assert(counter == 6);
+ ck_assert(ev_data.is_added == EINA_FALSE);
+ ck_assert(ev_data.child == it[2]);
+
+ elm_shutdown();
+}
+END_TEST
+
void elm_test_genlist(TCase *tc)
{
tcase_add_test(tc, elm_atspi_role_get);
tcase_add_test(tc, elm_atspi_children_get1);
tcase_add_test(tc, elm_atspi_children_get2);
+ 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);
}