From: Mike McCormack Date: Fri, 8 Jul 2011 06:38:28 +0000 (+0000) Subject: ecore: Add a main loop test X-Git-Tag: submit/devel/efl/20131022.203902~8950 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=07ecfa527a67746cd5c93f69f5e5a36a8ff7a0c2;p=platform%2Fupstream%2Fefl.git ecore: Add a main loop test Signed-off-by: Mike McCormack SVN revision: 61144 --- diff --git a/legacy/ecore/src/bin/Makefile.am b/legacy/ecore/src/bin/Makefile.am index fbe82ff..f7adf63 100644 --- a/legacy/ecore/src/bin/Makefile.am +++ b/legacy/ecore/src/bin/Makefile.am @@ -16,9 +16,9 @@ AM_CPPFLAGS = \ -DPACKAGE_BIN_DIR=\"$(bindir)\" \ -DPACKAGE_LIB_DIR=\"$(libdir)\" \ -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ -@EINA_CFLAGS@ @EVAS_CFLAGS@ @EET_CFLAGS@ +@EINA_CFLAGS@ @EVAS_CFLAGS@ -bin_PROGRAMS = $(ECORE_CONFIG_PROG) +bin_PROGRAMS = $(ECORE_CONFIG_PROG) ecore_test ecore_config_SOURCES = \ ecore_config.c @@ -28,10 +28,20 @@ $(ECORE_CONFIG_LIB) \ $(top_builddir)/src/lib/ecore_ipc/libecore_ipc.la \ $(top_builddir)/src/lib/ecore_con/libecore_con.la \ $(top_builddir)/src/lib/ecore/libecore.la \ -@EINA_LIBS@ @EVAS_LIBS@ @EET_LIBS@ +@EINA_LIBS@ @EVAS_LIBS@ ecore_config_DEPENDENCIES = \ $(top_builddir)/src/lib/ecore_ipc/libecore_ipc.la \ $(top_builddir)/src/lib/ecore_con/libecore_con.la \ $(top_builddir)/src/lib/ecore/libecore.la \ $(ECORE_CONFIG_LIB) + +ecore_test_SOURCES = \ +ecore_test.c + +ecore_test_LDADD = \ +$(top_builddir)/src/lib/ecore/libecore.la \ +@EINA_LIBS@ @EVAS_LIBS@ + +ecore_test_DEPENDENCIES = \ +$(top_builddir)/src/lib/ecore/libecore.la diff --git a/legacy/ecore/src/bin/ecore_test.c b/legacy/ecore/src/bin/ecore_test.c new file mode 100644 index 0000000..9ac2859 --- /dev/null +++ b/legacy/ecore/src/bin/ecore_test.c @@ -0,0 +1,91 @@ +#include +#include +#include + +const char *called = NULL; + +static const char *idler_str = "idler"; +static const char *idle_enterer_str = "idler_enterer"; +static const char *idle_exiter_str = "idler_exiter"; +static const char *timer_str = "timer"; +static const char *pipe_read_str = "pipe read"; + +int count; + +Eina_Bool idle_enterer_one(void *data) +{ + fprintf(stderr, "idle enterer!\n"); + if (count) + assert(called == timer_str); + else + assert(called == NULL); + called = idle_enterer_str; + return EINA_TRUE; +} + +Eina_Bool idler_one(void *data) +{ + fprintf(stderr, "idler!\n"); + assert(called == idle_enterer_str); + called = idler_str; + return EINA_TRUE; +} + +Eina_Bool idle_exiter_one(void *data) +{ + fprintf(stderr, "idle exiter!\n"); + assert(called == idler_str); + called = idle_exiter_str; + return EINA_TRUE; +} + +Eina_Bool timer_one(void *data) +{ + fprintf(stderr, "timer\n"); + assert(called == pipe_read_str); + called = timer_str; + + count++; + if (count == 10) + { + ecore_main_loop_quit(); + return EINA_FALSE; + } + + return EINA_TRUE; +} + +Eina_Bool pipe_read(void *data, Ecore_Fd_Handler *fd_handler) +{ + fprintf(stderr, "pipe read\n"); + assert(called == idle_exiter_str); + called = pipe_read_str; + + return EINA_TRUE; +} + +int main(int argc, char **argv) +{ + int fds[2]; + + assert(0 == pipe(fds)); + + assert(1 == write(fds[1], "x", 1)); + + ecore_init(); + + ecore_timer_add(0.0, timer_one, NULL); + ecore_main_fd_handler_add(fds[0], ECORE_FD_READ, pipe_read, NULL, NULL, NULL); + + ecore_idle_enterer_add(&idle_enterer_one, NULL); + ecore_idler_add(&idler_one, NULL); + ecore_idle_exiter_add(&idle_exiter_one, NULL); + + ecore_main_loop_begin(); + + /* FIXME?: glib main loop exits on an idle enterer */ + //assert(called == idle_enterer_str); + + ecore_shutdown(); + return 0; +}