forked from enlightenment/efl
eo2: migrated the eo-suite test to eo2.
This commit is contained in:
parent
ff64050a7b
commit
08b28211b6
|
@ -78,109 +78,6 @@ _eo_test_safety_print_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const c
|
|||
ctx.did = EINA_FALSE; \
|
||||
ctx.expected_level = EINA_LOG_LEVEL_ERR
|
||||
|
||||
START_TEST(eo_incomplete_desc)
|
||||
{
|
||||
eo_init();
|
||||
eina_log_print_cb_set(_eo_test_print_cb, &ctx);
|
||||
|
||||
const Eo_Class *klass;
|
||||
static Eo_Op TMP_BASE_ID = EO_NOOP;
|
||||
|
||||
enum {
|
||||
TEST_SUB_ID_FOO,
|
||||
TEST_SUB_ID_FOO2,
|
||||
TEST_SUB_ID_LAST
|
||||
};
|
||||
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION(TEST_SUB_ID_FOO, "Foo"),
|
||||
EO_OP_DESCRIPTION(TEST_SUB_ID_FOO2, "Foo2"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eo_Op_Description op_desc_wrong[] = {
|
||||
EO_OP_DESCRIPTION(TEST_SUB_ID_FOO2, "Foo2"),
|
||||
EO_OP_DESCRIPTION(TEST_SUB_ID_FOO, "Foo"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
/* XXX: In real life this should be const, this is just for testing. */
|
||||
static Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, op_desc, 1),
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
TEST_EO_ERROR("_eo_class_check_op_descs", "Class '%s' has a non-zero ops count, but base_id is NULL.");
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
fail_unless(ctx.did);
|
||||
|
||||
class_desc.ops.base_op_id = &TMP_BASE_ID;
|
||||
class_desc.ops.descs = NULL;
|
||||
|
||||
TEST_EO_ERROR("_eo_class_check_op_descs", "Class '%s' has a non-zero ops count, but there are no descs.");
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
fail_unless(ctx.did);
|
||||
|
||||
class_desc.ops.descs = op_desc;
|
||||
class_desc.ops.count = TEST_SUB_ID_LAST + 1;
|
||||
|
||||
TEST_EO_ERROR("_eo_class_check_op_descs", "Found too few Ops description for class '%s'. Expected 0x%lx descriptions, but found 0x%lx.");
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
fail_unless(ctx.did);
|
||||
|
||||
class_desc.ops.count = 0;
|
||||
|
||||
TEST_EO_ERROR("_eo_class_check_op_descs", "Found extra Ops description for class '%s'. Expected %lu descriptions, but found more.");
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
fail_unless(ctx.did);
|
||||
|
||||
class_desc.ops.count = TEST_SUB_ID_LAST;
|
||||
class_desc.ops.descs = op_desc_wrong;
|
||||
|
||||
TEST_EO_ERROR("_eo_class_check_op_descs", "Wrong order in Ops description for class '%s'. Expected 0x%lx and got 0x%lx");
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
fail_unless(ctx.did);
|
||||
|
||||
class_desc.ops.descs = op_desc;
|
||||
class_desc.name = NULL;
|
||||
|
||||
eina_log_print_cb_set(_eo_test_safety_print_cb, &ctx);
|
||||
|
||||
TEST_EO_ERROR("eo_class_new", "safety check failed: desc->name == NULL");
|
||||
klass = eo_class_new(&class_desc, NULL, NULL);
|
||||
fail_if(klass);
|
||||
fail_unless(ctx.did);
|
||||
|
||||
class_desc.name = "Simple";
|
||||
|
||||
|
||||
TEST_EO_ERROR("eo_class_new", "safety check failed: desc == NULL");
|
||||
klass = eo_class_new(NULL, NULL, NULL);
|
||||
fail_if(klass);
|
||||
fail_unless(ctx.did);
|
||||
|
||||
/* Should create a class. */
|
||||
klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
(void) klass;
|
||||
eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eo_inherit_errors)
|
||||
{
|
||||
eo_init();
|
||||
|
@ -191,7 +88,7 @@ START_TEST(eo_inherit_errors)
|
|||
const Eo_Class *klass_simple;
|
||||
|
||||
static const Eo_Class_Description class_desc_simple = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -202,7 +99,7 @@ START_TEST(eo_inherit_errors)
|
|||
};
|
||||
|
||||
static const Eo_Class_Description class_desc_mixin = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Mixin",
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -213,7 +110,7 @@ START_TEST(eo_inherit_errors)
|
|||
};
|
||||
|
||||
static Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"General",
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -226,7 +123,7 @@ START_TEST(eo_inherit_errors)
|
|||
klass_mixin = eo_class_new(&class_desc_mixin, NULL, NULL);
|
||||
fail_if(!klass_mixin);
|
||||
|
||||
klass_simple = eo_class_new(&class_desc_simple, EO_BASE_CLASS, NULL);
|
||||
klass_simple = eo_class_new(&class_desc_simple, EO2_BASE_CLASS, NULL);
|
||||
fail_if(!klass_simple);
|
||||
|
||||
TEST_EO_ERROR("eo_class_new", "Non-regular classes ('%s') aren't allowed to inherit from regular classes ('%s').");
|
||||
|
@ -259,7 +156,7 @@ START_TEST(eo_inconsistent_mro)
|
|||
const Eo_Class *klass_mixin3;
|
||||
|
||||
static const Eo_Class_Description class_desc_simple = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -270,7 +167,7 @@ START_TEST(eo_inconsistent_mro)
|
|||
};
|
||||
|
||||
static const Eo_Class_Description class_desc_mixin = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Mixin",
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -281,7 +178,7 @@ START_TEST(eo_inconsistent_mro)
|
|||
};
|
||||
|
||||
static const Eo_Class_Description class_desc_mixin2 = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Mixin2",
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -292,7 +189,7 @@ START_TEST(eo_inconsistent_mro)
|
|||
};
|
||||
|
||||
static const Eo_Class_Description class_desc_mixin3 = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Mixin3",
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -312,14 +209,14 @@ START_TEST(eo_inconsistent_mro)
|
|||
fail_if(!klass_mixin3);
|
||||
|
||||
TEST_EO_ERROR("_eo_class_mro_init", "Cannot create a consistent method resolution order for class '%s' because of '%s'.");
|
||||
klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin, klass_mixin2, NULL);
|
||||
klass = eo_class_new(&class_desc_simple, EO2_BASE_CLASS, klass_mixin, klass_mixin2, NULL);
|
||||
fail_if(klass);
|
||||
fail_unless(ctx.did);
|
||||
|
||||
klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin, NULL);
|
||||
klass = eo_class_new(&class_desc_simple, EO2_BASE_CLASS, klass_mixin2, klass_mixin, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin3, NULL);
|
||||
klass = eo_class_new(&class_desc_simple, EO2_BASE_CLASS, klass_mixin2, klass_mixin3, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
|
||||
|
@ -338,7 +235,7 @@ START_TEST(eo_bad_interface)
|
|||
const Eo_Class *klass;
|
||||
|
||||
static Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Interface",
|
||||
EO_CLASS_TYPE_INTERFACE,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -376,89 +273,9 @@ START_TEST(eo_bad_interface)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
static int _const_ops_counter = 0;
|
||||
|
||||
static void
|
||||
_const_ops_a_set(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list)
|
||||
{
|
||||
int a = va_arg(*list, int);
|
||||
(void) a;
|
||||
_const_ops_counter++;
|
||||
}
|
||||
|
||||
static void
|
||||
_const_ops_a_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
{
|
||||
_const_ops_counter++;
|
||||
}
|
||||
|
||||
static void
|
||||
_const_ops_class_hi_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
{
|
||||
_const_ops_counter++;
|
||||
}
|
||||
|
||||
static void
|
||||
_const_ops_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _const_ops_a_set),
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _const_ops_a_print),
|
||||
EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _const_ops_a_set),
|
||||
EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _const_ops_a_print),
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT), _const_ops_class_hi_print),
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT), _const_ops_class_hi_print),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
START_TEST(eo_op_types)
|
||||
{
|
||||
eo_init();
|
||||
eina_log_print_cb_set(_eo_test_print_cb, &ctx);
|
||||
|
||||
const Eo_Class *klass;
|
||||
|
||||
static Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
_const_ops_class_constructor,
|
||||
NULL
|
||||
};
|
||||
|
||||
TEST_EO_ERROR("eo_class_funcs_set", "Set function's op type (0x%x) is different than the one in the op description (%d) for op '%s:%s'. Func index: %lu");
|
||||
klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
TEST_EO_ERROR("eo_class_name_get", NULL);
|
||||
#ifdef HAVE_EO_ID
|
||||
ctx.expected_level = EINA_LOG_LEVEL_ERR;
|
||||
#else
|
||||
ctx.expected_level = EINA_LOG_LEVEL_CRITICAL;
|
||||
#endif
|
||||
/* Add class checks here... */
|
||||
Eo *obj = eo_add(klass, NULL);
|
||||
eo_do(obj, simple_a_set(7), simple_a_print(), simple_class_hi_print());
|
||||
|
||||
eo_unref(obj);
|
||||
|
||||
eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void eo_test_class_errors(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eo_incomplete_desc);
|
||||
tcase_add_test(tc, eo_inherit_errors);
|
||||
tcase_add_test(tc, eo_inconsistent_mro);
|
||||
tcase_add_test(tc, eo_bad_interface);
|
||||
tcase_add_test(tc, eo_op_types);
|
||||
}
|
||||
|
|
|
@ -7,78 +7,76 @@
|
|||
|
||||
#define MY_CLASS SIMPLE_CLASS
|
||||
|
||||
EAPI Eo_Op SIMPLE_BASE_ID = 0;
|
||||
|
||||
EAPI const Eo_Event_Description _EV_A_CHANGED =
|
||||
EO_EVENT_DESCRIPTION("a,changed", "Called when a has changed.");
|
||||
|
||||
static void
|
||||
_a_set(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
_a_set(Eo *obj EINA_UNUSED, void *class_data, int a)
|
||||
{
|
||||
Simple_Public_Data *pd = class_data;
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
printf("%s %d\n", eo_class_name_get(MY_CLASS), a);
|
||||
pd->a = a;
|
||||
|
||||
eo_do(obj, eo_event_callback_call(EV_A_CHANGED, &pd->a, NULL));
|
||||
eo2_do(obj, eo2_event_callback_call(EV_A_CHANGED, &pd->a));
|
||||
}
|
||||
|
||||
static void
|
||||
_a_print(Eo *obj EINA_UNUSED, void *class_data, va_list *list)
|
||||
static int
|
||||
_a_get(Eo *obj EINA_UNUSED, void *class_data)
|
||||
{
|
||||
Simple_Public_Data *pd = class_data;
|
||||
|
||||
return pd->a;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_a_print(Eo *obj EINA_UNUSED, void *class_data)
|
||||
{
|
||||
const Simple_Public_Data *pd = class_data;
|
||||
(void) list;
|
||||
printf("Print %s %d\n", eo_class_name_get(MY_CLASS), pd->a);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_class_hi_print(Eo_Class *klass, void *data EINA_UNUSED, va_list *list)
|
||||
static Eina_Bool
|
||||
_class_hi_print(Eo_Class *klass, void *data EINA_UNUSED)
|
||||
{
|
||||
(void) list;
|
||||
printf("Hi Print %s\n", eo_class_name_get(klass));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, va_list *list)
|
||||
_dbg_info_get(Eo *eo_obj, void *_pd EINA_UNUSED, Eo_Dbg_Info *root)
|
||||
{
|
||||
Eo_Dbg_Info *root = (Eo_Dbg_Info *) va_arg(*list, Eo_Dbg_Info *);
|
||||
eo_do_super(eo_obj, MY_CLASS, eo_dbg_info_get(root));
|
||||
eo2_do_super(eo_obj, MY_CLASS, eo2_dbg_info_get(root));
|
||||
Eo_Dbg_Info *group = EO_DBG_INFO_LIST_APPEND(root, "Test list");
|
||||
EO_DBG_INFO_APPEND(group, "Test", EINA_VALUE_TYPE_INT, 8);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DBG_INFO_GET), _dbg_info_get),
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _a_print),
|
||||
EO_OP_FUNC_CLASS(SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT), _class_hi_print),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
EO2_VOID_FUNC_BODYV(simple_a_set, EO2_FUNC_CALL(a), int a);
|
||||
EO2_FUNC_BODY(simple_a_get, int, 0);
|
||||
EO2_FUNC_BODY(simple_a_print, Eina_Bool, EINA_FALSE);
|
||||
EO2_FUNC_BODY(simple_class_hi_print, Eina_Bool, EINA_FALSE);
|
||||
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eo_Op_Description op_desc[] = {
|
||||
EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
|
||||
EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_PRINT, "Print property A"),
|
||||
EO_OP_DESCRIPTION_CLASS(SIMPLE_SUB_ID_CLASS_HI_PRINT, "Print Hi"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
static Eo2_Op_Description op_descs[] = {
|
||||
EO2_OP_FUNC_OVERRIDE(_dbg_info_get, eo2_dbg_info_get),
|
||||
EO2_OP_FUNC(_a_set, simple_a_set, "Set property a"),
|
||||
EO2_OP_FUNC(_a_get, simple_a_get, "Get property a"),
|
||||
EO2_OP_FUNC(_a_print, simple_a_print, "Print property a"),
|
||||
EO2_OP_CLASS_FUNC(_class_hi_print, simple_class_hi_print, "Print property a"),
|
||||
EO2_OP_SENTINEL
|
||||
};
|
||||
|
||||
static const Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
EO2_CLASS_DESCRIPTION_OPS(op_descs),
|
||||
NULL,
|
||||
sizeof(Simple_Public_Data),
|
||||
_class_constructor,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL)
|
||||
EO_DEFINE_CLASS(simple_class_get, &class_desc, EO2_BASE_CLASS, NULL)
|
||||
|
||||
|
|
|
@ -1,25 +1,15 @@
|
|||
#ifndef SIMPLE_H
|
||||
#define SIMPLE_H
|
||||
|
||||
extern EAPI Eo_Op SIMPLE_BASE_ID;
|
||||
|
||||
enum {
|
||||
SIMPLE_SUB_ID_A_SET,
|
||||
SIMPLE_SUB_ID_A_PRINT,
|
||||
SIMPLE_SUB_ID_CLASS_HI_PRINT,
|
||||
SIMPLE_SUB_ID_LAST
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int a;
|
||||
} Simple_Public_Data;
|
||||
|
||||
#define SIMPLE_ID(sub_id) (SIMPLE_BASE_ID + sub_id)
|
||||
|
||||
#define simple_a_set(a) SIMPLE_ID(SIMPLE_SUB_ID_A_SET), EO_TYPECHECK(int, a)
|
||||
#define simple_a_print() SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT)
|
||||
#define simple_class_hi_print() SIMPLE_ID(SIMPLE_SUB_ID_CLASS_HI_PRINT)
|
||||
EAPI void simple_a_set(int a);
|
||||
EAPI int simple_a_get(void);
|
||||
EAPI Eina_Bool simple_a_print(void);
|
||||
EAPI Eina_Bool simple_class_hi_print(void);
|
||||
|
||||
extern const Eo_Event_Description _EV_A_CHANGED;
|
||||
#define EV_A_CHANGED (&(_EV_A_CHANGED))
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
START_TEST(eo_simple)
|
||||
{
|
||||
eo_init();
|
||||
Eo *obj = eo_add(EO_BASE_CLASS, NULL);
|
||||
Eo *obj = eo2_add(EO2_BASE_CLASS, NULL);
|
||||
fail_if(obj);
|
||||
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
fail_if(!obj);
|
||||
eo_do(obj, eo_constructor());
|
||||
eo_do(obj, eo_destructor());
|
||||
eo2_do(obj, eo2_constructor());
|
||||
eo2_do(obj, eo2_destructor());
|
||||
eo_unref(obj);
|
||||
|
||||
eo_shutdown();
|
||||
|
@ -80,23 +80,23 @@ START_TEST(eo_signals)
|
|||
{ EO_EV_DEL, _eo_signals_eo_del_cb },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
|
||||
eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _eo_signals_cb_added_deled, callbacks));
|
||||
eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_DEL, _eo_signals_cb_added_deled, callbacks));
|
||||
eo_do(obj, eo_event_callback_array_priority_add(callbacks, -100, (void *) 1));
|
||||
eo_do(obj, eo_event_callback_array_add(callbacks, (void *) 3));
|
||||
eo_do(obj, eo_event_callback_array_priority_add(callbacks, -50, (void *) 2));
|
||||
fail_if(!eo_do(obj, simple_a_set(1)));
|
||||
eo2_do(obj, eo2_event_callback_add(EO_EV_CALLBACK_ADD, _eo_signals_cb_added_deled, callbacks));
|
||||
eo2_do(obj, eo2_event_callback_add(EO_EV_CALLBACK_DEL, _eo_signals_cb_added_deled, callbacks));
|
||||
eo2_do(obj, eo2_event_callback_array_priority_add(callbacks, -100, (void *) 1));
|
||||
eo2_do(obj, eo2_event_callback_array_add(callbacks, (void *) 3));
|
||||
eo2_do(obj, eo2_event_callback_array_priority_add(callbacks, -50, (void *) 2));
|
||||
eo2_do(obj, simple_a_set(1));
|
||||
ck_assert_int_eq(_eo_signals_cb_flag, 0x3);
|
||||
|
||||
eo_do(obj, eo_event_callback_array_del(callbacks, (void *) 1));
|
||||
eo_do(obj, eo_event_callback_array_del(callbacks, (void *) 2));
|
||||
eo_do(obj, eo_event_callback_array_del(callbacks, (void *) 3));
|
||||
eo2_do(obj, eo2_event_callback_array_del(callbacks, (void *) 1));
|
||||
eo2_do(obj, eo2_event_callback_array_del(callbacks, (void *) 2));
|
||||
eo2_do(obj, eo2_event_callback_array_del(callbacks, (void *) 3));
|
||||
/* Try to delete something that doesn't exist. */
|
||||
eo_do(obj, eo_event_callback_array_del(callbacks, (void *) 4));
|
||||
eo2_do(obj, eo2_event_callback_array_del(callbacks, (void *) 4));
|
||||
_eo_signals_cb_flag = 0;
|
||||
fail_if(!eo_do(obj, simple_a_set(1)));
|
||||
eo2_do(obj, simple_a_set(1));
|
||||
ck_assert_int_eq(_eo_signals_cb_flag, 0x0);
|
||||
|
||||
eo_unref(obj);
|
||||
|
@ -111,7 +111,7 @@ START_TEST(eo_data_fetch)
|
|||
|
||||
/* Usually should be const, not const only for the test... */
|
||||
static Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Simple2",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -121,10 +121,10 @@ START_TEST(eo_data_fetch)
|
|||
NULL
|
||||
};
|
||||
|
||||
const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
|
||||
const Eo_Class *klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
Eo *obj = eo_add(klass, NULL);
|
||||
Eo *obj = eo2_add(klass, NULL);
|
||||
fail_if(!obj);
|
||||
#ifdef EO_DEBUG
|
||||
fail_if(eo_data_scope_get(obj, SIMPLE_CLASS));
|
||||
|
@ -132,10 +132,10 @@ START_TEST(eo_data_fetch)
|
|||
eo_unref(obj);
|
||||
|
||||
class_desc.data_size = 0;
|
||||
klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
|
||||
klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
obj = eo_add(klass, NULL);
|
||||
obj = eo2_add(klass, NULL);
|
||||
fail_if(!obj);
|
||||
fail_if(eo_data_scope_get(obj, klass));
|
||||
eo_unref(obj);
|
||||
|
@ -153,7 +153,7 @@ START_TEST(eo_isa_tests)
|
|||
{
|
||||
/* Usually should be const, not const only for the test... */
|
||||
static Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Iface",
|
||||
EO_CLASS_TYPE_INTERFACE,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -170,7 +170,7 @@ START_TEST(eo_isa_tests)
|
|||
{
|
||||
/* Usually should be const, not const only for the test... */
|
||||
static Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Mixin",
|
||||
EO_CLASS_TYPE_MIXIN,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -187,7 +187,7 @@ START_TEST(eo_isa_tests)
|
|||
{
|
||||
/* Usually should be const, not const only for the test... */
|
||||
static Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Simple2",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -197,26 +197,26 @@ START_TEST(eo_isa_tests)
|
|||
NULL
|
||||
};
|
||||
|
||||
klass = eo_class_new(&class_desc, EO_BASE_CLASS, iface, mixin, NULL);
|
||||
klass = eo_class_new(&class_desc, EO2_BASE_CLASS, iface, mixin, NULL);
|
||||
fail_if(!klass);
|
||||
}
|
||||
|
||||
Eo *obj = eo_add(klass, NULL);
|
||||
Eo *obj = eo2_add(klass, NULL);
|
||||
fail_if(!obj);
|
||||
fail_if(eo_isa(obj, SIMPLE_CLASS));
|
||||
fail_if(!eo_isa(obj, iface));
|
||||
fail_if(!eo_isa(obj, mixin));
|
||||
fail_if(!eo_isa(obj, klass));
|
||||
fail_if(!eo_isa(obj, EO_BASE_CLASS));
|
||||
fail_if(!eo_isa(obj, EO2_BASE_CLASS));
|
||||
eo_unref(obj);
|
||||
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
fail_if(!obj);
|
||||
fail_if(eo_isa(obj, klass));
|
||||
fail_if(eo_isa(obj, iface));
|
||||
fail_if(eo_isa(obj, mixin));
|
||||
fail_if(!eo_isa(obj, SIMPLE_CLASS));
|
||||
fail_if(!eo_isa(obj, EO_BASE_CLASS));
|
||||
fail_if(!eo_isa(obj, EO2_BASE_CLASS));
|
||||
eo_unref(obj);
|
||||
|
||||
eo_shutdown();
|
||||
|
@ -228,13 +228,13 @@ START_TEST(eo_composite_tests)
|
|||
{
|
||||
eo_init();
|
||||
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
fail_if(!obj);
|
||||
Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj2 = eo2_add(SIMPLE_CLASS, NULL);
|
||||
fail_if(!obj2);
|
||||
|
||||
eo_composite_attach(obj2, obj);
|
||||
eo_do(obj2, eo_parent_set(NULL));
|
||||
eo2_do(obj2, eo2_parent_set(NULL));
|
||||
fail_if(eo_composite_is(obj2));
|
||||
|
||||
eo_unref(obj2);
|
||||
|
@ -253,30 +253,22 @@ _man_con(Eo *obj, void *data EINA_UNUSED, va_list *list EINA_UNUSED)
|
|||
{
|
||||
if (_man_should_con)
|
||||
eo_manual_free_set(obj, EINA_TRUE);
|
||||
eo_do_super(obj, cur_klass, eo_constructor());
|
||||
eo2_do_super(obj, cur_klass, eo2_constructor());
|
||||
}
|
||||
|
||||
static void
|
||||
_man_des(Eo *obj, void *data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
{
|
||||
eo_do_super(obj, cur_klass, eo_destructor());
|
||||
eo2_do_super(obj, cur_klass, eo2_destructor());
|
||||
if (_man_should_des)
|
||||
eo_manual_free_set(obj, EINA_FALSE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_man_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _man_con),
|
||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _man_des),
|
||||
EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _man_des),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
static Eo2_Op_Description op_descs[] = {
|
||||
EO2_OP_FUNC_OVERRIDE(_man_con, eo2_constructor),
|
||||
EO2_OP_FUNC_OVERRIDE(_man_des, eo2_destructor),
|
||||
EO2_OP_SENTINEL
|
||||
};
|
||||
|
||||
START_TEST(eo_man_free)
|
||||
{
|
||||
|
@ -284,35 +276,35 @@ START_TEST(eo_man_free)
|
|||
|
||||
/* Usually should be const, not const only for the test... */
|
||||
static Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Simple2",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
EO2_CLASS_DESCRIPTION_OPS(op_descs),
|
||||
NULL,
|
||||
10,
|
||||
_man_class_constructor,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
|
||||
const Eo_Class *klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL);
|
||||
fail_if(!klass);
|
||||
cur_klass = klass;
|
||||
|
||||
Eo *obj = eo_add(klass, NULL);
|
||||
Eo *obj = eo2_add(klass, NULL);
|
||||
fail_if(!obj);
|
||||
eo_unref(obj);
|
||||
|
||||
obj = eo_add(klass, NULL);
|
||||
obj = eo2_add(klass, NULL);
|
||||
fail_if(!obj);
|
||||
fail_if(eo_manual_free(obj));
|
||||
eo_unref(obj);
|
||||
|
||||
_man_should_des = EINA_FALSE;
|
||||
klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
|
||||
klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL);
|
||||
cur_klass = klass;
|
||||
fail_if(!klass);
|
||||
|
||||
obj = eo_add(klass, NULL);
|
||||
obj = eo2_add(klass, NULL);
|
||||
fail_if(!obj);
|
||||
fail_if(eo_manual_free(obj));
|
||||
fail_if(eo_destructed_is(obj));
|
||||
|
@ -320,23 +312,23 @@ START_TEST(eo_man_free)
|
|||
fail_if(!eo_destructed_is(obj));
|
||||
fail_if(!eo_manual_free(obj));
|
||||
|
||||
obj = eo_add(klass, NULL);
|
||||
obj = eo2_add(klass, NULL);
|
||||
fail_if(!obj);
|
||||
eo_unref(obj);
|
||||
fail_if(!eo_destructed_is(obj));
|
||||
fail_if(!eo_manual_free(obj));
|
||||
|
||||
_man_should_con = EINA_FALSE;
|
||||
klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
|
||||
klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL);
|
||||
cur_klass = klass;
|
||||
fail_if(!klass);
|
||||
|
||||
obj = eo_add(klass, NULL);
|
||||
obj = eo2_add(klass, NULL);
|
||||
fail_if(!obj);
|
||||
fail_if(eo_manual_free(obj));
|
||||
eo_unref(obj);
|
||||
|
||||
obj = eo_add(klass, NULL);
|
||||
obj = eo2_add(klass, NULL);
|
||||
fail_if(!obj);
|
||||
eo_manual_free_set(obj, EINA_TRUE);
|
||||
eo_unref(obj);
|
||||
|
@ -345,7 +337,7 @@ START_TEST(eo_man_free)
|
|||
eo_unref(obj);
|
||||
fail_if(!eo_manual_free(obj));
|
||||
|
||||
obj = eo_add(klass, NULL);
|
||||
obj = eo2_add(klass, NULL);
|
||||
fail_if(!obj);
|
||||
eo_manual_free_set(obj, EINA_TRUE);
|
||||
eo_unref(obj);
|
||||
|
@ -363,9 +355,9 @@ END_TEST
|
|||
START_TEST(eo_refs)
|
||||
{
|
||||
eo_init();
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj3 = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj2 = eo2_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj3 = eo2_add(SIMPLE_CLASS, NULL);
|
||||
|
||||
eo_xref(obj, obj2);
|
||||
fail_if(eo_ref_get(obj) != 2);
|
||||
|
@ -400,11 +392,11 @@ START_TEST(eo_refs)
|
|||
eo_unref(obj3);
|
||||
|
||||
/* Check hierarchy */
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
obj2 = eo_add(SIMPLE_CLASS, obj);
|
||||
obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
obj2 = eo2_add(SIMPLE_CLASS, obj);
|
||||
|
||||
Eo *wref;
|
||||
eo_do(obj2, eo_wref_add(&wref));
|
||||
eo2_do(obj2, eo2_wref_add(&wref));
|
||||
fail_if(!wref);
|
||||
|
||||
eo_unref(obj2);
|
||||
|
@ -416,13 +408,13 @@ START_TEST(eo_refs)
|
|||
fail_if(wref);
|
||||
|
||||
/* Just check it doesn't seg atm. */
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
eo_ref(obj);
|
||||
eo_unref(obj);
|
||||
eo_unref(obj);
|
||||
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
obj2 = eo_add(SIMPLE_CLASS, obj);
|
||||
obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
obj2 = eo2_add(SIMPLE_CLASS, obj);
|
||||
eo_unref(obj2);
|
||||
eo_ref(obj2);
|
||||
eo_del(obj2);
|
||||
|
@ -436,17 +428,17 @@ START_TEST(eo_weak_reference)
|
|||
{
|
||||
eo_init();
|
||||
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj2 = eo2_add(SIMPLE_CLASS, NULL);
|
||||
Eo *wref, *wref2, *wref3;
|
||||
eo_do(obj, eo_wref_add(&wref));
|
||||
eo2_do(obj, eo2_wref_add(&wref));
|
||||
fail_if(!wref);
|
||||
|
||||
eo_unref(obj);
|
||||
fail_if(wref);
|
||||
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
eo_do(obj, eo_wref_add(&wref));
|
||||
obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
eo2_do(obj, eo2_wref_add(&wref));
|
||||
|
||||
eo_ref(obj);
|
||||
fail_if(!wref);
|
||||
|
@ -457,37 +449,37 @@ START_TEST(eo_weak_reference)
|
|||
eo_unref(obj);
|
||||
fail_if(wref);
|
||||
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
|
||||
eo_do(obj, eo_wref_add(&wref));
|
||||
eo_do(obj, eo_wref_del(&wref));
|
||||
eo2_do(obj, eo2_wref_add(&wref));
|
||||
eo2_do(obj, eo2_wref_del(&wref));
|
||||
fail_if(wref);
|
||||
|
||||
eo_do(obj, eo_wref_add(&wref));
|
||||
eo_do(obj2, eo_wref_del(&wref));
|
||||
eo2_do(obj, eo2_wref_add(&wref));
|
||||
eo2_do(obj2, eo2_wref_del(&wref));
|
||||
fail_if(!wref);
|
||||
eo_wref_del_safe(&wref);
|
||||
eo2_wref_del_safe(&wref);
|
||||
fail_if(wref);
|
||||
|
||||
wref = obj;
|
||||
eo_do(obj, eo_wref_del(&wref));
|
||||
eo2_do(obj, eo2_wref_del(&wref));
|
||||
fail_if(wref);
|
||||
|
||||
wref = wref2 = wref3 = NULL;
|
||||
eo_do(obj, eo_wref_add(&wref), eo_wref_add(&wref2), eo_wref_add(&wref3));
|
||||
eo2_do(obj, eo2_wref_add(&wref), eo2_wref_add(&wref2), eo2_wref_add(&wref3));
|
||||
fail_if(!wref);
|
||||
fail_if(!wref2);
|
||||
fail_if(!wref3);
|
||||
eo_do(obj, eo_wref_del(&wref), eo_wref_del(&wref2), eo_wref_del(&wref3));
|
||||
eo2_do(obj, eo2_wref_del(&wref), eo2_wref_del(&wref2), eo2_wref_del(&wref3));
|
||||
fail_if(wref);
|
||||
fail_if(wref2);
|
||||
fail_if(wref3);
|
||||
|
||||
eo_do(obj, eo_wref_add(&wref2), eo_wref_add(&wref3));
|
||||
eo2_do(obj, eo2_wref_add(&wref2), eo2_wref_add(&wref3));
|
||||
wref = obj;
|
||||
eo_do(obj, eo_wref_del(&wref));
|
||||
eo2_do(obj, eo2_wref_del(&wref));
|
||||
fail_if(wref);
|
||||
eo_do(obj, eo_wref_del(&wref2), eo_wref_del(&wref3));
|
||||
eo2_do(obj, eo2_wref_del(&wref2), eo2_wref_del(&wref3));
|
||||
|
||||
eo_unref(obj);
|
||||
eo_unref(obj2);
|
||||
|
@ -497,77 +489,6 @@ START_TEST(eo_weak_reference)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
static void
|
||||
_a_set(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
{
|
||||
fail_if(EINA_TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
_op_errors_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_LAST), _a_set),
|
||||
EO_OP_FUNC(SIMPLE_ID(SIMPLE_SUB_ID_LAST + 1), _a_set),
|
||||
EO_OP_FUNC(0x0F010111, _a_set),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
START_TEST(eo_op_errors)
|
||||
{
|
||||
eo_init();
|
||||
|
||||
static const Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
NULL,
|
||||
0,
|
||||
_op_errors_class_constructor,
|
||||
NULL
|
||||
};
|
||||
|
||||
const Eo_Class *klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
Eo *obj = eo_add(klass, NULL);
|
||||
|
||||
/* Out of bounds op for a legal class. */
|
||||
fail_if(eo_do(obj, EO_BASE_ID(0x0111)));
|
||||
|
||||
/* Ilegal class. */
|
||||
fail_if(eo_do(obj, 0x0F010111));
|
||||
|
||||
fail_if(eo_ref_get(obj) != 1);
|
||||
|
||||
eo_ref(obj);
|
||||
fail_if(eo_ref_get(obj) != 2);
|
||||
|
||||
eo_ref(obj);
|
||||
fail_if(eo_ref_get(obj) != 3);
|
||||
|
||||
eo_unref(obj);
|
||||
fail_if(eo_ref_get(obj) != 2);
|
||||
|
||||
eo_unref(obj);
|
||||
fail_if(eo_ref_get(obj) != 1);
|
||||
|
||||
eo_unref(obj);
|
||||
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
fail_if(!eo_do(obj, simple_a_print()));
|
||||
fail_if(!eo_do(obj, simple_a_print()));
|
||||
fail_if(!eo_do(obj, simple_a_set(1)));
|
||||
eo_unref(obj);
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
static void
|
||||
_fake_free_func(void *data)
|
||||
{
|
||||
|
@ -581,59 +502,59 @@ _fake_free_func(void *data)
|
|||
START_TEST(eo_generic_data)
|
||||
{
|
||||
eo_init();
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
void *data;
|
||||
|
||||
eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL));
|
||||
eo_do(obj, eo_base_data_get("test1", &data));
|
||||
eo2_do(obj, eo2_base_data_set("test1", (void *) 1, NULL));
|
||||
eo2_do(obj, data = eo2_base_data_get("test1"));
|
||||
fail_if(1 != (intptr_t) data);
|
||||
eo_do(obj, eo_base_data_del("test1"));
|
||||
eo_do(obj, eo_base_data_get("test1", &data));
|
||||
eo2_do(obj, eo2_base_data_del("test1"));
|
||||
eo2_do(obj, data = eo2_base_data_get("test1"));
|
||||
fail_if(data);
|
||||
|
||||
eo_do(obj, eo_base_data_set("test1", (void *) 1, NULL));
|
||||
eo_do(obj, eo_base_data_set("test2", (void *) 2, NULL));
|
||||
eo_do(obj, eo_base_data_get("test1", &data));
|
||||
eo2_do(obj, eo2_base_data_set("test1", (void *) 1, NULL));
|
||||
eo2_do(obj, eo2_base_data_set("test2", (void *) 2, NULL));
|
||||
eo2_do(obj, data = eo2_base_data_get("test1"));
|
||||
fail_if(1 != (intptr_t) data);
|
||||
eo_do(obj, eo_base_data_get("test2", &data));
|
||||
eo2_do(obj, data = eo2_base_data_get("test2"));
|
||||
fail_if(2 != (intptr_t) data);
|
||||
|
||||
eo_do(obj, eo_base_data_get("test2", &data));
|
||||
eo2_do(obj, data = eo2_base_data_get("test2"));
|
||||
fail_if(2 != (intptr_t) data);
|
||||
eo_do(obj, eo_base_data_del("test2"));
|
||||
eo_do(obj, eo_base_data_get("test2", &data));
|
||||
eo2_do(obj, eo2_base_data_del("test2"));
|
||||
eo2_do(obj, data = eo2_base_data_get("test2"));
|
||||
fail_if(data);
|
||||
|
||||
eo_do(obj, eo_base_data_get("test1", &data));
|
||||
eo2_do(obj, data = eo2_base_data_get("test1"));
|
||||
fail_if(1 != (intptr_t) data);
|
||||
eo_do(obj, eo_base_data_del("test1"));
|
||||
eo_do(obj, eo_base_data_get("test1", &data));
|
||||
eo2_do(obj, eo2_base_data_del("test1"));
|
||||
eo2_do(obj, data = eo2_base_data_get("test1"));
|
||||
fail_if(data);
|
||||
|
||||
int a = 0;
|
||||
eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
|
||||
eo_do(obj, eo_base_data_get("test3", &data));
|
||||
eo2_do(obj, eo2_base_data_set("test3", &a, _fake_free_func));
|
||||
eo2_do(obj, data = eo2_base_data_get("test3"));
|
||||
fail_if(&a != data);
|
||||
eo_do(obj, eo_base_data_get("test3", NULL));
|
||||
eo_do(obj, eo_base_data_del("test3"));
|
||||
eo2_do(obj, eo2_base_data_get("test3"));
|
||||
eo2_do(obj, eo2_base_data_del("test3"));
|
||||
fail_if(a != 1);
|
||||
|
||||
a = 0;
|
||||
eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
|
||||
eo_do(obj, eo_base_data_set("test3", NULL, _fake_free_func));
|
||||
eo2_do(obj, eo2_base_data_set("test3", &a, _fake_free_func));
|
||||
eo2_do(obj, eo2_base_data_set("test3", NULL, _fake_free_func));
|
||||
fail_if(a != 1);
|
||||
a = 0;
|
||||
data = (void *) 123;
|
||||
eo_do(obj, eo_base_data_set(NULL, &a, _fake_free_func));
|
||||
eo_do(obj, eo_base_data_get(NULL, &data));
|
||||
eo2_do(obj, eo2_base_data_set(NULL, &a, _fake_free_func));
|
||||
eo2_do(obj, data = eo2_base_data_get(NULL));
|
||||
fail_if(data);
|
||||
eo_do(obj, eo_base_data_del(NULL));
|
||||
eo2_do(obj, eo2_base_data_del(NULL));
|
||||
|
||||
a = 0;
|
||||
eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
|
||||
eo_do(obj, eo_base_data_set("test3", NULL, NULL));
|
||||
eo2_do(obj, eo2_base_data_set("test3", &a, _fake_free_func));
|
||||
eo2_do(obj, eo2_base_data_set("test3", NULL, NULL));
|
||||
fail_if(a != 1);
|
||||
eo_do(obj, eo_base_data_set("test3", &a, _fake_free_func));
|
||||
eo2_do(obj, eo2_base_data_set("test3", &a, _fake_free_func));
|
||||
|
||||
eo_unref(obj);
|
||||
fail_if(a != 2);
|
||||
|
@ -642,6 +563,7 @@ START_TEST(eo_generic_data)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST(eo_magic_checks)
|
||||
{
|
||||
char _buf[sizeof(long)]; /* Just enough to hold eina magic + a bit more. */
|
||||
|
@ -650,32 +572,38 @@ START_TEST(eo_magic_checks)
|
|||
|
||||
memset(_buf, 1, sizeof(_buf));
|
||||
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, (Eo *) buf);
|
||||
Eo *obj = eo2_add(SIMPLE_CLASS, (Eo *) buf);
|
||||
fail_if(obj);
|
||||
|
||||
while (1)
|
||||
{
|
||||
int i = 20, a = 0;
|
||||
Eo *parent = NULL;
|
||||
Eo *wref = NULL;
|
||||
Eo *obj2 = NULL;
|
||||
|
||||
obj = eo_add((Eo_Class *) buf, NULL);
|
||||
obj = eo2_add((Eo_Class *) buf, NULL);
|
||||
fail_if(obj);
|
||||
|
||||
obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
fail_if(!obj);
|
||||
|
||||
fail_if(eo_do((Eo *) buf, EO_NOOP));
|
||||
fail_if(eo_do_super((Eo *) buf, SIMPLE_CLASS, EO_NOOP));
|
||||
fail_if(eo_do_super(obj, (const Eo_Class *) buf, EO_NOOP));
|
||||
eo2_do((Eo *) buf, simple_a_set(++i), a = simple_a_get());
|
||||
ck_assert_int_ne(i, a);
|
||||
eo2_do_super((Eo *) buf, SIMPLE_CLASS, simple_a_set(++i));
|
||||
eo2_do_super((Eo *) buf, SIMPLE_CLASS, a = simple_a_get());
|
||||
ck_assert_int_ne(i, a);
|
||||
eo2_do_super(obj, (const Eo_Class *) buf, simple_a_set(++i));
|
||||
eo2_do_super(obj, (const Eo_Class *) buf, a = simple_a_get());
|
||||
ck_assert_int_ne(i, a);
|
||||
fail_if(eo_class_get((Eo *) buf));
|
||||
fail_if(eo_class_name_get((Eo_Class*) buf));
|
||||
fail_if(eo_class_get(obj) != SIMPLE_CLASS);
|
||||
fail_if(eo_class_get(SIMPLE_CLASS) != EO_CLASS_CLASS);
|
||||
fail_if(eo_class_get(SIMPLE_CLASS) != EO2_CLASS_CLASS);
|
||||
eo_class_funcs_set((Eo_Class *) buf, NULL);
|
||||
eo_do((Eo_Class *) buf, NULL);
|
||||
eo_do_super((Eo_Class *) buf, SIMPLE_CLASS, EO_NOOP);
|
||||
eo_do_super(SIMPLE_CLASS, (Eo_Class *) buf, EO_NOOP);
|
||||
eo2_do((Eo_Class *) buf, NULL);
|
||||
eo2_do_super((Eo_Class *) buf, SIMPLE_CLASS, simple_a_set(++i));
|
||||
eo2_do_super(SIMPLE_CLASS, (Eo_Class *) buf, simple_a_set(++i)); // FIXME Jeremy: For some reason it tries to call the object function on the class!!!
|
||||
|
||||
fail_if(eo_class_new(NULL, (Eo_Class *) buf), NULL);
|
||||
|
||||
|
@ -693,9 +621,9 @@ START_TEST(eo_magic_checks)
|
|||
|
||||
fail_if(0 != eo_ref_get((Eo *) buf));
|
||||
|
||||
eo_do((Eo *) buf,
|
||||
eo_wref_add(&wref),
|
||||
eo_parent_get(&parent));
|
||||
eo2_do((Eo *) buf,
|
||||
eo2_wref_add(&wref),
|
||||
eo2_parent_get(&parent));
|
||||
fail_if(wref);
|
||||
fail_if(parent);
|
||||
|
||||
|
@ -709,8 +637,8 @@ START_TEST(eo_magic_checks)
|
|||
eo_composite_detach(obj, (Eo *) buf);
|
||||
eo_composite_is((Eo *) buf);
|
||||
|
||||
eo_do(obj, eo_event_callback_forwarder_add(NULL, (Eo *) buf));
|
||||
eo_do(obj, eo_event_callback_forwarder_del(NULL, (Eo *) buf));
|
||||
eo2_do(obj, eo2_event_callback_forwarder_add(NULL, (Eo *) buf));
|
||||
eo2_do(obj, eo2_event_callback_forwarder_del(NULL, (Eo *) buf));
|
||||
|
||||
eo_manual_free_set((Eo *) buf, EINA_TRUE);
|
||||
eo_manual_free((Eo *) buf);
|
||||
|
@ -734,72 +662,63 @@ START_TEST(eo_magic_checks)
|
|||
END_TEST
|
||||
|
||||
/* MULTI */
|
||||
static Eo_Op MULTI_BASE_ID;
|
||||
#define MULTI_ID(sub_id) (MULTI_BASE_ID + sub_id)
|
||||
#define multi_a_print() MULTI_ID(MULTI_SUB_ID_A_PRINT)
|
||||
#define multi_class_hi_print() MULTI_ID(MULTI_SUB_ID_CLASS_HI_PRINT)
|
||||
|
||||
static void
|
||||
_a_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
static Eina_Bool
|
||||
_a_print(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED)
|
||||
{
|
||||
printf("Hey\n");
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_class_hi_print(Eo_Class *klass EINA_UNUSED, void *class_data EINA_UNUSED, va_list *list EINA_UNUSED)
|
||||
static Eina_Bool
|
||||
_class_hi_print(Eo_Class *klass EINA_UNUSED, void *class_data EINA_UNUSED)
|
||||
{
|
||||
printf("Hi\n");
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
enum {
|
||||
MULTI_SUB_ID_A_PRINT,
|
||||
MULTI_SUB_ID_CLASS_HI_PRINT,
|
||||
MULTI_SUB_ID_LAST
|
||||
EO2_FUNC_BODY(multi_a_print, Eina_Bool, EINA_FALSE);
|
||||
EO2_FUNC_BODY(multi_class_hi_print, Eina_Bool, EINA_FALSE);
|
||||
|
||||
static Eo2_Op_Description _multi_do_op_descs[] = {
|
||||
EO2_OP_FUNC(_a_print, multi_a_print, "Print property a"),
|
||||
EO2_OP_FUNC(_class_hi_print, multi_class_hi_print, "Print Hi"),
|
||||
EO2_OP_SENTINEL
|
||||
};
|
||||
|
||||
static void
|
||||
_eo_multiple_do_class_constructor(Eo_Class *klass)
|
||||
{
|
||||
const Eo_Op_Func_Description func_desc[] = {
|
||||
EO_OP_FUNC(MULTI_ID(MULTI_SUB_ID_A_PRINT), _a_print),
|
||||
EO_OP_FUNC_CLASS(MULTI_ID(MULTI_SUB_ID_CLASS_HI_PRINT), _class_hi_print),
|
||||
EO_OP_FUNC_SENTINEL
|
||||
};
|
||||
|
||||
eo_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
static const Eo_Op_Description _eo_multiple_do_op_desc[] = {
|
||||
EO_OP_DESCRIPTION(MULTI_SUB_ID_A_PRINT, "Print property A"),
|
||||
EO_OP_DESCRIPTION_CLASS(MULTI_SUB_ID_CLASS_HI_PRINT, "Print Hi"),
|
||||
EO_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
|
||||
START_TEST(eo_multiple_do)
|
||||
{
|
||||
eo_init();
|
||||
|
||||
/* Usually should be const, not const only for the test... */
|
||||
static Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Inherit",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(&MULTI_BASE_ID, _eo_multiple_do_op_desc, MULTI_SUB_ID_LAST),
|
||||
EO2_CLASS_DESCRIPTION_OPS(_multi_do_op_descs),
|
||||
NULL,
|
||||
0,
|
||||
_eo_multiple_do_class_constructor,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
const Eo_Class *klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
Eo *obj = eo_add(klass, NULL);
|
||||
Eo *obj = eo2_add(klass, NULL);
|
||||
fail_if(!obj);
|
||||
|
||||
fail_if(!eo_do(obj, simple_a_print(), multi_a_print(), multi_a_print()));
|
||||
fail_if(!eo_do(klass, simple_class_hi_print(), multi_class_hi_print(), multi_class_hi_print()));
|
||||
Eina_Bool ca, cb, cc;
|
||||
|
||||
ca = cb = cc = EINA_FALSE;
|
||||
eo2_do(obj, ca = simple_a_print(), cb = multi_a_print(), cc = multi_a_print());
|
||||
fail_if(!(ca && cb && cc));
|
||||
|
||||
ca = cb = cc = EINA_FALSE;
|
||||
eo2_do(klass, ca = simple_class_hi_print(), cb = multi_class_hi_print(), cc = multi_class_hi_print());
|
||||
fail_if(!(ca && cb && cc));
|
||||
|
||||
eo_unref(obj);
|
||||
|
||||
|
@ -807,23 +726,23 @@ START_TEST(eo_multiple_do)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eo_add_do_and_custom)
|
||||
START_TEST(eo2_add_do_and_custom)
|
||||
{
|
||||
Simple_Public_Data *pd = NULL;
|
||||
Eo *obj = NULL;
|
||||
eo_init();
|
||||
|
||||
obj = eo_add_custom(SIMPLE_CLASS, NULL, eo_constructor());
|
||||
obj = eo2_add_custom(SIMPLE_CLASS, NULL, eo2_constructor());
|
||||
fail_if(!obj);
|
||||
eo_unref(obj);
|
||||
|
||||
obj = eo_add(SIMPLE_CLASS, NULL, simple_a_set(7));
|
||||
obj = eo2_add(SIMPLE_CLASS, NULL, simple_a_set(7));
|
||||
fail_if(!obj);
|
||||
pd = eo_data_scope_get(obj, SIMPLE_CLASS);
|
||||
fail_if(pd->a != 7);
|
||||
eo_unref(obj);
|
||||
|
||||
obj = eo_add_custom(SIMPLE_CLASS, NULL, eo_constructor(), simple_a_set(7));
|
||||
obj = eo2_add_custom(SIMPLE_CLASS, NULL, eo2_constructor(), simple_a_set(7));
|
||||
fail_if(!obj);
|
||||
pd = eo_data_scope_get(obj, SIMPLE_CLASS);
|
||||
fail_if(pd->a != 7);
|
||||
|
@ -839,7 +758,7 @@ START_TEST(eo_pointers_indirection)
|
|||
eo_init();
|
||||
|
||||
static const Eo_Class_Description class_desc = {
|
||||
EO_VERSION,
|
||||
EO2_VERSION,
|
||||
"Simple",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(NULL, NULL, 0),
|
||||
|
@ -849,11 +768,11 @@ START_TEST(eo_pointers_indirection)
|
|||
NULL
|
||||
};
|
||||
|
||||
const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
|
||||
const Eo_Class *klass = eo_class_new(&class_desc, EO2_BASE_CLASS, NULL);
|
||||
fail_if(!klass);
|
||||
|
||||
/* Check simple id validity */
|
||||
Eo *obj = eo_add(klass, NULL);
|
||||
Eo *obj = eo2_add(klass, NULL);
|
||||
fail_if(!obj);
|
||||
fail_if(!eo_isa(obj, klass));
|
||||
obj = (Eo *)((char *)(obj) + 1);
|
||||
|
@ -864,10 +783,10 @@ START_TEST(eo_pointers_indirection)
|
|||
fail_if(eo_isa(obj, klass));
|
||||
|
||||
/* Check id invalidity after deletion */
|
||||
Eo *obj1 = eo_add(klass, NULL);
|
||||
Eo *obj1 = eo2_add(klass, NULL);
|
||||
fail_if(!obj1);
|
||||
eo_unref(obj1);
|
||||
Eo *obj2 = eo_add(klass, NULL);
|
||||
Eo *obj2 = eo2_add(klass, NULL);
|
||||
fail_if(!obj2);
|
||||
fail_if(!eo_isa(obj2, klass));
|
||||
fail_if(eo_isa(obj1, klass));
|
||||
|
@ -880,7 +799,7 @@ START_TEST(eo_pointers_indirection)
|
|||
/* Creation of the objects */
|
||||
for ( obj_id = 0; obj_id < NB_OBJS; obj_id++)
|
||||
{
|
||||
objs[obj_id] = eo_add(klass, NULL);
|
||||
objs[obj_id] = eo2_add(klass, NULL);
|
||||
if(!objs[obj_id])
|
||||
fail_if(!objs[obj_id]);
|
||||
if(!eo_isa(objs[obj_id], klass))
|
||||
|
@ -896,7 +815,7 @@ START_TEST(eo_pointers_indirection)
|
|||
/* Creation of the deleted objects */
|
||||
for ( obj_id = 0; obj_id < NB_OBJS; obj_id+=2000)
|
||||
{
|
||||
objs[obj_id] = eo_add(klass, NULL);
|
||||
objs[obj_id] = eo2_add(klass, NULL);
|
||||
if(!objs[obj_id])
|
||||
fail_if(!objs[obj_id]);
|
||||
if(!eo_isa(objs[obj_id], klass))
|
||||
|
@ -916,18 +835,17 @@ END_TEST
|
|||
|
||||
void eo_test_general(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eo_generic_data);
|
||||
tcase_add_test(tc, eo_op_errors);
|
||||
tcase_add_test(tc, eo_simple);
|
||||
tcase_add_test(tc, eo_weak_reference);
|
||||
tcase_add_test(tc, eo_refs);
|
||||
tcase_add_test(tc, eo_magic_checks);
|
||||
tcase_add_test(tc, eo_data_fetch);
|
||||
tcase_add_test(tc, eo_man_free);
|
||||
tcase_add_test(tc, eo_composite_tests);
|
||||
tcase_add_test(tc, eo_isa_tests);
|
||||
tcase_add_test(tc, eo_multiple_do);
|
||||
tcase_add_test(tc, eo_add_do_and_custom);
|
||||
tcase_add_test(tc, eo_signals);
|
||||
tcase_add_test(tc, eo_data_fetch);
|
||||
tcase_add_test(tc, eo_isa_tests);
|
||||
tcase_add_test(tc, eo_composite_tests);
|
||||
tcase_add_test(tc, eo_man_free);
|
||||
tcase_add_test(tc, eo_refs);
|
||||
tcase_add_test(tc, eo_weak_reference);
|
||||
tcase_add_test(tc, eo_generic_data);
|
||||
tcase_add_test(tc, eo_magic_checks);
|
||||
tcase_add_test(tc, eo_multiple_do);
|
||||
tcase_add_test(tc, eo2_add_do_and_custom);
|
||||
tcase_add_test(tc, eo_pointers_indirection);
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ START_TEST(eo_value)
|
|||
Eina_Value val2, eo_val;
|
||||
void *tmpp = NULL;
|
||||
Eo_Dbg_Info *eo_dbg_info;
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj = eo2_add(SIMPLE_CLASS, NULL);
|
||||
|
||||
eo_dbg_info = EO_DBG_INFO_LIST_APPEND(NULL, "Root");
|
||||
fail_if(!eo_do(obj, eo_dbg_info_get(eo_dbg_info)));
|
||||
eo2_do(obj, eo2_dbg_info_get(eo_dbg_info));
|
||||
fail_if(!eo_dbg_info);
|
||||
ck_assert_str_eq(eo_dbg_info->name, "Root");
|
||||
str = eina_value_to_string(&eo_dbg_info->value);
|
||||
|
|
Loading…
Reference in New Issue