@EDBUS_CFLAGS@
bin_edbus_edbus_codegen_LDADD = @USE_EDBUS_LIBS@
bin_edbus_edbus_codegen_DEPENDENCIES = @USE_EDBUS_INTERNAL_LIBS@
+
+### Unit tests
+
+if EFL_ENABLE_TESTS
+
+check_PROGRAMS += tests/edbus/edbus_suite
+TESTS += tests/edbus/edbus_suite
+
+tests_edbus_edbus_suite_SOURCES = \
+tests/edbus/edbus_suite.c \
+tests/edbus/edbus_test_edbus_init.c \
+tests/edbus/edbus_suite.h
+
+tests_edbus_edbus_suite_CPPFLAGS = @CHECK_CFLAGS@ @EDBUS_CFLAGS@
+tests_edbus_edbus_suite_LDADD = @CHECK_LIBS@ @USE_EDBUS_LIBS@
+tests_edbus_edbus_suite_DEPENDENCIES = @USE_EDBUS_INTERNAL_LIBS@
+
+endif
--- /dev/null
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <EDBus.h>
+
+#include "edbus_suite.h"
+
+typedef struct _EDBus_Test_Case Edbus_Test_Case;
+
+struct _EDBus_Test_Case
+{
+ const char *test_case;
+ void (*build)(TCase *tc);
+};
+
+static const Edbus_Test_Case etc[] = {
+ { "edbus_init", edbus_test_edbus_init },
+ { }
+};
+
+static void
+_list_tests(void)
+{
+ const Edbus_Test_Case *itr;
+
+ itr = etc;
+ fputs("Available Test Cases:\n", stderr);
+ for (; itr->test_case; itr++)
+ printf("\t%s\n", itr->test_case);
+}
+
+static Eina_Bool
+_use_test(int argc, const char **argv, const char *test_case)
+{
+ if (argc < 1)
+ return 1;
+
+ for (; argc > 0; argc--, argv++)
+ {
+ if (strcmp(test_case, *argv) == 0)
+ return 1;
+ }
+ return 0;
+}
+
+static Suite *
+edbus_suite_build(int argc, const char **argv)
+{
+ TCase *tc;
+ Suite *s;
+ int i;
+
+ s = suite_create("Edbus");
+
+ for (i = 0; etc[i].test_case; ++i)
+ {
+ if (!_use_test(argc, argv, etc[i].test_case)) continue;
+ tc = tcase_create(etc[i].test_case);
+
+ etc[i].build(tc);
+
+ suite_add_tcase(s, tc);
+ tcase_set_timeout(tc, 0);
+ }
+
+ return s;
+}
+
+int
+main(int argc, char **argv)
+{
+ Suite *s;
+ SRunner *sr;
+ int i, failed_count;
+
+ for (i = 1; i < argc; i++)
+ if ((strcmp(argv[i], "-h") == 0) ||
+ (strcmp(argv[i], "--help") == 0))
+ {
+ fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
+ argv[0]);
+ _list_tests();
+ return 0;
+ }
+ else if ((strcmp(argv[i], "-l") == 0) ||
+ (strcmp(argv[i], "--list") == 0))
+ {
+ _list_tests();
+ return 0;
+ }
+
+ putenv("EFL_RUN_IN_TREE=1");
+
+ s = edbus_suite_build(argc - 1, (const char **)argv + 1);
+ sr = srunner_create(s);
+
+ srunner_run_all(sr, CK_ENV);
+ failed_count = srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
--- /dev/null
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <unistd.h>
+
+#include <Eina.h>
+#include <Ecore.h>
+#include <EDBus.h>
+
+#include "edbus_suite.h"
+
+static Eina_Bool
+_quit_cb(void *data EINA_UNUSED)
+{
+ ecore_main_loop_quit();
+ return EINA_FALSE;
+}
+
+START_TEST(edbus_test_edbus)
+{
+ int ret;
+
+ ret = edbus_init();
+ fail_if(ret != 1);
+
+ ret = edbus_shutdown();
+ fail_if(ret != 0);
+}
+END_TEST
+
+START_TEST(edbus_test_edbus_main_loop)
+{
+ Ecore_Timer *timer;
+ int ret;
+
+ ecore_init();
+ ret = edbus_init();
+ fail_if(ret != 1);
+
+ timer = ecore_timer_add(0.1, _quit_cb, NULL);
+ fail_if(timer == NULL);
+
+ ecore_main_loop_begin();
+
+ ret = edbus_shutdown();
+ fail_if(ret != 0);
+
+ ecore_shutdown();
+
+}
+END_TEST
+
+void edbus_test_edbus_init(TCase *tc)
+{
+ tcase_add_test(tc, edbus_test_edbus);
+ tcase_add_test(tc, edbus_test_edbus_main_loop);
+}