summaryrefslogtreecommitdiff
path: root/src/tests/efl/efl_test_model_container.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-02-09 14:51:08 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-05-01 10:39:01 -0700
commit5351720b66dcdb59c88a93cef61cb9449df7907d (patch)
treee194d9997f94d12c8737b16c7fd16fbe595c6fb5 /src/tests/efl/efl_test_model_container.c
parentbf2e65a38d0af1189639270e2983e3cdf39c8158 (diff)
ecore: update Ecore Efl.Model tests.
Diffstat (limited to '')
-rw-r--r--src/tests/efl/efl_test_model_container.c107
1 files changed, 31 insertions, 76 deletions
diff --git a/src/tests/efl/efl_test_model_container.c b/src/tests/efl/efl_test_model_container.c
index aee7dab078..50a2fd401a 100644
--- a/src/tests/efl/efl_test_model_container.c
+++ b/src/tests/efl/efl_test_model_container.c
@@ -25,95 +25,57 @@
25#include <Efl.h> 25#include <Efl.h>
26#include <Ecore.h> 26#include <Ecore.h>
27 27
28typedef struct _Test_Container_Data {
29 int item_count;
30 Eina_Bool pass_flag;
31 Eina_Bool fail_flag;
32} Test_Container_Data;
33
34typedef struct _Test_Container_Item_Data { 28typedef struct _Test_Container_Item_Data {
35 Test_Container_Data* test_data;
36 unsigned int index; 29 unsigned int index;
37} Test_Container_Item_Data; 30} Test_Container_Item_Data;
38 31
39const int base_int[7] = {10, 11, 12, 13, 14, 0, 16}; 32const int base_int[7] = {10, 11, 12, 13, 14, 0, 16};
40const char * const base_str[7] = {"A", "B", "C", "D", "E", "", "GH"}; 33const char * const base_str[7] = {"A", "B", "C", "D", "E", "", "GH"};
41 34
42static void 35static Eina_Value
43_future_error_then(void *data EINA_UNUSED, Efl_Event const* event EINA_UNUSED) 36_children_slice_future_then(void *data EINA_UNUSED,
37 const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
44{ 38{
45 ck_abort_msg("Promise failed"); 39 unsigned int i, len;
46} 40 Efl_Model *child = NULL;
47 41
48static void 42 fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ARRAY);
49_container_property_get_then(void *data, Efl_Event const *event)
50{
51 Eina_Accessor *value_itt = (Eina_Accessor*)((Efl_Future_Event_Success*)event->info)->value;
52 Test_Container_Item_Data *test_item_data = data;
53 Eina_Value *value_int = NULL;
54 Eina_Value *value_str = NULL;
55 int cmp_int = 0;
56 const char *cmp_str = NULL;
57 43
58 test_item_data->test_data->item_count++; 44 EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
59
60 if (!value_itt || !eina_accessor_data_get(value_itt, 0, (void**)&value_int) ||
61 !eina_accessor_data_get(value_itt, 1, (void**)&value_str))
62 { 45 {
63 test_item_data->test_data->fail_flag = EINA_TRUE; 46 Eina_Value *value_int = NULL;
64 ecore_main_loop_quit(); 47 Eina_Value *value_str = NULL;
65 return; 48 const char *cmp_str = NULL;
66 } 49 int cmp_int = 0;
67 50
68 eina_value_get(value_int, &cmp_int); 51 value_int = efl_model_property_get(child, "test_p_int");
69 eina_value_get(value_str, &cmp_str); 52 value_str = efl_model_property_get(child, "test_p_str");
70 53
71 if (cmp_int != base_int[test_item_data->index] || 54 fail_if(eina_value_type_get(value_int) != EINA_VALUE_TYPE_INT);
72 strcmp(cmp_str, base_str[test_item_data->index]) != 0) 55 fail_if(eina_value_type_get(value_str) != EINA_VALUE_TYPE_STRING);
73 {
74 test_item_data->test_data->fail_flag = EINA_TRUE;
75 }
76
77 if (test_item_data->test_data->item_count == 7)
78 {
79 test_item_data->test_data->pass_flag = EINA_TRUE;
80 }
81 ecore_main_loop_quit();
82}
83 56
84static void 57 eina_value_get(value_int, &cmp_int);
85_children_slice_future_then(void *data, Efl_Event const *event) 58 eina_value_get(value_str, &cmp_str);
86{
87 Eina_Accessor *children_accessor = (Eina_Accessor *)((Efl_Future_Event_Success*)event->info)->value;
88 unsigned int i = 0;
89 Efl_Model *child;
90 59
91 if (children_accessor) 60 if (cmp_int != base_int[i] ||
92 { 61 strcmp(cmp_str, base_str[i]) != 0)
93 EINA_ACCESSOR_FOREACH(children_accessor, i, child) 62 {
94 { 63 abort();
95 Efl_Future *futures[3] = {NULL,}; 64 }
96 Efl_Future *future_all = NULL; 65 }
97 Test_Container_Item_Data *test_item_data = calloc(1, sizeof(Test_Container_Item_Data)); 66 fprintf(stderr, "len: %i\n", len);
98 67
99 test_item_data->test_data = data; 68 fail_if(len != 7);
100 test_item_data->index = i;
101 69
102 futures[0] = efl_model_property_get(child, "test_p_int"); 70 ecore_main_loop_quit();
103 futures[1] = efl_model_property_get(child, "test_p_str");
104 71
105 future_all = efl_future_all(futures[0], futures[1]); 72 return v;
106 efl_future_then(future_all, _container_property_get_then, _future_error_then, NULL, test_item_data);
107 }
108 }
109} 73}
110 74
111
112EFL_START_TEST(efl_test_model_container_values) 75EFL_START_TEST(efl_test_model_container_values)
113{ 76{
114 Efl_Model_Container* model; 77 Efl_Model_Container* model;
115 Efl_Future *future; 78 Eina_Future *future;
116 Test_Container_Data test_data;
117 int **cmp_int; 79 int **cmp_int;
118 const char **cmp_str; 80 const char **cmp_str;
119 int i; 81 int i;
@@ -143,18 +105,11 @@ EFL_START_TEST(efl_test_model_container_values)
143 free(cmp_int); 105 free(cmp_int);
144 free(cmp_str); 106 free(cmp_str);
145 107
146 future = efl_model_children_slice_get(model, 0, 0); 108 future = efl_model_children_slice_get(model, 0, efl_model_children_count_get(model));
147
148 test_data.item_count = 0;
149 test_data.pass_flag = EINA_FALSE;
150 test_data.fail_flag = EINA_FALSE;
151
152 efl_future_then(future, _children_slice_future_then, _future_error_then, NULL, &test_data);
153 109
154 while ((!test_data.pass_flag) && (!test_data.fail_flag)) ecore_main_loop_iterate(); 110 eina_future_then(future, _children_slice_future_then, NULL);
155 111
156 ck_assert(!!test_data.pass_flag); 112 ecore_main_loop_begin();
157 ck_assert(!test_data.fail_flag);
158} 113}
159EFL_END_TEST 114EFL_END_TEST
160 115