aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am37
-rw-r--r--tests/dummy-indicator-blank.c1
-rw-r--r--tests/dummy-indicator-null.c80
-rw-r--r--tests/dummy-indicator-signaler.c109
-rw-r--r--tests/dummy-indicator-simple.c78
-rw-r--r--tests/test-loader.c45
6 files changed, 333 insertions, 17 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7c306bc..80c4191 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -11,6 +11,7 @@ check_PROGRAMS = \
lib_LTLIBRARIES = \
libdummy-indicator-blank.la \
libdummy-indicator-null.la \
+ libdummy-indicator-signaler.la \
libdummy-indicator-simple.la
DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf
@@ -28,7 +29,9 @@ test_loader_CFLAGS = \
-DBUILD_DIR="\"$(builddir)\""
test_loader_LDADD = \
- $(LIBINDICATOR_LIBS) $(top_builddir)/libindicator/.libs/libindicator.a
+ $(LIBINDICATOR_LIBS) \
+ -L$(top_builddir)/libindicator/.libs \
+ -lindicator
#############################
# Dummy Indicator Blank
@@ -42,7 +45,9 @@ libdummy_indicator_blank_la_CFLAGS = \
$(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
libdummy_indicator_blank_la_LIBADD = \
- $(LIBINDICATOR_LIBS)
+ $(LIBINDICATOR_LIBS) \
+ -L$(top_builddir)/libindicator/.libs \
+ -lindicator
libdummy_indicator_blank_la_LDFLAGS = \
-module \
@@ -60,13 +65,35 @@ libdummy_indicator_null_la_CFLAGS = \
$(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
libdummy_indicator_null_la_LIBADD = \
- $(LIBINDICATOR_LIBS)
+ $(LIBINDICATOR_LIBS) \
+ -L$(top_builddir)/libindicator/.libs \
+ -lindicator
libdummy_indicator_null_la_LDFLAGS = \
-module \
-avoid-version
#############################
+# Dummy Indicator Signaler
+#############################
+
+libdummy_indicator_signaler_la_SOURCES = \
+ dummy-indicator-signaler.c
+
+libdummy_indicator_signaler_la_CFLAGS = \
+ -Wall -Werror \
+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
+
+libdummy_indicator_signaler_la_LIBADD = \
+ $(LIBINDICATOR_LIBS) \
+ -L$(top_builddir)/libindicator/.libs \
+ -lindicator
+
+libdummy_indicator_signaler_la_LDFLAGS = \
+ -module \
+ -avoid-version
+
+#############################
# Dummy Indicator Simple
#############################
@@ -78,7 +105,9 @@ libdummy_indicator_simple_la_CFLAGS = \
$(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
libdummy_indicator_simple_la_LIBADD = \
- $(LIBINDICATOR_LIBS)
+ $(LIBINDICATOR_LIBS) \
+ -L$(top_builddir)/libindicator/.libs \
+ -lindicator
libdummy_indicator_simple_la_LDFLAGS = \
-module \
diff --git a/tests/dummy-indicator-blank.c b/tests/dummy-indicator-blank.c
index 41249f2..5cfe0f0 100644
--- a/tests/dummy-indicator-blank.c
+++ b/tests/dummy-indicator-blank.c
@@ -2,5 +2,4 @@
#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
index ff99d71..767067d 100644
--- a/tests/dummy-indicator-null.c
+++ b/tests/dummy-indicator-null.c
@@ -1,23 +1,95 @@
+#include <glib.h>
+#include <glib-object.h>
+
#include "libindicator/indicator.h"
+#include "libindicator/indicator-object.h"
+
+#define DUMMY_INDICATOR_NULL_TYPE (dummy_indicator_null_get_type ())
+#define DUMMY_INDICATOR_NULL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DUMMY_INDICATOR_NULL_TYPE, DummyIndicatorNull))
+#define DUMMY_INDICATOR_NULL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DUMMY_INDICATOR_NULL_TYPE, DummyIndicatorNullClass))
+#define IS_DUMMY_INDICATOR_NULL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DUMMY_INDICATOR_NULL_TYPE))
+#define IS_DUMMY_INDICATOR_NULL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DUMMY_INDICATOR_NULL_TYPE))
+#define DUMMY_INDICATOR_NULL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DUMMY_INDICATOR_NULL_TYPE, DummyIndicatorNullClass))
+
+typedef struct _DummyIndicatorNull DummyIndicatorNull;
+typedef struct _DummyIndicatorNullClass DummyIndicatorNullClass;
+
+struct _DummyIndicatorNullClass {
+ IndicatorObjectClass parent_class;
+};
+
+struct _DummyIndicatorNull {
+ IndicatorObject parent;
+};
+
+GType dummy_indicator_null_get_type (void);
INDICATOR_SET_VERSION
-INDICATOR_SET_NAME("dummy-indicator-null")
+INDICATOR_SET_TYPE(DUMMY_INDICATOR_NULL_TYPE)
+
GtkLabel *
-get_label (void)
+get_label (IndicatorObject * io)
{
return NULL;
}
GtkImage *
-get_icon (void)
+get_icon (IndicatorObject * io)
{
return NULL;
}
GtkMenu *
-get_menu (void)
+get_menu (IndicatorObject * io)
{
return NULL;
}
+
+static void dummy_indicator_null_class_init (DummyIndicatorNullClass *klass);
+static void dummy_indicator_null_init (DummyIndicatorNull *self);
+static void dummy_indicator_null_dispose (GObject *object);
+static void dummy_indicator_null_finalize (GObject *object);
+
+G_DEFINE_TYPE (DummyIndicatorNull, dummy_indicator_null, INDICATOR_OBJECT_TYPE);
+
+static void
+dummy_indicator_null_class_init (DummyIndicatorNullClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = dummy_indicator_null_dispose;
+ object_class->finalize = dummy_indicator_null_finalize;
+
+ IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass);
+
+ io_class->get_label = get_label;
+ io_class->get_image = get_icon;
+ io_class->get_menu = get_menu;
+
+ return;
+}
+
+static void
+dummy_indicator_null_init (DummyIndicatorNull *self)
+{
+
+ return;
+}
+
+static void
+dummy_indicator_null_dispose (GObject *object)
+{
+
+ G_OBJECT_CLASS (dummy_indicator_null_parent_class)->dispose (object);
+ return;
+}
+
+static void
+dummy_indicator_null_finalize (GObject *object)
+{
+
+ G_OBJECT_CLASS (dummy_indicator_null_parent_class)->finalize (object);
+ return;
+}
diff --git a/tests/dummy-indicator-signaler.c b/tests/dummy-indicator-signaler.c
new file mode 100644
index 0000000..0444110
--- /dev/null
+++ b/tests/dummy-indicator-signaler.c
@@ -0,0 +1,109 @@
+#include <glib.h>
+#include <glib-object.h>
+
+#include "libindicator/indicator.h"
+#include "libindicator/indicator-object.h"
+
+#define DUMMY_INDICATOR_SIGNALER_TYPE (dummy_indicator_signaler_get_type ())
+#define DUMMY_INDICATOR_SIGNALER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DUMMY_INDICATOR_SIGNALER_TYPE, DummyIndicatorSignaler))
+#define DUMMY_INDICATOR_SIGNALER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DUMMY_INDICATOR_SIGNALER_TYPE, DummyIndicatorSignalerClass))
+#define IS_DUMMY_INDICATOR_SIGNALER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DUMMY_INDICATOR_SIGNALER_TYPE))
+#define IS_DUMMY_INDICATOR_SIGNALER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DUMMY_INDICATOR_SIGNALER_TYPE))
+#define DUMMY_INDICATOR_SIGNALER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DUMMY_INDICATOR_SIGNALER_TYPE, DummyIndicatorSignalerClass))
+
+typedef struct _DummyIndicatorSignaler DummyIndicatorSignaler;
+typedef struct _DummyIndicatorSignalerClass DummyIndicatorSignalerClass;
+
+struct _DummyIndicatorSignalerClass {
+ IndicatorObjectClass parent_class;
+};
+
+struct _DummyIndicatorSignaler {
+ IndicatorObject parent;
+};
+
+GType dummy_indicator_signaler_get_type (void);
+
+INDICATOR_SET_VERSION
+INDICATOR_SET_TYPE(DUMMY_INDICATOR_SIGNALER_TYPE)
+
+GtkLabel *
+get_label (IndicatorObject * io)
+{
+ return GTK_LABEL(gtk_label_new("Signaler Item"));
+}
+
+GtkImage *
+get_icon (IndicatorObject * io)
+{
+ return GTK_IMAGE(gtk_image_new());
+}
+
+GtkMenu *
+get_menu (IndicatorObject * io)
+{
+ 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;
+}
+
+static void dummy_indicator_signaler_class_init (DummyIndicatorSignalerClass *klass);
+static void dummy_indicator_signaler_init (DummyIndicatorSignaler *self);
+static void dummy_indicator_signaler_dispose (GObject *object);
+static void dummy_indicator_signaler_finalize (GObject *object);
+
+G_DEFINE_TYPE (DummyIndicatorSignaler, dummy_indicator_signaler, INDICATOR_OBJECT_TYPE);
+
+static void
+dummy_indicator_signaler_class_init (DummyIndicatorSignalerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = dummy_indicator_signaler_dispose;
+ object_class->finalize = dummy_indicator_signaler_finalize;
+
+ IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass);
+
+ io_class->get_label = get_label;
+ io_class->get_image = get_icon;
+ io_class->get_menu = get_menu;
+
+ return;
+}
+
+static gboolean
+idle_signal (gpointer data)
+{
+ DummyIndicatorSignaler * self = DUMMY_INDICATOR_SIGNALER(data);
+
+ g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID, 0, GUINT_TO_POINTER(5), TRUE);
+ g_signal_emit(G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, GUINT_TO_POINTER(5), TRUE);
+
+ return FALSE; /* Don't queue again */
+}
+
+static void
+dummy_indicator_signaler_init (DummyIndicatorSignaler *self)
+{
+ g_idle_add(idle_signal, self);
+ return;
+}
+
+static void
+dummy_indicator_signaler_dispose (GObject *object)
+{
+
+ G_OBJECT_CLASS (dummy_indicator_signaler_parent_class)->dispose (object);
+ return;
+}
+
+static void
+dummy_indicator_signaler_finalize (GObject *object)
+{
+
+ G_OBJECT_CLASS (dummy_indicator_signaler_parent_class)->finalize (object);
+ return;
+}
diff --git a/tests/dummy-indicator-simple.c b/tests/dummy-indicator-simple.c
index cee4eac..654650f 100644
--- a/tests/dummy-indicator-simple.c
+++ b/tests/dummy-indicator-simple.c
@@ -1,23 +1,46 @@
+#include <glib.h>
+#include <glib-object.h>
#include "libindicator/indicator.h"
+#include "libindicator/indicator-object.h"
+
+#define DUMMY_INDICATOR_SIMPLE_TYPE (dummy_indicator_simple_get_type ())
+#define DUMMY_INDICATOR_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DUMMY_INDICATOR_SIMPLE_TYPE, DummyIndicatorSimple))
+#define DUMMY_INDICATOR_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DUMMY_INDICATOR_SIMPLE_TYPE, DummyIndicatorSimpleClass))
+#define IS_DUMMY_INDICATOR_SIMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DUMMY_INDICATOR_SIMPLE_TYPE))
+#define IS_DUMMY_INDICATOR_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DUMMY_INDICATOR_SIMPLE_TYPE))
+#define DUMMY_INDICATOR_SIMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DUMMY_INDICATOR_SIMPLE_TYPE, DummyIndicatorSimpleClass))
+
+typedef struct _DummyIndicatorSimple DummyIndicatorSimple;
+typedef struct _DummyIndicatorSimpleClass DummyIndicatorSimpleClass;
+
+struct _DummyIndicatorSimpleClass {
+ IndicatorObjectClass parent_class;
+};
+
+struct _DummyIndicatorSimple {
+ IndicatorObject parent;
+};
+
+GType dummy_indicator_simple_get_type (void);
INDICATOR_SET_VERSION
-INDICATOR_SET_NAME("dummy-indicator-simple")
+INDICATOR_SET_TYPE(DUMMY_INDICATOR_SIMPLE_TYPE)
GtkLabel *
-get_label (void)
+get_label (IndicatorObject * io)
{
return GTK_LABEL(gtk_label_new("Simple Item"));
}
GtkImage *
-get_icon (void)
+get_icon (IndicatorObject * io)
{
return GTK_IMAGE(gtk_image_new());
}
GtkMenu *
-get_menu (void)
+get_menu (IndicatorObject * io)
{
GtkMenu * main_menu = GTK_MENU(gtk_menu_new());
GtkWidget * loading_item = gtk_menu_item_new_with_label("Loading...");
@@ -26,3 +49,50 @@ get_menu (void)
return main_menu;
}
+
+static void dummy_indicator_simple_class_init (DummyIndicatorSimpleClass *klass);
+static void dummy_indicator_simple_init (DummyIndicatorSimple *self);
+static void dummy_indicator_simple_dispose (GObject *object);
+static void dummy_indicator_simple_finalize (GObject *object);
+
+G_DEFINE_TYPE (DummyIndicatorSimple, dummy_indicator_simple, INDICATOR_OBJECT_TYPE);
+
+static void
+dummy_indicator_simple_class_init (DummyIndicatorSimpleClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = dummy_indicator_simple_dispose;
+ object_class->finalize = dummy_indicator_simple_finalize;
+
+ IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass);
+
+ io_class->get_label = get_label;
+ io_class->get_image = get_icon;
+ io_class->get_menu = get_menu;
+
+ return;
+}
+
+static void
+dummy_indicator_simple_init (DummyIndicatorSimple *self)
+{
+
+ return;
+}
+
+static void
+dummy_indicator_simple_dispose (GObject *object)
+{
+
+ G_OBJECT_CLASS (dummy_indicator_simple_parent_class)->dispose (object);
+ return;
+}
+
+static void
+dummy_indicator_simple_finalize (GObject *object)
+{
+
+ G_OBJECT_CLASS (dummy_indicator_simple_parent_class)->finalize (object);
+ return;
+}
diff --git a/tests/test-loader.c b/tests/test-loader.c
index 4b2b096..485a951 100644
--- a/tests/test-loader.c
+++ b/tests/test-loader.c
@@ -4,14 +4,48 @@
void destroy_cb (gpointer data, GObject * object);
void
+entry_change_cb (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer data)
+{
+ gpointer * valuestore = (gpointer *)data;
+ *valuestore = entry;
+ return;
+}
+
+void
+test_loader_filename_dummy_signaler (void)
+{
+ IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-signaler.so");
+ g_assert(object != NULL);
+
+ gpointer added_value = NULL, removed_value = NULL;
+
+ g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_change_cb), &added_value);
+ g_signal_connect(G_OBJECT(object), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_change_cb), &removed_value);
+
+ GList * list = indicator_object_get_entries(object);
+ g_assert(list != NULL);
+ g_list_free(list);
+
+ while (g_main_context_pending(NULL)) {
+ g_main_context_iteration(NULL, TRUE);
+ }
+
+ g_assert(GPOINTER_TO_UINT(added_value) == 5);
+ g_assert(GPOINTER_TO_UINT(removed_value) == 5);
+
+ g_object_unref(object);
+
+ return;
+}
+
+
+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_assert(indicator_object_get_entries(object) != NULL);
g_object_unref(object);
@@ -45,7 +79,9 @@ 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);
+ g_assert(object != NULL);
+ g_assert(indicator_object_get_entries(object) == NULL);
+ g_object_unref(G_OBJECT(object));
return;
}
@@ -89,6 +125,7 @@ test_loader_creation_deletion_suite (void)
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);
+ g_test_add_func ("/libindicator/loader/dummy/signaler", test_loader_filename_dummy_signaler);
return;
}