summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-02-12 11:06:48 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-05-01 10:39:01 -0700
commit702bcd7de9049776ebf97492775ffe6e35c7caf4 (patch)
tree95474d7100b32b4f7bda76e2881e241576e28b81 /src
parent37374c8da6443a4ad2f35215799a91a2091d9726 (diff)
eldbus: migrate tests to use new Efl.Model API.
Diffstat (limited to 'src')
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model.c338
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model.h7
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_connection.c85
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_method.c67
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_object.c126
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_proxy.c62
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_signal.c29
-rw-r--r--src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c61
8 files changed, 531 insertions, 244 deletions
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model.c b/src/tests/eldbus/eldbus_test_eldbus_model.c
index 642b501b0c..cb783544a9 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model.c
@@ -14,57 +14,68 @@
14#include "eldbus_test_eldbus_model.h" 14#include "eldbus_test_eldbus_model.h"
15#include "eldbus_suite.h" 15#include "eldbus_suite.h"
16 16
17static void 17static Eina_Value
18_future_then_quit_cb(void *data , Efl_Event const *event) 18_future_then_quit_u_cb(void *data,
19{ 19 const Eina_Value v,
20 Efl_Future_Event_Success* info = event->info; 20 const Eina_Future *dead_future EINA_UNUSED)
21 *(void**)data = info->value;
22 ecore_main_loop_quit();
23}
24
25static void
26_future_then_quit_u_cb(void *data , Efl_Event const *event)
27{ 21{
28 unsigned *lhs = data; 22 unsigned *lhs = data;
29 unsigned *rhs = ((Efl_Future_Event_Success*)event->info)->value;; 23 unsigned r = 0;
30 *lhs = *rhs; 24
25 eina_value_uint_get(&v, &r);
26
27 *lhs = r;
31 ecore_main_loop_quit(); 28 ecore_main_loop_quit();
29
30 return v;
32} 31}
33 32
34static void 33static Eina_Value
35_future_then_cp(void *data , Efl_Event const *event) 34_future_then_cp(void *data ,
35 const Eina_Value v,
36 const Eina_Future *dead_future EINA_UNUSED)
36{ 37{
37 Eina_Value* value = ((Efl_Future_Event_Success*)event->info)->value; 38 Eina_Value *value = data;
38 eina_value_copy(value, data); 39
40 eina_value_copy(&v, value);
39 ecore_main_loop_quit(); 41 ecore_main_loop_quit();
42
43 return v;
40} 44}
41 45
42 46
43static void 47static Eina_Value
44_future_check_err(void *data EINA_UNUSED, Efl_Event const *value EINA_UNUSED) 48_future_check_err(void *data,
49 const Eina_Value v,
50 const Eina_Future *dead_future EINA_UNUSED)
45{ 51{
46 ck_assert_msg(0, "Future Expected Error:\n"); 52 Eina_Error *expected_error = data;
53 Eina_Error got = 0;
47 54
48 ecore_main_loop_quit(); 55 fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ERROR);
49}
50 56
51static void 57 eina_value_error_get(&v, &got);
52_error_then_ok(void* data, Efl_Event const* event) 58
53{ 59 if (expected_error)
54 Efl_Future_Event_Failure* info = event->info; 60 ck_assert_int_eq(got, *expected_error);
55 Eina_Error const** expected_error = (Eina_Error const**)data;
56 61
57 if (*expected_error)
58 ck_assert_int_eq(info->error, **expected_error);
59 ecore_main_loop_quit(); 62 ecore_main_loop_quit();
63
64 return v;
60} 65}
61 66
62static void 67static Eina_Value
63_error_then_cb(void* data EINA_UNUSED, Efl_Event const* event) 68_future_then_quit_cb(void* data,
69 const Eina_Value v,
70 const Eina_Future *dead_future EINA_UNUSED)
64{ 71{
65 Efl_Future_Event_Failure* info = event->info; 72 Eina_Value **value = data;
66 ck_assert_msg(0,"Future ERROR: %s\n", eina_error_msg_get(info->error)); 73
74 *value = eina_value_dup(&v);
75
67 ecore_main_loop_quit(); 76 ecore_main_loop_quit();
77
78 return v;
68} 79}
69 80
70static void 81static void
@@ -74,27 +85,27 @@ _efl_event_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
74 efl_event_callback_stop(event->object); 85 efl_event_callback_stop(event->object);
75} 86}
76 87
77void * 88Eina_Value *
78efl_model_future_then(Efl_Future *future) 89efl_model_future_then(Eina_Future *future)
79{ 90{
80 void *data = NULL; 91 Eina_Value *data = NULL;
81 efl_future_then(future, &_future_then_quit_cb, &_error_then_cb, NULL, &data); 92 eina_future_then(future, &_future_then_quit_cb, &data);
82 ecore_main_loop_begin(); 93 ecore_main_loop_begin();
83 return data; 94 return data;
84} 95}
85 96
86void 97void
87check_efl_model_future_error(Efl_Future *future, Eina_Error *err) 98check_efl_model_future_error(Eina_Future *future, Eina_Error *err)
88{ 99{
89 efl_future_then(future, &_future_check_err, &_error_then_ok, NULL, &err); 100 eina_future_then(future, &_future_check_err, err);
90 ecore_main_loop_begin(); 101 ecore_main_loop_begin();
91} 102}
92 103
93int 104int
94efl_model_future_then_u(Efl_Future *future) 105efl_model_future_then_u(Eina_Future *future)
95{ 106{
96 unsigned i = -1; 107 unsigned i = -1;
97 efl_future_then(future, &_future_then_quit_u_cb, &_error_then_cb, NULL, &i); 108 eina_future_then(future, &_future_then_quit_u_cb, &i);
98 ecore_main_loop_begin(); 109 ecore_main_loop_begin();
99 return i; 110 return i;
100} 111}
@@ -110,21 +121,24 @@ efl_model_wait_for_event(Eo *obj, const Efl_Event_Description* event)
110Efl_Model * 121Efl_Model *
111efl_model_nth_child_get(Efl_Model *efl_model, unsigned int n) 122efl_model_nth_child_get(Efl_Model *efl_model, unsigned int n)
112{ 123{
113 Eina_Accessor *accessor; 124 Eina_Future *future;
114 Efl_Future *future; 125 Eina_Value *array;
126 Eo *child = NULL;
127 unsigned int len, i;
115 128
116 future = efl_model_children_slice_get(efl_model, n, 1); 129 future = efl_model_children_slice_get(efl_model, n, 1);
117 efl_ref(future);
118 ck_assert_ptr_ne(NULL, future);
119 130
120 accessor = efl_model_future_then(future); 131 array = efl_model_future_then(future);
121 ck_assert_ptr_ne(NULL, accessor); 132 fail_if(eina_value_type_get(array) != EINA_VALUE_TYPE_ARRAY);
122 Eo *child = NULL; 133
134 EINA_VALUE_ARRAY_FOREACH(array, len, i, child)
135 ;
136
137 child = efl_ref(child);
138 eina_value_free(array);
139
140 fail_if(!child);
123 141
124 Eina_Bool ret = eina_accessor_data_get(accessor, 0, (void**)&child);
125 efl_unref(future);
126 ck_assert(ret);
127 ck_assert_ptr_ne(NULL, child);
128 return child; 142 return child;
129} 143}
130 144
@@ -137,12 +151,11 @@ efl_model_first_child_get(Efl_Model *efl_model)
137void 151void
138check_property(Eo *object, const char *property_name, const char *expected_value) 152check_property(Eo *object, const char *property_name, const char *expected_value)
139{ 153{
140 Efl_Future *future; 154 Eina_Value *value;
141 future = efl_model_property_get(object, property_name);
142 ck_assert_ptr_ne(NULL, future);
143 Eina_Value *value = efl_model_future_then(future);
144 char *actual_value; 155 char *actual_value;
145 eina_value_get(value, &actual_value); 156
157 value = efl_model_property_get(object, property_name);
158 actual_value = eina_value_to_string(value);
146 if (!actual_value) 159 if (!actual_value)
147 ck_assert_ptr_eq(expected_value, actual_value); 160 ck_assert_ptr_eq(expected_value, actual_value);
148 else 161 else
@@ -151,12 +164,14 @@ check_property(Eo *object, const char *property_name, const char *expected_value
151 ck_assert_msg(is_property_equal, "'%s' != '%s'", expected_value, actual_value); 164 ck_assert_msg(is_property_equal, "'%s' != '%s'", expected_value, actual_value);
152 free(actual_value); 165 free(actual_value);
153 } 166 }
167 eina_value_free(value);
154} 168}
155 169
156Eo * 170Eo *
157create_connection(void) 171create_connection(void)
158{ 172{
159 Eo *connection = efl_add_ref(ELDBUS_MODEL_CONNECTION_CLASS, efl_main_loop_get(), eldbus_model_connection_custom_constructor(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE)); 173 Eo *connection = efl_add_ref(ELDBUS_MODEL_CONNECTION_CLASS, efl_main_loop_get(),
174 eldbus_model_connect(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE));
160 ck_assert_ptr_ne(NULL, connection); 175 ck_assert_ptr_ne(NULL, connection);
161 return connection; 176 return connection;
162} 177}
@@ -164,7 +179,10 @@ create_connection(void)
164Eo * 179Eo *
165create_object(void) 180create_object(void)
166{ 181{
167 Eo *object = efl_add_ref(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(), eldbus_model_object_custom_constructor(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE, ELDBUS_FDO_BUS, ELDBUS_FDO_PATH)); 182 Eo *object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(),
183 eldbus_model_connect(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE),
184 eldbus_model_object_bus_set(efl_added, ELDBUS_FDO_BUS),
185 eldbus_model_object_path_set(efl_added, ELDBUS_FDO_PATH));
168 ck_assert_ptr_ne(NULL, object); 186 ck_assert_ptr_ne(NULL, object);
169 return object; 187 return object;
170} 188}
@@ -173,9 +191,8 @@ void
173check_efl_model_children_count_eq(Efl_Model *efl_model, unsigned int expected_children_count) 191check_efl_model_children_count_eq(Efl_Model *efl_model, unsigned int expected_children_count)
174{ 192{
175 unsigned int actual_children_count; 193 unsigned int actual_children_count;
176 Efl_Future *future; 194
177 future = efl_model_children_count_get(efl_model); 195 actual_children_count = efl_model_children_count_get(efl_model);
178 actual_children_count = efl_model_future_then_u(future);
179 ck_assert_int_eq(expected_children_count, actual_children_count); 196 ck_assert_int_eq(expected_children_count, actual_children_count);
180} 197}
181 198
@@ -183,9 +200,8 @@ void
183check_efl_model_children_count_ge(Efl_Model *efl_model, unsigned int minimum_children_count) 200check_efl_model_children_count_ge(Efl_Model *efl_model, unsigned int minimum_children_count)
184{ 201{
185 unsigned int actual_children_count; 202 unsigned int actual_children_count;
186 Efl_Future *future; 203
187 future = efl_model_children_count_get(efl_model); 204 actual_children_count = efl_model_children_count_get(efl_model);
188 actual_children_count = efl_model_future_then_u(future);
189 ck_assert_int_ge(actual_children_count, minimum_children_count); 205 ck_assert_int_ge(actual_children_count, minimum_children_count);
190} 206}
191 207
@@ -193,72 +209,60 @@ void
193check_efl_model_children_slice_get(Efl_Model *efl_model) 209check_efl_model_children_slice_get(Efl_Model *efl_model)
194{ 210{
195 unsigned count; 211 unsigned count;
196 Efl_Future *future; 212 Eina_Future *future;
197 Eina_Accessor *accessor; 213 Eina_Value *array;
214 Eo *first_child = NULL;
215 Eo *last_child = NULL;
216 Eo *nonexistent_child = NULL;
217 Eo *child = NULL;
198 218
199 future = efl_model_children_count_get(efl_model); 219 count = efl_model_children_count_get(efl_model);
200 count = efl_model_future_then_u(future);
201 ck_assert_msg((int)count > 0, "There must be at least 1 child to test"); 220 ck_assert_msg((int)count > 0, "There must be at least 1 child to test");
202 221
203 // Test slice all 222 // Test slice all
204 future = efl_model_children_slice_get(efl_model, 0, 0); 223 future = efl_model_children_slice_get(efl_model, 0, count);
205 efl_ref(future); 224 array = efl_model_future_then(future);
206 accessor = efl_model_future_then(future); 225 ck_assert_ptr_ne(NULL, array);
207 ck_assert_ptr_ne(NULL, accessor); 226 fail_if(eina_value_type_get(array) != EINA_VALUE_TYPE_ARRAY);
208 227
209 // Get first child 228 // Get first child
210 Eo *first_child = NULL; 229 eina_value_array_get(array, 0, &first_child);
211 Eina_Bool ret = eina_accessor_data_get(accessor, 0, (void**)&first_child);
212 ck_assert(ret);
213 ck_assert_ptr_ne(NULL, first_child); 230 ck_assert_ptr_ne(NULL, first_child);
214 231
215 // get last child 232 // get last child
216 Eo *last_child = NULL; 233 eina_value_array_get(array, count - 1, &last_child);
217 ret = eina_accessor_data_get(accessor, count - 1, (void**)&last_child);
218 ck_assert(ret);
219 ck_assert_ptr_ne(NULL, last_child); 234 ck_assert_ptr_ne(NULL, last_child);
220 235
221 // Test nonexistent child 236 // Test nonexistent child
222 Eo *nonexistent_child = NULL; 237 eina_value_array_get(array, count, &nonexistent_child);
223 ret = eina_accessor_data_get(accessor, count, (void**)&nonexistent_child);
224 ck_assert(!ret);
225 ck_assert_ptr_eq(NULL, nonexistent_child); 238 ck_assert_ptr_eq(NULL, nonexistent_child);
226 efl_unref(future); 239 eina_value_free(array);
227 240
228 // Test slice first child 241 // Test slice first child
229 Eo *child = NULL;
230 future = efl_model_children_slice_get(efl_model, 0, 1); 242 future = efl_model_children_slice_get(efl_model, 0, 1);
231 efl_ref(future); 243 array = efl_model_future_then(future);
232 accessor = efl_model_future_then(future); 244 ck_assert_ptr_ne(NULL, array);
233 ck_assert_ptr_ne(NULL, accessor); 245 eina_value_array_get(array, 0, &child);
234 ret = eina_accessor_data_get(accessor, 0, (void**)&child);
235 ck_assert(ret);
236 ck_assert_ptr_ne(NULL, child); 246 ck_assert_ptr_ne(NULL, child);
237 ret = eina_accessor_data_get(accessor, 1, (void**)&child); 247 eina_value_array_get(array, 1, &child);
238 ck_assert(!ret);
239 ck_assert_ptr_eq(first_child, child); 248 ck_assert_ptr_eq(first_child, child);
240 efl_unref(future); 249 eina_value_free(array);
241 250
242 // Test slice last child 251 // Test slice last child
243 future = efl_model_children_slice_get(efl_model, count - 1, 1); 252 future = efl_model_children_slice_get(efl_model, count - 1, 1);
244 efl_ref(future); 253 array = efl_model_future_then(future);
245 accessor = efl_model_future_then(future); 254 ck_assert_ptr_ne(NULL, array);
246 ck_assert_ptr_ne(NULL, accessor); 255 eina_value_array_get(array, 0, &child);
247 ret = eina_accessor_data_get(accessor, 0, (void**)&child);
248 ck_assert(ret);
249 ck_assert_ptr_ne(NULL, child); 256 ck_assert_ptr_ne(NULL, child);
250 ret = eina_accessor_data_get(accessor, 1, (void**)&child); 257 eina_value_array_get(array, 1, &child);
251 ck_assert(!ret);
252 ck_assert_ptr_eq(last_child, child); 258 ck_assert_ptr_eq(last_child, child);
253 efl_unref(future);
254 259
255 // Test slice nonexistent element 260 // Test slice nonexistent element
256 future = efl_model_children_slice_get(efl_model, count, 1); 261 future = efl_model_children_slice_get(efl_model, count, 1);
257 efl_ref(future);
258 ck_assert_ptr_ne(NULL, future); 262 ck_assert_ptr_ne(NULL, future);
259 accessor = efl_model_future_then(future); 263 array = efl_model_future_then(future);
260 ck_assert_ptr_eq(NULL, accessor); 264 fail_if(eina_value_type_get(array) != EINA_VALUE_TYPE_ERROR);
261 efl_unref(future); 265 eina_value_free(array);
262} 266}
263 267
264EFL_START_TEST(smoke) 268EFL_START_TEST(smoke)
@@ -277,29 +281,58 @@ EFL_START_TEST(object)
277} 281}
278EFL_END_TEST 282EFL_END_TEST
279 283
284static Eina_Value
285_leave(void *data EINA_UNUSED, const Eina_Value v,
286 const Eina_Future *dead EINA_UNUSED)
287{
288 ecore_main_loop_quit();
289 return v;
290}
291static void
292_count_changed(void *data EINA_UNUSED, const Efl_Event *ev)
293{
294 Eina_Future *f;
295 f = efl_loop_job(efl_provider_find(ev->object, EFL_LOOP_CLASS));
296 eina_future_then(f, _leave, NULL);
297}
298
299static Eina_Future *
300_async_slice_get(Efl_Model *model)
301{
302 efl_event_callback_add(model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
303 if (!efl_model_children_count_get(model))
304 ecore_main_loop_begin();
305
306 efl_event_callback_del(model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
307
308 return efl_model_children_slice_get(model, 0, efl_model_children_count_get(model));
309}
310
280EFL_START_TEST(proxy) 311EFL_START_TEST(proxy)
281{ 312{
282 Eo *root = create_object(); 313 Eina_Future *future = NULL;
314 Eina_Value *array = NULL;
315 Eo *proxy = NULL;
316 Eo *root;
317 unsigned int i, len;
318
319 root = create_object();
283 320
284 Eina_Accessor *accessor = NULL; 321 future = _async_slice_get(root);
285 Efl_Future *future = NULL;
286 future = efl_model_children_slice_get(root, 0, 0);
287 efl_ref(future);
288 ck_assert_ptr_ne(NULL, future); 322 ck_assert_ptr_ne(NULL, future);
289 323
290 accessor = efl_model_future_then(future); 324 array = efl_model_future_then(future);
291 ck_assert_ptr_ne(NULL, accessor); 325 ck_assert_ptr_ne(NULL, array);
292 326
293 unsigned int i; 327 EINA_VALUE_ARRAY_FOREACH(array, len, i, proxy)
294 Eo *proxy;
295 EINA_ACCESSOR_FOREACH(accessor, i, proxy)
296 { 328 {
297 ck_assert_ptr_ne(NULL, proxy); 329 ck_assert_ptr_ne(NULL, proxy);
298 //efl_model_load_and_wait_for_load_status(proxy, EFL_MODEL_LOAD_STATUS_LOADED); 330 //efl_model_load_and_wait_for_load_status(proxy, EFL_MODEL_LOAD_STATUS_LOADED);
299 } 331 }
300 efl_unref(future);
301 332
302 efl_unref(root); 333 eina_value_free(array);
334
335 efl_del(root);
303 336
304} 337}
305EFL_END_TEST 338EFL_END_TEST
@@ -315,19 +348,19 @@ eldbus_test_eldbus_model(TCase *tc)
315Eldbus_Model_Proxy * 348Eldbus_Model_Proxy *
316eldbus_model_proxy_from_object_get(Eldbus_Model_Object *object, const char *interface_name) 349eldbus_model_proxy_from_object_get(Eldbus_Model_Object *object, const char *interface_name)
317{ 350{
318 Eina_Accessor *accessor; 351 Eina_Future *future = NULL;
319 Efl_Future *future = NULL;
320 future = efl_model_children_slice_get(object, 0, 0);
321 ck_assert_ptr_ne(NULL, future);
322 efl_ref(future);
323 accessor = efl_model_future_then(future);
324 ck_assert_ptr_ne(NULL, accessor);
325
326 Eo *proxy = NULL; 352 Eo *proxy = NULL;
327 unsigned int i; 353 Eina_Value *array;
328 EINA_ACCESSOR_FOREACH(accessor, i, proxy) 354 unsigned int len, i;
355
356 future = _async_slice_get(object);
357 array = efl_model_future_then(future);
358 ck_assert_ptr_ne(NULL, array);
359
360 EINA_VALUE_ARRAY_FOREACH(array, len, i, proxy)
329 { 361 {
330 const char *name; 362 const char *name;
363
331 name = eldbus_model_proxy_name_get(proxy); 364 name = eldbus_model_proxy_name_get(proxy);
332 ck_assert_ptr_ne(NULL, name); 365 ck_assert_ptr_ne(NULL, name);
333 if (strcmp(name, interface_name) == 0) 366 if (strcmp(name, interface_name) == 0)
@@ -336,29 +369,30 @@ eldbus_model_proxy_from_object_get(Eldbus_Model_Object *object, const char *inte
336 proxy = NULL; 369 proxy = NULL;
337 370
338end: 371end:
339 efl_unref(future); 372 eina_value_free(array);
340 return proxy; 373 return proxy;
341} 374}
342 375
343static Eldbus_Model_Arguments * 376static Eldbus_Model_Arguments *
344_eldbus_model_arguments_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *method_name, const Efl_Class *klass) 377_eldbus_model_arguments_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *method_name, const Efl_Class *klass)
345{ 378{
346 Eina_Accessor *accessor; 379 Eina_Future *future = NULL;
347 Efl_Future *future = NULL; 380 Eo *child = NULL;
348 future = efl_model_children_slice_get(proxy, 0, 0); 381 Eina_Value *array;
382 unsigned int len, i;
383
384 future = _async_slice_get(proxy);
349 ck_assert_ptr_ne(NULL, future); 385 ck_assert_ptr_ne(NULL, future);
350 efl_ref(future); 386 array = efl_model_future_then(future);
351 accessor = efl_model_future_then(future); 387 ck_assert_ptr_ne(NULL, array);
352 ck_assert_ptr_ne(NULL, accessor);
353 388
354 Eo *child = NULL; 389 EINA_VALUE_ARRAY_FOREACH(array, len, i, child)
355 unsigned int i;
356 EINA_ACCESSOR_FOREACH(accessor, i, child)
357 { 390 {
391 const char *name;
392
358 if (!efl_isa(child, klass)) 393 if (!efl_isa(child, klass))
359 continue; 394 continue;
360 395
361 const char *name;
362 name = eldbus_model_arguments_arg_name_get(child); 396 name = eldbus_model_arguments_arg_name_get(child);
363 ck_assert_ptr_ne(NULL, name); 397 ck_assert_ptr_ne(NULL, name);
364 if (strcmp(name, method_name) == 0) 398 if (strcmp(name, method_name) == 0)
@@ -367,7 +401,7 @@ _eldbus_model_arguments_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *me
367 child = NULL; 401 child = NULL;
368 402
369end: 403end:
370 efl_unref(future); 404 eina_value_free(array);
371 return child; 405 return child;
372} 406}
373 407
@@ -386,41 +420,39 @@ eldbus_model_signal_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *signal
386void 420void
387check_efl_model_property_int_eq(Efl_Model *efl_model, const char *property, int expected_value) 421check_efl_model_property_int_eq(Efl_Model *efl_model, const char *property, int expected_value)
388{ 422{
389 Eina_Value property_value; 423 const Eina_Value_Type *property_type;
390 Efl_Future *future; 424 Eina_Value *property_value;
391 future = efl_model_property_get(efl_model, property); 425 int actual_value = 0;
392 ck_assert_ptr_ne(NULL, future);
393
394 efl_future_then(future, &_future_then_cp, &_error_then_cb, NULL, &property_value);
395 ecore_main_loop_begin();
396 426
397 const Eina_Value_Type *property_type = eina_value_type_get(&property_value); 427 property_value = efl_model_property_get(efl_model, property);
428 property_type = eina_value_type_get(property_value);
398 ck_assert_ptr_eq(EINA_VALUE_TYPE_INT, property_type); 429 ck_assert_ptr_eq(EINA_VALUE_TYPE_INT, property_type);
399 430
400 int actual_value = 0; 431 eina_value_get(property_value, &actual_value);
401 eina_value_get(&property_value, &actual_value);
402 ck_assert_int_eq(expected_value, actual_value); 432 ck_assert_int_eq(expected_value, actual_value);
403 eina_value_flush(&property_value); 433 eina_value_free(property_value);
404} 434}
405 435
406void 436void
407check_efl_model_property_int_set(Efl_Model *efl_model, const char *property, int value) 437check_efl_model_property_int_set(Efl_Model *efl_model, const char *property, int value)
408{ 438{
409 Eina_Value eina_value, value_ret; 439 Eina_Value eina_value = EINA_VALUE_EMPTY, value_ret = EINA_VALUE_EMPTY;
410 Efl_Future *future; 440 Eina_Future *future;
441 const Eina_Value_Type *property_type;
411 442
412 eina_value_setup(&eina_value, EINA_VALUE_TYPE_INT); 443 eina_value_setup(&eina_value, EINA_VALUE_TYPE_INT);
413 eina_value_set(&eina_value, value); 444 eina_value_set(&eina_value, value);
414 future = efl_model_property_set(efl_model, property, &eina_value); 445 future = efl_model_property_set(efl_model, property, &eina_value);
415 446
416 efl_future_then(future, &_future_then_cp, &_error_then_cb, NULL, &value_ret); 447 eina_future_then(future, &_future_then_cp, &value_ret);
417 ecore_main_loop_begin(); 448 ecore_main_loop_begin();
418 449
419 const Eina_Value_Type *property_type = eina_value_type_get(&value_ret); 450 property_type = eina_value_type_get(&value_ret);
420 ck_assert_ptr_eq(EINA_VALUE_TYPE_INT, property_type); 451 ck_assert_ptr_eq(EINA_VALUE_TYPE_INT, property_type);
421 452
422 int actual_value; 453 int actual_value;
423 eina_value_get(&value_ret, &actual_value); 454 eina_value_get(&value_ret, &actual_value);
424 ck_assert_int_eq(value, actual_value); 455 ck_assert_int_eq(value, actual_value);
425 eina_value_flush(&eina_value); 456 eina_value_flush(&eina_value);
457 eina_value_flush(&value_ret);
426} 458}
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model.h b/src/tests/eldbus/eldbus_test_eldbus_model.h
index 6eee973e3c..c23c36680d 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model.h
+++ b/src/tests/eldbus/eldbus_test_eldbus_model.h
@@ -19,11 +19,10 @@ void check_efl_model_children_count_ge(Efl_Model *obj, unsigned int minimum_chil
19void check_efl_model_children_slice_get(Efl_Model *efl_model); 19void check_efl_model_children_slice_get(Efl_Model *efl_model);
20void check_efl_model_property_int_eq(Efl_Model *obj, const char *property, int expected_value); 20void check_efl_model_property_int_eq(Efl_Model *obj, const char *property, int expected_value);
21void check_efl_model_property_int_set(Efl_Model *obj, const char *property, int value); 21void check_efl_model_property_int_set(Efl_Model *obj, const char *property, int value);
22void check_efl_model_future_error(Efl_Future *future, Eina_Error *err); 22void check_efl_model_future_error(Eina_Future *future, Eina_Error *err);
23 23
24 24Eina_Value *efl_model_future_then(Eina_Future *future);
25void *efl_model_future_then(Efl_Future *future); 25int efl_model_future_then_u(Eina_Future *future);
26int efl_model_future_then_u(Efl_Future *future);
27 26
28Eldbus_Model_Proxy *eldbus_model_proxy_from_object_get(Eldbus_Model_Object *object, const char *interface_name); 27Eldbus_Model_Proxy *eldbus_model_proxy_from_object_get(Eldbus_Model_Object *object, const char *interface_name);
29Eldbus_Model_Method *eldbus_model_method_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *method_name); 28Eldbus_Model_Method *eldbus_model_method_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *method_name);
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_connection.c b/src/tests/eldbus/eldbus_test_eldbus_model_connection.c
index 254a600bd6..2eba5e4386 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_connection.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_connection.c
@@ -41,40 +41,88 @@ EFL_END_TEST
41 41
42EFL_START_TEST(property_get) 42EFL_START_TEST(property_get)
43{ 43{
44 Efl_Future *future; 44 Eina_Value *v;
45 future = efl_model_property_get(connection, UNIQUE_NAME_PROPERTY); 45
46 efl_model_future_then(future); 46 v = efl_model_property_get(connection, UNIQUE_NAME_PROPERTY);
47 fail_if(v == NULL);
47 48
48 // Nonexistent property must raise ERROR 49 // Nonexistent property must raise ERROR
49 future = NULL; 50 v = efl_model_property_get(connection, "nonexistent");
50 future = efl_model_property_get(connection, "nonexistent"); 51 fail_if(v == NULL);
51 check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_FOUND); 52 fail_if(eina_value_type_get(v) != EINA_VALUE_TYPE_ERROR);
53 /* fail_if(v != NULL || eina_value_type_get(v) != EINA_VALUE_TYPE_ERROR); */
52} 54}
53EFL_END_TEST 55EFL_END_TEST
54 56
57static Eina_Value
58_failed_property_set(void *data, const Eina_Value v,
59 const Eina_Future *dead_future EINA_UNUSED)
60{
61 Eina_Value *expected = data;
62
63 fail_if(eina_value_type_get(expected) != eina_value_type_get(&v));
64
65 if (eina_value_type_get(expected) == EINA_VALUE_TYPE_ERROR)
66 {
67 Eina_Error exerr = 0, goterr = 0;
68
69 eina_value_error_get(expected, &exerr);
70 eina_value_error_get(&v, &goterr);
71
72 fail_if(exerr != goterr);
73 }
74 ecore_main_loop_quit();
75
76 return v;
77}
78
55EFL_START_TEST(property_set) 79EFL_START_TEST(property_set)
56{ 80{
57 Eina_Value value; 81 Eina_Value value;
58 Efl_Future *future; 82 Eina_Future *future;
59 83
60 // Nonexistent property must raise ERROR 84 // Nonexistent property must raise ERROR
61 eina_value_setup(&value, EINA_VALUE_TYPE_INT); 85 eina_value_setup(&value, EINA_VALUE_TYPE_INT);
62 eina_value_set(&value, 1); 86 eina_value_set(&value, 1);
63 future = efl_model_property_set(connection, "nonexistent", &value); 87 future = efl_model_property_set(connection, "nonexistent", &value);
64 check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_FOUND); 88 eina_future_then(future, _failed_property_set, eina_value_error_new(EFL_MODEL_ERROR_NOT_FOUND));
89
90 ecore_main_loop_begin();
65 91
66 // UNIQUE_NAME_PROPERTY is read-only 92 // UNIQUE_NAME_PROPERTY is read-only
67 future = efl_model_property_set(connection, UNIQUE_NAME_PROPERTY, &value); 93 future = efl_model_property_set(connection, UNIQUE_NAME_PROPERTY, &value);
68 check_efl_model_future_error(future, &EFL_MODEL_ERROR_READ_ONLY); 94 eina_future_then(future, _failed_property_set, eina_value_error_new(EFL_MODEL_ERROR_READ_ONLY));
95
96 ecore_main_loop_begin();
69 97
70 eina_value_flush(&value); 98 eina_value_flush(&value);
71} 99}
72EFL_END_TEST 100EFL_END_TEST
73 101
102static Eina_Value
103_leave(void *data EINA_UNUSED, const Eina_Value v,
104 const Eina_Future *dead EINA_UNUSED)
105{
106 ecore_main_loop_quit();
107 return v;
108}
109static void
110_count_changed(void *data EINA_UNUSED, const Efl_Event *ev)
111{
112 Eina_Future *f;
113 f = efl_loop_job(efl_provider_find(ev->object, EFL_LOOP_CLASS));
114 eina_future_then(f, _leave, NULL);
115}
116
74static void 117static void
75_test_children_count(Eo *efl_model) 118_test_children_count(Eo *efl_model)
76{ 119{
77 // At least this connection <unique_name> and 'org.freedesktop.DBus' must exist 120 // At least this connection <unique_name> and 'org.freedesktop.DBus' must exist
121 efl_event_callback_add(efl_model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
122 if (!efl_model_children_count_get(efl_model))
123 ecore_main_loop_begin();
124 efl_event_callback_del(efl_model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
125
78 check_efl_model_children_count_ge(efl_model, 2); 126 check_efl_model_children_count_ge(efl_model, 2);
79} 127}
80 128
@@ -86,6 +134,11 @@ EFL_END_TEST
86 134
87EFL_START_TEST(children_slice_get) 135EFL_START_TEST(children_slice_get)
88{ 136{
137 efl_event_callback_add(connection, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
138 if (!efl_model_children_count_get(connection))
139 ecore_main_loop_begin();
140 efl_event_callback_del(connection, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
141
89 check_efl_model_children_slice_get(connection); 142 check_efl_model_children_slice_get(connection);
90} 143}
91EFL_END_TEST 144EFL_END_TEST
@@ -101,17 +154,15 @@ EFL_END_TEST
101EFL_START_TEST(child_del) 154EFL_START_TEST(child_del)
102{ 155{
103 unsigned int expected_children_count = 0; 156 unsigned int expected_children_count = 0;
104 Efl_Future *future; 157 unsigned int actual_children_count = 0;
105 future = efl_model_children_count_get(connection); 158 Eo *child;
106 ck_assert_ptr_ne(NULL, future);
107 expected_children_count = efl_model_future_then_u(future);
108 159
109 Eo *child = efl_model_first_child_get(connection); 160 expected_children_count = efl_model_children_count_get(connection);
161
162 child = efl_model_first_child_get(connection);
110 efl_model_child_del(connection, child); 163 efl_model_child_del(connection, child);
111 164
112 unsigned int actual_children_count = 0; 165 actual_children_count = efl_model_children_count_get(connection);
113 future = efl_model_children_count_get(connection);
114 actual_children_count = efl_model_future_then_u(future);
115 166
116 ck_assert_int_le(expected_children_count, actual_children_count); 167 ck_assert_int_le(expected_children_count, actual_children_count);
117} 168}
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_method.c b/src/tests/eldbus/eldbus_test_eldbus_model_method.c
index 073aee82dd..5e561d4a5a 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_method.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_method.c
@@ -27,7 +27,10 @@ _setup(void)
27{ 27{
28 fake_server = fake_server_start(&fake_server_data); 28 fake_server = fake_server_start(&fake_server_data);
29 29
30 fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(), eldbus_model_object_custom_constructor(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE, FAKE_SERVER_BUS, FAKE_SERVER_PATH)); 30 fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(),
31 eldbus_model_connect(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE),
32 eldbus_model_object_bus_set(efl_added, FAKE_SERVER_BUS),
33 eldbus_model_object_path_set(efl_added, FAKE_SERVER_PATH));
31 ck_assert_ptr_ne(NULL, fake_server_object); 34 ck_assert_ptr_ne(NULL, fake_server_object);
32 35
33 fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE); 36 fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE);
@@ -60,26 +63,59 @@ EFL_END_TEST
60EFL_START_TEST(property_get) 63EFL_START_TEST(property_get)
61{ 64{
62 // Input only property returns error 65 // Input only property returns error
63 Efl_Future *future; 66 Eina_Value *v;
64 future = efl_model_property_get(method, ARGUMENT_A); 67 Eina_Value i = EINA_VALUE_EMPTY;
65 check_efl_model_future_error(future, NULL); 68 int iv = -1;
66 69
67 future = efl_model_property_get(method, ARGUMENT_RESULT); 70 v = efl_model_property_get(method, ARGUMENT_A);
68 efl_model_future_then(future); 71 fail_if(eina_value_type_get(v) != EINA_VALUE_TYPE_ERROR);
72 eina_value_free(v);
73
74 v = efl_model_property_get(method, ARGUMENT_RESULT);
75 eina_value_setup(&i, EINA_VALUE_TYPE_INT);
76 fail_if(eina_value_convert(v, &i) != EINA_TRUE);
77 fail_if(eina_value_int_get(&i, &iv) != EINA_TRUE);
78 fail_if(iv != 0);
79 eina_value_flush(&i);
80 eina_value_free(v);
69 81
70 // Nonexistent property returns error 82 // Nonexistent property returns error
71 future = efl_model_property_get(method, "nonexistent"); 83 v = efl_model_property_get(method, "nonexistent");
72 check_efl_model_future_error(future, NULL); 84 fail_if(eina_value_type_get(v) != EINA_VALUE_TYPE_ERROR);
85 eina_value_free(v);
73} 86}
74EFL_END_TEST 87EFL_END_TEST
75 88
89static Eina_Value
90_expected_error(void *data,
91 const Eina_Value v,
92 const Eina_Future *dead_future EINA_UNUSED)
93{
94 fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ERROR);
95
96 if (data)
97 {
98 Eina_Error *expected = data;
99 Eina_Error error;
100
101 eina_value_error_get(&v, &error);
102
103 fail_if(*expected != error);
104 }
105
106 ecore_main_loop_quit();
107
108 return v;
109}
110
76EFL_START_TEST(property_set) 111EFL_START_TEST(property_set)
77{ 112{
78 // Output argument returns error 113 // Output argument returns error
79 Efl_Future *future; 114 Eina_Future *future;
80 Eina_Value dummy = {0}; 115 Eina_Value dummy = EINA_VALUE_EMPTY;
116
81 future = efl_model_property_set(method, ARGUMENT_RESULT, &dummy); 117 future = efl_model_property_set(method, ARGUMENT_RESULT, &dummy);
82 check_efl_model_future_error(future, NULL); 118 eina_future_then(future, _expected_error, NULL);
83} 119}
84EFL_END_TEST 120EFL_END_TEST
85 121
@@ -97,9 +133,12 @@ EFL_END_TEST
97 133
98EFL_START_TEST(children_slice_get) 134EFL_START_TEST(children_slice_get)
99{ 135{
100 Efl_Future *future; 136 Eina_Future *future;
137
101 future = efl_model_children_slice_get(method, 1, 1); 138 future = efl_model_children_slice_get(method, 1, 1);
102 check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_SUPPORTED); 139 eina_future_then(future, _expected_error, &EFL_MODEL_ERROR_NOT_SUPPORTED);
140
141 ecore_main_loop_begin();
103} 142}
104EFL_END_TEST 143EFL_END_TEST
105 144
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_object.c b/src/tests/eldbus/eldbus_test_eldbus_model_object.c
index caddcf4b18..3c5a2cbee2 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_object.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_object.c
@@ -41,31 +41,58 @@ EFL_END_TEST
41 41
42EFL_START_TEST(property_get) 42EFL_START_TEST(property_get)
43{ 43{
44 Efl_Future *future; 44 Eina_Value *v;
45 future = efl_model_property_get(object, UNIQUE_NAME_PROPERTY); 45
46 efl_model_future_then(future); 46 v = efl_model_property_get(object, UNIQUE_NAME_PROPERTY);
47 fail_if(v == NULL);
48 fail_if(eina_value_type_get(v) == EINA_VALUE_TYPE_ERROR);
49 eina_value_free(v);
47 50
48 // Nonexistent property must raise ERROR 51 // Nonexistent property must raise ERROR
49 future = NULL; 52 v = efl_model_property_get(object, "nonexistent");
50 future = efl_model_property_get(object, "nonexistent"); 53 fail_if(v == NULL);
51 check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_FOUND); 54 fail_if(eina_value_type_get(v) != EINA_VALUE_TYPE_ERROR);
55 eina_value_free(v);
52} 56}
53EFL_END_TEST 57EFL_END_TEST
54 58
59static Eina_Value
60_expect_error(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
61{
62 Eina_Error *expected = data;
63 Eina_Error result = 0;
64
65 fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ERROR);
66
67 if (!expected) return v;
68
69 eina_value_error_get(&v, &result);
70 fail_if(result != *expected);
71
72 ecore_main_loop_quit();
73
74 return v;
75}
76
55EFL_START_TEST(property_set) 77EFL_START_TEST(property_set)
56{ 78{
57 Eina_Value value; 79 Eina_Future *future;
58 Efl_Future *future; 80 Eina_Value value = EINA_VALUE_EMPTY;
59 81
60 // Nonexistent property must raise ERROR 82 // Nonexistent property must raise ERROR
61 eina_value_setup(&value, EINA_VALUE_TYPE_INT); 83 eina_value_setup(&value, EINA_VALUE_TYPE_INT);
62 eina_value_set(&value, 1); 84 eina_value_set(&value, 1);
85
63 future = efl_model_property_set(object, "nonexistent", &value); 86 future = efl_model_property_set(object, "nonexistent", &value);
64 check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_FOUND); 87 eina_future_then(future, _expect_error, &EFL_MODEL_ERROR_NOT_FOUND);
88
89 ecore_main_loop_begin();
65 90
66 // UNIQUE_NAME_PROPERTY is read-only 91 // UNIQUE_NAME_PROPERTY is read-only
67 future = efl_model_property_set(object, UNIQUE_NAME_PROPERTY, &value); 92 future = efl_model_property_set(object, UNIQUE_NAME_PROPERTY, &value);
68 check_efl_model_future_error(future, &EFL_MODEL_ERROR_READ_ONLY); 93 eina_future_then(future, _expect_error, &EFL_MODEL_ERROR_READ_ONLY);
94
95 ecore_main_loop_begin();
69 96
70 eina_value_flush(&value); 97 eina_value_flush(&value);
71} 98}
@@ -78,14 +105,42 @@ _test_children_count(Eo *efl_model)
78 check_efl_model_children_count_ge(efl_model, 2); 105 check_efl_model_children_count_ge(efl_model, 2);
79} 106}
80 107
108static Eina_Value
109_leave(void *data EINA_UNUSED, const Eina_Value v,
110 const Eina_Future *dead EINA_UNUSED)
111{
112 ecore_main_loop_quit();
113
114 return v;
115}
116
117static void
118_count_changed(void *data EINA_UNUSED, const Efl_Event *ev)
119{
120 Eina_Future *f;
121
122 f = efl_loop_job(efl_provider_find(ev->object, EFL_LOOP_CLASS));
123 eina_future_then(f, _leave, NULL);
124}
125
81EFL_START_TEST(children_count) 126EFL_START_TEST(children_count)
82{ 127{
128 efl_event_callback_add(object, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
129 efl_model_children_count_get(object);
130
131 ecore_main_loop_begin();
132
83 _test_children_count(object); 133 _test_children_count(object);
84} 134}
85EFL_END_TEST 135EFL_END_TEST
86 136
87EFL_START_TEST(children_slice_get) 137EFL_START_TEST(children_slice_get)
88{ 138{
139 efl_event_callback_add(object, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
140 efl_model_children_count_get(object);
141
142 ecore_main_loop_begin();
143
89 check_efl_model_children_slice_get(object); 144 check_efl_model_children_slice_get(object);
90} 145}
91EFL_END_TEST 146EFL_END_TEST
@@ -98,23 +153,52 @@ EFL_START_TEST(child_add)
98} 153}
99EFL_END_TEST 154EFL_END_TEST
100 155
156static void
157_children_wait(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
158{
159 ecore_main_loop_quit();
160}
161
162static Eina_Value
163_one_child(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
164{
165 Eo **child = data;
166
167 fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ARRAY);
168 fail_if(eina_value_array_count(&v) != 1);
169 eina_value_array_get(&v, 0, &child);
170
171 ecore_main_loop_quit();
172
173 return v;
174}
175
101EFL_START_TEST(child_del) 176EFL_START_TEST(child_del)
102{ 177{
178 Eina_Future *future;
179 Eo *child = NULL;
103 unsigned int expected_children_count = 0; 180 unsigned int expected_children_count = 0;
104 Efl_Future *future; 181 unsigned int actual_children_count = 0;
105 future = efl_model_children_count_get(object);
106 ck_assert_ptr_ne(NULL, future);
107 expected_children_count = efl_model_future_then_u(future);
108 ck_assert_msg(expected_children_count, "There must be at least 1 child to test");
109 182
110 Eo *child = efl_model_first_child_get(object); 183 efl_event_callback_add(object, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _children_wait, NULL);
184 expected_children_count = efl_model_children_count_get(object);
185
186 if (!expected_children_count)
187 {
188 ecore_main_loop_begin();
189 expected_children_count = efl_model_children_count_get(object);
190 }
191
192 fail_if(expected_children_count == 0);
193
194 future = efl_model_children_slice_get(object, 0, 1);
195 eina_future_then(future, _one_child, &child);
196 ecore_main_loop_begin();
197
198 fail_if(!child);
111 efl_model_child_del(object, child); 199 efl_model_child_del(object, child);
112 200
113 future = NULL; 201 actual_children_count = efl_model_children_count_get(object);
114 unsigned int actual_children_count = 0;
115 future = efl_model_children_count_get(object);
116 ck_assert_ptr_ne(NULL, future);
117 actual_children_count = efl_model_future_then_u(future);
118 ck_assert_int_le(expected_children_count, actual_children_count); 202 ck_assert_int_le(expected_children_count, actual_children_count);
119} 203}
120EFL_END_TEST 204EFL_END_TEST
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_proxy.c b/src/tests/eldbus/eldbus_test_eldbus_model_proxy.c
index 2e677d52be..c9568080ea 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_proxy.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_proxy.c
@@ -14,11 +14,34 @@
14static Eo *dbus_object1 = NULL; 14static Eo *dbus_object1 = NULL;
15static Eo *dbus_proxy = NULL; 15static Eo *dbus_proxy = NULL;
16 16
17static Eina_Value
18_leave(void *data EINA_UNUSED, const Eina_Value v,
19 const Eina_Future *dead EINA_UNUSED)
20{
21 ecore_main_loop_quit();
22
23 return v;
24}
25
26static void
27_count_changed(void *data EINA_UNUSED, const Efl_Event *ev)
28{
29 Eina_Future *f;
30
31 f = efl_loop_job(efl_provider_find(ev->object, EFL_LOOP_CLASS));
32 eina_future_then(f, _leave, NULL);
33}
34
17static void 35static void
18_setup(void) 36_setup(void)
19{ 37{
20 dbus_object1 = create_object(); 38 dbus_object1 = create_object();
21 39
40 efl_event_callback_add(dbus_object1, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
41 efl_model_children_count_get(dbus_object1);
42
43 ecore_main_loop_begin();
44
22 dbus_proxy = eldbus_model_proxy_from_object_get(dbus_object1, ELDBUS_FDO_INTERFACE); 45 dbus_proxy = eldbus_model_proxy_from_object_get(dbus_object1, ELDBUS_FDO_INTERFACE);
23 ck_assert_ptr_ne(NULL, dbus_proxy); 46 ck_assert_ptr_ne(NULL, dbus_proxy);
24} 47}
@@ -46,16 +69,23 @@ EFL_END_TEST
46EFL_START_TEST(property_get) 69EFL_START_TEST(property_get)
47{ 70{
48 // Nonexistent property must return ERROR 71 // Nonexistent property must return ERROR
49 Efl_Future *future; 72 Eina_Value *value;
50 future = efl_model_property_get(dbus_proxy, "nonexistent"); 73 Eina_Error err = 0;
51 check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_FOUND); 74
75 value = efl_model_property_get(dbus_proxy, "nonexistent");
76
77 fail_if(eina_value_type_get(value) != EINA_VALUE_TYPE_ERROR);
78 eina_value_error_get(value, &err);
79 fail_if(err != EFL_MODEL_ERROR_NOT_FOUND);
80
81 eina_value_free(value);
52} 82}
53EFL_END_TEST 83EFL_END_TEST
54 84
55EFL_START_TEST(property_set) 85EFL_START_TEST(property_set)
56{ 86{
57 Eina_Value value; 87 Eina_Value value;
58 Efl_Future *future; 88 Eina_Future *future;
59 89
60 // Nonexistent property must return ERROR 90 // Nonexistent property must return ERROR
61 eina_value_setup(&value, EINA_VALUE_TYPE_INT); 91 eina_value_setup(&value, EINA_VALUE_TYPE_INT);
@@ -69,6 +99,11 @@ EFL_END_TEST
69static void 99static void
70_test_dbus_proxy_children_count(Eo *efl_model) 100_test_dbus_proxy_children_count(Eo *efl_model)
71{ 101{
102 efl_event_callback_add(efl_model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
103 efl_model_children_count_get(efl_model);
104
105 ecore_main_loop_begin();
106
72 // 'org.freedesktop.DBus::AddMatch' and 'org.freedesktop.DBus::ListNames' at least 107 // 'org.freedesktop.DBus::AddMatch' and 'org.freedesktop.DBus::ListNames' at least
73 check_efl_model_children_count_ge(efl_model, 2); 108 check_efl_model_children_count_ge(efl_model, 2);
74} 109}
@@ -81,6 +116,11 @@ EFL_END_TEST
81 116
82EFL_START_TEST(children_slice_get) 117EFL_START_TEST(children_slice_get)
83{ 118{
119 efl_event_callback_add(dbus_proxy, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed, NULL);
120 efl_model_children_count_get(dbus_proxy);
121
122 ecore_main_loop_begin();
123
84 check_efl_model_children_slice_get(dbus_proxy); 124 check_efl_model_children_slice_get(dbus_proxy);
85} 125}
86EFL_END_TEST 126EFL_END_TEST
@@ -95,18 +135,18 @@ EFL_END_TEST
95 135
96EFL_START_TEST(child_del) 136EFL_START_TEST(child_del)
97{ 137{
138 Eina_Future *future;
139 Eo *child;
98 unsigned int expected_children_count = 0; 140 unsigned int expected_children_count = 0;
99 Efl_Future *future; 141 unsigned int actual_children_count = 0;
100 future = efl_model_children_count_get(dbus_proxy); 142
143 expected_children_count = efl_model_children_count_get(dbus_proxy);
101 ck_assert_ptr_ne(NULL, future); 144 ck_assert_ptr_ne(NULL, future);
102 expected_children_count = efl_model_future_then_u(future);
103 145
104 Eo *child = efl_model_first_child_get(dbus_proxy); 146 child = efl_model_first_child_get(dbus_proxy);
105 efl_model_child_del(dbus_proxy, child); 147 efl_model_child_del(dbus_proxy, child);
106 148
107 unsigned int actual_children_count = 0; 149 actual_children_count = efl_model_children_count_get(dbus_proxy);
108 future = efl_model_children_count_get(dbus_proxy);
109 actual_children_count = efl_model_future_then_u(future);
110 150
111 ck_assert_int_le(expected_children_count, actual_children_count); 151 ck_assert_int_le(expected_children_count, actual_children_count);
112} 152}
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_signal.c b/src/tests/eldbus/eldbus_test_eldbus_model_signal.c
index f9800be5d4..1c362016b3 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_signal.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_signal.c
@@ -25,7 +25,10 @@ _setup(void)
25{ 25{
26 fake_server = fake_server_start(&fake_server_data); 26 fake_server = fake_server_start(&fake_server_data);
27 27
28 fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(), eldbus_model_object_custom_constructor(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE, FAKE_SERVER_BUS, FAKE_SERVER_PATH)); 28 fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(),
29 eldbus_model_connect(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE),
30 eldbus_model_object_bus_set(efl_added, FAKE_SERVER_BUS),
31 eldbus_model_object_path_set(efl_added, FAKE_SERVER_PATH));
29 ck_assert_ptr_ne(NULL, fake_server_object); 32 ck_assert_ptr_ne(NULL, fake_server_object);
30 33
31 fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE); 34 fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE);
@@ -58,22 +61,29 @@ EFL_END_TEST
58 61
59EFL_START_TEST(property_get) 62EFL_START_TEST(property_get)
60{ 63{
64 Eina_Value *value;
65 Eina_Error err;
66
61 // Signal properties always have output direction 67 // Signal properties always have output direction
62 Efl_Future *future; 68 value = efl_model_property_get(pong_signal, ARGUMENT_A);
63 future = efl_model_property_get(pong_signal, ARGUMENT_A); 69 fail_if(value == NULL);
64 efl_model_future_then(future);
65 70
66 // Nonexistent property must return ERROR 71 // Nonexistent property must return ERROR
67 future = efl_model_property_get(pong_signal, "nonexistent"); 72 value = efl_model_property_get(pong_signal, "nonexistent");
68 check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_FOUND); 73 fail_if(value == NULL);
74 fail_if(eina_value_type_get(value) != EINA_VALUE_TYPE_ERROR);
75
76 eina_value_error_get(value, &err);
77 fail_if(err != EFL_MODEL_ERROR_NOT_FOUND);
69} 78}
70EFL_END_TEST 79EFL_END_TEST
71 80
72EFL_START_TEST(property_set) 81EFL_START_TEST(property_set)
73{ 82{
74 // Signals have output arguments only. All returns error 83 // Signals have output arguments only. All returns error
75 Efl_Future *future; 84 Eina_Value dummy = EINA_VALUE_EMPTY;
76 Eina_Value dummy = {0}; 85 Eina_Future *future;
86
77 future = efl_model_property_set(pong_signal, ARGUMENT_A, &dummy); 87 future = efl_model_property_set(pong_signal, ARGUMENT_A, &dummy);
78 check_efl_model_future_error(future, NULL); 88 check_efl_model_future_error(future, NULL);
79} 89}
@@ -93,7 +103,8 @@ EFL_END_TEST
93 103
94EFL_START_TEST(children_slice_get) 104EFL_START_TEST(children_slice_get)
95{ 105{
96 Efl_Future *future; 106 Eina_Future *future;
107
97 future = efl_model_children_slice_get(pong_signal, 1, 1); 108 future = efl_model_children_slice_get(pong_signal, 1, 1);
98 check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_SUPPORTED); 109 check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_SUPPORTED);
99} 110}
diff --git a/src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c b/src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c
index 47259d4038..c4bdba2bd0 100644
--- a/src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c
+++ b/src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c
@@ -31,7 +31,10 @@ _setup(void)
31 }; 31 };
32 fake_server = fake_server_start(&fake_server_data); 32 fake_server = fake_server_start(&fake_server_data);
33 33
34 fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(), eldbus_model_object_custom_constructor(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE, FAKE_SERVER_BUS, FAKE_SERVER_PATH)); 34 fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(),
35 eldbus_model_connect(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE),
36 eldbus_model_object_bus_set(efl_added, FAKE_SERVER_BUS),
37 eldbus_model_object_path_set(efl_added, FAKE_SERVER_PATH));
35 ck_assert_ptr_ne(NULL, fake_server_object); 38 ck_assert_ptr_ne(NULL, fake_server_object);
36 39
37 fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE); 40 fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE);
@@ -50,7 +53,8 @@ EFL_START_TEST(properties_get)
50 const Eina_Array *properties = efl_model_properties_get(fake_server_proxy); 53 const Eina_Array *properties = efl_model_properties_get(fake_server_proxy);
51 ck_assert_ptr_ne(NULL, properties); 54 ck_assert_ptr_ne(NULL, properties);
52 55
53 const unsigned int expected_properties_count = 3; // FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_WRITEONLY_PROPERTY and FAKE_SERVER_READWRITE_PROPERTY properties 56 // FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_WRITEONLY_PROPERTY and FAKE_SERVER_READWRITE_PROPERTY properties
57 const unsigned int expected_properties_count = 3;
54 const unsigned int actual_properties_count = eina_array_count(properties); 58 const unsigned int actual_properties_count = eina_array_count(properties);
55 ck_assert_int_eq(expected_properties_count, actual_properties_count); 59 ck_assert_int_eq(expected_properties_count, actual_properties_count);
56 60
@@ -58,15 +62,43 @@ EFL_START_TEST(properties_get)
58} 62}
59EFL_END_TEST 63EFL_END_TEST
60 64
65static Eina_Future *f = NULL;
66
67static Eina_Value
68_leave(void *data EINA_UNUSED, const Eina_Value v,
69 const Eina_Future *dead EINA_UNUSED)
70{
71 ecore_main_loop_quit();
72 f = NULL;
73 return v;
74}
75
76static void
77_property_ready(void *data EINA_UNUSED, const Efl_Event *ev)
78{
79 if (f) return ;
80 f = efl_loop_job(efl_provider_find(ev->object, EFL_LOOP_CLASS));
81 eina_future_then(f, _leave, NULL);
82}
83
61EFL_START_TEST(property_get) 84EFL_START_TEST(property_get)
62{ 85{
86 Eina_Value *value;
87
88 efl_event_callback_add(fake_server_proxy, EFL_MODEL_EVENT_PROPERTIES_CHANGED, _property_ready, NULL);
89 value = efl_model_property_get(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY);
90 eina_value_free(value);
91 value = efl_model_property_get(fake_server_proxy, FAKE_SERVER_READWRITE_PROPERTY);
92 eina_value_free(value);
93
94 ecore_main_loop_begin();
95
63 check_efl_model_property_int_eq(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_READONLY_PROPERTY_VALUE); 96 check_efl_model_property_int_eq(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_READONLY_PROPERTY_VALUE);
64 check_efl_model_property_int_eq(fake_server_proxy, FAKE_SERVER_READWRITE_PROPERTY, FAKE_SERVER_READWRITE_PROPERTY_VALUE); 97 check_efl_model_property_int_eq(fake_server_proxy, FAKE_SERVER_READWRITE_PROPERTY, FAKE_SERVER_READWRITE_PROPERTY_VALUE);
65 98
66 // Write-only property returns error 99 // Write-only property returns error
67 Efl_Future *future; 100 value = efl_model_property_get(fake_server_proxy, FAKE_SERVER_WRITEONLY_PROPERTY);
68 future = efl_model_property_get(fake_server_proxy, FAKE_SERVER_WRITEONLY_PROPERTY); 101 eina_value_free(value);
69 (void)future;
70 //ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status); 102 //ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
71 103
72 _teardown(); 104 _teardown();
@@ -89,12 +121,13 @@ _check_property_set(const char *property_name, int expected_property_value, int
89 121
90EFL_START_TEST(property_set) 122EFL_START_TEST(property_set)
91{ 123{
124 Eina_Future *future;
125 Eina_Value dummy = EINA_VALUE_EMPTY;
126
92 _check_property_set(FAKE_SERVER_WRITEONLY_PROPERTY, 0x12345678, &fake_server_data.writeonly_property); 127 _check_property_set(FAKE_SERVER_WRITEONLY_PROPERTY, 0x12345678, &fake_server_data.writeonly_property);
93 _check_property_set(FAKE_SERVER_READWRITE_PROPERTY, 0x76543210, &fake_server_data.readwrite_property); 128 _check_property_set(FAKE_SERVER_READWRITE_PROPERTY, 0x76543210, &fake_server_data.readwrite_property);
94 129
95 // Read-only property returns error 130 // Read-only property returns error
96 Efl_Future *future;
97 Eina_Value dummy = {0};
98 future = efl_model_property_set(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY, &dummy); 131 future = efl_model_property_set(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY, &dummy);
99 check_efl_model_future_error(future, &EFL_MODEL_ERROR_READ_ONLY); 132 check_efl_model_future_error(future, &EFL_MODEL_ERROR_READ_ONLY);
100 133
@@ -155,20 +188,18 @@ EFL_END_TEST
155EFL_START_TEST(child_del) 188EFL_START_TEST(child_del)
156{ 189{
157 // Tests that it is not possible to delete children 190 // Tests that it is not possible to delete children
158 Efl_Future *future; 191 Eo *child;
159 unsigned int expected_children_count = 0; 192 unsigned int expected_children_count = 0;
160 future = efl_model_children_count_get(fake_server_proxy); 193 unsigned int actual_children_count = 0;
161 expected_children_count = efl_model_future_then_u(future); 194
195 expected_children_count = efl_model_children_count_get(fake_server_proxy);
162 ck_assert_msg(expected_children_count, "There must be at least 1 child to test"); 196 ck_assert_msg(expected_children_count, "There must be at least 1 child to test");
163 197
164 // efl_model_child_del always returns ERROR 198 // efl_model_child_del always returns ERROR
165 Eo *child = efl_model_first_child_get(fake_server_proxy); 199 child = efl_model_first_child_get(fake_server_proxy);
166 efl_model_child_del(fake_server_proxy, child); 200 efl_model_child_del(fake_server_proxy, child);
167 201
168 unsigned int actual_children_count = 0; 202 actual_children_count = efl_model_children_count_get(fake_server_proxy);
169 future = efl_model_children_count_get(fake_server_proxy);
170 actual_children_count = efl_model_future_then_u(future);
171
172 ck_assert_int_le(expected_children_count, actual_children_count); 203 ck_assert_int_le(expected_children_count, actual_children_count);
173 204
174 _teardown(); 205 _teardown();