forked from enlightenment/efl
parent
bef76f0407
commit
230de30c3e
|
@ -4,6 +4,7 @@ if (CHECK_ENABLED)
|
|||
eobj_suite.c
|
||||
eobj_test_init.c
|
||||
eobj_test_general.c
|
||||
class_simple.c
|
||||
)
|
||||
|
||||
add_executable(eobj_suite ${EOBJ_SUITE_CC_SOURCES})
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
#include "Eobj.h"
|
||||
#include "class_simple.h"
|
||||
|
||||
EAPI Eobj_Op SIMPLE_BASE_ID = 0;
|
||||
|
||||
static Eobj_Class *_my_class = NULL;
|
||||
|
||||
static void
|
||||
_a_set(Eobj *obj, Eobj_Op op, va_list *list)
|
||||
{
|
||||
Simple_Public_Data *pd = eobj_data_get(obj, _my_class);
|
||||
(void) op;
|
||||
int a;
|
||||
a = va_arg(*list, int);
|
||||
printf("%s %d\n", eobj_class_name_get(_my_class), a);
|
||||
pd->a = a;
|
||||
}
|
||||
|
||||
static void
|
||||
_a_print(Eobj *obj, Eobj_Op op, va_list *list)
|
||||
{
|
||||
Simple_Public_Data *pd = eobj_data_get(obj, _my_class);
|
||||
(void) op;
|
||||
(void) list;
|
||||
printf("Print %s %d\n", eobj_class_name_get(_my_class), pd->a);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_constructor(Eobj_Class *klass)
|
||||
{
|
||||
const Eobj_Op_Func_Description func_desc[] = {
|
||||
EOBJ_OP_FUNC_DESCRIPTION(SIMPLE_ID(SIMPLE_SUB_ID_A_SET), _a_set),
|
||||
EOBJ_OP_FUNC_DESCRIPTION(SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT), _a_print),
|
||||
EOBJ_OP_FUNC_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
eobj_class_funcs_set(klass, func_desc);
|
||||
}
|
||||
|
||||
const Eobj_Class *
|
||||
simple_class_get(void)
|
||||
{
|
||||
if (_my_class) return _my_class;
|
||||
|
||||
static const Eobj_Op_Description op_desc[] = {
|
||||
EOBJ_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "i", "Set property A"),
|
||||
EOBJ_OP_DESCRIPTION_SENTINEL
|
||||
};
|
||||
|
||||
static const Eobj_Class_Description class_desc = {
|
||||
"Simple",
|
||||
EOBJ_CLASS_TYPE_REGULAR,
|
||||
EOBJ_CLASS_DESCRIPTION_OPS(&SIMPLE_BASE_ID, op_desc, SIMPLE_SUB_ID_LAST),
|
||||
NULL,
|
||||
sizeof(Simple_Public_Data),
|
||||
NULL,
|
||||
NULL,
|
||||
_class_constructor,
|
||||
NULL
|
||||
};
|
||||
|
||||
return _my_class = eobj_class_new(&class_desc, EOBJ_CLASS_BASE, NULL);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef SIMPLE_H
|
||||
#define SIMPLE_H
|
||||
|
||||
#include "Eobj.h"
|
||||
|
||||
extern EAPI Eobj_Op SIMPLE_BASE_ID;
|
||||
|
||||
enum {
|
||||
SIMPLE_SUB_ID_A_SET,
|
||||
SIMPLE_SUB_ID_A_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), EOBJ_TYPECHECK(int, a)
|
||||
#define SIMPLE_A_PRINT() SIMPLE_ID(SIMPLE_SUB_ID_A_PRINT)
|
||||
|
||||
extern const Eobj_Event_Description _SIG_A_CHANGED;
|
||||
#define SIG_A_CHANGED (&(_SIG_A_CHANGED))
|
||||
|
||||
#define SIMPLE_CLASS simple_class_get()
|
||||
const Eobj_Class *simple_class_get(void) EINA_CONST;
|
||||
|
||||
#endif
|
|
@ -7,12 +7,25 @@
|
|||
#include "eobj_suite.h"
|
||||
#include "Eobj.h"
|
||||
|
||||
START_TEST(eobj_simple)
|
||||
#include "class_simple.h"
|
||||
|
||||
START_TEST(eobj_op_errors)
|
||||
{
|
||||
eobj_init();
|
||||
Eobj *obj = eobj_add(SIMPLE_CLASS, NULL);
|
||||
|
||||
/* Out of bounds op for a legal class. */
|
||||
fail_if(eobj_do(obj, 0x00010111));
|
||||
|
||||
/* Ilegal class. */
|
||||
fail_if(eobj_do(obj, 0x0F010111));
|
||||
|
||||
eobj_unref(obj);
|
||||
eobj_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void eobj_test_general(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eobj_simple);
|
||||
tcase_add_test(tc, eobj_op_errors);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
START_TEST(eobj_simple)
|
||||
{
|
||||
fail_if(!eobj_init()); /* one init by test suite */
|
||||
fail_if(eobj_init() != 1);
|
||||
fail_if(eobj_shutdown() != 1);
|
||||
fail_if(!eobj_shutdown());
|
||||
}
|
||||
END_TEST
|
||||
|
|
Loading…
Reference in New Issue