diff options
-rw-r--r-- | tests/test-glib-proxy-client.c | 24 | ||||
-rw-r--r-- | tests/test-glib-proxy-server.c | 25 | ||||
-rw-r--r-- | tests/test-glib-proxy.h | 4 |
3 files changed, 41 insertions, 12 deletions
diff --git a/tests/test-glib-proxy-client.c b/tests/test-glib-proxy-client.c index 50ad5d3..0ae2e20 100644 --- a/tests/test-glib-proxy-client.c +++ b/tests/test-glib-proxy-client.c @@ -26,10 +26,11 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "test-glib-proxy.h" -static guint layouton = -1; +static guint layouton = -2; static GMainLoop * mainloop = NULL; static gboolean passed = TRUE; static guint death_timer = 0; +static guint verify_timer = 0; static gboolean verify_props (DbusmenuMenuitem * mi, gchar ** properties) @@ -118,16 +119,22 @@ layout_updated (DbusmenuClient * client, gpointer data) g_debug("\tIgnored, no root"); return; } - layouton++; - g_timeout_add (1500, layout_verify_timer, client); + if (verify_timer != 0) { + g_source_remove(verify_timer); + } + + verify_timer = g_timeout_add (3000, layout_verify_timer, client); return; } static gboolean layout_verify_timer (gpointer data) { - g_debug("Verifing Layout: %d", layouton); DbusmenuMenuitem * menuroot = dbusmenu_client_get_root(DBUSMENU_CLIENT(data)); + layouton = dbusmenu_menuitem_property_get_int(menuroot, LAYOUT_ON); + + g_debug("Verifing Layout: %d", layouton); + verify_timer = 0; proplayout_t * layout = &layouts[layouton]; if (!verify_root_to_layout(menuroot, layout)) { @@ -136,13 +143,18 @@ layout_verify_timer (gpointer data) } else { /* Extend our death */ g_source_remove(death_timer); - death_timer = g_timeout_add_seconds(10, timer_func, data); + death_timer = g_timeout_add_seconds(4, timer_func, data); } if (layouts[layouton+1].id == -1) { g_main_loop_quit(mainloop); } + GValue value = {0}; + g_value_init(&value, G_TYPE_INT); + g_value_set_int(&value, 0); + dbusmenu_menuitem_handle_event(menuroot, "clicked", &value, layouton); + return FALSE; } @@ -154,7 +166,7 @@ main (int argc, char ** argv) DbusmenuClient * client = dbusmenu_client_new("test.proxy.first_proxy", "/org/test"); g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(layout_updated), NULL); - death_timer = g_timeout_add_seconds(10, timer_func, client); + death_timer = g_timeout_add_seconds(4, timer_func, client); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); diff --git a/tests/test-glib-proxy-server.c b/tests/test-glib-proxy-server.c index cba8ec7..f32b426 100644 --- a/tests/test-glib-proxy-server.c +++ b/tests/test-glib-proxy-server.c @@ -69,22 +69,39 @@ layout2menuitem (proplayout_t * layout) static guint layouton = 0; static DbusmenuServer * server = NULL; static GMainLoop * mainloop = NULL; +static guint death_timer = 0; static gboolean timer_func (gpointer data) { + g_debug("Death timer. Oops. Got to: %d", layouton); + g_main_loop_quit(mainloop); + return FALSE; +} + +static void +layout_change (DbusmenuMenuitem * oldroot, guint timestamp, gpointer data) +{ if (layouts[layouton].id == -1) { g_main_loop_quit(mainloop); - return FALSE; + return; } g_debug("Updating to Layout %d", layouton); DbusmenuMenuitem * mi = layout2menuitem(&layouts[layouton]); + g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(layout_change), NULL); + dbusmenu_menuitem_property_set_int(mi, LAYOUT_ON, layouton); dbusmenu_server_set_root(server, mi); g_object_unref(G_OBJECT(mi)); layouton++; - return TRUE; + /* Extend our death */ + if (death_timer != 0) { + g_source_remove(death_timer); + } + death_timer = g_timeout_add_seconds(4, timer_func, data); + + return; } int @@ -111,9 +128,7 @@ main (int argc, char ** argv) } server = dbusmenu_server_new("/org/test"); - - timer_func(NULL); - g_timeout_add(2500, timer_func, NULL); + layout_change(NULL, 0, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); diff --git a/tests/test-glib-proxy.h b/tests/test-glib-proxy.h index bc12df6..7bb58b6 100644 --- a/tests/test-glib-proxy.h +++ b/tests/test-glib-proxy.h @@ -22,6 +22,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <glib.h> +#define LAYOUT_ON "proxy-layout-on" + typedef struct _proplayout_t proplayout_t; struct _proplayout_t { gint id; @@ -132,7 +134,7 @@ proplayout_t submenu_5_1[] = { }; proplayout_t layouts[] = { - {id: 1, properties: props1, submenu: NULL}, + {id: 1, properties: props1, submenu: submenu_5_5}, {id: 10, properties: props2, submenu: submenu_4_1}, {id: 20, properties: props3, submenu: submenu_4_2}, {id: 100, properties: props2, submenu: submenu_4_0}, |