aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-12-03 21:37:58 -0600
committerTed Gould <ted@gould.cx>2010-12-03 21:37:58 -0600
commit2855f7ddc41cee49729cc94a43a3bead2de22055 (patch)
treef04bc5fb347c145d8ee5a015967ccfb2e3faaa85 /tests
parent40c2ed841e817647a7f9bf0798815bbf8279769c (diff)
parent671666f8ece765624fe6f2c94e6ece24688c5b8c (diff)
downloadlibayatana-appindicator-2855f7ddc41cee49729cc94a43a3bead2de22055.tar.gz
libayatana-appindicator-2855f7ddc41cee49729cc94a43a3bead2de22055.tar.bz2
libayatana-appindicator-2855f7ddc41cee49729cc94a43a3bead2de22055.zip
Merging in removing of the service
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am60
-rw-r--r--tests/test-approver.c179
2 files changed, 16 insertions, 223 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f2bdbb2..5b7879c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,5 @@
check_PROGRAMS = \
- test-approver \
test-libappindicator \
test-libappindicator-dbus-client \
test-libappindicator-dbus-server \
@@ -23,12 +22,12 @@ test_libappindicator_SOURCES = \
test-libappindicator.c
test_libappindicator_CFLAGS = \
- $(INDICATOR_CFLAGS) \
+ $(LIBRARY_CFLAGS) \
-Wall -Werror \
-I$(top_srcdir)/src
test_libappindicator_LDADD = \
- $(INDICATOR_LIBS) \
+ $(LIBRARY_LIBS) \
$(top_builddir)/src/libappindicator.la
#########################################
@@ -40,12 +39,12 @@ test_libappindicator_dbus_client_SOURCES = \
test-libappindicator-dbus-client.c
test_libappindicator_dbus_client_CFLAGS = \
- $(INDICATOR_CFLAGS) \
+ $(LIBRARY_CFLAGS) \
-Wall -Werror \
-I$(top_srcdir)/src
test_libappindicator_dbus_client_LDADD = \
- $(INDICATOR_LIBS) \
+ $(LIBRARY_LIBS) \
$(top_builddir)/src/libappindicator.la
#########################################
@@ -57,12 +56,12 @@ test_libappindicator_dbus_server_SOURCES = \
test-libappindicator-dbus-server.c
test_libappindicator_dbus_server_CFLAGS = \
- $(INDICATOR_CFLAGS) \
+ $(LIBRARY_CFLAGS) \
-Wall -Werror \
-I$(top_srcdir)/src
test_libappindicator_dbus_server_LDADD = \
- $(INDICATOR_LIBS) \
+ $(LIBRARY_LIBS) \
$(top_builddir)/src/libappindicator.la
#########################################
@@ -74,12 +73,12 @@ test_libappindicator_status_client_SOURCES = \
test-libappindicator-status-client.c
test_libappindicator_status_client_CFLAGS = \
- $(INDICATOR_CFLAGS) \
+ $(LIBRARY_CFLAGS) \
-Wall -Werror \
-I$(top_srcdir)/src
test_libappindicator_status_client_LDADD = \
- $(INDICATOR_LIBS) \
+ $(LIBRARY_LIBS) \
$(top_builddir)/src/libappindicator.la
#########################################
@@ -91,42 +90,15 @@ test_libappindicator_status_server_SOURCES = \
test-libappindicator-status-server.c
test_libappindicator_status_server_CFLAGS = \
- $(INDICATOR_CFLAGS) \
+ $(LIBRARY_CFLAGS) \
-Wall -Werror \
-I$(top_srcdir)/src
test_libappindicator_status_server_LDADD = \
- $(INDICATOR_LIBS) \
+ $(LIBRARY_LIBS) \
$(top_builddir)/src/libappindicator.la
#########################################
-## test-approver
-#########################################
-
-test_approver_SOURCES = \
- test-approver.c
-
-test_approver_CFLAGS = \
- $(INDICATOR_CFLAGS) \
- -Wall -Werror \
- -I$(top_srcdir)/src \
- -I$(top_builddir)/src
-
-test_approver_LDADD = \
- $(INDICATOR_LIBS) \
- $(top_builddir)/src/libappindicator.la
-
-test-approver-tester: test-approver Makefile.am
- @echo "#!/bin/bash" > $@
- @echo export INDICATOR_SERVICE_SHUTDOWN_TIMEOUT=1000 >> $@
- @echo . $(srcdir)/run-xvfb.sh >> $@
- @echo $(DBUS_RUNNER) --task $(builddir)/test-approver --task-name Approver --task $(top_builddir)/src/indicator-application-service --task-name Service --ignore-return >> $@
- @chmod +x $@
-
-TESTS += test-approver-tester
-
-
-#########################################
## test-libappindicator-fallback
#########################################
@@ -134,24 +106,24 @@ test_libappindicator_fallback_watcher_SOURCES = \
test-libappindicator-fallback-watcher.c
test_libappindicator_fallback_watcher_CFLAGS = \
- $(INDICATOR_CFLAGS) \
+ $(LIBRARY_CFLAGS) \
-Wall -Werror \
-I$(top_srcdir)/src
test_libappindicator_fallback_watcher_LDADD = \
- $(INDICATOR_LIBS) \
+ $(LIBRARY_LIBS) \
$(top_builddir)/src/libappindicator.la
test_libappindicator_fallback_item_SOURCES = \
test-libappindicator-fallback-item.c
test_libappindicator_fallback_item_CFLAGS = \
- $(INDICATOR_CFLAGS) \
+ $(LIBRARY_CFLAGS) \
-Wall -Werror \
-I$(top_srcdir)/src
test_libappindicator_fallback_item_LDADD = \
- $(INDICATOR_LIBS) \
+ $(LIBRARY_LIBS) \
$(top_builddir)/src/libappindicator.la
test-libappindicator-fallback: test-libappindicator-fallback-watcher test-libappindicator-fallback-item Makefile.am
@@ -210,11 +182,11 @@ test_simple_app_SOURCES = \
test-simple-app.c
test_simple_app_CFLAGS = \
- $(INDICATOR_CFLAGS) \
+ $(LIBRARY_CFLAGS) \
-Wall -Werror \
-I$(top_srcdir)/src
test_simple_app_LDADD = \
- $(INDICATOR_LIBS) \
+ $(LIBRARY_LIBS) \
$(top_builddir)/src/libappindicator.la
diff --git a/tests/test-approver.c b/tests/test-approver.c
deleted file mode 100644
index 2665505..0000000
--- a/tests/test-approver.c
+++ /dev/null
@@ -1,179 +0,0 @@
-#include <glib.h>
-#include <glib-object.h>
-
-#include <dbus/dbus-glib-bindings.h>
-
-#include "notification-watcher-client.h"
-#include "dbus-shared.h"
-#include "app-indicator.h"
-
-#define APPROVER_PATH "/my/approver"
-
-#define INDICATOR_ID "test-indicator-id"
-#define INDICATOR_ICON "test-indicator-icon-name"
-#define INDICATOR_CATEGORY APP_INDICATOR_CATEGORY_APPLICATION_STATUS
-
-#define TEST_APPROVER_TYPE (test_approver_get_type ())
-#define TEST_APPROVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_APPROVER_TYPE, TestApprover))
-#define TEST_APPROVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEST_APPROVER_TYPE, TestApproverClass))
-#define IS_TEST_APPROVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_APPROVER_TYPE))
-#define IS_TEST_APPROVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEST_APPROVER_TYPE))
-#define TEST_APPROVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_APPROVER_TYPE, TestApproverClass))
-
-typedef struct _TestApprover TestApprover;
-typedef struct _TestApproverClass TestApproverClass;
-
-struct _TestApproverClass {
- GObjectClass parent_class;
-};
-
-struct _TestApprover {
- GObject parent;
-};
-
-GType test_approver_get_type (void);
-
-static void test_approver_class_init (TestApproverClass *klass);
-static void test_approver_init (TestApprover *self);
-static gboolean _notification_approver_server_approve_item (TestApprover * ta, const gchar * id, const gchar * category, guint pid, const gchar * address, const gchar * path, gboolean * approved, GError ** error);
-
-#include "../src/notification-approver-server.h"
-
-GMainLoop * main_loop = NULL;
-DBusGConnection * session_bus = NULL;
-DBusGProxy * bus_proxy = NULL;
-AppIndicator * app_indicator = NULL;
-gboolean passed = FALSE;
-
-G_DEFINE_TYPE (TestApprover, test_approver, G_TYPE_OBJECT);
-
-static void
-test_approver_class_init (TestApproverClass *klass)
-{
- dbus_g_object_type_install_info(TEST_APPROVER_TYPE,
- &dbus_glib__notification_approver_server_object_info);
-
- return;
-}
-
-static void
-test_approver_init (TestApprover *self)
-{
- dbus_g_connection_register_g_object(session_bus,
- APPROVER_PATH,
- G_OBJECT(self));
-
- return;
-}
-
-static gboolean
-_notification_approver_server_approve_item (TestApprover * ta, const gchar * id, const gchar * category, guint pid, const gchar * address, const gchar * path, gboolean * approved, GError ** error)
-{
- *approved = TRUE;
- g_debug("Asked to approve indicator");
-
- if (g_strcmp0(id, INDICATOR_ID) == 0) {
- passed = TRUE;
- }
-
- g_main_loop_quit(main_loop);
-
- return TRUE;
-}
-
-static void
-register_cb (DBusGProxy * proxy, GError * error, gpointer user_data)
-{
- if (error != NULL) {
- g_warning("Unable to register approver: %s", error->message);
- g_error_free(error);
- g_main_loop_quit(main_loop);
- return;
- }
-
- g_debug("Building App Indicator");
- app_indicator = app_indicator_new(INDICATOR_ID, INDICATOR_ICON, INDICATOR_CATEGORY);
-
- GtkWidget * menu = gtk_menu_new();
- GtkWidget * mi = gtk_image_menu_item_new_from_stock(GTK_STOCK_ABOUT, NULL);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), mi);
-
- app_indicator_set_menu(app_indicator, GTK_MENU(menu));
-
- return;
-}
-
-gint owner_count = 0;
-gboolean
-check_for_service (gpointer user_data)
-{
- g_debug("Checking for Watcher");
-
- if (owner_count > 100) {
- g_warning("Couldn't find watcher after 100 tries.");
- g_main_loop_quit(main_loop);
- return FALSE;
- }
-
- owner_count++;
-
- gboolean has_owner = FALSE;
- org_freedesktop_DBus_name_has_owner(bus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, &has_owner, NULL);
-
- if (has_owner) {
- const char * cats = NULL;
- DBusGProxy * proxy = dbus_g_proxy_new_for_name(session_bus,
- NOTIFICATION_WATCHER_DBUS_ADDR,
- NOTIFICATION_WATCHER_DBUS_OBJ,
- NOTIFICATION_WATCHER_DBUS_IFACE);
-
- g_debug("Registering Approver");
- org_kde_StatusNotifierWatcher_x_ayatana_register_notification_approver_async (proxy, APPROVER_PATH, &cats, register_cb, NULL);
-
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-fail_timeout (gpointer user_data)
-{
- g_debug("Failure timeout initiated.");
- g_main_loop_quit(main_loop);
- return FALSE;
-}
-
-int
-main (int argc, char ** argv)
-{
- GError * error = NULL;
-
- gtk_init(&argc, &argv);
- g_debug("Initing");
-
- session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
- if (error != NULL) {
- g_warning("Unable to get session bus: %s", error->message);
- g_error_free(error);
- return -1;
- }
-
- TestApprover * approver = g_object_new(TEST_APPROVER_TYPE, NULL);
-
- bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
-
- g_timeout_add(100, check_for_service, NULL);
- g_timeout_add_seconds(2, fail_timeout, NULL);
-
- main_loop = g_main_loop_new(NULL, FALSE);
- g_main_loop_run(main_loop);
-
- g_object_unref(approver);
-
- if (!passed) {
- return -1;
- }
-
- return 0;
-}