This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efl.

View the commit online.

commit 674e3de23b1935fb047214ccd0e141843bf9e92b
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 15 18:54:40 2026 -0600

    tests: models refuse a size or a value for a row that has no index
    
    Exact_Model and Container_Model each refuse to write for a row that
    has no index (0xFFFFFFFF): the row left while a slice holding it was
    pending. Such a row only exists since a pending composite slice
    follows the rows that move before it, so these checks could not be
    written with the fixes that made the models refuse it.
    
    The Exact_Model row has no size and takes none, and the total is left
    alone. The Container_Model row takes no value, and the values of the
    others do not grow to reach it.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/tests/efl/efl_test_container_model.c | 80 ++++++++++++++++++++++++++++
 src/tests/elementary/efl_ui_model.c      | 90 +++++++++++++++++++++++++++-----
 2 files changed, 157 insertions(+), 13 deletions(-)

diff --git a/src/tests/efl/efl_test_container_model.c b/src/tests/efl/efl_test_container_model.c
index 35dfed77f3..1920a9e93f 100644
--- a/src/tests/efl/efl_test_container_model.c
+++ b/src/tests/efl/efl_test_container_model.c
@@ -115,8 +115,88 @@ EFL_START_TEST(efl_test_container_model_values)
 EFL_END_TEST
 
 
