From 8f801277df211416ca9636b3d28ead43f9f50a35 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Jan 2009 12:47:51 -0600 Subject: Moving the tests so that they can guarantee to build after the library builds as otherwise they end up getting built first. --- tests/Makefile.am | 38 ++++++++++++++++++++++++++++++++++ tests/indicate-alot.c | 24 ++++++++++++++++++++++ tests/indicate-and-crash.c | 20 ++++++++++++++++++ tests/listen-and-print.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++ tests/test.js | 6 ++++++ 5 files changed, 139 insertions(+) create mode 100644 tests/Makefile.am create mode 100644 tests/indicate-alot.c create mode 100644 tests/indicate-and-crash.c create mode 100644 tests/listen-and-print.c create mode 100755 tests/test.js (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..03ec716 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,38 @@ + +noinst_PROGRAMS = \ + indicate-and-crash \ + indicate-alot \ + listen-and-print + +indicate_and_crash_SOURCES = \ + indicate-and-crash.c + +indicate_and_crash_CFLAGS = \ + -I $(srcdir)/.. \ + $(LIBINDICATE_CFLAGS) + +indicate_and_crash_LDADD = \ + ../libindicate/libindicate.la \ + $(LIBINDICATE_LIBS) + +indicate_alot_SOURCES = \ + indicate-alot.c + +indicate_alot_CFLAGS = \ + -I $(srcdir)/.. \ + $(LIBINDICATE_CFLAGS) + +indicate_alot_LDADD = \ + ../libindicate/libindicate.la \ + $(LIBINDICATE_LIBS) + +listen_and_print_SOURCES = \ + listen-and-print.c + +listen_and_print_CFLAGS = \ + -I $(srcdir)/.. \ + $(LIBINDICATE_CFLAGS) + +listen_and_print_LDADD = \ + ../libindicate/libindicate.la \ + $(LIBINDICATE_LIBS) diff --git a/tests/indicate-alot.c b/tests/indicate-alot.c new file mode 100644 index 0000000..bebf726 --- /dev/null +++ b/tests/indicate-alot.c @@ -0,0 +1,24 @@ + +#include +#include "libindicate/indicator.h" + +#define ALOT 30 + + +int +main (int argc, char ** argv) +{ + g_type_init(); + + IndicateIndicator * indicators[ALOT]; + int i; + + for (i = 0; i < ALOT; i++) { + indicators[i] = indicate_indicator_new(); + indicate_indicator_show(indicators[i]); + } + + g_main_loop_run(g_main_loop_new(NULL, FALSE)); + + return 0; +} diff --git a/tests/indicate-and-crash.c b/tests/indicate-and-crash.c new file mode 100644 index 0000000..5a50e30 --- /dev/null +++ b/tests/indicate-and-crash.c @@ -0,0 +1,20 @@ + +#include +#include "libindicate/indicator.h" + +gboolean crashfunc (gpointer data) { *(int *)data = 5; return FALSE;} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + IndicateIndicator * indicator = indicate_indicator_new(); + indicate_indicator_show(indicator); + + g_timeout_add_seconds(15, crashfunc, NULL); + + g_main_loop_run(g_main_loop_new(NULL, FALSE)); + + return 0; +} diff --git a/tests/listen-and-print.c b/tests/listen-and-print.c new file mode 100644 index 0000000..9ad2cc8 --- /dev/null +++ b/tests/listen-and-print.c @@ -0,0 +1,51 @@ + +#include +#include "libindicate/listener.h" + +static void +indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data) +{ + g_debug("Indicator Added: %s %d %s", (gchar *)server, (guint)indicator, type); +} + +static void +indicator_removed (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data) +{ + g_debug("Indicator Removed: %s %d %s", (gchar *)server, (guint)indicator, type); +} + +static void +indicator_modified (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gchar * property, gpointer data) +{ + g_debug("Indicator Modified: %s %d %s %s", (gchar *)server, (guint)indicator, type, property); +} + +static void +server_added (IndicateListener * listener, IndicateListenerServer * server, gpointer data) +{ + g_debug("Indicator Server Added: %s", (gchar *)server); +} + +static void +server_removed (IndicateListener * listener, IndicateListenerServer * server, gpointer data) +{ + g_debug("Indicator Server Removed: %s", (gchar *)server); +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + IndicateListener * listener = indicate_listener_new(); + + g_signal_connect(listener, "indicator-added", G_CALLBACK(indicator_added), NULL); + g_signal_connect(listener, "indicator-removed", G_CALLBACK(indicator_removed), NULL); + g_signal_connect(listener, "indicator-modified", G_CALLBACK(indicator_modified), NULL); + g_signal_connect(listener, "server-added", G_CALLBACK(server_added), NULL); + g_signal_connect(listener, "server-removed", G_CALLBACK(server_removed), NULL); + + g_main_loop_run(g_main_loop_new(NULL, FALSE)); + + return 0; +} diff --git a/tests/test.js b/tests/test.js new file mode 100755 index 0000000..45b0d05 --- /dev/null +++ b/tests/test.js @@ -0,0 +1,6 @@ +#!/usr/local/bin/seed +Seed.import_namespace("Indicate"); + +var indicator = new Indicate.Indicator(); + +indicator.show(); -- cgit v1.2.3