efl_ui_spec: introduce tests that ensure we are not leaking objects

Summary:
with those two tests we are checking two things:
- Check that there is no left out canvas object after the widget is
invalidated but not deleted. For now this only deals with canvas
objects.
- Additionally this also ensures that ref;del;unref as well as simple
del is never ever going to end up in a error, even with children beeing
added.

This pretty much mirrors the tests for legacy in
0d48cb46d4 , except that these tests do
not check for evas parent contsruction vs. real widget parent
construction. Which is intendet, as none-legacy widgets do error out
when a not widget object is passed as parent.
Depends on D10291

Reviewers: zmike

Reviewed By: zmike

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10292
This commit is contained in:
Marcel Hollerbach 2019-10-07 09:38:12 -04:00 committed by Mike Blumenkrantz
parent d52e77dcb7
commit b0ac1ec85f
3 changed files with 128 additions and 0 deletions

View File

@ -0,0 +1,126 @@
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Efl_Ui.h>
#include "efl_ui_spec_suite.h"
#include "suite_helpers.h"
/* spec-meta-start
{"test-interface":"Efl.Ui.Widget",
"test-widgets": [
"Efl.Ui.Image",
"Efl.Ui.Image_Zoomable",
"Efl.Ui.Box",
"Efl.Ui.Clock",
"Efl.Ui.Layout",
"Efl.Ui.List_View",
"Efl.Ui.Tab_Bar",
"Efl.Ui.Tags",
"Efl.Ui.Panel",
"Efl.Ui.Scroller",
"Efl.Ui.Slider",
"Efl.Ui.Calendar",
"Efl.Ui.Check",
"Efl.Ui.Panes",
"Efl.Ui.Grid",
"Efl.Ui.List",
"Efl.Ui.Spin",
"Efl.Ui.Spin_Button",
"Efl.Ui.Spotlight.Container",
"Efl.Ui.Popup",
"Efl.Ui.Alert_Popup",
"Efl.Ui.Slider_Interval",
"Efl.Ui.Frame",
"Efl.Ui.Progressbar",
"Efl.Ui.Video",
"Efl.Ui.Navigation_Layout",
"Efl.Ui.Bg",
"Efl.Ui.Datepicker",
"Efl.Ui.Grid_Default_Item",
"Efl.Ui.List_Default_Item",
"Efl.Ui.List_Placeholder_Item",
"Efl.Ui.Tab_Page",
"Efl.Ui.Timepicker",
"Efl.Ui.Navigation_Bar",
"Efl.Ui.Relative_Layout",
"Efl.Ui.Animation_View",
"Efl.Ui.Table",
"Efl.Ui.Flip"
],
"custom-mapping" : {
"Efl.Ui.Grid" : "EFL_UI_GRID_DEFAULT_ITEM_CLASS",
"Efl.Ui.List" : "EFL_UI_LIST_DEFAULT_ITEM_CLASS",
"Efl.Ui.Tab_Bar" : "EFL_UI_TAB_BAR_DEFAULT_ITEM_CLASS"
}
}
spec-meta-end */
EFL_START_TEST(no_leaking_canvas_object)
{
Eina_List *not_invalidate = NULL;
Eina_Iterator *iter = eo_objects_iterator_new();
Eo *obj;
EINA_ITERATOR_FOREACH(iter, obj)
{
if (!efl_alive_get(obj)) continue;
if (!efl_isa(obj, EFL_CANVAS_OBJECT_CLASS)) continue;
not_invalidate = eina_list_append(not_invalidate, obj);
}
eina_iterator_free(iter);
//now try to will those widgets
if (efl_isa(widget, EFL_PACK_LINEAR_INTERFACE))
{
for (int i = 0; i < 30; ++i)
{
Efl_Ui_Widget *w = create_test_widget();
efl_pack_end(widget, w);
}
}
else if (efl_isa(widget, EFL_CONTENT_INTERFACE))
{
efl_content_set(widget, create_test_widget());
}
else if (efl_isa(widget, EFL_TEXT_INTERFACE))
{
efl_text_set(widget, "Test Things!");
}
//now reference things, and delete the widget again. This means, the widget will be invalidated.
efl_ref(widget);
efl_del(widget);
ck_assert_int_eq(efl_alive_get(widget), EINA_FALSE);
ck_assert_int_eq(efl_ref_count(widget), 1);
iter = eo_objects_iterator_new();
//now check if there are leaked objects from the widget
EINA_ITERATOR_FOREACH(iter, obj)
{
if (!efl_alive_get(obj)) continue;
if (!efl_isa(obj, EFL_CANVAS_OBJECT_CLASS)) continue;
ck_assert_ptr_ne(eina_list_data_find(not_invalidate, obj), NULL);
}
eina_iterator_free(iter);
efl_unref(widget);
}
EFL_END_TEST
EFL_START_TEST(no_err_on_shutdown)
{
efl_ref(widget);
efl_del(widget);
efl_unref(widget);
}
EFL_END_TEST
void
efl_ui_widget_behavior_test(TCase *tc)
{
tcase_add_test(tc, no_leaking_canvas_object);
tcase_add_test(tc, no_err_on_shutdown);
}

View File

@ -23,6 +23,7 @@ void efl_ui_view_behavior_test(TCase *tc);
void efl_ui_single_selectable_behavior_test(TCase *tc);
void efl_ui_multi_selectable_behavior_test(TCase *tc);
void efl_ui_selectable_behavior_test(TCase *tc);
void efl_ui_widget_behavior_test(TCase *tc);
void efl_test_container_content_equal(Efl_Ui_Widget **wid, unsigned int len);
void efl_test_container_expect_evt_content_added(Efl_Ui_Widget *widget, const Efl_Event_Description *ev, Eina_Bool *flag, void *event_data);

View File

@ -12,6 +12,7 @@ efl_ui_suite_behavior_test_files = files([
'efl_test_multi_selectable.c',
'efl_test_selectable.c',
'efl_test_gfx_view.c',
'efl_test_basics.c'
])
efl_ui_suite_behavior_src = files([