aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-01-29 11:57:42 -0600
committerCharles Kerr <charles.kerr@canonical.com>2013-01-29 11:57:42 -0600
commit345b7af04ab99882da94328308e6a65bc2df5b31 (patch)
treef9e1245b0122adf7c45a0e9bf966ce361131e5de /tests
parent82b3dc0d5c08a789641eeb475d393ceb82c0b959 (diff)
downloadlibayatana-appindicator-345b7af04ab99882da94328308e6a65bc2df5b31.tar.gz
libayatana-appindicator-345b7af04ab99882da94328308e6a65bc2df5b31.tar.bz2
libayatana-appindicator-345b7af04ab99882da94328308e6a65bc2df5b31.zip
flush the dbus connection before exiting test-libappindicator-status-server
Diffstat (limited to 'tests')
-rw-r--r--tests/test-libappindicator-status-client.c2
-rw-r--r--tests/test-libappindicator-status-server.c37
2 files changed, 23 insertions, 16 deletions
diff --git a/tests/test-libappindicator-status-client.c b/tests/test-libappindicator-status-client.c
index 50e9c08..cd60e6c 100644
--- a/tests/test-libappindicator-status-client.c
+++ b/tests/test-libappindicator-status-client.c
@@ -116,7 +116,7 @@ main (gint argc, gchar * argv[])
return 1;
}
- DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+ DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(session_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
guint nameret = 0;
if (!org_freedesktop_DBus_request_name(bus_proxy, NOTIFICATION_WATCHER_DBUS_ADDR, 0, &nameret, &error)) {
diff --git a/tests/test-libappindicator-status-server.c b/tests/test-libappindicator-status-server.c
index 8cd5571..9674f61 100644
--- a/tests/test-libappindicator-status-server.c
+++ b/tests/test-libappindicator-status-server.c
@@ -22,34 +22,39 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdlib.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
#include <glib.h>
#include <app-indicator.h>
static GMainLoop * mainloop = NULL;
static gboolean active = FALSE;
static guint toggle_count = 0;
+static GDBusConnection * connection = NULL;
+
+static gboolean
+times_up (gpointer unused G_GNUC_UNUSED)
+{
+ g_dbus_connection_flush_sync (connection, NULL, NULL);
+ g_clear_object (&connection);
+
+ g_main_loop_quit (mainloop);
+ return G_SOURCE_REMOVE;
+}
gboolean
toggle (gpointer userdata)
{
- if (active) {
- app_indicator_set_status (APP_INDICATOR(userdata), APP_INDICATOR_STATUS_ATTENTION);
- active = FALSE;
- } else {
- app_indicator_set_status (APP_INDICATOR(userdata), APP_INDICATOR_STATUS_ACTIVE);
- active = TRUE;
- }
-
- toggle_count++;
+ const AppIndicatorStatus new_status = active ? APP_INDICATOR_STATUS_ATTENTION
+ : APP_INDICATOR_STATUS_ACTIVE;
+ app_indicator_set_status (APP_INDICATOR(userdata), new_status);
+ ++toggle_count;
+ active = !active;
if (toggle_count == 100) {
- g_main_loop_quit(mainloop);
- return FALSE;
+ g_timeout_add (100, times_up, NULL);
+ return G_SOURCE_REMOVE;
}
- return TRUE;
+ return G_SOURCE_CONTINUE;
}
gint
@@ -59,7 +64,8 @@ main (gint argc, gchar * argv[])
g_usleep(100000);
- g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL))));
+ connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+ g_debug("DBus Name: %s", g_dbus_connection_get_unique_name (connection));
AppIndicator * ci = app_indicator_new ("my-id", "my-icon-name", APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
app_indicator_set_attention_icon (ci, "my-attention-icon");
@@ -76,6 +82,7 @@ main (gint argc, gchar * argv[])
g_main_loop_run(mainloop);
g_object_unref(G_OBJECT(ci));
+
g_debug("Quiting");
return 0;