summaryrefslogtreecommitdiff
path: root/src/tests/eo/suite
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2016-10-19 16:20:19 +0100
committerTom Hacohen <tom@stosb.com>2016-10-19 16:32:16 +0100
commitd952b350982aa8ad7575fcceec18d0075034b41c (patch)
tree9cc3f99e95803d8a71a11083574419fd78f76c02 /src/tests/eo/suite
parent5a659fafd22de295f8a4fb276e343f0da870779f (diff)
Eo: Add a regression test for ref leak in function resolve
This adds a regression test for the last commit.
Diffstat (limited to 'src/tests/eo/suite')
-rw-r--r--src/tests/eo/suite/eo_test_general.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c
index 39749241bd..f0548d7b5e 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -966,6 +966,66 @@ START_TEST(eo_magic_checks)
966} 966}
967END_TEST 967END_TEST
968 968
969/* resolve issues */
970
971static Eina_Bool
972_a_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED)
973{
974 printf("Hey\n");
975
976 return EINA_TRUE;
977}
978
979EFL_FUNC_BODY(resolve_a_print, Eina_Bool, EINA_FALSE);
980
981static Eina_Bool
982_multi_class_initializer(Efl_Class *klass)
983{
984 EFL_OPS_DEFINE(ops,
985 EFL_OBJECT_OP_FUNC(resolve_a_print, _a_print),
986 );
987
988 return efl_class_functions_set(klass, &ops, NULL);
989}
990
991START_TEST(efl_func_resolve)
992{
993 efl_object_init();
994
995 /* Usually should be const, not const only for the test... */
996 static Efl_Class_Description class_desc = {
997 EO_VERSION,
998 "Inherit",
999 EFL_CLASS_TYPE_REGULAR,
1000 0,
1001 _multi_class_initializer,
1002 NULL,
1003 NULL
1004 };
1005
1006 const Efl_Class *klass = efl_class_new(&class_desc, SIMPLE_CLASS, NULL);
1007 fail_if(!klass);
1008
1009 Eo *obj = efl_add(klass, NULL);
1010 fail_if(!resolve_a_print(obj));
1011 efl_unref(obj);
1012
1013
1014 obj = efl_add(SIMPLE_CLASS, NULL);
1015 fail_if(!obj);
1016 efl_manual_free_set(obj, EINA_TRUE);
1017
1018 fail_if(resolve_a_print(obj));
1019
1020 efl_unref(obj);
1021
1022 fail_if(!efl_destructed_is(obj));
1023 efl_manual_free(obj);
1024
1025 efl_object_shutdown();
1026}
1027END_TEST
1028
969START_TEST(efl_add_do_and_custom) 1029START_TEST(efl_add_do_and_custom)
970{ 1030{
971 Simple_Public_Data *pd = NULL; 1031 Simple_Public_Data *pd = NULL;
@@ -1485,6 +1545,7 @@ void eo_test_general(TCase *tc)
1485 tcase_add_test(tc, efl_weak_reference); 1545 tcase_add_test(tc, efl_weak_reference);
1486 tcase_add_test(tc, eo_generic_data); 1546 tcase_add_test(tc, eo_generic_data);
1487 tcase_add_test(tc, eo_magic_checks); 1547 tcase_add_test(tc, eo_magic_checks);
1548 tcase_add_test(tc, efl_func_resolve);
1488 tcase_add_test(tc, efl_add_do_and_custom); 1549 tcase_add_test(tc, efl_add_do_and_custom);
1489 tcase_add_test(tc, eo_pointers_indirection); 1550 tcase_add_test(tc, eo_pointers_indirection);
1490 tcase_add_test(tc, efl_add_failures); 1551 tcase_add_test(tc, efl_add_failures);