cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=80b1ca8e4373534ad9ac848cdb7f34862cfee017

commit 80b1ca8e4373534ad9ac848cdb7f34862cfee017
Author: Lukasz Stanislawski <l.stanisl...@samsung.com>
Date:   Thu Apr 17 19:36:10 2014 +0200

    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.b...@free.fr>
---
 src/Makefile_Eo.am                      | 10 +++++
 src/lib/eo/eo_base_class.c              |  2 +-
 src/lib/eo/eo_private.h                 |  2 -
 src/tests/eo/children/children_main.c   | 72 +++++++++++++++++++++++++++++++++
 src/tests/eo/children/children_simple.c | 22 ++++++++++
 src/tests/eo/children/children_simple.h |  7 ++++
 6 files changed, 112 insertions(+), 3 deletions(-)

diff --git a/src/Makefile_Eo.am b/src/Makefile_Eo.am
index 7c2b093..cd5e6b6 100644
--- a/src/Makefile_Eo.am
+++ b/src/Makefile_Eo.am
@@ -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 \
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index b1bd8b2..483e390 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -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;
 
diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h
index 8648d02..6cb12c4 100644
--- a/src/lib/eo/eo_private.h
+++ b/src/lib/eo/eo_private.h
@@ -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;
diff --git a/src/tests/eo/children/children_main.c 
b/src/tests/eo/children/children_main.c
new file mode 100644
index 0000000..0e0832f
--- /dev/null
+++ b/src/tests/eo/children/children_main.c
@@ -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;
+}
diff --git a/src/tests/eo/children/children_simple.c 
b/src/tests/eo/children/children_simple.c
new file mode 100644
index 0000000..cd351d3
--- /dev/null
+++ b/src/tests/eo/children/children_simple.c
@@ -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)
+
diff --git a/src/tests/eo/children/children_simple.h 
b/src/tests/eo/children/children_simple.h
new file mode 100644
index 0000000..1502e59
--- /dev/null
+++ b/src/tests/eo/children/children_simple.h
@@ -0,0 +1,7 @@
+#ifndef SIMPLE_H
+#define SIMPLE_H
+
+#define SIMPLE_CLASS simple_class_get()
+const Eo_Class *simple_class_get(void);
+
+#endif

-- 


Reply via email to