forked from enlightenment/efl
eo: fix broken children iterator, remove redundant fields.
@fix Summary: Tests added. Reviewers: raster, JackDanielZ, tasn CC: cedric Differential Revision: https://phab.enlightenment.org/D763 Signed-off-by: Cedric Bail <cedric.bail@free.fr>
This commit is contained in:
parent
e32f033853
commit
80b1ca8e43
|
@ -38,8 +38,18 @@ tests/eo/test_function_overrides \
|
|||
tests/eo/test_interface \
|
||||
tests/eo/test_mixin \
|
||||
tests/eo/test_signals \
|
||||
tests/eo/test_children \
|
||||
tests/eo/eo_suite
|
||||
|
||||
tests_eo_test_children_SOURCES = \
|
||||
tests/eo/children/children_main.c \
|
||||
tests/eo/children/children_simple.c \
|
||||
tests/eo/children/children_simple.h
|
||||
tests_eo_test_children_CPPFLAGS = -I$(top_builddir)/src/lib/efl @EO_CFLAGS@
|
||||
tests_eo_test_children_LDADD = @USE_EO_LIBS@
|
||||
tests_eo_test_children_DEPENDENCIES = @USE_EO_INTERNAL_LIBS@
|
||||
TESTS += tests/eo/test_children
|
||||
|
||||
tests_eo_test_access_SOURCES = \
|
||||
tests/eo/access/access_inherit.c \
|
||||
tests/eo/access/access_inherit.h \
|
||||
|
|
|
@ -251,7 +251,7 @@ _children_iterator_new(Eo *obj_id, void *class_data)
|
|||
if (!it) return NULL;
|
||||
|
||||
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
|
||||
it->current = obj->children;
|
||||
it->current = pd->children;
|
||||
it->obj = _eo_ref(obj);
|
||||
it->obj_id = obj_id;
|
||||
|
||||
|
|
|
@ -86,8 +86,6 @@ struct _Eo_Base
|
|||
struct _Eo_Object
|
||||
{
|
||||
Eo_Base header;
|
||||
Eo *parent;
|
||||
Eina_List *children;
|
||||
const _Eo_Class *klass;
|
||||
#ifdef EO_DEBUG
|
||||
Eina_Inlist *xrefs;
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eo.h"
|
||||
|
||||
#include "../eunit_tests.h"
|
||||
#include "children_simple.h"
|
||||
|
||||
|
||||
#define CHECK_ITER_DATA(iter, data, expected_data) \
|
||||
fail_if(!eina_iterator_next(iter, &(data))); \
|
||||
fail_if(expected_data != data);
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
Eina_Iterator *iter = NULL;
|
||||
void *chld;
|
||||
|
||||
eo_init();
|
||||
|
||||
Eo *parent = eo_add(SIMPLE_CLASS, NULL);
|
||||
|
||||
Eo *child1 = eo_add(SIMPLE_CLASS, parent);
|
||||
Eo *child2 = eo_add(SIMPLE_CLASS, parent);
|
||||
Eo *child3 = eo_add(SIMPLE_CLASS, parent);
|
||||
|
||||
eo_do(parent, iter = eo_children_iterator_new());
|
||||
fail_if(!iter);
|
||||
|
||||
CHECK_ITER_DATA(iter, chld, child1);
|
||||
CHECK_ITER_DATA(iter, chld, child2);
|
||||
CHECK_ITER_DATA(iter, chld, child3);
|
||||
fail_if(eina_iterator_next(iter, &chld));
|
||||
|
||||
eina_iterator_free(iter);
|
||||
|
||||
eo_del(child2);
|
||||
|
||||
eo_do(parent, iter = eo_children_iterator_new());
|
||||
fail_if(!iter);
|
||||
|
||||
CHECK_ITER_DATA(iter, chld, child1);
|
||||
CHECK_ITER_DATA(iter, chld, child3);
|
||||
fail_if(eina_iterator_next(iter, &chld));
|
||||
|
||||
eina_iterator_free(iter);
|
||||
|
||||
|
||||
eo_del(child1);
|
||||
|
||||
eo_do(parent, iter = eo_children_iterator_new());
|
||||
fail_if(!iter);
|
||||
|
||||
CHECK_ITER_DATA(iter, chld, child3);
|
||||
fail_if(eina_iterator_next(iter, &chld));
|
||||
eina_iterator_free(iter);
|
||||
|
||||
|
||||
eo_del(child3);
|
||||
|
||||
eo_do(parent, iter = eo_children_iterator_new());
|
||||
fail_if(iter);
|
||||
|
||||
eo_unref(parent);
|
||||
|
||||
eo_shutdown();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eo.h"
|
||||
#include "children_simple.h"
|
||||
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
static const Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_NOOPS(),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, NULL)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef SIMPLE_H
|
||||
#define SIMPLE_H
|
||||
|
||||
#define SIMPLE_CLASS simple_class_get()
|
||||
const Eo_Class *simple_class_get(void);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue