aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-02-09 18:19:57 +0100
committerLars Uebernickel <lars.uebernickel@canonical.com>2012-02-09 18:19:57 +0100
commit7cfac76de2725dc1b6848f6640e0334e88d561cf (patch)
tree0e8b2a9058d0e0bdd05c7dd2c9f713951ed0d993 /test
parent768e63b62c50cc6867fb1b685ab1f941a11b2aae (diff)
downloadayatana-indicator-printers-7cfac76de2725dc1b6848f6640e0334e88d561cf.tar.gz
ayatana-indicator-printers-7cfac76de2725dc1b6848f6640e0334e88d561cf.tar.bz2
ayatana-indicator-printers-7cfac76de2725dc1b6848f6640e0334e88d561cf.zip
Add mock cups notifier (only sends one message for now)
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am15
-rw-r--r--test/mock-cups-notifier.c52
2 files changed, 67 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..d07a786
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,15 @@
+
+bin_PROGRAMS = mock-cups-notifier
+DISTCLEANFILES = mock-cups-notifier
+
+mock_cups_notifier_SOURCES = \
+ mock-cups-notifier.c \
+ $(top_builddir)/src/cups-notifier.c \
+ $(top_builddir)/src/cups-notifier.h
+
+mock_cups_notifier_CPPFLAGS = \
+ $(SERVICE_CFLAGS) \
+ -I$(top_builddir)/src
+
+mock_cups_notifier_LDADD = $(SERVICE_LIBS)
+
diff --git a/test/mock-cups-notifier.c b/test/mock-cups-notifier.c
new file mode 100644
index 0000000..10d5fe5
--- /dev/null
+++ b/test/mock-cups-notifier.c
@@ -0,0 +1,52 @@
+
+#include <glib.h>
+#include <cups-notifier.h>
+
+
+int main (int argc, char **argv)
+{
+ GMainLoop *loop;
+ CupsNotifier *notifier;
+ GDBusConnection *con;
+ GError *error = NULL;
+
+ g_type_init ();
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ con = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error) {
+ g_printerr ("Error getting system bus: %s\n", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ notifier = cups_notifier_skeleton_new ();
+
+ g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (notifier),
+ con,
+ "/org/cups/cupsd/Notifier",
+ &error);
+ if (error) {
+ g_printerr ("Error exporting cups Notifier object: %s\n", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ cups_notifier_emit_printer_state_changed (notifier,
+ "Printer state changed!",
+ "file:///tmp/print",
+ "hp-LaserJet-1012",
+ 5,
+ "toner-low",
+ FALSE);
+
+ g_main_context_iteration (NULL, FALSE);
+
+out:
+ g_clear_object (&notifier);
+ g_clear_object (&con);
+ g_main_loop_unref (loop);
+ return 0;
+}
+