ecore: Add a main loop test

Signed-off-by: Mike McCormack <mj.mccormack@samsung.com>

SVN revision: 61144
This commit is contained in:
Mike McCormack 2011-07-08 06:38:28 +00:00 committed by Mike McCormack
parent 8b02e5b6ab
commit 07ecfa527a
2 changed files with 104 additions and 3 deletions

View File

@ -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

View File

@ -0,0 +1,91 @@
#include <Ecore.h>
#include <assert.h>
#include <unistd.h>
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;
}