summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dransfeld <sd@tango.flipp.net>2013-11-29 22:20:13 +0100
committerSebastian Dransfeld <sd@tango.flipp.net>2013-11-29 22:20:50 +0100
commitb47e7651aa1eb697bd12f95f73c9afc3fd5a3e84 (patch)
tree4185bf3132de914f5b0b24adc61c4579010d7201
parent575f466a1022b1827d7cbbf6f205d3ee674f4bec (diff)
efreet: add async menu test
-rw-r--r--src/Makefile_Efreet.am11
-rw-r--r--src/tests/efreet/efreet_async_test.c72
2 files changed, 83 insertions, 0 deletions
diff --git a/src/Makefile_Efreet.am b/src/Makefile_Efreet.am
index 725760a82..322531615 100644
--- a/src/Makefile_Efreet.am
+++ b/src/Makefile_Efreet.am
@@ -108,6 +108,7 @@ if EFL_ENABLE_TESTS
noinst_PROGRAMS += \
tests/efreet/efreet_test \
+tests/efreet/efreet_async_test \
tests/efreet/efreet_spec_test \
tests/efreet/efreet_cache_test \
tests/efreet/efreet_icon_cache_dump \
@@ -137,6 +138,16 @@ tests/efreet/ef_test.h \
tests/efreet/ef_utils.c \
tests/efreet/main.c
+# efreet_async_test
+tests_efreet_efreet_async_test_CPPFLAGS = -I$(top_builddir)/src/lib/efl $(EFREET_COMMON_CPPFLAGS)
+tests_efreet_efreet_async_test_LDADD = \
+@USE_EFREET_LIBS@
+tests_efreet_efreet_async_test_DEPENDENCIES = \
+@USE_EFREET_INTERNAL_LIBS@
+
+tests_efreet_efreet_async_test_SOURCES = \
+tests/efreet/efreet_async_test.c
+
# efreet_spec_test
tests_efreet_efreet_spec_test_CPPFLAGS = -I$(top_builddir)/src/lib/efl $(EFREET_COMMON_CPPFLAGS)
tests_efreet_efreet_spec_test_LDADD = @USE_EFREET_LIBS@
diff --git a/src/tests/efreet/efreet_async_test.c b/src/tests/efreet/efreet_async_test.c
new file mode 100644
index 000000000..2c3618987
--- /dev/null
+++ b/src/tests/efreet/efreet_async_test.c
@@ -0,0 +1,72 @@
+#include <unistd.h>
+#include <Eina.h>
+#include <Ecore.h>
+#include <Efreet.h>
+
+#define TCOUNT 10
+#define MCOUNT 10
+#define MENU "/etc/xdg/menus/applications.menu"
+
+static int count = 0;
+static Eina_Lock lock;
+static Eina_Thread threads[TCOUNT];
+
+static void
+menu_cb(void *data EINA_UNUSED, Efreet_Menu *menu)
+{
+ efreet_menu_dump(menu, "");
+ eina_lock_take(&lock);
+ count++;
+ fprintf(stderr, "count: %d\n", count);
+ if (count == (MCOUNT * TCOUNT)) ecore_main_loop_quit();
+ eina_lock_release(&lock);
+ efreet_menu_free(menu);
+}
+
+static void *
+thread_cb(void *data EINA_UNUSED, Eina_Thread t EINA_UNUSED)
+{
+ int i;
+ for (i = 0; i < MCOUNT; i++) {
+ efreet_menu_async_parse(MENU, menu_cb, NULL);
+ usleep(1e5);
+ }
+ return NULL;
+}
+
+static void
+create_threads(void)
+{
+ int i;
+
+ for (i = 0; i < TCOUNT; i++)
+ {
+ if (!eina_thread_create(&threads[i], EINA_THREAD_NORMAL, -1, thread_cb, NULL))
+ fprintf(stderr, "error: eina_thread_create\n");
+ usleep(1e5);
+ }
+}
+
+int
+main(void)
+{
+ int i;
+
+ eina_init();
+ ecore_init();
+ efreet_init();
+
+ eina_lock_new(&lock);
+
+ create_threads();
+ ecore_main_loop_begin();
+ for (i = 0; i < TCOUNT; i++)
+ eina_thread_join(threads[i]);
+
+ eina_lock_free(&lock);
+
+ efreet_shutdown();
+ ecore_shutdown();
+ eina_shutdown();
+ return 0;
+}