summaryrefslogtreecommitdiff
path: root/src/tests/eo/suite
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-09-08 18:39:38 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-09-08 18:39:38 +0900
commit150cc62a0d151e6477a191ec5e97299b01f14fc2 (patch)
treeeae2e7ada424ac4cdab938222a22701dabfe1c1c /src/tests/eo/suite
parentbe29f3f4ecfda76de98963b5f2d04c0ccc672590 (diff)
eo domain tests - make a start on them with some basic ones
this adds tests for some of the basic domain tests. doing the inter-thread ones is going to be much more.... fun.
Diffstat (limited to 'src/tests/eo/suite')
-rw-r--r--src/tests/eo/suite/eo_test_domain.c89
-rw-r--r--src/tests/eo/suite/eo_test_domain.h19
-rw-r--r--src/tests/eo/suite/eo_test_general.c67
3 files changed, 175 insertions, 0 deletions
diff --git a/src/tests/eo/suite/eo_test_domain.c b/src/tests/eo/suite/eo_test_domain.c
new file mode 100644
index 0000000000..9ed5f9a277
--- /dev/null
+++ b/src/tests/eo/suite/eo_test_domain.c
@@ -0,0 +1,89 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "Eina.h"
6#include "Eo.h"
7#include "eo_test_domain.h"
8
9#define MY_CLASS DOMAIN_CLASS
10
11EAPI const Efl_Event_Description _EV_DOMAIN_A_CHANGED =
12 EFL_EVENT_DESCRIPTION("domain,a,changed");
13
14static void
15_a_set(Eo *obj EINA_UNUSED, void *class_data, int a)
16{
17 Domain_Public_Data *pd = class_data;
18 printf("Set Begin\n");
19 pd->a = a;
20 sleep(1);
21 printf("Set End\n");
22 printf("Call Events\n");
23 efl_event_callback_legacy_call(obj, EV_DOMAIN_A_CHANGED, &pd->a);
24 printf("Call Events End\n");
25}
26
27static int
28_a_get(Eo *obj EINA_UNUSED, void *class_data)
29{
30 Domain_Public_Data *pd = class_data;
31 printf("Get Begin\n");
32 return pd->a;
33}
34
35//return obj = efl_add(DOMAIN_CLASS, NULL);
36
37EFL_VOID_FUNC_BODYV(domain_recursive, EFL_FUNC_CALL(n), int n);
38
39static void
40_recursive(Eo *obj, void *class_data EINA_UNUSED, int n)
41{
42 static int count = 0;
43
44 if (count < n)
45 {
46 count++;
47 domain_recursive(obj, n);
48 }
49 else
50 count = 0;
51}
52
53static void
54_dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, Efl_Dbg_Info *root)
55{
56 efl_dbg_info_get(efl_super(eo_obj, MY_CLASS), root);
57 Efl_Dbg_Info *group = EFL_DBG_INFO_LIST_APPEND(root, "Test list");
58 EFL_DBG_INFO_APPEND(group, "Test", EINA_VALUE_TYPE_INT, 8);
59}
60
61EFL_VOID_FUNC_BODYV(domain_a_set, EFL_FUNC_CALL(a), int a);
62EFL_FUNC_BODY(domain_a_get, int, 0);
63EFL_FUNC_BODY(domain_a_print, Eina_Bool, EINA_FALSE);
64EFL_FUNC_BODY_CONST(domain_class_hi_print, Eina_Bool, EINA_FALSE);
65EFL_VOID_FUNC_BODY(domain_pure_virtual);
66EFL_VOID_FUNC_BODY(domain_no_implementation);
67
68static Eina_Bool
69_class_initializer(Efl_Class *klass)
70{
71 EFL_OPS_DEFINE(ops,
72 EFL_OBJECT_OP_FUNC(domain_a_set, _a_set),
73 EFL_OBJECT_OP_FUNC(domain_a_get, _a_get),
74 EFL_OBJECT_OP_FUNC(domain_recursive, _recursive)
75 );
76 return efl_class_functions_set(klass, &ops);
77}
78
79static const Efl_Class_Description class_desc = {
80 EO_VERSION,
81 "Domain",
82 EFL_CLASS_TYPE_REGULAR,
83 sizeof(Domain_Public_Data),
84 _class_initializer,
85 NULL,
86 NULL
87};
88
89EFL_DEFINE_CLASS(domain_class_get, &class_desc, EO_CLASS, NULL)
diff --git a/src/tests/eo/suite/eo_test_domain.h b/src/tests/eo/suite/eo_test_domain.h
new file mode 100644
index 0000000000..ac7428534a
--- /dev/null
+++ b/src/tests/eo/suite/eo_test_domain.h
@@ -0,0 +1,19 @@
1#ifndef DOMAIN_H
2#define DOMAIN_H
3
4typedef struct
5{
6 int a;
7} Domain_Public_Data;
8
9EAPI void domain_a_set(Eo *obj, int a);
10EAPI int domain_a_get(Eo *obj);
11EAPI void domain_recursive(Eo *obj, int n);
12
13extern const Efl_Event_Description _EV_DOMAIN_A_CHANGED;
14#define EV_DOMAIN_A_CHANGED (&(_EV_DOMAIN_A_CHANGED))
15
16#define DOMAIN_CLASS domain_class_get()
17const Efl_Class *domain_class_get(void);
18
19#endif
diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c
index 95ab0b7d6d..9be6de54d2 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -9,6 +9,7 @@
9#include "eo_suite.h" 9#include "eo_suite.h"
10#include "eo_test_class_simple.h" 10#include "eo_test_class_simple.h"
11#include "eo_test_class_singleton.h" 11#include "eo_test_class_singleton.h"
12#include "eo_test_domain.h"
12 13
13/* Loading this internal header for testing purposes. */ 14/* Loading this internal header for testing purposes. */
14#include "eo_ptr_indirection.h" 15#include "eo_ptr_indirection.h"
@@ -1354,6 +1355,71 @@ START_TEST(eo_rec_interface)
1354} 1355}
1355END_TEST 1356END_TEST
1356 1357
1358START_TEST(eo_domain)
1359{
1360 Eo *obj, *objs;
1361
1362 printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
1363 efl_object_init();
1364
1365 fail_if(efl_domain_get() != EFL_ID_DOMAIN_MAIN);
1366
1367 fail_if(efl_domain_switch(EFL_ID_DOMAIN_THREAD) != EINA_TRUE);
1368
1369 fail_if(efl_domain_get() != EFL_ID_DOMAIN_THREAD);
1370
1371 fail_if(efl_domain_switch(EFL_ID_DOMAIN_MAIN) != EINA_TRUE);
1372
1373 fail_if(efl_domain_get() != EFL_ID_DOMAIN_MAIN);
1374
1375 fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_MAIN);
1376
1377 fail_if(efl_domain_current_set(EFL_ID_DOMAIN_SHARED) != EINA_TRUE);
1378
1379 fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_SHARED);
1380
1381 fail_if(efl_domain_current_set(EFL_ID_DOMAIN_MAIN) != EINA_TRUE);
1382
1383 fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_MAIN);
1384
1385 fail_if(efl_domain_current_push(EFL_ID_DOMAIN_SHARED) != EINA_TRUE);
1386
1387 fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_SHARED);
1388
1389 fail_if(efl_domain_current_push(EFL_ID_DOMAIN_THREAD) != EINA_TRUE);
1390
1391 fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_THREAD);
1392
1393 efl_domain_current_pop();
1394
1395 fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_SHARED);
1396
1397 efl_domain_current_pop();
1398
1399 fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_MAIN);
1400
1401 objs = efl_add(DOMAIN_CLASS, NULL);
1402
1403 efl_domain_current_push(EFL_ID_DOMAIN_SHARED);
1404 obj = efl_add(DOMAIN_CLASS, NULL);
1405 efl_domain_current_pop();
1406
1407 fail_if(efl_compatible(objs, obj) == EINA_TRUE);
1408
1409 domain_a_set(obj, 1234);
1410 fail_if(domain_a_get(obj) != 1234);
1411
1412 domain_a_set(objs, 1234);
1413 fail_if(domain_a_get(objs) != 1234);
1414
1415 efl_del(obj);
1416 efl_del(objs);
1417
1418 efl_object_shutdown();
1419 printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
1420}
1421END_TEST
1422
1357void eo_test_general(TCase *tc) 1423void eo_test_general(TCase *tc)
1358{ 1424{
1359 tcase_add_test(tc, eo_simple); 1425 tcase_add_test(tc, eo_simple);
@@ -1376,4 +1442,5 @@ void eo_test_general(TCase *tc)
1376 tcase_add_test(tc, efl_name); 1442 tcase_add_test(tc, efl_name);
1377 tcase_add_test(tc, eo_comment); 1443 tcase_add_test(tc, eo_comment);
1378 tcase_add_test(tc, eo_rec_interface); 1444 tcase_add_test(tc, eo_rec_interface);
1445 tcase_add_test(tc, eo_domain);
1379} 1446}