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.
This commit is contained in:
parent
be29f3f4ec
commit
150cc62a0d
|
@ -119,6 +119,8 @@ tests/eo/suite/eo_test_class_simple.c \
|
||||||
tests/eo/suite/eo_test_class_simple.h \
|
tests/eo/suite/eo_test_class_simple.h \
|
||||||
tests/eo/suite/eo_test_class_singleton.c \
|
tests/eo/suite/eo_test_class_singleton.c \
|
||||||
tests/eo/suite/eo_test_class_singleton.h \
|
tests/eo/suite/eo_test_class_singleton.h \
|
||||||
|
tests/eo/suite/eo_test_domain.c \
|
||||||
|
tests/eo/suite/eo_test_domain.h \
|
||||||
tests/eo/suite/eo_suite.c \
|
tests/eo/suite/eo_suite.c \
|
||||||
tests/eo/suite/eo_suite.h \
|
tests/eo/suite/eo_suite.h \
|
||||||
tests/eo/suite/eo_error_msgs.h \
|
tests/eo/suite/eo_error_msgs.h \
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Eina.h"
|
||||||
|
#include "Eo.h"
|
||||||
|
#include "eo_test_domain.h"
|
||||||
|
|
||||||
|
#define MY_CLASS DOMAIN_CLASS
|
||||||
|
|
||||||
|
EAPI const Efl_Event_Description _EV_DOMAIN_A_CHANGED =
|
||||||
|
EFL_EVENT_DESCRIPTION("domain,a,changed");
|
||||||
|
|
||||||
|
static void
|
||||||
|
_a_set(Eo *obj EINA_UNUSED, void *class_data, int a)
|
||||||
|
{
|
||||||
|
Domain_Public_Data *pd = class_data;
|
||||||
|
printf("Set Begin\n");
|
||||||
|
pd->a = a;
|
||||||
|
sleep(1);
|
||||||
|
printf("Set End\n");
|
||||||
|
printf("Call Events\n");
|
||||||
|
efl_event_callback_legacy_call(obj, EV_DOMAIN_A_CHANGED, &pd->a);
|
||||||
|
printf("Call Events End\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_a_get(Eo *obj EINA_UNUSED, void *class_data)
|
||||||
|
{
|
||||||
|
Domain_Public_Data *pd = class_data;
|
||||||
|
printf("Get Begin\n");
|
||||||
|
return pd->a;
|
||||||
|
}
|
||||||
|
|
||||||
|
//return obj = efl_add(DOMAIN_CLASS, NULL);
|
||||||
|
|
||||||
|
EFL_VOID_FUNC_BODYV(domain_recursive, EFL_FUNC_CALL(n), int n);
|
||||||
|
|
||||||
|
static void
|
||||||
|
_recursive(Eo *obj, void *class_data EINA_UNUSED, int n)
|
||||||
|
{
|
||||||
|
static int count = 0;
|
||||||
|
|
||||||
|
if (count < n)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
domain_recursive(obj, n);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, Efl_Dbg_Info *root)
|
||||||
|
{
|
||||||
|
efl_dbg_info_get(efl_super(eo_obj, MY_CLASS), root);
|
||||||
|
Efl_Dbg_Info *group = EFL_DBG_INFO_LIST_APPEND(root, "Test list");
|
||||||
|
EFL_DBG_INFO_APPEND(group, "Test", EINA_VALUE_TYPE_INT, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
EFL_VOID_FUNC_BODYV(domain_a_set, EFL_FUNC_CALL(a), int a);
|
||||||
|
EFL_FUNC_BODY(domain_a_get, int, 0);
|
||||||
|
EFL_FUNC_BODY(domain_a_print, Eina_Bool, EINA_FALSE);
|
||||||
|
EFL_FUNC_BODY_CONST(domain_class_hi_print, Eina_Bool, EINA_FALSE);
|
||||||
|
EFL_VOID_FUNC_BODY(domain_pure_virtual);
|
||||||
|
EFL_VOID_FUNC_BODY(domain_no_implementation);
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_class_initializer(Efl_Class *klass)
|
||||||
|
{
|
||||||
|
EFL_OPS_DEFINE(ops,
|
||||||
|
EFL_OBJECT_OP_FUNC(domain_a_set, _a_set),
|
||||||
|
EFL_OBJECT_OP_FUNC(domain_a_get, _a_get),
|
||||||
|
EFL_OBJECT_OP_FUNC(domain_recursive, _recursive)
|
||||||
|
);
|
||||||
|
return efl_class_functions_set(klass, &ops);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Efl_Class_Description class_desc = {
|
||||||
|
EO_VERSION,
|
||||||
|
"Domain",
|
||||||
|
EFL_CLASS_TYPE_REGULAR,
|
||||||
|
sizeof(Domain_Public_Data),
|
||||||
|
_class_initializer,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
EFL_DEFINE_CLASS(domain_class_get, &class_desc, EO_CLASS, NULL)
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef DOMAIN_H
|
||||||
|
#define DOMAIN_H
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int a;
|
||||||
|
} Domain_Public_Data;
|
||||||
|
|
||||||
|
EAPI void domain_a_set(Eo *obj, int a);
|
||||||
|
EAPI int domain_a_get(Eo *obj);
|
||||||
|
EAPI void domain_recursive(Eo *obj, int n);
|
||||||
|
|
||||||
|
extern const Efl_Event_Description _EV_DOMAIN_A_CHANGED;
|
||||||
|
#define EV_DOMAIN_A_CHANGED (&(_EV_DOMAIN_A_CHANGED))
|
||||||
|
|
||||||
|
#define DOMAIN_CLASS domain_class_get()
|
||||||
|
const Efl_Class *domain_class_get(void);
|
||||||
|
|
||||||
|
#endif
|
|
@ -9,6 +9,7 @@
|
||||||
#include "eo_suite.h"
|
#include "eo_suite.h"
|
||||||
#include "eo_test_class_simple.h"
|
#include "eo_test_class_simple.h"
|
||||||
#include "eo_test_class_singleton.h"
|
#include "eo_test_class_singleton.h"
|
||||||
|
#include "eo_test_domain.h"
|
||||||
|
|
||||||
/* Loading this internal header for testing purposes. */
|
/* Loading this internal header for testing purposes. */
|
||||||
#include "eo_ptr_indirection.h"
|
#include "eo_ptr_indirection.h"
|
||||||
|
@ -1354,6 +1355,71 @@ START_TEST(eo_rec_interface)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(eo_domain)
|
||||||
|
{
|
||||||
|
Eo *obj, *objs;
|
||||||
|
|
||||||
|
printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
|
||||||
|
efl_object_init();
|
||||||
|
|
||||||
|
fail_if(efl_domain_get() != EFL_ID_DOMAIN_MAIN);
|
||||||
|
|
||||||
|
fail_if(efl_domain_switch(EFL_ID_DOMAIN_THREAD) != EINA_TRUE);
|
||||||
|
|
||||||
|
fail_if(efl_domain_get() != EFL_ID_DOMAIN_THREAD);
|
||||||
|
|
||||||
|
fail_if(efl_domain_switch(EFL_ID_DOMAIN_MAIN) != EINA_TRUE);
|
||||||
|
|
||||||
|
fail_if(efl_domain_get() != EFL_ID_DOMAIN_MAIN);
|
||||||
|
|
||||||
|
fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_MAIN);
|
||||||
|
|
||||||
|
fail_if(efl_domain_current_set(EFL_ID_DOMAIN_SHARED) != EINA_TRUE);
|
||||||
|
|
||||||
|
fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_SHARED);
|
||||||
|
|
||||||
|
fail_if(efl_domain_current_set(EFL_ID_DOMAIN_MAIN) != EINA_TRUE);
|
||||||
|
|
||||||
|
fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_MAIN);
|
||||||
|
|
||||||
|
fail_if(efl_domain_current_push(EFL_ID_DOMAIN_SHARED) != EINA_TRUE);
|
||||||
|
|
||||||
|
fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_SHARED);
|
||||||
|
|
||||||
|
fail_if(efl_domain_current_push(EFL_ID_DOMAIN_THREAD) != EINA_TRUE);
|
||||||
|
|
||||||
|
fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_THREAD);
|
||||||
|
|
||||||
|
efl_domain_current_pop();
|
||||||
|
|
||||||
|
fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_SHARED);
|
||||||
|
|
||||||
|
efl_domain_current_pop();
|
||||||
|
|
||||||
|
fail_if(efl_domain_current_get() != EFL_ID_DOMAIN_MAIN);
|
||||||
|
|
||||||
|
objs = efl_add(DOMAIN_CLASS, NULL);
|
||||||
|
|
||||||
|
efl_domain_current_push(EFL_ID_DOMAIN_SHARED);
|
||||||
|
obj = efl_add(DOMAIN_CLASS, NULL);
|
||||||
|
efl_domain_current_pop();
|
||||||
|
|
||||||
|
fail_if(efl_compatible(objs, obj) == EINA_TRUE);
|
||||||
|
|
||||||
|
domain_a_set(obj, 1234);
|
||||||
|
fail_if(domain_a_get(obj) != 1234);
|
||||||
|
|
||||||
|
domain_a_set(objs, 1234);
|
||||||
|
fail_if(domain_a_get(objs) != 1234);
|
||||||
|
|
||||||
|
efl_del(obj);
|
||||||
|
efl_del(objs);
|
||||||
|
|
||||||
|
efl_object_shutdown();
|
||||||
|
printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
void eo_test_general(TCase *tc)
|
void eo_test_general(TCase *tc)
|
||||||
{
|
{
|
||||||
tcase_add_test(tc, eo_simple);
|
tcase_add_test(tc, eo_simple);
|
||||||
|
@ -1376,4 +1442,5 @@ void eo_test_general(TCase *tc)
|
||||||
tcase_add_test(tc, efl_name);
|
tcase_add_test(tc, efl_name);
|
||||||
tcase_add_test(tc, eo_comment);
|
tcase_add_test(tc, eo_comment);
|
||||||
tcase_add_test(tc, eo_rec_interface);
|
tcase_add_test(tc, eo_rec_interface);
|
||||||
|
tcase_add_test(tc, eo_domain);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue