summaryrefslogtreecommitdiff
path: root/src/tests/elementary/efl_ui_model.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-01-16 14:11:51 -0800
committerCedric BAIL <cedric.bail@free.fr>2019-01-30 12:06:22 -0800
commit40cc1aca0df34ee6c36853a51d6d6761bf3a253f (patch)
tree3aff89097fdddbc4d3f6060e6728f3b65c8c722a /src/tests/elementary/efl_ui_model.c
parentd1b1dce5ffba429c05f6aacfb9972085862710e7 (diff)
elementary: add a test for Efl.Ui.Model_Exact.
Reviewed-by: SangHyeon Jade Lee <sh10233.lee@samsung.com> Differential Revision: https://phab.enlightenment.org/D7664
Diffstat (limited to '')
-rw-r--r--src/tests/elementary/efl_ui_model.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/tests/elementary/efl_ui_model.c b/src/tests/elementary/efl_ui_model.c
index b3c764014a..b8965dfc54 100644
--- a/src/tests/elementary/efl_ui_model.c
+++ b/src/tests/elementary/efl_ui_model.c
@@ -4,6 +4,7 @@
4 4
5#include "efl_ui_suite.h" 5#include "efl_ui_suite.h"
6#include "efl_ui_model_homogeneous.eo.h" 6#include "efl_ui_model_homogeneous.eo.h"
7#include "efl_ui_model_exact.eo.h"
7 8
8static const int child_number = 3; 9static const int child_number = 3;
9static const int base_ints[] = { 41, 42, 43 }; 10static const int base_ints[] = { 41, 42, 43 };
@@ -177,8 +178,78 @@ EFL_START_TEST(efl_ui_model_homogeneous_test)
177} 178}
178EFL_END_TEST 179EFL_END_TEST
179 180
181static Eina_Value
182_children_exact_slice_get_then(Efl_Model *model, void *data EINA_UNUSED, const Eina_Value v)
183{
184 unsigned int i, len;
185 Efl_Model *child = NULL;
186 Eina_Future *all[4] = { NULL, NULL, NULL, EINA_FUTURE_SENTINEL };
187 Eina_Future *f;
188
189 fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ARRAY);
190
191 EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
192 {
193 ck_assert_int_eq(_property_uint_expected(child, "self.width"), 0);
194 ck_assert_int_eq(_property_uint_expected(child, "self.height"), 0);
195 }
196
197 EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
198 {
199 Eina_Value *v;
200 unsigned int w, h;
201
202 v = efl_model_property_get(child, "test_p_int");
203 eina_value_uint_convert(v, &w);
204 eina_value_uint_convert(v, &h);
205 eina_value_free(v);
206
207 w *= 2;
208 h *= 3;
209
210 all[i] = eina_future_all(efl_model_property_set(child, "self.width", eina_value_uint_new(w)),
211 efl_model_property_set(child, "self.height", eina_value_uint_new(h)));
212 all[i] = efl_future_then(model, all[i], .success = _child_should_succeed);
213 }
214
215 f = eina_future_all_array(all);
216 f = efl_future_then(model, f, .success = _total_succeed, .error = _total_failed);
217 return eina_future_as_value(f);
218}
219
220EFL_START_TEST(efl_ui_model_exact_test)
221{
222 Efl_Model_Item *base_model, *model;
223 Eina_Future *future;
224 Eina_Value *ret__;
225 int real__;
226
227 base_model = _generate_base_model();
228
229 model = efl_add_ref(EFL_UI_MODEL_EXACT_CLASS, efl_main_loop_get(),
230 efl_ui_view_model_set(efl_added, base_model));
231 ck_assert(!!model);
232
233 future = efl_model_children_slice_get(model, 0, efl_model_children_count_get(model));
234 efl_future_then(model, future, .success = _children_exact_slice_get_then);
235
236 ck_assert_int_eq(_property_uint_expected(model, "total.width"), 0);
237 ck_assert_int_eq(_property_uint_expected(model, "total.height"), 0);
238 ck_assert_int_eq(_property_error_expected(model, "item.width"), EAGAIN);
239 ck_assert_int_eq(_property_error_expected(model, "item.height"), EAGAIN);
240
241 ret__ = efl_loop_begin(efl_app_main_get(EFL_APP_CLASS));
242 real__ = efl_loop_exit_code_process(ret__);
243 fail_if(real__ != 0);
244
245 ck_assert_int_eq(_property_uint_expected(model, "total.width"), base_ints[2] * 2);
246 ck_assert_int_eq(_property_uint_expected(model, "total.height"), base_ints[0] * 3 + base_ints[1] * 3 + base_ints[2] * 3);
247}
248EFL_END_TEST
249
180void 250void
181efl_ui_model(TCase *tc) 251efl_ui_model(TCase *tc)
182{ 252{
183 tcase_add_test(tc, efl_ui_model_homogeneous_test); 253 tcase_add_test(tc, efl_ui_model_homogeneous_test);
254 tcase_add_test(tc, efl_ui_model_exact_test);
184} 255}