aboutsummaryrefslogtreecommitdiff
path: root/tests/test-glib-properties-client.c
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-05-19 04:24:27 +0200
committerTed Gould <ted@canonical.com>2009-05-19 04:24:27 +0200
commit17a0a712d5187101216ed937955c6871a000d8b0 (patch)
tree7970a33bd7578dae01fd3d6ec1c721fd63e29141 /tests/test-glib-properties-client.c
parent9f3095425e166de4b82c0066057749edafe3980e (diff)
downloadlibdbusmenu-17a0a712d5187101216ed937955c6871a000d8b0.tar.gz
libdbusmenu-17a0a712d5187101216ed937955c6871a000d8b0.tar.bz2
libdbusmenu-17a0a712d5187101216ed937955c6871a000d8b0.zip
Handling death better. Now we extend our life the more successful we are. Plus if we get through all the layouts we quit right then.
Diffstat (limited to 'tests/test-glib-properties-client.c')
-rw-r--r--tests/test-glib-properties-client.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/tests/test-glib-properties-client.c b/tests/test-glib-properties-client.c
index 11cd70d..d840217 100644
--- a/tests/test-glib-properties-client.c
+++ b/tests/test-glib-properties-client.c
@@ -29,6 +29,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
static guint layouton = 0;
static GMainLoop * mainloop = NULL;
static gboolean passed = TRUE;
+static guint death_timer = 0;
static gboolean
verify_props (DbusmenuMenuitem * mi, gchar ** properties)
@@ -90,6 +91,15 @@ verify_root_to_layout(DbusmenuMenuitem * mi, proplayout_t * layout)
return FALSE;
}
+static gboolean
+timer_func (gpointer data)
+{
+ g_debug("Death timer. Oops. Got to: %d", layouton);
+ passed = FALSE;
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
static void
layout_updated (DbusmenuClient * client, gpointer data)
{
@@ -99,35 +109,35 @@ layout_updated (DbusmenuClient * client, gpointer data)
proplayout_t * layout = &layouts[layouton];
if (!verify_root_to_layout(menuroot, layout)) {
- g_debug("Failed layout: %d", layouton);
+ g_debug("FAILED LAYOUT: %d", layouton);
passed = FALSE;
+ } else {
+ /* Extend our death */
+ g_source_remove(death_timer);
+ death_timer = g_timeout_add_seconds(10, timer_func, client);
}
layouton++;
+
+ if (layouts[layouton].id == 0) {
+ g_main_loop_quit(mainloop);
+ }
return;
}
-static gboolean
-timer_func (gpointer data)
-{
- g_debug("Death timer. Oops. Got to: %d", layouton);
- passed = FALSE;
- g_main_loop_quit(mainloop);
- return FALSE;
-}
-
int
main (int argc, char ** argv)
{
g_type_init();
+ /* Make sure the server starts up and all that */
g_usleep(500000);
DbusmenuClient * client = dbusmenu_client_new(":1.0", "/org/test");
g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(layout_updated), NULL);
- g_timeout_add_seconds(10, timer_func, client);
+ death_timer = g_timeout_add_seconds(10, timer_func, client);
mainloop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(mainloop);