aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-10-28 16:46:25 -0500
committerTed Gould <ted@canonical.com>2009-10-28 16:46:25 -0500
commit0220cc7a435f3f03761697afd316ac1b86a10211 (patch)
treed612bfedf1888385c5e5e6a5c7d0f3c530f19dcb /tests
parentb5f41d1c0ca30f1cf7379e754d906681ccfbe9e1 (diff)
parentb98a4811a0b03335da1fad3d0e0bce08bdad2a00 (diff)
downloadlibayatana-indicator-0220cc7a435f3f03761697afd316ac1b86a10211.tar.gz
libayatana-indicator-0220cc7a435f3f03761697afd316ac1b86a10211.tar.bz2
libayatana-indicator-0220cc7a435f3f03761697afd316ac1b86a10211.zip
Grabbing the loader branch
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am92
-rw-r--r--tests/dummy-indicator-blank.c6
-rw-r--r--tests/dummy-indicator-null.c23
-rw-r--r--tests/dummy-indicator-simple.c28
-rw-r--r--tests/test-loader.c109
5 files changed, 258 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..8121136
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,92 @@
+
+check_PROGRAMS = \
+ test-loader
+
+lib_LTLIBRARIES = \
+ libdummy-indicator-blank.la \
+ libdummy-indicator-null.la \
+ libdummy-indicator-simple.la
+
+#############################
+# Test Loader
+#############################
+
+test_loader_SOURCES = \
+ test-loader.c
+
+test_loader_CFLAGS = \
+ -Wall -Werror \
+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir) \
+ -DBUILD_DIR="\"$(builddir)\""
+
+test_loader_LDADD = \
+ $(LIBINDICATOR_LIBS) $(top_builddir)/libindicator/.libs/libindicator.a
+
+#############################
+# Dummy Indicator Blank
+#############################
+
+libdummy_indicator_blank_la_SOURCES = \
+ dummy-indicator-blank.c
+
+libdummy_indicator_blank_la_CFLAGS = \
+ -Wall -Werror \
+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
+
+libdummy_indicator_blank_la_LIBADD = \
+ $(LIBINDICATOR_LIBS)
+
+libdummy_indicator_blank_la_LDFLAGS = \
+ -module \
+ -avoid-version
+
+#############################
+# Dummy Indicator NULL
+#############################
+
+libdummy_indicator_null_la_SOURCES = \
+ dummy-indicator-null.c
+
+libdummy_indicator_null_la_CFLAGS = \
+ -Wall -Werror \
+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
+
+libdummy_indicator_null_la_LIBADD = \
+ $(LIBINDICATOR_LIBS)
+
+libdummy_indicator_null_la_LDFLAGS = \
+ -module \
+ -avoid-version
+
+#############################
+# Dummy Indicator Simple
+#############################
+
+libdummy_indicator_simple_la_SOURCES = \
+ dummy-indicator-simple.c
+
+libdummy_indicator_simple_la_CFLAGS = \
+ -Wall -Werror \
+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
+
+libdummy_indicator_simple_la_LIBADD = \
+ $(LIBINDICATOR_LIBS)
+
+libdummy_indicator_simple_la_LDFLAGS = \
+ -module \
+ -avoid-version
+
+#############################
+# Test stuff
+#############################
+
+XML_REPORT = loader-check-results.xml
+HTML_REPORT = loader-check-results.html
+
+loader-tester: test-loader libdummy-indicator-null.la libdummy-indicator-simple.la
+ @gtester -k --verbose -o=$(XML_REPORT) ./test-loader
+
+check-local: loader-tester
+
+DISTCLEANFILES = $(XML_REPORT) $(HTML_REPORT)
+
diff --git a/tests/dummy-indicator-blank.c b/tests/dummy-indicator-blank.c
new file mode 100644
index 0000000..41249f2
--- /dev/null
+++ b/tests/dummy-indicator-blank.c
@@ -0,0 +1,6 @@
+
+#include "libindicator/indicator.h"
+
+INDICATOR_SET_VERSION
+INDICATOR_SET_NAME("dummy-indicator-null")
+
diff --git a/tests/dummy-indicator-null.c b/tests/dummy-indicator-null.c
new file mode 100644
index 0000000..ff99d71
--- /dev/null
+++ b/tests/dummy-indicator-null.c
@@ -0,0 +1,23 @@
+
+#include "libindicator/indicator.h"
+
+INDICATOR_SET_VERSION
+INDICATOR_SET_NAME("dummy-indicator-null")
+
+GtkLabel *
+get_label (void)
+{
+ return NULL;
+}
+
+GtkImage *
+get_icon (void)
+{
+ return NULL;
+}
+
+GtkMenu *
+get_menu (void)
+{
+ return NULL;
+}
diff --git a/tests/dummy-indicator-simple.c b/tests/dummy-indicator-simple.c
new file mode 100644
index 0000000..cee4eac
--- /dev/null
+++ b/tests/dummy-indicator-simple.c
@@ -0,0 +1,28 @@
+
+#include "libindicator/indicator.h"
+
+INDICATOR_SET_VERSION
+INDICATOR_SET_NAME("dummy-indicator-simple")
+
+GtkLabel *
+get_label (void)
+{
+ return GTK_LABEL(gtk_label_new("Simple Item"));
+}
+
+GtkImage *
+get_icon (void)
+{
+ return GTK_IMAGE(gtk_image_new());
+}
+
+GtkMenu *
+get_menu (void)
+{
+ GtkMenu * main_menu = GTK_MENU(gtk_menu_new());
+ GtkWidget * loading_item = gtk_menu_item_new_with_label("Loading...");
+ gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), loading_item);
+ gtk_widget_show(GTK_WIDGET(loading_item));
+
+ return main_menu;
+}
diff --git a/tests/test-loader.c b/tests/test-loader.c
new file mode 100644
index 0000000..4b2b096
--- /dev/null
+++ b/tests/test-loader.c
@@ -0,0 +1,109 @@
+#include <gtk/gtk.h>
+#include "libindicator/indicator-object.h"
+
+void destroy_cb (gpointer data, GObject * object);
+
+void
+test_loader_filename_dummy_simple_accessors (void)
+{
+ IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-simple.so");
+ g_assert(object != NULL);
+
+ g_assert(indicator_object_get_label(object) != NULL);
+ g_assert(indicator_object_get_menu(object) != NULL);
+ g_assert(indicator_object_get_icon(object) != NULL);
+
+ g_object_unref(object);
+
+ return;
+}
+
+void
+test_loader_filename_dummy_simple (void)
+{
+ IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-simple.so");
+ g_assert(object != NULL);
+
+ gboolean unreffed = FALSE;
+ g_object_weak_ref(G_OBJECT(object), destroy_cb, &unreffed);
+
+ g_object_unref(object);
+ g_assert(unreffed == TRUE);
+
+ return;
+}
+
+void
+test_loader_filename_dummy_blank (void)
+{
+ IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-blank.so");
+ g_assert(object == NULL);
+ return;
+}
+
+void
+test_loader_filename_dummy_null (void)
+{
+ IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-null.so");
+ g_assert(object == NULL);
+ return;
+}
+
+void
+test_loader_filename_bad (void)
+{
+ IndicatorObject * object = indicator_object_new_from_file("/this/file/should/not/exist.so");
+ g_assert(object == NULL);
+ return;
+}
+
+void
+destroy_cb (gpointer data, GObject * object)
+{
+ gboolean * bob = (gboolean *)data;
+ *bob = TRUE;
+ return;
+}
+
+void
+test_loader_refunref (void)
+{
+ GObject * object = g_object_new(INDICATOR_OBJECT_TYPE, NULL);
+
+ gboolean unreffed = FALSE;
+ g_object_weak_ref(object, destroy_cb, &unreffed);
+
+ g_object_unref(object);
+
+ g_assert(unreffed == TRUE);
+
+ return;
+}
+
+void
+test_loader_creation_deletion_suite (void)
+{
+ g_test_add_func ("/libindicator/loader/ref_and_unref", test_loader_refunref);
+ g_test_add_func ("/libindicator/loader/filename_bad", test_loader_filename_bad);
+ g_test_add_func ("/libindicator/loader/dummy/null_load", test_loader_filename_dummy_null);
+ g_test_add_func ("/libindicator/loader/dummy/blank_load", test_loader_filename_dummy_null);
+ g_test_add_func ("/libindicator/loader/dummy/simple_load", test_loader_filename_dummy_simple);
+ g_test_add_func ("/libindicator/loader/dummy/simple_accessors", test_loader_filename_dummy_simple_accessors);
+
+ return;
+}
+
+
+int
+main (int argc, char ** argv)
+{
+ g_type_init ();
+ g_test_init (&argc, &argv, NULL);
+ gtk_init(&argc, &argv);
+
+ test_loader_creation_deletion_suite();
+
+ g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
+
+ return g_test_run();
+}