summaryrefslogtreecommitdiff
path: root/src/tests/eo/suite
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2018-01-10 15:23:29 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2018-01-10 16:31:06 +0900
commitf285fd59259b528a1866b20d5d78723797490d92 (patch)
tree305baa07ec9db525a7d817c9240510d650ddceb3 /src/tests/eo/suite
parent63bbf0f3e58b37045846270b1225aaaa4331f63d (diff)
eo: Add "destruct" event
Triggered after (almost) complete destruction of the object. Not called "deleted" because the other event is already "del". I don't like "destruct" much but this follows the terminology of "constructor" / "destructor". @feature
Diffstat (limited to 'src/tests/eo/suite')
-rw-r--r--src/tests/eo/suite/eo_test_general.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c
index 46c351fdd9..e475889e95 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -1719,6 +1719,44 @@ START_TEST(efl_cast_test)
1719} 1719}
1720END_TEST 1720END_TEST
1721 1721
1722static void _destruct_test_del_cb(void *data, const Efl_Event *ev EINA_UNUSED)
1723{
1724 int *var = data;
1725 *var = 1;
1726}
1727
1728static void _destruct_test_destruct_cb(void *data, const Efl_Event *ev)
1729{
1730 int *var = data;
1731 *var *= 2;
1732
1733 ck_assert_int_eq(efl_ref_count(ev->object), 0);
1734
1735 // test disabled: object isn't yet marked as destructed (we're inside the
1736 // base class destructor here).
1737 //ck_assert_int_ne(efl_destructed_is(ev->object), 0);
1738}
1739
1740START_TEST(efl_object_destruct_test)
1741{
1742 int var = 0;
1743 Eo *obj;
1744
1745 efl_object_init();
1746
1747 obj = efl_add(SIMPLE_CLASS, NULL);
1748 fail_if(efl_ref_count(obj) != 1);
1749 efl_event_callback_add(obj, EFL_EVENT_DEL, _destruct_test_del_cb, &var);
1750 efl_event_callback_add(obj, EFL_EVENT_DESTRUCT, _destruct_test_destruct_cb, &var);
1751 efl_del(obj);
1752
1753 // var should be 2 if del then destruct, 0 otherwise
1754 ck_assert_int_eq(var, 2);
1755
1756 efl_object_shutdown();
1757}
1758END_TEST
1759
1722static void 1760static void
1723_auto_unref_del_cb(void *data, const Efl_Event *ev EINA_UNUSED) 1761_auto_unref_del_cb(void *data, const Efl_Event *ev EINA_UNUSED)
1724{ 1762{
@@ -1797,5 +1835,6 @@ void eo_test_general(TCase *tc)
1797 tcase_add_test(tc, eo_rec_interface); 1835 tcase_add_test(tc, eo_rec_interface);
1798 tcase_add_test(tc, eo_domain); 1836 tcase_add_test(tc, eo_domain);
1799 tcase_add_test(tc, efl_cast_test); 1837 tcase_add_test(tc, efl_cast_test);
1838 tcase_add_test(tc, efl_object_destruct_test);
1800 tcase_add_test(tc, efl_object_auto_unref_test); 1839 tcase_add_test(tc, efl_object_auto_unref_test);
1801} 1840}