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
This commit is contained in:
Cedric BAIL 2019-01-16 14:11:51 -08:00
parent d1b1dce5ff
commit 40cc1aca0d
1 changed files with 71 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#include "efl_ui_suite.h"
#include "efl_ui_model_homogeneous.eo.h"
#include "efl_ui_model_exact.eo.h"
static const int child_number = 3;
static const int base_ints[] = { 41, 42, 43 };
@ -177,8 +178,78 @@ EFL_START_TEST(efl_ui_model_homogeneous_test)
}
EFL_END_TEST
static Eina_Value
_children_exact_slice_get_then(Efl_Model *model, void *data EINA_UNUSED, const Eina_Value v)
{
unsigned int i, len;
Efl_Model *child = NULL;
Eina_Future *all[4] = { NULL, NULL, NULL, EINA_FUTURE_SENTINEL };
Eina_Future *f;
fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ARRAY);
EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
{
ck_assert_int_eq(_property_uint_expected(child, "self.width"), 0);
ck_assert_int_eq(_property_uint_expected(child, "self.height"), 0);
}
EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
{
Eina_Value *v;
unsigned int w, h;
v = efl_model_property_get(child, "test_p_int");
eina_value_uint_convert(v, &w);
eina_value_uint_convert(v, &h);
eina_value_free(v);
w *= 2;
h *= 3;
all[i] = eina_future_all(efl_model_property_set(child, "self.width", eina_value_uint_new(w)),
efl_model_property_set(child, "self.height", eina_value_uint_new(h)));
all[i] = efl_future_then(model, all[i], .success = _child_should_succeed);
}
f = eina_future_all_array(all);
f = efl_future_then(model, f, .success = _total_succeed, .error = _total_failed);
return eina_future_as_value(f);
}
EFL_START_TEST(efl_ui_model_exact_test)
{
Efl_Model_Item *base_model, *model;
Eina_Future *future;
Eina_Value *ret__;
int real__;
base_model = _generate_base_model();
model = efl_add_ref(EFL_UI_MODEL_EXACT_CLASS, efl_main_loop_get(),
efl_ui_view_model_set(efl_added, base_model));
ck_assert(!!model);
future = efl_model_children_slice_get(model, 0, efl_model_children_count_get(model));
efl_future_then(model, future, .success = _children_exact_slice_get_then);
ck_assert_int_eq(_property_uint_expected(model, "total.width"), 0);
ck_assert_int_eq(_property_uint_expected(model, "total.height"), 0);
ck_assert_int_eq(_property_error_expected(model, "item.width"), EAGAIN);
ck_assert_int_eq(_property_error_expected(model, "item.height"), EAGAIN);
ret__ = efl_loop_begin(efl_app_main_get(EFL_APP_CLASS));
real__ = efl_loop_exit_code_process(ret__);
fail_if(real__ != 0);
ck_assert_int_eq(_property_uint_expected(model, "total.width"), base_ints[2] * 2);
ck_assert_int_eq(_property_uint_expected(model, "total.height"), base_ints[0] * 3 + base_ints[1] * 3 + base_ints[2] * 3);
}
EFL_END_TEST
void
efl_ui_model(TCase *tc)
{
tcase_add_test(tc, efl_ui_model_homogeneous_test);
tcase_add_test(tc, efl_ui_model_exact_test);
}