+// A row that left while the slice holding it was pending has no index (0xFFFFFFFF):
+// it takes no value, and the values of the others do not grow to reach it.
+static Eina_Value
+_gone_kids_then(void *data, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
+{
+   Eo **kids = data;
+   unsigned int i, len;
+   Eo *c;
+
+   EINA_VALUE_ARRAY_FOREACH(&v, len, i, c)
+     {
+        if (i < 2) kids[i] = efl_ref(c);
+     }
+   return v;
+}
+
+static Eina_Value
+_gone_set_then(void *data, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
+{
+   Eina_Error *err = data;
+
+   *err = 0;
+   if (eina_value_type_get(&v) == EINA_VALUE_TYPE_ERROR) eina_value_error_get(&v, err);
+   return v;
+}
+
+EFL_START_TEST(efl_test_container_model_gone_row)
+{
+   Efl_Model *base, *model, *rows[3];
+   Eo *kids[2] = { NULL, NULL };
+   Eina_Error err = -1;
+   int values[3] = { 10, 11, 12 };
+   int *pv[4] = { &values[0], &values[1], &values[2], NULL };
+   Eina_Value *v;
+   int got = 0;
+   unsigned int i;
+
+   base = efl_add_ref(EFL_GENERIC_MODEL_CLASS, efl_main_loop_get());
+   for (i = 0; i < 3; i++)
+     {
+        rows[i] = efl_model_child_add(base);
+        ck_assert(!!rows[i]);
+     }
+   model = efl_add_ref(EFL_CONTAINER_MODEL_CLASS, efl_main_loop_get(),
+                       efl_ui_view_model_set(efl_added, base));
+   efl_container_model_child_property_add(model, "p", EINA_VALUE_TYPE_INT,
+                                          eina_carray_iterator_new((void **) pv));
+
+   eina_future_then(efl_model_children_slice_get(model, 0, 2), _gone_kids_then, kids, NULL);
+   efl_model_child_del(base, rows[0]);
+   for (i = 0; (i < 8) && !kids[1]; i++)
+     {
+        ecore_main_loop_iterate();
+     }
+   ck_assert(!!kids[0]);
+   ck_assert_int_eq(efl_composite_model_index_get(kids[0]), 0xFFFFFFFF);
+
+   eina_future_then(efl_model_property_set(kids[0], "p", eina_value_int_new(99)),
+                    _gone_set_then, &err, NULL);
+   for (i = 0; (i < 8) && (err == -1); i++)
+     {
+        ecore_main_loop_iterate();
+     }
+   ck_assert_int_eq(err, EFL_MODEL_ERROR_INCORRECT_VALUE);
+
+   // row 1 is at 0 now (the values stay by index: that is how this model keeps them)
+   ck_assert_int_eq(efl_composite_model_index_get(kids[1]), 0);
+   v = efl_model_property_get(kids[1], "p");
+   ck_assert(eina_value_int_get(v, &got));
+   eina_value_free(v);
+   ck_assert_int_eq(got, 10);
+
+   efl_unref(kids[0]);
+   efl_unref(kids[1]);
+   efl_unref(model);
+   efl_unref(base);
+}
+EFL_END_TEST
+
 void
 efl_test_case_container_model(TCase *tc)
 {
    tcase_add_test(tc, efl_test_container_model_values);
+   tcase_add_test(tc, efl_test_container_model_gone_row);
 }
diff --git a/src/tests/elementary/efl_ui_model.c b/src/tests/elementary/efl_ui_model.c
index 1ff7b6ea25..d2a8dfca7f 100644
--- a/src/tests/elementary/efl_ui_model.c
+++ b/src/tests/elementary/efl_ui_model.c
@@ -356,6 +356,82 @@ EFL_START_TEST(efl_ui_average_model_test)
 }
 EFL_END_TEST
 
+// A row that left while the slice holding it was pending has no index (0xFFFFFFFF):
+// it has no size, takes none, and leaves the total alone.
+static Eina_Value
+_gone_kids_then(void *data, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
+{
+   Eo **kids = data;
+   unsigned int i, len;
+   Eo *c;
+
+   EINA_VALUE_ARRAY_FOREACH(&v, len, i, c)
+     {
+        if (i < 2) kids[i] = efl_ref(c);
+     }
+   return v;
+}
+
+static Eina_Value
+_gone_set_then(void *data, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
+{
+   Eina_Error *err = data;
+
+   *err = 0;
+   if (eina_value_type_get(&v) == EINA_VALUE_TYPE_ERROR) eina_value_error_get(&v, err);
+   return v;
+}
+
+EFL_START_TEST(efl_ui_exact_model_gone_row)
+{
+   Eina_Value told = eina_value_uint_init(10);
+   Efl_Model *base_model, *model, *row0;
+   Eo *kids[2] = { NULL, NULL };
+   Eina_Error err = -1;
+   unsigned int i;
+
+   base_model = _generate_base_model();
+   model = efl_add_ref(EFL_UI_EXACT_MODEL_CLASS, efl_main_loop_get(),
+                       efl_ui_view_model_set(efl_added, base_model));
+   ck_assert(!!model);
+
+   eina_future_then(efl_model_children_slice_get(base_model, 0, 1), _gone_kids_then, kids, NULL);
+   for (i = 0; (i < 8) && !kids[0]; i++)
+     {
+        ecore_main_loop_iterate();
+     }
+   row0 = kids[0];
+   kids[0] = NULL;
+   ck_assert(!!row0);
+
+   eina_future_then(efl_model_children_slice_get(model, 0, 2), _gone_kids_then, kids, NULL);
+   efl_model_child_del(base_model, row0);
+   for (i = 0; (i < 8) && !kids[1]; i++)
+     {
+        ecore_main_loop_iterate();
+     }
+   ck_assert(!!kids[0]);
+   ck_assert_int_eq(efl_composite_model_index_get(kids[0]), 0xFFFFFFFF);
+
+   ck_assert_int_eq(_property_error_expected(kids[0], "self.height"), EAGAIN);
+   eina_future_then(efl_model_property_set(kids[0], "self.height", &told),
+                    _gone_set_then, &err, NULL);
+   for (i = 0; (i < 8) && (err == -1); i++)
+     {
+        ecore_main_loop_iterate();
+     }
+   ck_assert_int_eq(err, EFL_MODEL_ERROR_INCORRECT_VALUE);
+   ck_assert_int_eq(_property_uint_expected(model, "total.height"), 0);
+
+   eina_value_flush(&told);
+   efl_unref(row0);
+   efl_unref(kids[0]);
+   efl_unref(kids[1]);
+   efl_unref(model);
+   efl_unref(base_model);
+}
+EFL_END_TEST
+
 // Rows past the first block of 1024 are kept in other slots, and a slot that is
 // reused for another block must be written back under its own block.
 #define MANY_ROWS 3500
@@ -627,19 +703,6 @@ _many_free(Many_Rows *many, Efl_Model *model, Efl_Generic_Model *base_model)
    efl_unref(base_model);
 }
 
-static Eina_Value
-_gone_set_then(void *data, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
-{
-   Eina_Error *err = data;
-
-   *err = 0;
-   if (eina_value_type_get(&v) == EINA_VALUE_TYPE_ERROR)
-     {
-        eina_value_error_get(&v, err);
-     }
-   return v;
-}
-
 // A row that leaves takes its height out of what the average is over, and
 // is no longer one that was seen.
 EFL_START_TEST(efl_ui_average_model_remove)
@@ -1802,6 +1865,7 @@ efl_ui_model(TCase *tc)
    tcase_add_test(tc, efl_ui_average_model_last_ref_dropped);
    tcase_add_test(tc, efl_ui_average_model_first_measure);
    tcase_add_test(tc, efl_ui_exact_model_test);
+   tcase_add_test(tc, efl_ui_exact_model_gone_row);
    tcase_add_test(tc, efl_ui_exact_model_many_rows);
    tcase_add_test(tc, efl_ui_exact_model_insert_remove);
    tcase_add_test(tc, efl_ui_exact_model_removed_row_write);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to