2012-09-07 14:56:44 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2015-05-08 06:21:23 -07:00
|
|
|
#define EO_BASE_BETA
|
2015-05-06 09:05:38 -07:00
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
#include "Eo.h"
|
2012-09-25 23:56:52 -07:00
|
|
|
#include "composite_objects_simple.h"
|
|
|
|
#include "composite_objects_comp.h"
|
2012-04-12 03:48:08 -07:00
|
|
|
|
2012-04-12 04:20:26 -07:00
|
|
|
#include "../eunit_tests.h"
|
|
|
|
|
2012-04-12 03:48:08 -07:00
|
|
|
static int cb_called = EINA_FALSE;
|
|
|
|
|
|
|
|
static Eina_Bool
|
2016-02-29 02:18:40 -08:00
|
|
|
_a_changed_cb(void *data, const Eo_Event *event)
|
2012-04-12 03:48:08 -07:00
|
|
|
{
|
2016-02-29 02:18:40 -08:00
|
|
|
int new_a = *((int *) event->event_info);
|
2012-04-12 03:48:08 -07:00
|
|
|
printf("%s event_info:'%d' data:'%s'\n", __func__, new_a, (const char *) data);
|
|
|
|
|
|
|
|
cb_called = EINA_TRUE;
|
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
return EO_CALLBACK_CONTINUE;
|
2012-04-12 03:48:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
(void) argc;
|
|
|
|
(void) argv;
|
2012-05-01 00:40:14 -07:00
|
|
|
eo_init();
|
2012-04-12 03:48:08 -07:00
|
|
|
|
2016-03-11 04:24:08 -08:00
|
|
|
Eo *obj = eo_add(COMP_CLASS, NULL);
|
2016-03-01 10:06:28 -08:00
|
|
|
eo_event_callback_add(obj, EV_A_CHANGED, _a_changed_cb, NULL);
|
2012-04-12 03:48:08 -07:00
|
|
|
|
2014-02-18 06:33:24 -08:00
|
|
|
fail_if(!eo_isa(obj, COMP_CLASS));
|
|
|
|
fail_if(!eo_isa(obj, SIMPLE_CLASS));
|
|
|
|
|
2013-12-30 13:16:55 -08:00
|
|
|
int a = 0;
|
2014-10-28 09:19:30 -07:00
|
|
|
cb_called = EINA_FALSE;
|
2016-03-01 10:06:28 -08:00
|
|
|
simple_a_set(obj, 1);
|
2012-04-12 04:20:26 -07:00
|
|
|
fail_if(!cb_called);
|
2012-04-12 03:48:08 -07:00
|
|
|
|
2014-10-28 09:19:30 -07:00
|
|
|
/* Test functions from all across the chain. */
|
|
|
|
cb_called = EINA_FALSE;
|
2016-03-01 10:06:28 -08:00
|
|
|
simple_a_set1(obj, 1);
|
2014-10-28 09:19:30 -07:00
|
|
|
fail_if(!cb_called);
|
|
|
|
cb_called = EINA_FALSE;
|
2016-03-01 10:06:28 -08:00
|
|
|
simple_a_set15(obj, 1);
|
2014-10-28 09:19:30 -07:00
|
|
|
fail_if(!cb_called);
|
|
|
|
cb_called = EINA_FALSE;
|
2016-03-01 10:06:28 -08:00
|
|
|
simple_a_set32(obj, 1);
|
2014-10-28 09:19:30 -07:00
|
|
|
fail_if(!cb_called);
|
|
|
|
|
2016-03-01 10:06:28 -08:00
|
|
|
a = simple_a_get(obj);
|
2012-04-12 04:20:26 -07:00
|
|
|
fail_if(a != 1);
|
|
|
|
|
2012-04-12 07:37:57 -07:00
|
|
|
/* disable the callback forwarder, and fail if it's still called. */
|
2013-12-30 13:16:55 -08:00
|
|
|
Eo *simple = NULL;
|
2016-03-01 10:06:28 -08:00
|
|
|
simple = eo_key_data_get(obj, "simple-obj");
|
2012-05-01 00:40:14 -07:00
|
|
|
eo_ref(simple);
|
2016-03-01 10:06:28 -08:00
|
|
|
eo_event_callback_forwarder_del(simple, EV_A_CHANGED, obj);
|
2012-04-12 07:37:57 -07:00
|
|
|
|
|
|
|
cb_called = EINA_FALSE;
|
2016-03-01 10:06:28 -08:00
|
|
|
simple_a_set(obj, 2);
|
2012-04-12 07:37:57 -07:00
|
|
|
fail_if(cb_called);
|
|
|
|
|
2016-03-01 10:06:28 -08:00
|
|
|
fail_if(!eo_composite_part_is(simple));
|
|
|
|
fail_if(!eo_composite_detach(obj, simple));
|
|
|
|
fail_if(eo_composite_detach(obj, simple));
|
|
|
|
fail_if(eo_composite_part_is(simple));
|
|
|
|
fail_if(!eo_composite_attach(obj, simple));
|
|
|
|
fail_if(!eo_composite_part_is(simple));
|
|
|
|
fail_if(eo_composite_attach(obj, simple));
|
2014-10-21 04:37:00 -07:00
|
|
|
|
2016-03-01 10:06:28 -08:00
|
|
|
fail_if(eo_composite_attach(simple, obj));
|
2012-04-12 07:37:57 -07:00
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
eo_unref(simple);
|
|
|
|
eo_unref(obj);
|
2012-04-12 03:48:08 -07:00
|
|
|
|
2012-05-01 00:40:14 -07:00
|
|
|
eo_shutdown();
|
2012-04-12 03:48:08 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|