summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-09-03 19:36:44 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-09-03 19:36:44 -0300
commitff18dbee7356f3147b4b3ad6ce33bfc8b3ad9eed (patch)
tree4fd8ba8ebf1e116b8c3ac7f0135e276e9a87212f
parentee2df33b36b8172991481f4844054beced02bb27 (diff)
ecore: WIP composite selection modeldevs/felipealmeida/wip-selection
-rw-r--r--src/Makefile_Ecore.am4
-rw-r--r--src/Makefile_Efl.am2
-rw-r--r--src/lib/ecore/Ecore_Eo.h2
-rw-r--r--src/lib/ecore/efl_model_accessor_view.c104
-rw-r--r--src/lib/ecore/efl_model_accessor_view_private.h5
-rw-r--r--src/lib/ecore/efl_model_composite_boolean.c21
-rw-r--r--src/lib/ecore/efl_model_composite_boolean.eo15
-rw-r--r--src/lib/ecore/efl_model_composite_selection.c144
-rw-r--r--src/lib/ecore/efl_model_composite_selection.eo16
-rw-r--r--src/lib/ecore/efl_model_composite_selection_children.eo7
-rw-r--r--src/tests/efl/efl_test_model_composite.c (renamed from src/tests/efl/efl_test_model_composite_boolean.c)120
-rw-r--r--src/tests/efl/efl_test_model_container.c2
12 files changed, 421 insertions, 21 deletions
diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am
index c5be098bf7..0ba8c95320 100644
--- a/src/Makefile_Ecore.am
+++ b/src/Makefile_Ecore.am
@@ -30,6 +30,8 @@ ecore_eolian_files = \
30 lib/ecore/efl_model_container_item.eo \ 30 lib/ecore/efl_model_container_item.eo \
31 lib/ecore/efl_model_composite_boolean.eo \ 31 lib/ecore/efl_model_composite_boolean.eo \
32 lib/ecore/efl_model_composite_boolean_children.eo \ 32 lib/ecore/efl_model_composite_boolean_children.eo \
33 lib/ecore/efl_model_composite_selection.eo \
34 lib/ecore/efl_model_composite_selection_children.eo \
33 $(ecore_eolian_files_legacy) 35 $(ecore_eolian_files_legacy)
34 36
35ecore_eolian_c = $(ecore_eolian_files:%.eo=%.eo.c) 37ecore_eolian_c = $(ecore_eolian_files:%.eo=%.eo.c)
@@ -90,6 +92,8 @@ lib/ecore/efl_model_container.c \
90lib/ecore/efl_model_container_item.c \ 92lib/ecore/efl_model_container_item.c \
91lib/ecore/efl_model_container_private.h \ 93lib/ecore/efl_model_container_private.h \
92lib/ecore/efl_model_composite_boolean.c \ 94lib/ecore/efl_model_composite_boolean.c \
95lib/ecore/efl_model_composite_selection.c \
96lib/ecore/efl_model_accessor_view.c \
93lib/ecore/ecore_pipe.c \ 97lib/ecore/ecore_pipe.c \
94lib/ecore/ecore_poller.c \ 98lib/ecore/ecore_poller.c \
95lib/ecore/ecore_time.c \ 99lib/ecore/ecore_time.c \
diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am
index d615e27595..58b2c091cc 100644
--- a/src/Makefile_Efl.am
+++ b/src/Makefile_Efl.am
@@ -187,7 +187,7 @@ TESTS += tests/efl/efl_suite
187tests_efl_efl_suite_SOURCES = \ 187tests_efl_efl_suite_SOURCES = \
188tests/efl/efl_suite.c \ 188tests/efl/efl_suite.c \
189tests/efl/efl_test_model_container.c \ 189tests/efl/efl_test_model_container.c \
190tests/efl/efl_test_model_composite_boolean.c \ 190tests/efl/efl_test_model_composite.c \
191tests/efl/efl_suite.h 191tests/efl/efl_suite.h
192 192
193tests_efl_efl_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ 193tests_efl_efl_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h
index 502f6419ec..aadd2ba136 100644
--- a/src/lib/ecore/Ecore_Eo.h
+++ b/src/lib/ecore/Ecore_Eo.h
@@ -115,6 +115,8 @@ EAPI Efl_Future *efl_future_iterator_race(Eina_Iterator *it);
115#include "efl_model_container_item.eo.h" 115#include "efl_model_container_item.eo.h"
116#include "efl_model_composite_boolean.eo.h" 116#include "efl_model_composite_boolean.eo.h"
117#include "efl_model_composite_boolean_children.eo.h" 117#include "efl_model_composite_boolean_children.eo.h"
118#include "efl_model_composite_selection.eo.h"
119#include "efl_model_composite_selection_children.eo.h"
118 120
119/** 121/**
120 * @} 122 * @}
diff --git a/src/lib/ecore/efl_model_accessor_view.c b/src/lib/ecore/efl_model_accessor_view.c
new file mode 100644
index 0000000000..6b62b1ddac
--- /dev/null
+++ b/src/lib/ecore/efl_model_accessor_view.c
@@ -0,0 +1,104 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eina.h"
6#include "Eo.h"
7
8#include "efl_model_accessor_view_private.h"
9
10typedef struct _Efl_Model_Accessor
11{
12 Eina_Accessor vtable;
13 Eina_Accessor *real_accessor;
14 void* pdata;
15 Efl_Model_Accessor_View_Constructor_Cb cb;
16} Efl_Model_Accessor;
17
18static Eina_Bool
19_efl_model_acessor_get_at(Efl_Model_Accessor *acc, unsigned int idx, void **data)
20{
21 void* eo;
22 Eo *p, *new_eo;
23
24 if(eina_accessor_data_get(acc->real_accessor, idx, &eo))
25 {
26 p = eo;
27 new_eo = acc->cb(acc->pdata, p);
28 *data = new_eo;
29 return EINA_TRUE;
30 }
31 else
32 return EINA_FALSE;
33}
34
35static void *
36_efl_model_acessor_get_container(Efl_Model_Accessor *acc)
37{
38 return eina_accessor_container_get(acc->real_accessor);
39}
40
41static void
42_efl_model_acessor_free(Efl_Model_Accessor *acc)
43{
44 if (acc->real_accessor)
45 {
46 eina_accessor_free(acc->real_accessor);
47 acc->real_accessor = NULL;
48 }
49
50 free(acc);
51}
52
53static Eina_Bool
54_efl_model_acessor_lock(Efl_Model_Accessor *acc)
55{
56 return eina_accessor_lock(acc->real_accessor);
57}
58
59static Eina_Bool
60_efl_model_acessor_unlock(Efl_Model_Accessor *acc)
61{
62 return eina_accessor_unlock(acc->real_accessor);
63}
64
65static Efl_Model_Accessor *
66_efl_model_acessor_clone(Efl_Model_Accessor *acc EINA_UNUSED)
67{
68 return NULL;
69}
70
71static void
72_efl_model_accessor_setup(Efl_Model_Accessor *acc,
73 Eina_Accessor* real_accessor,
74 Efl_Model_Accessor_View_Constructor_Cb ctor,
75 void* pdata)
76{
77 acc->vtable.version = EINA_ACCESSOR_VERSION;
78 acc->vtable.get_at = FUNC_ACCESSOR_GET_AT(_efl_model_acessor_get_at);
79 acc->vtable.get_container = FUNC_ACCESSOR_GET_CONTAINER(_efl_model_acessor_get_container);
80 acc->vtable.free = FUNC_ACCESSOR_FREE(_efl_model_acessor_free);
81
82 acc->vtable.lock = FUNC_ACCESSOR_LOCK(_efl_model_acessor_lock);
83 acc->vtable.unlock = FUNC_ACCESSOR_LOCK(_efl_model_acessor_unlock);
84
85 acc->vtable.clone = FUNC_ACCESSOR_CLONE(_efl_model_acessor_clone);
86
87 EINA_MAGIC_SET(&acc->vtable, EINA_MAGIC_ACCESSOR);
88
89 acc->real_accessor = real_accessor;
90 acc->cb = ctor;
91 acc->pdata = pdata;
92}
93
94Eina_Accessor* efl_model_accessor_view_new(Eina_Accessor* accessor,
95 Efl_Model_Accessor_View_Constructor_Cb ctor,
96 void* data)
97{
98 Efl_Model_Accessor* acc = calloc(1, sizeof(Efl_Model_Accessor));
99 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
100 _efl_model_accessor_setup(acc, accessor, ctor, data);
101 return &acc->vtable;
102}
103
104
diff --git a/src/lib/ecore/efl_model_accessor_view_private.h b/src/lib/ecore/efl_model_accessor_view_private.h
new file mode 100644
index 0000000000..c44f2ec3cb
--- /dev/null
+++ b/src/lib/ecore/efl_model_accessor_view_private.h
@@ -0,0 +1,5 @@
1
2typedef Eo*(*Efl_Model_Accessor_View_Constructor_Cb)(void* data, Eo* child);
3
4Eina_Accessor* efl_model_accessor_view_new(Eina_Accessor* accessor,
5 Efl_Model_Accessor_View_Constructor_Cb constructor, void* data);
diff --git a/src/lib/ecore/efl_model_composite_boolean.c b/src/lib/ecore/efl_model_composite_boolean.c
index 7ec344d05c..b9b83b989a 100644
--- a/src/lib/ecore/efl_model_composite_boolean.c
+++ b/src/lib/ecore/efl_model_composite_boolean.c
@@ -151,33 +151,46 @@ static Efl_Future *
151_efl_model_composite_boolean_children_efl_model_property_get(Eo *obj EINA_UNUSED, 151_efl_model_composite_boolean_children_efl_model_property_get(Eo *obj EINA_UNUSED,
152 Efl_Model_Composite_Boolean_Children_Data *pd, const char *property) 152 Efl_Model_Composite_Boolean_Children_Data *pd, const char *property)
153{ 153{
154 fprintf(stderr, "%s %s:%d %s\n", __func__, __FILE__, __LINE__, property); fflush(stderr);
154 Efl_Model_Hash_Value *hv = eina_hash_find(pd->parent_pd->values, property); 155 Efl_Model_Hash_Value *hv = eina_hash_find(pd->parent_pd->values, property);
155 if (hv) 156 if (hv)
156 { 157 {
158 fprintf(stderr, "%s %s:%d %s\n", __func__, __FILE__, __LINE__, property); fflush(stderr);
157 Efl_Promise *promise = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get()); 159 Efl_Promise *promise = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
158 Efl_Future *rfuture = efl_promise_future_get(promise); 160 Efl_Future *rfuture = efl_promise_future_get(promise);
161 fprintf(stderr, "%s %s:%d %s\n", __func__, __FILE__, __LINE__, property); fflush(stderr);
159 162
160 Eina_Value *eina_value = eina_value_new(EINA_VALUE_TYPE_UCHAR); 163 Eina_Value *eina_value = eina_value_new(EINA_VALUE_TYPE_UCHAR);
161 if (hv->bits_count <= pd->index) 164 if (hv->bits_count <= pd->index)
162 { 165 {
163 unsigned char f = hv->default_value; 166 fprintf(stderr, "%s %s:%d %s\n", __func__, __FILE__, __LINE__, property); fflush(stderr);
164 eina_value_set(eina_value, f); 167 unsigned char f = hv->default_value;
168 eina_value_set(eina_value, f);
165 } 169 }
166 else 170 else
167 { 171 {
172 fprintf(stderr, "%s %s:%d %s\n", __func__, __FILE__, __LINE__, property); fflush(stderr);
168 eina_value_set(eina_value, _bit_get(hv->buffer, pd->index)); 173 eina_value_set(eina_value, _bit_get(hv->buffer, pd->index));
169 } 174 }
175 fprintf(stderr, "%s %s:%d %s\n", __func__, __FILE__, __LINE__, property); fflush(stderr);
170 efl_promise_value_set(promise, eina_value, (Eina_Free_Cb)eina_value_free); 176 efl_promise_value_set(promise, eina_value, (Eina_Free_Cb)eina_value_free);
177 fprintf(stderr, "%s %s:%d %s\n", __func__, __FILE__, __LINE__, property); fflush(stderr);
171 return rfuture; 178 return rfuture;
172 } 179 }
173 else if (pd->composite_child) 180 else if (pd->composite_child)
181 {
182 fprintf(stderr, "%s %s:%d %s\n", __func__, __FILE__, __LINE__, property); fflush(stderr);
174 return efl_model_property_get(pd->composite_child, property); 183 return efl_model_property_get(pd->composite_child, property);
184 }
175 else 185 else
176 { 186 {
187 fprintf(stderr, "%s %s:%d %s\n", __func__, __FILE__, __LINE__, property); fflush(stderr);
177 Efl_Promise *promise = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get()); 188 Efl_Promise *promise = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
178 Efl_Future *rfuture = efl_promise_future_get(promise); 189 Efl_Future *rfuture = efl_promise_future_get(promise);
179 190
191 fprintf(stderr, "%s %s:%d %s\n", __func__, __FILE__, __LINE__, property); fflush(stderr);
180 efl_promise_failed_set(promise, EFL_MODEL_ERROR_NOT_FOUND); 192 efl_promise_failed_set(promise, EFL_MODEL_ERROR_NOT_FOUND);
193 fprintf(stderr, "%s %s:%d %s\n", __func__, __FILE__, __LINE__, property); fflush(stderr);
181 return rfuture; 194 return rfuture;
182 } 195 }
183} 196}
@@ -494,7 +507,7 @@ _efl_model_composite_boolean_efl_object_destructor(Eo *obj, Efl_Model_Composite_
494} 507}
495 508
496static void 509static void
497_efl_model_composite_boolean_composite_model_set(Eo *obj EINA_UNUSED, 510_efl_model_composite_boolean_efl_ui_view_model_set(Eo *obj EINA_UNUSED,
498 Efl_Model_Composite_Boolean_Data *pd, Efl_Model *model) 511 Efl_Model_Composite_Boolean_Data *pd, Efl_Model *model)
499{ 512{
500 if (pd->composite_model) 513 if (pd->composite_model)
@@ -506,7 +519,7 @@ _efl_model_composite_boolean_composite_model_set(Eo *obj EINA_UNUSED,
506} 519}
507 520
508static Efl_Model * 521static Efl_Model *
509_efl_model_composite_boolean_composite_model_get(Eo *obj EINA_UNUSED, Efl_Model_Composite_Boolean_Data *pd) 522_efl_model_composite_boolean_efl_ui_view_model_get(Eo *obj EINA_UNUSED, Efl_Model_Composite_Boolean_Data *pd)
510{ 523{
511 return pd->composite_model; 524 return pd->composite_model;
512} 525}
diff --git a/src/lib/ecore/efl_model_composite_boolean.eo b/src/lib/ecore/efl_model_composite_boolean.eo
index cdca17e998..bb7eacbb11 100644
--- a/src/lib/ecore/efl_model_composite_boolean.eo
+++ b/src/lib/ecore/efl_model_composite_boolean.eo
@@ -1,17 +1,7 @@
1class Efl.Model.Composite.Boolean (Efl.Object, Efl.Model) 1class Efl.Model.Composite.Boolean (Efl.Object, Efl.Model, Efl.Ui.View)
2{ 2{
3 [[Efl model composite boolean class]] 3 [[Efl model composite boolean class]]
4 methods { 4 methods {
5 @property composite_model {
6 [[Composite model]]
7 set {
8 }
9 get {
10 }
11 values {
12 model: Efl.Model; [[Efl model]]
13 }
14 }
15 property_add { 5 property_add {
16 [[Adds property]] 6 [[Adds property]]
17 params { 7 params {
@@ -29,9 +19,10 @@ class Efl.Model.Composite.Boolean (Efl.Object, Efl.Model)
29 Efl.Model.children_count_get; 19 Efl.Model.children_count_get;
30 Efl.Model.child_add; 20 Efl.Model.child_add;
31 Efl.Model.child_del; 21 Efl.Model.child_del;
22 Efl.Ui.View.model { set; get; }
32 } 23 }
33 constructors { 24 constructors {
34 .composite_model; 25 Efl.Ui.View.model;
35 .property_add @optional; 26 .property_add @optional;
36 } 27 }
37} 28}
diff --git a/src/lib/ecore/efl_model_composite_selection.c b/src/lib/ecore/efl_model_composite_selection.c
new file mode 100644
index 0000000000..86e2fcf40e
--- /dev/null
+++ b/src/lib/ecore/efl_model_composite_selection.c
@@ -0,0 +1,144 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eina.h"
6#include "Efl.h"
7#include <Ecore.h>
8#include "Eo.h"
9
10#include "efl_model_composite_selection.eo.h"
11#include "efl_model_accessor_view_private.h"
12
13typedef struct _Efl_Model_Composite_Selection_Data
14{
15 Efl_Model_Composite_Selection* obj;
16 struct {
17 Efl_Model* selected_child;
18 } exclusive_data;
19 Eina_Bool is_exclusive;
20
21} Efl_Model_Composite_Selection_Data;
22
23typedef struct _Efl_Model_Composite_Selection_Children_Data
24{
25 Efl_Model_Composite_Selection_Data* pd;
26} Efl_Model_Composite_Selection_Children_Data;
27
28static Eo*
29_efl_model_composite_selection_efl_object_constructor(Eo *obj,
30 Efl_Model_Composite_Selection_Data *pd EINA_UNUSED)
31{
32 efl_constructor(efl_super(obj, EFL_MODEL_COMPOSITE_SELECTION_CLASS));
33 efl_model_composite_boolean_property_add(obj, "selected", EINA_FALSE);
34 return obj;
35}
36
37/***************************/
38
39static void _select_slice_then(void* data, Eo_Event const* event)
40{
41
42}
43
44/***************************/
45
46static Efl_Future*
47_efl_model_composite_selection_select(Eo *obj,
48 Efl_Model_Composite_Selection_Data *pd, int idx)
49{
50 if(pd->is_exclusive)
51 {
52
53 }
54 else
55 {
56
57 }
58}
59
60static Efl_Future *
61_efl_model_composite_selection_children_efl_model_property_set(Eo *obj EINA_UNUSED,
62 Efl_Model_Composite_Selection_Children_Data *pd, const char *property, const Eina_Value *value)
63{
64
65 fprintf(stderr, "%s %s:%d %s\n", __func__, __FILE__, __LINE__, property); fflush(stderr);
66 if(!strcmp("selected", property))
67 {
68 unsigned long v = EINA_FALSE;
69 if(eina_value_type_get(value) != EINA_VALUE_TYPE_ULONG)
70 {
71 Eina_Value to;
72 eina_value_setup(&to, EINA_VALUE_TYPE_ULONG);
73 if(eina_value_convert(value, &to))
74 eina_value_get(&to, &v);
75 eina_value_flush(&to);
76 }
77
78
79 if(v && pd->pd->is_exclusive)
80 {
81 Efl_Promise *promise = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
82 Efl_Future *rfuture = efl_promise_future_get(promise);
83 // unset current selected
84 // set this child as current
85 // bookkeep this child as current selection
86 // return with future for this asynchronous task
87 }
88 }
89
90 return efl_model_property_set(efl_super(obj, EFL_MODEL_COMPOSITE_SELECTION_CHILDREN_CLASS),
91 property, value);
92}
93
94static Eo* _construct_children(void* pdata, Eo* child)
95{
96 Efl_Model_Composite_Selection_Data* pd = pdata;
97 Eo* new_child = efl_add(EFL_MODEL_COMPOSITE_SELECTION_CHILDREN_CLASS, NULL);
98 Efl_Model_Composite_Selection_Children_Data* data = efl_data_scope_get
99 (new_child, EFL_MODEL_COMPOSITE_SELECTION_CHILDREN_CLASS);
100 data->pd = pd;
101 efl_composite_attach(new_child, child);
102 return new_child;
103}
104
105static void _composited_children_slice_get_then(void* data, Efl_Event const* event)
106{
107 Efl_Promise* promise = data;
108 Efl_Future_Event_Success* success = event->info;
109 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
110 efl_promise_value_set(promise,
111 efl_model_accessor_view_new(success->value, &_construct_children,
112 NULL),
113 (Eina_Free_Cb)&eina_accessor_free);
114 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
115}
116static void _composited_children_slice_get_fail(void* data, Efl_Event const* event)
117{
118 Efl_Promise* promise = data;
119 Efl_Future_Event_Failure* failure = event->info;
120 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
121 efl_promise_failed_set(promise, failure->error);
122}
123
124static Efl_Future *
125_efl_model_composite_selection_efl_model_children_slice_get(Eo *obj, Efl_Model_Composite_Selection_Data *pd, unsigned int start, unsigned int count)
126{
127 Efl_Promise *promise = efl_add(EFL_PROMISE_CLASS, ecore_main_loop_get());
128 Efl_Future *rfuture = efl_promise_future_get(promise);
129 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
130
131 Efl_Future* composited_future = efl_model_children_slice_get
132 (efl_super(obj, EFL_MODEL_COMPOSITE_SELECTION_CLASS),
133 start, count);
134 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
135 efl_future_then(composited_future, &_composited_children_slice_get_then,
136 &_composited_children_slice_get_fail, NULL, promise);
137 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
138
139 return rfuture;
140}
141
142#include "efl_model_composite_selection.eo.c"
143#include "efl_model_composite_selection_children.eo.c"
144
diff --git a/src/lib/ecore/efl_model_composite_selection.eo b/src/lib/ecore/efl_model_composite_selection.eo
new file mode 100644
index 0000000000..cfa9e388d8
--- /dev/null
+++ b/src/lib/ecore/efl_model_composite_selection.eo
@@ -0,0 +1,16 @@
1class Efl.Model.Composite.Selection (Efl.Model.Composite.Boolean)
2{
3 [[Efl model composite selection class]]
4 methods {
5 select {
6 params {
7 idx: int;
8 }
9 return: future<eina.value>;
10 }
11 }
12 implements {
13 Efl.Object.constructor;
14 Efl.Model.children_slice_get;
15 }
16}
diff --git a/src/lib/ecore/efl_model_composite_selection_children.eo b/src/lib/ecore/efl_model_composite_selection_children.eo
new file mode 100644
index 0000000000..2ea5c950ef
--- /dev/null
+++ b/src/lib/ecore/efl_model_composite_selection_children.eo
@@ -0,0 +1,7 @@
1class Efl.Model.Composite.Selection.Children (Efl.Object, Efl.Model)
2{
3 [[Efl model composite selection children class]]
4 implements {
5 Efl.Model.property_set;
6 }
7}
diff --git a/src/tests/efl/efl_test_model_composite_boolean.c b/src/tests/efl/efl_test_model_composite.c
index 2b94fa7aa0..4c6eef99c4 100644
--- a/src/tests/efl/efl_test_model_composite_boolean.c
+++ b/src/tests/efl/efl_test_model_composite.c
@@ -37,8 +37,15 @@ typedef struct _Test_Child_Data
37 unsigned int idx; 37 unsigned int idx;
38} Test_Child_Data; 38} Test_Child_Data;
39 39
40typedef struct _Selection_Test_Child_Data
41{
42 Test_Data *tdata;
43 unsigned int idx;
44} Selection_Test_Child_Data;
45
40const int child_number = 3; 46const int child_number = 3;
41const int base_ints[] = { 41, 42, 43 }; 47const int base_ints[] = { 41, 42, 43 };
48const Eina_Bool base_selections[] = { EINA_FALSE, EINA_FALSE, EINA_TRUE };
42 49
43static void 50static void
44_future_error_then(void *data EINA_UNUSED, Efl_Event const* event EINA_UNUSED) 51_future_error_then(void *data EINA_UNUSED, Efl_Event const* event EINA_UNUSED)
@@ -79,6 +86,38 @@ _property_get_then(void *data, Efl_Event const *event)
79} 86}
80 87
81static void 88static void
89_selection_property_get_then(void *data, Efl_Event const *event)
90{
91 Selection_Test_Child_Data *t = data;
92 Eina_Accessor *value_itt = (Eina_Accessor*)((Efl_Future_Event_Success*)event->info)->value;
93 int v_int = 0;
94 Eina_Bool v_bool = EINA_FALSE;
95
96 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
97
98#define EFL_TEST_value_get_and_compare(it, i, var, cmp) \
99 do { \
100 Eina_Value *vvv = NULL; \
101 if (!eina_accessor_data_get(it, i, (void **)&vvv) || !vvv || \
102 !eina_value_get(vvv, &var) || var != cmp) \
103 { \
104 fprintf(stderr, "Could not get value!\n"); fflush(stderr); \
105 ck_abort_msg("Could not get value"); \
106 return; \
107 } \
108 } while(0)
109
110 EFL_TEST_value_get_and_compare(value_itt, 0, v_int, base_ints[t->idx]);
111 EFL_TEST_value_get_and_compare(value_itt, 1, v_bool, base_selections[t->idx]);
112
113 t->tdata->child_count++;
114 if (t->tdata->child_count == 3)
115 t->tdata->success_flag = EINA_TRUE;
116
117#undef EFL_TEST_value_get_and_compare
118}
119
120static void
82_children_slice_get_then(void *data, Efl_Event const* event) 121_children_slice_get_then(void *data, Efl_Event const* event)
83{ 122{
84 Eina_Accessor *children = (Eina_Accessor *)((Efl_Future_Event_Success*)event->info)->value; 123 Eina_Accessor *children = (Eina_Accessor *)((Efl_Future_Event_Success*)event->info)->value;
@@ -86,7 +125,6 @@ _children_slice_get_then(void *data, Efl_Event const* event)
86 Test_Child_Data *t; 125 Test_Child_Data *t;
87 unsigned int i = 0; 126 unsigned int i = 0;
88 127
89 fprintf(stderr, "OPAAAAAAa\n");
90 EINA_ACCESSOR_FOREACH(children, i, child) 128 EINA_ACCESSOR_FOREACH(children, i, child)
91 { 129 {
92 Efl_Future *futures[3] = {NULL,}; 130 Efl_Future *futures[3] = {NULL,};
@@ -105,6 +143,37 @@ _children_slice_get_then(void *data, Efl_Event const* event)
105 } 143 }
106} 144}
107 145
146static void
147_selection_children_slice_get_then(void *data, Efl_Event const* event)
148{
149 Eina_Accessor *children = (Eina_Accessor *)((Efl_Future_Event_Success*)event->info)->value;
150 Efl_Model *child;
151 Test_Child_Data *t;
152 unsigned int i = 0;
153
154 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
155
156 EINA_ACCESSOR_FOREACH(children, i, child)
157 {
158 Efl_Future *futures[3] = {NULL,};
159 Efl_Future *future_all = NULL;
160
161 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
162 futures[0] = efl_model_property_get(child, "test_p_int");
163 futures[1] = efl_model_property_get(child, "selected");
164 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
165
166 future_all = efl_future_all(futures[0], futures[1]);
167 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
168
169 t = calloc(1, sizeof(Selection_Test_Child_Data));
170 t->tdata = data;
171 t->idx = i;
172 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
173 efl_future_then(future_all, _selection_property_get_then, _future_error_then, NULL, t);
174 }
175}
176
108START_TEST(efl_test_model_composite_boolean) 177START_TEST(efl_test_model_composite_boolean)
109{ 178{
110 Efl_Model_Item *base_model, *child; 179 Efl_Model_Item *base_model, *child;
@@ -131,7 +200,7 @@ START_TEST(efl_test_model_composite_boolean)
131 } 200 }
132 201
133 model = efl_add(EFL_MODEL_COMPOSITE_BOOLEAN_CLASS, NULL, 202 model = efl_add(EFL_MODEL_COMPOSITE_BOOLEAN_CLASS, NULL,
134 efl_model_composite_boolean_composite_model_set(efl_added, base_model), 203 efl_ui_view_model_set(efl_added, base_model),
135 efl_model_composite_boolean_property_add(efl_added, "test_p_true", EINA_TRUE), 204 efl_model_composite_boolean_property_add(efl_added, "test_p_true", EINA_TRUE),
136 efl_model_composite_boolean_property_add(efl_added, "test_p_false", EINA_FALSE)); 205 efl_model_composite_boolean_property_add(efl_added, "test_p_false", EINA_FALSE));
137 ck_assert(!!model); 206 ck_assert(!!model);
@@ -148,8 +217,53 @@ START_TEST(efl_test_model_composite_boolean)
148} 217}
149END_TEST 218END_TEST
150 219
220START_TEST(efl_test_model_composite_selection)
221{
222 Efl_Model_Item *base_model, *child;
223 int i;
224 Eina_Value v;
225 Efl_Model_Composite_Selection *model;
226 Test_Data *tdata;
227 Efl_Future *future;
228
229 fail_if(!ecore_init(), "ERROR: Cannot init Ecore!\n");
230 fail_if(!efl_object_init(), "ERROR: Cannot init EO!\n");
231
232 eina_value_setup(&v, EINA_VALUE_TYPE_INT);
233
234 base_model = efl_add(EFL_MODEL_ITEM_CLASS, NULL);
235 ck_assert(!!base_model);
236
237 for (i = 0; i < child_number; ++i)
238 {
239 child = efl_model_child_add(base_model);
240 ck_assert(!!child);
241 ck_assert(eina_value_set(&v, base_ints[i]));
242 efl_model_property_set(child, "test_p_int", &v);
243 }
244
245 model = efl_add(EFL_MODEL_COMPOSITE_SELECTION_CLASS, NULL,
246 efl_ui_view_model_set(efl_added, base_model));
247 ck_assert(!!model);
248 efl_model_composite_selection_select(model, 3);
249
250 tdata = calloc(1, sizeof(Test_Data));
251 future = efl_model_children_slice_get(model, 0, 0);
252 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
253 efl_future_then(future, _selection_children_slice_get_then, _future_error_then, NULL, tdata);
254 fprintf(stderr, "%s %s:%d\n", __func__, __FILE__, __LINE__); fflush(stderr);
255
256 ecore_main_loop_iterate();
257
258 ck_assert(tdata->success_flag);
259
260 ecore_shutdown();
261}
262END_TEST
263
151void 264void
152efl_test_case_model_composite_boolean(TCase *tc) 265efl_test_case_model_composite_boolean(TCase *tc)
153{ 266{
154 tcase_add_test(tc, efl_test_model_composite_boolean); 267 /* tcase_add_test(tc, efl_test_model_composite_boolean); */
268 tcase_add_test(tc, efl_test_model_composite_selection);
155} 269}
diff --git a/src/tests/efl/efl_test_model_container.c b/src/tests/efl/efl_test_model_container.c
index 5710ef2337..63e79d31e7 100644
--- a/src/tests/efl/efl_test_model_container.c
+++ b/src/tests/efl/efl_test_model_container.c
@@ -167,5 +167,5 @@ END_TEST
167void 167void
168efl_test_case_model_container(TCase *tc) 168efl_test_case_model_container(TCase *tc)
169{ 169{
170 tcase_add_test(tc, efl_test_model_container_values); 170 /* tcase_add_test(tc, efl_test_model_container_values); */
171} 171}