summaryrefslogtreecommitdiff
path: root/src/tests/eo/suite
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-06-14 13:40:46 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-06-14 16:54:11 +0900
commitb96722cfb8baf5761295c487faf7396a873a2428 (patch)
tree446048f63cd93e1d92ad54bbc36e088f92b83124 /src/tests/eo/suite
parent97c10e9346837fcd354fe9144d57cd8d63654d00 (diff)
eo: Add API efl_data_scope_safe_get
This is a safe version of efl_data_scope_get, meaning that it will return NULL if the object is not of the required type, or if there is no data for that class, or if the given class was used as an interface (and isn't a mixin). @feature
Diffstat (limited to 'src/tests/eo/suite')
-rw-r--r--src/tests/eo/suite/eo_test_class_simple.c22
-rw-r--r--src/tests/eo/suite/eo_test_class_simple.h4
-rw-r--r--src/tests/eo/suite/eo_test_general.c24
3 files changed, 49 insertions, 1 deletions
diff --git a/src/tests/eo/suite/eo_test_class_simple.c b/src/tests/eo/suite/eo_test_class_simple.c
index 56620c68a2..281549c629 100644
--- a/src/tests/eo/suite/eo_test_class_simple.c
+++ b/src/tests/eo/suite/eo_test_class_simple.c
@@ -142,7 +142,7 @@ static const Efl_Class_Description class_desc2 = {
142 EO_VERSION, 142 EO_VERSION,
143 "Simple2", 143 "Simple2",
144 EFL_CLASS_TYPE_REGULAR, 144 EFL_CLASS_TYPE_REGULAR,
145 0, 145 sizeof(Simple_Public_Data),
146 _class_initializer2, 146 _class_initializer2,
147 NULL, 147 NULL,
148 NULL 148 NULL
@@ -150,6 +150,26 @@ static const Efl_Class_Description class_desc2 = {
150 150
151EFL_DEFINE_CLASS(simple2_class_get, &class_desc2, EO_CLASS, NULL) 151EFL_DEFINE_CLASS(simple2_class_get, &class_desc2, EO_CLASS, NULL)
152 152
153
154static Eina_Bool
155_class_initializer3(Efl_Class *klass)
156{
157 return efl_class_functions_set(klass, NULL, NULL);
158}
159
160static const Efl_Class_Description class_desc3 = {
161 EO_VERSION,
162 "Simple3",
163 EFL_CLASS_TYPE_REGULAR,
164 sizeof(Simple_Public_Data),
165 _class_initializer3,
166 NULL,
167 NULL
168};
169
170EFL_DEFINE_CLASS(simple3_class_get, &class_desc3, SIMPLE_CLASS, SIMPLE2_CLASS, NULL)
171
172
153static Efl_Object* 173static Efl_Object*
154_interface_get(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Efl_Object *klass) 174_interface_get(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, const Efl_Object *klass)
155{ 175{
diff --git a/src/tests/eo/suite/eo_test_class_simple.h b/src/tests/eo/suite/eo_test_class_simple.h
index 7d7432b5a0..9023119577 100644
--- a/src/tests/eo/suite/eo_test_class_simple.h
+++ b/src/tests/eo/suite/eo_test_class_simple.h
@@ -29,6 +29,10 @@ EAPI int simple2_class_beef_get(const Efl_Class *obj);
29#define SIMPLE2_CLASS simple2_class_get() 29#define SIMPLE2_CLASS simple2_class_get()
30const Efl_Class *simple2_class_get(void); 30const Efl_Class *simple2_class_get(void);
31 31
32// simple3(simple, simple2)
33#define SIMPLE3_CLASS simple3_class_get()
34const Efl_Class *simple3_class_get(void);
35
32#define SEARCHABLE_CLASS searchable_class_get() 36#define SEARCHABLE_CLASS searchable_class_get()
33const Efl_Class *searchable_class_get(void); 37const Efl_Class *searchable_class_get(void);
34 38
diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c
index 8798e2a80e..0d6f322f1f 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -304,6 +304,29 @@ START_TEST(efl_data_fetch)
304} 304}
305END_TEST 305END_TEST
306 306
307START_TEST(efl_data_safe_fetch)
308{
309 efl_object_init();
310
311 Eo *obj = efl_add(SIMPLE2_CLASS, NULL);
312 fail_if(!obj || !efl_data_scope_safe_get(obj, SIMPLE2_CLASS));
313 efl_unref(obj);
314
315 obj = efl_add(SIMPLE3_CLASS, NULL);
316 fail_if(!obj);
317 fail_if(!efl_isa(obj, SIMPLE_CLASS));
318 fail_if(!efl_isa(obj, SIMPLE2_CLASS));
319 fail_if(!efl_isa(obj, SIMPLE3_CLASS));
320 fail_if(!efl_data_scope_safe_get(obj, SIMPLE_CLASS));
321 fail_if(!efl_data_scope_safe_get(obj, SIMPLE3_CLASS));
322 fail_if(efl_data_scope_safe_get(obj, SIMPLE2_CLASS) != NULL);
323 fail_if(efl_data_scope_safe_get(NULL, EFL_OBJECT_CLASS) != NULL);
324 efl_unref(obj);
325
326 efl_object_shutdown();
327}
328END_TEST
329
307START_TEST(efl_isa_tests) 330START_TEST(efl_isa_tests)
308{ 331{
309 efl_object_init(); 332 efl_object_init();
@@ -1687,6 +1710,7 @@ void eo_test_general(TCase *tc)
1687 tcase_add_test(tc, efl_object_override_tests); 1710 tcase_add_test(tc, efl_object_override_tests);
1688 tcase_add_test(tc, eo_signals); 1711 tcase_add_test(tc, eo_signals);
1689 tcase_add_test(tc, efl_data_fetch); 1712 tcase_add_test(tc, efl_data_fetch);
1713 tcase_add_test(tc, efl_data_safe_fetch);
1690 tcase_add_test(tc, efl_isa_tests); 1714 tcase_add_test(tc, efl_isa_tests);
1691 tcase_add_test(tc, efl_composite_tests); 1715 tcase_add_test(tc, efl_composite_tests);
1692 tcase_add_test(tc, eo_man_free); 1716 tcase_add_test(tc, eo_man_free);