summaryrefslogtreecommitdiff
path: root/src/tests/eldbus/eldbus_test_eldbus_model.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/eldbus/eldbus_test_eldbus_model.c')
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model.c58
1 files changed, 25 insertions, 33 deletions
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model.c b/src/tests/eldbus/eldbus_test_eldbus_model.c
index adba9f5..5439217 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model.c
@@ -24,9 +24,9 @@ _eo_event_quit_cb(void *data EINA_UNUSED, const Eo_Event *event EINA_UNUSED)
24void 24void
25efl_model_wait_for_event(Eo *obj, const Eo_Event_Description* event) 25efl_model_wait_for_event(Eo *obj, const Eo_Event_Description* event)
26{ 26{
27 eo_do(obj, eo_event_callback_add(event, _eo_event_quit_cb, NULL)); 27 eo_event_callback_add(obj, event, _eo_event_quit_cb, NULL);
28 ecore_main_loop_begin(); 28 ecore_main_loop_begin();
29 eo_do(obj, eo_event_callback_del(event, _eo_event_quit_cb, NULL)); 29 eo_event_callback_del(obj, event, _eo_event_quit_cb, NULL);
30} 30}
31 31
32static Eina_Bool 32static Eina_Bool
@@ -49,13 +49,13 @@ void
49efl_model_wait_for_load_status(Efl_Model_Base *efl_model, Efl_Model_Load_Status expected_status) 49efl_model_wait_for_load_status(Efl_Model_Base *efl_model, Efl_Model_Load_Status expected_status)
50{ 50{
51 Efl_Model_Load_Status actual_status; 51 Efl_Model_Load_Status actual_status;
52 eo_do(efl_model, actual_status = efl_model_load_status_get()); 52 actual_status = efl_model_load_status_get(efl_model);
53 if (expected_status == actual_status) 53 if (expected_status == actual_status)
54 return; 54 return;
55 55
56 eo_do(efl_model, eo_event_callback_add(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _event_load_status_quit_cb, (void*)expected_status)); 56 eo_event_callback_add(efl_model, EFL_MODEL_BASE_EVENT_LOAD_STATUS, _event_load_status_quit_cb, (void*)expected_status);
57 ecore_main_loop_begin(); 57 ecore_main_loop_begin();
58 eo_do(efl_model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_LOAD_STATUS, _event_load_status_quit_cb, (void*)expected_status)); 58 eo_event_callback_del(efl_model, EFL_MODEL_BASE_EVENT_LOAD_STATUS, _event_load_status_quit_cb, (void*)expected_status);
59} 59}
60 60
61Efl_Model_Base * 61Efl_Model_Base *
@@ -63,7 +63,7 @@ efl_model_nth_child_get(Efl_Model_Base *efl_model, unsigned int n)
63{ 63{
64 Eina_Accessor *accessor; 64 Eina_Accessor *accessor;
65 Efl_Model_Load_Status status; 65 Efl_Model_Load_Status status;
66 eo_do(efl_model, status = efl_model_children_slice_get(n, 1, &accessor)); 66 status = efl_model_children_slice_get(efl_model, n, 1, &accessor);
67 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status); 67 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
68 ck_assert_ptr_ne(NULL, accessor); 68 ck_assert_ptr_ne(NULL, accessor);
69 Eo *child = NULL; 69 Eo *child = NULL;
@@ -83,7 +83,7 @@ efl_model_first_child_get(Efl_Model_Base *efl_model)
83void 83void
84efl_model_load_and_wait_for_load_status(Eo *obj, Efl_Model_Load_Status expected_status) 84efl_model_load_and_wait_for_load_status(Eo *obj, Efl_Model_Load_Status expected_status)
85{ 85{
86 eo_do(obj, efl_model_load()); 86 efl_model_load(obj);
87 efl_model_wait_for_load_status(obj, expected_status); 87 efl_model_wait_for_load_status(obj, expected_status);
88} 88}
89 89
@@ -106,7 +106,7 @@ check_property(Eo *object, const char *property_name, const char *expected_value
106{ 106{
107 Eina_Value const* property_value; 107 Eina_Value const* property_value;
108 Efl_Model_Load_Status status; 108 Efl_Model_Load_Status status;
109 eo_do(object, status = efl_model_property_get(property_name, &property_value)); 109 status = efl_model_property_get(object, property_name, &property_value);
110 ck_assert_msg(EFL_MODEL_LOAD_STATUS_ERROR != status, "Nonexistent property: %s", property_name); 110 ck_assert_msg(EFL_MODEL_LOAD_STATUS_ERROR != status, "Nonexistent property: %s", property_name);
111 ck_assert_ptr_ne(NULL, property_value); 111 ck_assert_ptr_ne(NULL, property_value);
112 char *actual_value = eina_value_to_string(property_value); 112 char *actual_value = eina_value_to_string(property_value);
@@ -123,10 +123,7 @@ check_property(Eo *object, const char *property_name, const char *expected_value
123Eo * 123Eo *
124create_connection(void) 124create_connection(void)
125{ 125{
126 Eo *connection = eo_add_ref(ELDBUS_MODEL_CONNECTION_CLASS, NULL, 126 Eo *connection = eo_add_ref(ELDBUS_MODEL_CONNECTION_CLASS, NULL, eldbus_model_connection_constructor(eoid, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE));
127 eldbus_model_connection_constructor(ELDBUS_CONNECTION_TYPE_SESSION,
128 NULL,
129 EINA_FALSE));
130 ck_assert_ptr_ne(NULL, connection); 127 ck_assert_ptr_ne(NULL, connection);
131 return connection; 128 return connection;
132} 129}
@@ -142,12 +139,7 @@ create_and_load_connection(void)
142Eo * 139Eo *
143create_object(void) 140create_object(void)
144{ 141{
145 Eo *object = eo_add_ref(ELDBUS_MODEL_OBJECT_CLASS, NULL, 142 Eo *object = eo_add_ref(ELDBUS_MODEL_OBJECT_CLASS, NULL, eldbus_model_object_constructor(eoid, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE, ELDBUS_FDO_BUS, ELDBUS_FDO_PATH));
146 eldbus_model_object_constructor(ELDBUS_CONNECTION_TYPE_SESSION,
147 NULL,
148 EINA_FALSE,
149 ELDBUS_FDO_BUS,
150 ELDBUS_FDO_PATH));
151 ck_assert_ptr_ne(NULL, object); 143 ck_assert_ptr_ne(NULL, object);
152 return object; 144 return object;
153} 145}
@@ -164,7 +156,7 @@ void
164check_efl_model_load_status_get(Efl_Model_Base *efl_model, Efl_Model_Load_Status expected_load_status) 156check_efl_model_load_status_get(Efl_Model_Base *efl_model, Efl_Model_Load_Status expected_load_status)
165{ 157{
166 Efl_Model_Load_Status actual_load_status; 158 Efl_Model_Load_Status actual_load_status;
167 eo_do(efl_model, actual_load_status = efl_model_load_status_get()); 159 actual_load_status = efl_model_load_status_get(efl_model);
168 ck_assert_int_eq(expected_load_status, actual_load_status); 160 ck_assert_int_eq(expected_load_status, actual_load_status);
169} 161}
170 162
@@ -172,7 +164,7 @@ void
172check_efl_model_children_count_eq(Efl_Model_Base *efl_model, unsigned int expected_children_count) 164check_efl_model_children_count_eq(Efl_Model_Base *efl_model, unsigned int expected_children_count)
173{ 165{
174 unsigned int actual_children_count = 0; 166 unsigned int actual_children_count = 0;
175 eo_do(efl_model, efl_model_children_count_get(&actual_children_count)); 167 efl_model_children_count_get(efl_model, &actual_children_count);
176 ck_assert_int_eq(expected_children_count, actual_children_count); 168 ck_assert_int_eq(expected_children_count, actual_children_count);
177} 169}
178 170
@@ -181,7 +173,7 @@ check_efl_model_children_count_ge(Efl_Model_Base *efl_model, unsigned int minimu
181{ 173{
182 unsigned int actual_children_count = 0; 174 unsigned int actual_children_count = 0;
183 Efl_Model_Load_Status status; 175 Efl_Model_Load_Status status;
184 eo_do(efl_model, status = efl_model_children_count_get(&actual_children_count)); 176 status = efl_model_children_count_get(efl_model, &actual_children_count);
185 // A minimum count only exists if model have EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN 177 // A minimum count only exists if model have EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN
186 ck_assert((EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN & status) == EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN); 178 ck_assert((EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN & status) == EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN);
187 179
@@ -193,13 +185,13 @@ check_efl_model_children_slice_get(Efl_Model_Base *efl_model)
193{ 185{
194 unsigned int count = 0; 186 unsigned int count = 0;
195 Efl_Model_Load_Status status; 187 Efl_Model_Load_Status status;
196 eo_do(efl_model, status = efl_model_children_count_get(&count)); 188 status = efl_model_children_count_get(efl_model, &count);
197 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status); 189 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
198 ck_assert_msg(count, "There must be at least 1 child to test"); 190 ck_assert_msg(count, "There must be at least 1 child to test");
199 191
200 // Test slice all 192 // Test slice all
201 Eina_Accessor *accessor; 193 Eina_Accessor *accessor;
202 eo_do(efl_model, status = efl_model_children_slice_get(0, 0, &accessor)); 194 status = efl_model_children_slice_get(efl_model, 0, 0, &accessor);
203 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status); 195 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
204 ck_assert_ptr_ne(NULL, accessor); 196 ck_assert_ptr_ne(NULL, accessor);
205 // Get first child 197 // Get first child
@@ -221,7 +213,7 @@ check_efl_model_children_slice_get(Efl_Model_Base *efl_model)
221 213
222 // Test slice first child 214 // Test slice first child
223 Eo *child = NULL; 215 Eo *child = NULL;
224 eo_do(efl_model, status = efl_model_children_slice_get(1, 1, &accessor)); 216 status = efl_model_children_slice_get(efl_model, 1, 1, &accessor);
225 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status); 217 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
226 ck_assert_ptr_ne(NULL, accessor); 218 ck_assert_ptr_ne(NULL, accessor);
227 ret = eina_accessor_data_get(accessor, 0, (void**)&child); 219 ret = eina_accessor_data_get(accessor, 0, (void**)&child);
@@ -233,7 +225,7 @@ check_efl_model_children_slice_get(Efl_Model_Base *efl_model)
233 eina_accessor_free(accessor); 225 eina_accessor_free(accessor);
234 226
235 // Test slice last child 227 // Test slice last child
236 eo_do(efl_model, status = efl_model_children_slice_get(count, 1, &accessor)); 228 status = efl_model_children_slice_get(efl_model, count, 1, &accessor);
237 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status); 229 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
238 ck_assert_ptr_ne(NULL, accessor); 230 ck_assert_ptr_ne(NULL, accessor);
239 ret = eina_accessor_data_get(accessor, 0, (void**)&child); 231 ret = eina_accessor_data_get(accessor, 0, (void**)&child);
@@ -245,7 +237,7 @@ check_efl_model_children_slice_get(Efl_Model_Base *efl_model)
245 eina_accessor_free(accessor); 237 eina_accessor_free(accessor);
246 238
247 // Test slice nonexistent element 239 // Test slice nonexistent element
248 eo_do(efl_model, status = efl_model_children_slice_get(count + 1, 1, &accessor)); 240 status = efl_model_children_slice_get(efl_model, count + 1, 1, &accessor);
249 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status); 241 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
250 ck_assert_ptr_eq(NULL, accessor); 242 ck_assert_ptr_eq(NULL, accessor);
251} 243}
@@ -284,7 +276,7 @@ START_TEST(proxy)
284 efl_model_load_and_wait_for_load_status(root, EFL_MODEL_LOAD_STATUS_LOADED); 276 efl_model_load_and_wait_for_load_status(root, EFL_MODEL_LOAD_STATUS_LOADED);
285 277
286 Eina_Accessor *accessor = NULL; 278 Eina_Accessor *accessor = NULL;
287 eo_do(root, efl_model_children_slice_get(0, 0, &accessor)); 279 efl_model_children_slice_get(root, 0, 0, &accessor);
288 ck_assert_ptr_ne(NULL, accessor); 280 ck_assert_ptr_ne(NULL, accessor);
289 281
290 unsigned int i; 282 unsigned int i;
@@ -314,7 +306,7 @@ eldbus_model_proxy_from_object_get(Eldbus_Model_Object *object, const char *inte
314{ 306{
315 Eina_Accessor *accessor; 307 Eina_Accessor *accessor;
316 Efl_Model_Load_Status status; 308 Efl_Model_Load_Status status;
317 eo_do(object, status = efl_model_children_slice_get(0, 0, &accessor)); 309 status = efl_model_children_slice_get(object, 0, 0, &accessor);
318 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status); 310 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
319 ck_assert_ptr_ne(NULL, accessor); 311 ck_assert_ptr_ne(NULL, accessor);
320 312
@@ -323,7 +315,7 @@ eldbus_model_proxy_from_object_get(Eldbus_Model_Object *object, const char *inte
323 EINA_ACCESSOR_FOREACH(accessor, i, proxy) 315 EINA_ACCESSOR_FOREACH(accessor, i, proxy)
324 { 316 {
325 const char *name; 317 const char *name;
326 eo_do(proxy, name = eldbus_model_proxy_name_get()); 318 name = eldbus_model_proxy_name_get(proxy);
327 ck_assert_ptr_ne(NULL, name); 319 ck_assert_ptr_ne(NULL, name);
328 if (strcmp(name, interface_name) == 0) 320 if (strcmp(name, interface_name) == 0)
329 goto end; 321 goto end;
@@ -340,7 +332,7 @@ _eldbus_model_arguments_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *me
340{ 332{
341 Eina_Accessor *accessor; 333 Eina_Accessor *accessor;
342 Efl_Model_Load_Status status; 334 Efl_Model_Load_Status status;
343 eo_do(proxy, status = efl_model_children_slice_get(0, 0, &accessor)); 335 status = efl_model_children_slice_get(proxy, 0, 0, &accessor);
344 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status); 336 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
345 ck_assert_ptr_ne(NULL, accessor); 337 ck_assert_ptr_ne(NULL, accessor);
346 338
@@ -352,7 +344,7 @@ _eldbus_model_arguments_from_proxy_get(Eldbus_Model_Proxy *proxy, const char *me
352 continue; 344 continue;
353 345
354 const char *name; 346 const char *name;
355 eo_do(child, name = eldbus_model_arguments_name_get()); 347 name = eldbus_model_arguments_name_get(child);
356 ck_assert_ptr_ne(NULL, name); 348 ck_assert_ptr_ne(NULL, name);
357 if (strcmp(name, method_name) == 0) 349 if (strcmp(name, method_name) == 0)
358 goto end; 350 goto end;
@@ -381,7 +373,7 @@ check_efl_model_property_int_eq(Efl_Model_Base *efl_model, const char *property,
381{ 373{
382 Eina_Value const* property_value; 374 Eina_Value const* property_value;
383 Efl_Model_Load_Status status; 375 Efl_Model_Load_Status status;
384 eo_do(efl_model, status = efl_model_property_get(property, &property_value)); 376 status = efl_model_property_get(efl_model, property, &property_value);
385 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status); 377 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
386 ck_assert_ptr_ne(NULL, property_value); 378 ck_assert_ptr_ne(NULL, property_value);
387 379
@@ -400,7 +392,7 @@ check_efl_model_property_int_set(Efl_Model_Base *efl_model, const char *property
400 eina_value_setup(&eina_value, EINA_VALUE_TYPE_INT); 392 eina_value_setup(&eina_value, EINA_VALUE_TYPE_INT);
401 eina_value_set(&eina_value, value); 393 eina_value_set(&eina_value, value);
402 Efl_Model_Load_Status status; 394 Efl_Model_Load_Status status;
403 eo_do(efl_model, status = efl_model_property_set(property, &eina_value)); 395 status = efl_model_property_set(efl_model, property, &eina_value);
404 eina_value_flush(&eina_value); 396 eina_value_flush(&eina_value);
405 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status); 397 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_LOADED, status);
406} 398}