summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-04-28 11:03:09 -0700
committerCedric BAIL <cedric.bail@free.fr>2019-05-29 15:53:26 -0700
commit0e73a88133862b90a3dfdc56ac4073f8f8d18c3f (patch)
tree7ecb7aee641f0dec39cdb26f263644370fb08c92
parentc84c4212671ff1155ab044def41326667bab90f5 (diff)
ecore: add simple test for property_string_add.
Reviewed-by: Lauro Neto <Lauro Moura <lauromoura@expertisesolutions.com.br>> Differential Revision: https://phab.enlightenment.org/D8756
-rw-r--r--src/tests/efl/efl_test_view_model.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/tests/efl/efl_test_view_model.c b/src/tests/efl/efl_test_view_model.c
index 3153d62343..13e0a13027 100644
--- a/src/tests/efl/efl_test_view_model.c
+++ b/src/tests/efl/efl_test_view_model.c
@@ -133,7 +133,8 @@ _properties_changed(void *data, const Efl_Event *event)
133 Property_Change_Test tests[] = { 133 Property_Change_Test tests[] = {
134 { EINA_FALSE, "test_p_int" }, 134 { EINA_FALSE, "test_p_int" },
135 { EINA_FALSE, "color" }, 135 { EINA_FALSE, "color" },
136 { EINA_FALSE, "label" } 136 { EINA_FALSE, "label" },
137 { EINA_FALSE, "output" }
137 }; 138 };
138 139
139 EINA_ARRAY_ITER_NEXT(ev->changed_properties, i, property, iterator) 140 EINA_ARRAY_ITER_NEXT(ev->changed_properties, i, property, iterator)
@@ -176,8 +177,19 @@ _efl_test_view_model_child_get(Eo *obj EINA_UNUSED,
176 Eina_Value *p_color = NULL; 177 Eina_Value *p_color = NULL;
177 Eina_Value *p_label = NULL; 178 Eina_Value *p_label = NULL;
178 Eina_Value *p_deadend = NULL; 179 Eina_Value *p_deadend = NULL;
180 Eina_Value *p_output = NULL;
181 Eina_Value *p_broken = NULL;
182 Eina_Value *p_weird = NULL;
183 char *s_output;
184 char *s_weird;
185 char *s_broken;
186 char *color;
187 char *error;
179 Eina_Error err = 0; 188 Eina_Error err = 0;
180 int v_int = 0; 189 int v_int = 0;
190 int vindex = 0;
191 int vindex2 = 0;
192 int rindex = 0;
181 193
182 p_int = efl_model_property_get(child, "test_p_int"); 194 p_int = efl_model_property_get(child, "test_p_int");
183 ck_assert(eina_value_int_get(p_int, &v_int)); 195 ck_assert(eina_value_int_get(p_int, &v_int));
@@ -185,6 +197,27 @@ _efl_test_view_model_child_get(Eo *obj EINA_UNUSED,
185 p_color = efl_model_property_get(child, "color"); 197 p_color = efl_model_property_get(child, "color");
186 p_label = efl_model_property_get(child, "label"); 198 p_label = efl_model_property_get(child, "label");
187 p_deadend = efl_model_property_get(child, "deadend"); 199 p_deadend = efl_model_property_get(child, "deadend");
200 p_output = efl_model_property_get(child, "output");
201 p_weird = efl_model_property_get(child, "weird");
202 p_broken = efl_model_property_get(child, "broken");
203
204 s_output = eina_value_to_string(p_output);
205 s_weird = eina_value_to_string(p_weird);
206 s_broken = eina_value_to_string(p_broken);
207
208 sscanf(s_output, "Index %i. has #%ms for index %i", &rindex, &color, &vindex);
209 sscanf(s_broken, "%i in error with '%m[A-Za-z ]'", &vindex2, &error);
210
211 ck_assert_ptr_eq(eina_value_type_get(p_output), EINA_VALUE_TYPE_STRING);
212 ck_assert_int_eq(rindex, v_int);
213 ck_assert_int_eq(vindex2, vindex);
214 ck_assert_str_eq(error, "Value not found");
215
216 free(s_output);
217 free(s_weird);
218 free(s_broken);
219 free(color);
220 free(error);
188 221
189 ck_assert_ptr_eq(eina_value_type_get(p_deadend), EINA_VALUE_TYPE_ERROR); 222 ck_assert_ptr_eq(eina_value_type_get(p_deadend), EINA_VALUE_TYPE_ERROR);
190 eina_value_error_get(p_deadend, &err); 223 eina_value_error_get(p_deadend, &err);
@@ -204,6 +237,7 @@ _efl_test_view_model_child_get(Eo *obj EINA_UNUSED,
204 eina_value_free(p_color); 237 eina_value_free(p_color);
205 eina_value_free(p_label); 238 eina_value_free(p_label);
206 eina_value_free(p_deadend); 239 eina_value_free(p_deadend);
240 eina_value_free(p_output);
207 } 241 }
208 242
209 all[i] = EINA_FUTURE_SENTINEL; 243 all[i] = EINA_FUTURE_SENTINEL;
@@ -303,6 +337,18 @@ EFL_START_TEST(efl_test_view_model)
303 NULL, NULL, NULL, 337 NULL, NULL, NULL,
304 NULL); 338 NULL);
305 339
340 efl_view_model_property_string_add(mv, "output",
341 "${label} has ${color} for index ${index}",
342 "${index} not ready",
343 "${index} in error");
344
345 efl_view_model_property_string_add(mv, "broken",
346 "${nope} has ${color} for index ${index}",
347 "${index} not ready",
348 "${index} in error with '${nope}'");
349
350 efl_view_model_property_string_add(mv, "weird", "${} % { } has ${", NULL, NULL);
351
306 f = efl_model_children_slice_get(mv, 0, efl_model_children_count_get(mv)); 352 f = efl_model_children_slice_get(mv, 0, efl_model_children_count_get(mv));
307 f = efl_future_then(mv, f, .success_type = EINA_VALUE_TYPE_ARRAY, 353 f = efl_future_then(mv, f, .success_type = EINA_VALUE_TYPE_ARRAY,
308 .success = _efl_test_view_model_child_get); 354 .success = _efl_test_view_model_child_get);