summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorSangHyeon Jade Lee <sh10233.lee@samsung.com>2019-09-04 11:07:37 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-09-04 11:07:37 -0400
commit4e379f5db4861301b77bf945f7365cb0faa04feb (patch)
tree50a12adf37d0b44eaf253a9dac24e2e1a8c82e75 /src/tests
parent8b49bdb830b8c7b921712ed467f89aa8d6e6ca3f (diff)
Efl_Ui: Move elementary and change namespace Ui for ui related models
Summary: Select and View is ui characteristic features, so Efl_Select_Model and Efl_View_Model move to elementary from ecore seems more natural. namespace also should changed to Efl.Ui as it's right place. Test Plan: run the test while building it Reviewers: cedric, felipealmeida, bu5hm4n, zmike, lauromoura Reviewed By: zmike Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9820
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/efl/efl_suite.c1
-rw-r--r--src/tests/efl/efl_suite.h1
-rw-r--r--src/tests/efl/efl_test_composite_model.c98
-rw-r--r--src/tests/efl/meson.build1
-rw-r--r--src/tests/elementary/efl_ui_suite.c2
-rw-r--r--src/tests/elementary/efl_ui_suite.h2
-rw-r--r--src/tests/elementary/efl_ui_test_select_model.c130
-rw-r--r--src/tests/elementary/efl_ui_test_view_model.c (renamed from src/tests/efl/efl_test_view_model.c)29
-rw-r--r--src/tests/elementary/meson.build2
9 files changed, 149 insertions, 117 deletions
diff --git a/src/tests/efl/efl_suite.c b/src/tests/efl/efl_suite.c
index 4385b82f72..d5a444b3bf 100644
--- a/src/tests/efl/efl_suite.c
+++ b/src/tests/efl/efl_suite.c
@@ -27,7 +27,6 @@
27 27
28static const Efl_Test_Case etc[] = { 28static const Efl_Test_Case etc[] = {
29 { "Efl_Container_Model", efl_test_case_container_model }, 29 { "Efl_Container_Model", efl_test_case_container_model },
30 { "Efl_View_Model", efl_test_case_view_model },
31 { "Efl_Boolean_Model", efl_test_case_boolean_model }, 30 { "Efl_Boolean_Model", efl_test_case_boolean_model },
32 { NULL, NULL } 31 { NULL, NULL }
33}; 32};
diff --git a/src/tests/efl/efl_suite.h b/src/tests/efl/efl_suite.h
index 4a670deab9..2d4cc7af21 100644
--- a/src/tests/efl/efl_suite.h
+++ b/src/tests/efl/efl_suite.h
@@ -22,7 +22,6 @@
22#include <check.h> 22#include <check.h>
23#include "../efl_check.h" 23#include "../efl_check.h"
24void efl_test_case_container_model(TCase *tc); 24void efl_test_case_container_model(TCase *tc);
25void efl_test_case_view_model(TCase *tc);
26void efl_test_case_boolean_model(TCase *tc); 25void efl_test_case_boolean_model(TCase *tc);
27 26
28#endif /* EFL_SUITE_H_ */ 27#endif /* EFL_SUITE_H_ */
diff --git a/src/tests/efl/efl_test_composite_model.c b/src/tests/efl/efl_test_composite_model.c
index b3c9ebdc33..9538a1173f 100644
--- a/src/tests/efl/efl_test_composite_model.c
+++ b/src/tests/efl/efl_test_composite_model.c
@@ -70,47 +70,6 @@ _children_slice_get_then(void *data EINA_UNUSED,
70 return v; 70 return v;
71} 71}
72 72
73static Eina_Value
74_selection_children_slice_get_then(void *data EINA_UNUSED,
75 const Eina_Value v,
76 const Eina_Future *dead_future EINA_UNUSED)
77{
78 unsigned int i, len;
79 Efl_Model *child = NULL;
80
81 fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ARRAY);
82
83 EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
84 {
85 Eina_Value *p_int = NULL;
86 Eina_Value *p_bool = NULL;
87 Eina_Value *p_index = NULL;
88 int v_int = 0;
89 unsigned int index = 0;
90 Eina_Bool v_bool = EINA_FALSE;
91
92 p_bool = efl_model_property_get(child, "selected");
93 p_int = efl_model_property_get(child, "test_p_int");
94 p_index = efl_model_property_get(child, "child.index");
95
96 eina_value_get(p_bool, &v_bool);
97 eina_value_get(p_int, &v_int);
98 fail_if(!eina_value_uint_convert(p_index, &index));
99
100 fail_if(v_bool != base_selections[i]);
101 fail_if(v_int != base_ints[i]);
102 ck_assert_int_eq(i, index);
103
104 eina_value_free(p_bool);
105 eina_value_free(p_int);
106 eina_value_free(p_index);
107 }
108
109 ecore_main_loop_quit();
110
111 return v;
112}
113
114EFL_START_TEST(efl_test_boolean_model) 73EFL_START_TEST(efl_test_boolean_model)
115{ 74{
116 Efl_Generic_Model *base_model, *child; 75 Efl_Generic_Model *base_model, *child;
@@ -145,62 +104,6 @@ EFL_START_TEST(efl_test_boolean_model)
145} 104}
146EFL_END_TEST 105EFL_END_TEST
147 106
148static Eina_Value
149_wait_propagate(void *data EINA_UNUSED,
150 const Eina_Value v,
151 const Eina_Future *dead_future EINA_UNUSED)
152{
153 ecore_main_loop_quit();
154 return v;
155}
156
157EFL_START_TEST(efl_test_select_model)
158{
159 Efl_Generic_Model *base_model, *child;
160 int i;
161 Eina_Value v = { 0 };
162 Efl_Select_Model *model;
163 Eina_Future *future;
164 Eina_Iterator *it;
165 uint64_t *index;
166
167 eina_value_setup(&v, EINA_VALUE_TYPE_INT);
168
169 base_model = efl_add_ref(EFL_GENERIC_MODEL_CLASS, efl_main_loop_get());
170 ck_assert(!!base_model);
171
172 for (i = 0; i < child_number; ++i)
173 {
174 child = efl_model_child_add(base_model);
175 ck_assert(!!child);
176 ck_assert(eina_value_set(&v, base_ints[i]));
177 efl_model_property_set(child, "test_p_int", &v);
178 }
179
180 model = efl_add_ref(EFL_SELECT_MODEL_CLASS, efl_main_loop_get(),
181 efl_ui_view_model_set(efl_added, base_model));
182 ck_assert(!!model);
183 future = efl_model_property_set(model, "child.selected", eina_value_int_new(2));
184 eina_future_then(future, _wait_propagate, NULL, NULL);
185 ecore_main_loop_begin();
186
187 future = efl_model_children_slice_get(model, 0, efl_model_children_count_get(model));
188 eina_future_then(future, _selection_children_slice_get_then, NULL, NULL);
189
190 ecore_main_loop_begin();
191
192 it = efl_select_model_selected_get(model);
193 EINA_ITERATOR_FOREACH(it, index)
194 fail_if(*index != 2);
195 eina_iterator_free(it);
196
197 it = efl_select_model_unselected_get(model);
198 EINA_ITERATOR_FOREACH(it, index)
199 fail_if(*index == 2);
200 eina_iterator_free(it);
201}
202EFL_END_TEST
203
204typedef struct _Efl_Filter_Model_Wait Efl_Filter_Model_Wait; 107typedef struct _Efl_Filter_Model_Wait Efl_Filter_Model_Wait;
205struct _Efl_Filter_Model_Wait 108struct _Efl_Filter_Model_Wait
206{ 109{
@@ -465,6 +368,5 @@ void
465efl_test_case_boolean_model(TCase *tc) 368efl_test_case_boolean_model(TCase *tc)
466{ 369{
467 tcase_add_test(tc, efl_test_boolean_model); 370 tcase_add_test(tc, efl_test_boolean_model);
468 tcase_add_test(tc, efl_test_select_model);
469 tcase_add_test(tc, efl_test_filter_model); 371 tcase_add_test(tc, efl_test_filter_model);
470} 372}
diff --git a/src/tests/efl/meson.build b/src/tests/efl/meson.build
index 6bd1353804..aba64ac2f3 100644
--- a/src/tests/efl/meson.build
+++ b/src/tests/efl/meson.build
@@ -3,7 +3,6 @@ efl_suite_src = [
3 'efl_suite.h', 3 'efl_suite.h',
4 'efl_test_composite_model.c', 4 'efl_test_composite_model.c',
5 'efl_test_container_model.c', 5 'efl_test_container_model.c',
6 'efl_test_view_model.c'
7] 6]
8 7
9efl_suite_bin = executable('efl_suite', 8efl_suite_bin = executable('efl_suite',
diff --git a/src/tests/elementary/efl_ui_suite.c b/src/tests/elementary/efl_ui_suite.c
index 07f3c40b06..b893f253c1 100644
--- a/src/tests/elementary/efl_ui_suite.c
+++ b/src/tests/elementary/efl_ui_suite.c
@@ -38,6 +38,8 @@ static const Efl_Test_Case etc[] = {
38 { "efl_ui_collection", efl_ui_test_item_container }, 38 { "efl_ui_collection", efl_ui_test_item_container },
39 { "efl_ui_grid_container", efl_ui_test_grid_container }, 39 { "efl_ui_grid_container", efl_ui_test_grid_container },
40 { "efl_ui_list_container", efl_ui_test_list_container }, 40 { "efl_ui_list_container", efl_ui_test_list_container },
41 { "efl_ui_select_model", efl_ui_test_select_model },
42 { "efl_ui_view_model", efl_ui_test_view_model },
41 { NULL, NULL } 43 { NULL, NULL }
42}; 44};
43 45
diff --git a/src/tests/elementary/efl_ui_suite.h b/src/tests/elementary/efl_ui_suite.h
index 0ddf9bd62f..00294a9a71 100644
--- a/src/tests/elementary/efl_ui_suite.h
+++ b/src/tests/elementary/efl_ui_suite.h
@@ -49,6 +49,8 @@ void efl_ui_test_grid_container(TCase *tc);
49void efl_ui_test_config(TCase *tc); 49void efl_ui_test_config(TCase *tc);
50void efl_ui_test_popup(TCase *tc); 50void efl_ui_test_popup(TCase *tc);
51void efl_ui_test_scroller(TCase *tc); 51void efl_ui_test_scroller(TCase *tc);
52void efl_ui_test_select_model(TCase *tc);
53void efl_ui_test_view_model(TCase *tc);
52 54
53void loop_timer_interval_set(Eo *obj, double in); 55void loop_timer_interval_set(Eo *obj, double in);
54 56
diff --git a/src/tests/elementary/efl_ui_test_select_model.c b/src/tests/elementary/efl_ui_test_select_model.c
new file mode 100644
index 0000000000..e11155c0aa
--- /dev/null
+++ b/src/tests/elementary/efl_ui_test_select_model.c
@@ -0,0 +1,130 @@
1/* EFL - EFL library
2 * Copyright (C) 2013 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifdef HAVE_CONFIG_H
20# include "config.h"
21#endif
22
23#include "efl_ui_suite.h"
24
25static const int child_number = 3;
26static const int base_ints[] = { 41, 42, 43 };
27static const Eina_Bool base_selections[] = { EINA_FALSE, EINA_FALSE, EINA_TRUE };
28
29static Eina_Value
30_selection_children_slice_get_then(void *data EINA_UNUSED,
31 const Eina_Value v,
32 const Eina_Future *dead_future EINA_UNUSED)
33{
34 unsigned int i, len;
35 Efl_Model *child = NULL;
36
37 fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ARRAY);
38
39 EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
40 {
41 Eina_Value *p_int = NULL;
42 Eina_Value *p_bool = NULL;
43 Eina_Value *p_index = NULL;
44 int v_int = 0;
45 unsigned int index = 0;
46 Eina_Bool v_bool = EINA_FALSE;
47
48 p_bool = efl_model_property_get(child, "selected");
49 p_int = efl_model_property_get(child, "test_p_int");
50 p_index = efl_model_property_get(child, "child.index");
51
52 eina_value_get(p_bool, &v_bool);
53 eina_value_get(p_int, &v_int);
54 fail_if(!eina_value_uint_convert(p_index, &index));
55
56 fail_if(v_bool != base_selections[i]);
57 fail_if(v_int != base_ints[i]);
58 ck_assert_int_eq(i, index);
59
60 eina_value_free(p_bool);
61 eina_value_free(p_int);
62 eina_value_free(p_index);
63 }
64
65 ecore_main_loop_quit();
66
67 return v;
68}
69
70static Eina_Value
71_wait_propagate(void *data EINA_UNUSED,
72 const Eina_Value v,
73 const Eina_Future *dead_future EINA_UNUSED)
74{
75 ecore_main_loop_quit();
76 return v;
77}
78
79EFL_START_TEST(efl_test_select_model)
80{
81 Efl_Generic_Model *base_model, *child;
82 int i;
83 Eina_Value v = { 0 };
84 Efl_Ui_Select_Model *model;
85 Eina_Future *future;
86 Eina_Iterator *it;
87 uint64_t *index;
88
89 eina_value_setup(&v, EINA_VALUE_TYPE_INT);
90
91 base_model = efl_add_ref(EFL_GENERIC_MODEL_CLASS, efl_main_loop_get());
92 ck_assert(!!base_model);
93
94 for (i = 0; i < child_number; ++i)
95 {
96 child = efl_model_child_add(base_model);
97 ck_assert(!!child);
98 ck_assert(eina_value_set(&v, base_ints[i]));
99 efl_model_property_set(child, "test_p_int", &v);
100 }
101
102 model = efl_add_ref(EFL_UI_SELECT_MODEL_CLASS, efl_main_loop_get(),
103 efl_ui_view_model_set(efl_added, base_model));
104 ck_assert(!!model);
105 future = efl_model_property_set(model, "child.selected", eina_value_int_new(2));
106 eina_future_then(future, _wait_propagate, NULL, NULL);
107 ecore_main_loop_begin();
108
109 future = efl_model_children_slice_get(model, 0, efl_model_children_count_get(model));
110 eina_future_then(future, _selection_children_slice_get_then, NULL, NULL);
111
112 ecore_main_loop_begin();
113
114 it = efl_ui_select_model_selected_get(model);
115 EINA_ITERATOR_FOREACH(it, index)
116 fail_if(*index != 2);
117 eina_iterator_free(it);
118
119 it = efl_ui_select_model_unselected_get(model);
120 EINA_ITERATOR_FOREACH(it, index)
121 fail_if(*index == 2);
122 eina_iterator_free(it);
123}
124EFL_END_TEST
125
126void
127efl_ui_test_select_model(TCase *tc)
128{
129 tcase_add_test(tc, efl_test_select_model);
130}
diff --git a/src/tests/efl/efl_test_view_model.c b/src/tests/elementary/efl_ui_test_view_model.c
index 13e0a13027..b282ea1252 100644
--- a/src/tests/efl/efl_test_view_model.c
+++ b/src/tests/elementary/efl_ui_test_view_model.c
@@ -20,10 +20,7 @@
20# include "config.h" 20# include "config.h"
21#endif 21#endif
22 22
23#include "efl_suite.h" 23#include "efl_ui_suite.h"
24
25#include <Efl.h>
26#include <Ecore.h>
27 24
28static const int child_number = 3; 25static const int child_number = 3;
29static const int base_ints[] = { 41, 42, 43 }; 26static const int base_ints[] = { 41, 42, 43 };
@@ -31,7 +28,7 @@ static const char *_efl_test_view_model_label_format = "Index %i.";
31static const char *dependences[] = { "test_p_int" }; 28static const char *dependences[] = { "test_p_int" };
32 29
33static Eina_Value * 30static Eina_Value *
34_efl_test_view_model_label_get(void *data, const Efl_View_Model *mv, Eina_Stringshare *property) 31_efl_test_view_model_label_get(void *data, const Efl_Ui_View_Model *mv, Eina_Stringshare *property)
35{ 32{
36 Eina_Strbuf *buf; 33 Eina_Strbuf *buf;
37 Eina_Value *r; 34 Eina_Value *r;
@@ -54,7 +51,7 @@ _efl_test_view_model_label_get(void *data, const Efl_View_Model *mv, Eina_String
54} 51}
55 52
56static Eina_Future * 53static Eina_Future *
57_efl_test_view_model_label_set(void *data EINA_UNUSED, Efl_View_Model *mv, Eina_Stringshare *property EINA_UNUSED, Eina_Value *value EINA_UNUSED) 54_efl_test_view_model_label_set(void *data EINA_UNUSED, Efl_Ui_View_Model *mv, Eina_Stringshare *property EINA_UNUSED, Eina_Value *value EINA_UNUSED)
58{ 55{
59 return efl_loop_future_rejected(mv, EFL_MODEL_ERROR_READ_ONLY); 56 return efl_loop_future_rejected(mv, EFL_MODEL_ERROR_READ_ONLY);
60} 57}
@@ -66,7 +63,7 @@ _efl_test_view_model_label_clean(void *data)
66} 63}
67 64
68static Eina_Value * 65static Eina_Value *
69_efl_test_view_model_color_get(void *data EINA_UNUSED, const Efl_View_Model *mv, Eina_Stringshare *property) 66_efl_test_view_model_color_get(void *data EINA_UNUSED, const Efl_Ui_View_Model *mv, Eina_Stringshare *property)
70{ 67{
71 Eina_Strbuf *buf; 68 Eina_Strbuf *buf;
72 Eina_Value *r; 69 Eina_Value *r;
@@ -88,7 +85,7 @@ _efl_test_view_model_color_get(void *data EINA_UNUSED, const Efl_View_Model *mv,
88} 85}
89 86
90static Eina_Future * 87static Eina_Future *
91_efl_test_view_model_color_set(void *data EINA_UNUSED, Efl_View_Model *mv, Eina_Stringshare *property EINA_UNUSED, Eina_Value *value EINA_UNUSED) 88_efl_test_view_model_color_set(void *data EINA_UNUSED, Efl_Ui_View_Model *mv, Eina_Stringshare *property EINA_UNUSED, Eina_Value *value EINA_UNUSED)
92{ 89{
93 return efl_loop_future_rejected(mv, EFL_MODEL_ERROR_READ_ONLY); 90 return efl_loop_future_rejected(mv, EFL_MODEL_ERROR_READ_ONLY);
94} 91}
@@ -318,36 +315,36 @@ EFL_START_TEST(efl_test_view_model)
318 efl_model_property_set(child, "test_p_int", &v); 315 efl_model_property_set(child, "test_p_int", &v);
319 } 316 }
320 317
321 mv = efl_add_ref(EFL_VIEW_MODEL_CLASS, efl_main_loop_get(), 318 mv = efl_add_ref(EFL_UI_VIEW_MODEL_CLASS, efl_main_loop_get(),
322 efl_ui_view_model_set(efl_added, base_model)); 319 efl_ui_view_model_set(efl_added, base_model));
323 ck_assert(!!mv); 320 ck_assert(!!mv);
324 321
325 efl_view_model_property_logic_add(mv, "label", 322 efl_ui_view_model_property_logic_add(mv, "label",
326 (void*) _efl_test_view_model_label_format, _efl_test_view_model_label_get, _efl_test_view_model_label_clean, 323 (void*) _efl_test_view_model_label_format, _efl_test_view_model_label_get, _efl_test_view_model_label_clean,
327 (void*) _efl_test_view_model_label_format, _efl_test_view_model_label_set, _efl_test_view_model_label_clean, 324 (void*) _efl_test_view_model_label_format, _efl_test_view_model_label_set, _efl_test_view_model_label_clean,
328 EINA_C_ARRAY_ITERATOR_NEW(dependences)); 325 EINA_C_ARRAY_ITERATOR_NEW(dependences));
329 326
330 efl_view_model_property_logic_add(mv, "color", 327 efl_ui_view_model_property_logic_add(mv, "color",
331 NULL, _efl_test_view_model_color_get, _efl_test_view_model_color_clean, 328 NULL, _efl_test_view_model_color_get, _efl_test_view_model_color_clean,
332 NULL, _efl_test_view_model_color_set, _efl_test_view_model_color_clean, 329 NULL, _efl_test_view_model_color_set, _efl_test_view_model_color_clean,
333 EINA_C_ARRAY_ITERATOR_NEW(dependences)); 330 EINA_C_ARRAY_ITERATOR_NEW(dependences));
334 331
335 efl_view_model_property_logic_add(mv, "deadend", 332 efl_ui_view_model_property_logic_add(mv, "deadend",
336 NULL, NULL, NULL, 333 NULL, NULL, NULL,
337 NULL, NULL, NULL, 334 NULL, NULL, NULL,
338 NULL); 335 NULL);
339 336
340 efl_view_model_property_string_add(mv, "output", 337 efl_ui_view_model_property_string_add(mv, "output",
341 "${label} has ${color} for index ${index}", 338 "${label} has ${color} for index ${index}",
342 "${index} not ready", 339 "${index} not ready",
343 "${index} in error"); 340 "${index} in error");
344 341
345 efl_view_model_property_string_add(mv, "broken", 342 efl_ui_view_model_property_string_add(mv, "broken",
346 "${nope} has ${color} for index ${index}", 343 "${nope} has ${color} for index ${index}",
347 "${index} not ready", 344 "${index} not ready",
348 "${index} in error with '${nope}'"); 345 "${index} in error with '${nope}'");
349 346
350 efl_view_model_property_string_add(mv, "weird", "${} % { } has ${", NULL, NULL); 347 efl_ui_view_model_property_string_add(mv, "weird", "${} % { } has ${", NULL, NULL);
351 348
352 f = efl_model_children_slice_get(mv, 0, efl_model_children_count_get(mv)); 349 f = efl_model_children_slice_get(mv, 0, efl_model_children_count_get(mv));
353 f = efl_future_then(mv, f, .success_type = EINA_VALUE_TYPE_ARRAY, 350 f = efl_future_then(mv, f, .success_type = EINA_VALUE_TYPE_ARRAY,
@@ -367,7 +364,7 @@ EFL_START_TEST(efl_test_view_model)
367EFL_END_TEST 364EFL_END_TEST
368 365
369void 366void
370efl_test_case_view_model(TCase *tc) 367efl_ui_test_view_model(TCase *tc)
371{ 368{
372 tcase_add_test(tc, efl_test_view_model); 369 tcase_add_test(tc, efl_test_view_model);
373} 370}
diff --git a/src/tests/elementary/meson.build b/src/tests/elementary/meson.build
index 5204c6473a..161a389967 100644
--- a/src/tests/elementary/meson.build
+++ b/src/tests/elementary/meson.build
@@ -154,6 +154,8 @@ efl_ui_suite_src = [
154 'efl_ui_test_position_manager_common.c', 154 'efl_ui_test_position_manager_common.c',
155 'efl_ui_test_popup.c', 155 'efl_ui_test_popup.c',
156 'efl_ui_test_scroller.c', 156 'efl_ui_test_scroller.c',
157 'efl_ui_test_select_model.c',
158 'efl_ui_test_view_model.c',
157] 159]
158 160
159efl_ui_suite = executable('efl_ui_suite', 161efl_ui_suite = executable('efl_ui_suite',