summaryrefslogtreecommitdiff
path: root/src/tests/efl
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2017-01-31 18:17:58 -0200
committerCedric BAIL <cedric@osg.samsung.com>2017-02-06 15:26:21 -0800
commit093c5921888dd4810233c6ba3e97479758e2589c (patch)
treecea9d80b886a1e48f994f987535c209edcb704d9 /src/tests/efl
parentde83cc77d3a8864ed3cf367a860a6573ceabe8d7 (diff)
downloadefl-093c5921888dd4810233c6ba3e97479758e2589c.tar.gz
efl: add efl_model and efl_ui_view classes
Efl.Model.Container and Efl.Model.Item to efl/interfaces are used to create Efl.Model objects with predefined property values. This is useful to any situation where we want an Efl.Model with explicit defined property values. Efl.Ui.View and Efl.Ui.Factory are used to connect Efl.Models with Widgets, Elm.Layout and Efl.Ui.Image has changed to use news interfaces Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/tests/efl')
-rw-r--r--src/tests/efl/efl_suite.c51
-rw-r--r--src/tests/efl/efl_suite.h26
-rw-r--r--src/tests/efl/efl_test_model_container.c171
3 files changed, 248 insertions, 0 deletions
diff --git a/src/tests/efl/efl_suite.c b/src/tests/efl/efl_suite.c
new file mode 100644
index 0000000000..653aac2201
--- /dev/null
+++ b/src/tests/efl/efl_suite.c
@@ -0,0 +1,51 @@
+/* EINA - EFL data type library
+ * Copyright (C) 2008 Cedric Bail
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library;
+ * if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <Eina.h>
+
+#include "efl_suite.h"
+#include "../efl_check.h"
+
+static const Efl_Test_Case etc[] = {
+ { "Efl_Model_Container", efl_test_case_model_container },
+ { NULL, NULL }
+};
+
+int
+main(int argc, char **argv)
+{
+ int failed_count;
+
+ if (!_efl_test_option_disp(argc, argv, etc))
+ return 0;
+
+ putenv("EFL_RUN_IN_TREE=1");
+
+ eina_init();
+
+ failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
+ "Efl", etc);
+
+ eina_shutdown();
+
+ return (failed_count == 0) ? 0 : 255;
+}
diff --git a/src/tests/efl/efl_suite.h b/src/tests/efl/efl_suite.h
new file mode 100644
index 0000000000..d5a7caa9ec
--- /dev/null
+++ b/src/tests/efl/efl_suite.h
@@ -0,0 +1,26 @@
+/* EFL - EFL library
+ * Copyright (C) 2008 Cedric Bail
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library;
+ * if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef EFL_SUITE_H_
+#define EFL_SUITE_H_
+
+#include <check.h>
+
+void efl_test_case_model_container(TCase *tc);
+
+#endif /* EFL_SUITE_H_ */
diff --git a/src/tests/efl/efl_test_model_container.c b/src/tests/efl/efl_test_model_container.c
new file mode 100644
index 0000000000..5710ef2337
--- /dev/null
+++ b/src/tests/efl/efl_test_model_container.c
@@ -0,0 +1,171 @@
+/* EFL - EFL library
+ * Copyright (C) 2013 Cedric Bail
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library;
+ * if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "efl_suite.h"
+
+#include <Efl.h>
+#include <Ecore.h>
+
+typedef struct _Test_Container_Data {
+ int item_count;
+ Eina_Bool pass_flag;
+ Eina_Bool fail_flag;
+} Test_Container_Data;
+
+typedef struct _Test_Container_Item_Data {
+ Test_Container_Data* test_data;
+ unsigned int index;
+} Test_Container_Item_Data;
+
+const int base_int[7] = {10, 11, 12, 13, 14, 0, 16};
+const char * const base_str[7] = {"A", "B", "C", "D", "E", "", "GH"};
+
+static void
+_future_error_then(void *data EINA_UNUSED, Efl_Event const* event EINA_UNUSED)
+{
+ ck_abort_msg("Promise failed");
+}
+
+static void
+_container_property_get_then(void *data, Efl_Event const *event)
+{
+ Eina_Accessor *value_itt = (Eina_Accessor*)((Efl_Future_Event_Success*)event->info)->value;
+ Test_Container_Item_Data *test_item_data = data;
+ Eina_Value *value_int = NULL;
+ Eina_Value *value_str = NULL;
+ int cmp_int = 0;
+ const char *cmp_str = NULL;
+
+ test_item_data->test_data->item_count++;
+
+ if (!value_itt || !eina_accessor_data_get(value_itt, 0, (void**)&value_int) ||
+ !eina_accessor_data_get(value_itt, 1, (void**)&value_str))
+ {
+ test_item_data->test_data->fail_flag = EINA_TRUE;
+ ecore_main_loop_quit();
+ return;
+ }
+
+ eina_value_get(value_int, &cmp_int);
+ eina_value_get(value_str, &cmp_str);
+
+ if (cmp_int != base_int[test_item_data->index] ||
+ strcmp(cmp_str, base_str[test_item_data->index]) != 0)
+ {
+ test_item_data->test_data->fail_flag = EINA_TRUE;
+ }
+
+ if (test_item_data->test_data->item_count == 7)
+ {
+ test_item_data->test_data->pass_flag = EINA_TRUE;
+ }
+ ecore_main_loop_quit();
+}
+
+static void
+_children_slice_future_then(void *data, Efl_Event const *event)
+{
+ Eina_Accessor *children_accessor = (Eina_Accessor *)((Efl_Future_Event_Success*)event->info)->value;
+ unsigned int i = 0;
+ Efl_Model *child;
+
+ if (children_accessor)
+ {
+ EINA_ACCESSOR_FOREACH(children_accessor, i, child)
+ {
+ Efl_Future *futures[3] = {NULL,};
+ Efl_Future *future_all = NULL;
+ Test_Container_Item_Data *test_item_data = calloc(1, sizeof(Test_Container_Item_Data));
+
+ test_item_data->test_data = data;
+ test_item_data->index = i;
+
+ futures[0] = efl_model_property_get(child, "test_p_int");
+ futures[1] = efl_model_property_get(child, "test_p_str");
+
+ future_all = efl_future_all(futures[0], futures[1]);
+ efl_future_then(future_all, _container_property_get_then, _future_error_then, NULL, test_item_data);
+ }
+ }
+}
+
+
+START_TEST(efl_test_model_container_values)
+{
+ Efl_Model_Container* model;
+ Efl_Future *future;
+ Test_Container_Data test_data;
+ int **cmp_int;
+ const char **cmp_str;
+ int i;
+
+ fail_if(!ecore_init(), "ERROR: Cannot init Ecore!\n");
+ fail_if(!efl_object_init(), "ERROR: Cannot init EO!\n");
+
+ cmp_int = calloc(8, sizeof(int*));
+ cmp_str = calloc(8, sizeof(const char*));
+ for (i = 0; i < 7; ++i)
+ {
+ cmp_int[i] = calloc(1, sizeof(int));
+ *(cmp_int[i]) = base_int[i];
+ cmp_str[i] = strdup(base_str[i]);
+ }
+
+ model = efl_add(EFL_MODEL_CONTAINER_CLASS, NULL);
+
+ efl_model_container_child_property_add(model, "test_p_int", EINA_VALUE_TYPE_INT,
+ eina_carray_iterator_new((void**)cmp_int));
+
+ efl_model_container_child_property_add(model, "test_p_str", EINA_VALUE_TYPE_STRING,
+ eina_carray_iterator_new((void**)cmp_str));
+
+ for (i = 0; i < 7; ++i)
+ {
+ free(cmp_int[i]);
+ free((void*)cmp_str[i]);
+ }
+ free(cmp_int);
+ free(cmp_str);
+
+ future = efl_model_children_slice_get(model, 0, 0);
+
+ test_data.item_count = 0;
+ test_data.pass_flag = EINA_FALSE;
+ test_data.fail_flag = EINA_FALSE;
+
+ efl_future_then(future, _children_slice_future_then, _future_error_then, NULL, &test_data);
+
+ ecore_main_loop_iterate();
+
+ ck_assert(!!test_data.pass_flag);
+ ck_assert(!test_data.fail_flag);
+
+ ecore_shutdown();
+}
+END_TEST
+
+
+void
+efl_test_case_model_container(TCase *tc)
+{
+ tcase_add_test(tc, efl_test_model_container_values);
+}