From 17a0a712d5187101216ed937955c6871a000d8b0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 19 May 2009 04:24:27 +0200 Subject: 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. --- tests/test-glib-properties-client.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'tests/test-glib-properties-client.c') 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 . 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); -- cgit v1.2.3