From 54fd03c702247158b4c238a4f1e59d80fd6a5145 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 18 Jun 2013 16:08:09 -0500 Subject: run test-gtk-remove inside of dbus-test-runner --- tests/Makefile.am | 19 +++++-- tests/test-gtk-remove-server.c | 118 +++++++++++++++++++++++++++++++++++++++++ tests/test-gtk-remove.c | 118 ----------------------------------------- 3 files changed, 132 insertions(+), 123 deletions(-) create mode 100644 tests/test-gtk-remove-server.c delete mode 100644 tests/test-gtk-remove.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 1fbaaf5..0977356 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -78,11 +78,11 @@ endif if WANT_LIBDBUSMENUGTK check_PROGRAMS += \ test-gtk-objects \ - test-gtk-remove \ test-gtk-label-client \ test-gtk-label-server \ test-gtk-shortcut-client \ test-gtk-shortcut-server \ + test-gtk-remove-server \ test-gtk-reorder-server \ test-gtk-submenu-server \ test-gtk-submenu-client \ @@ -632,21 +632,30 @@ CLEANFILES += test-gtk-shortcut-client.pyc # Test GTK Remove ######################### -test_gtk_remove_SOURCES = \ - test-gtk-remove.c +test-gtk-remove: test-gtk-remove-server Makefile.am + @echo "#!/bin/bash" > $@ + @echo export UBUNTU_MENUPROXY="" >> $@ + @echo export G_DEBUG=fatal_criticals >> $@ + @echo $(XVFB_RUN) >> $@ + @echo $(DBUS_RUNNER) --task ./test-gtk-remove-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> $@ + @chmod +x $@ + +test_gtk_remove_server_SOURCES = \ + test-gtk-remove-server.c -test_gtk_remove_CFLAGS = \ +test_gtk_remove_server_CFLAGS = \ -I $(top_srcdir) \ $(DBUSMENUGTK_CFLAGS) \ $(DBUSMENUTESTS_CFLAGS) \ $(DBUSMENUGLIB_CFLAGS) -Wall -Werror -test_gtk_remove_LDADD = \ +test_gtk_remove_server_LDADD = \ $(top_builddir)/libdbusmenu-glib/libdbusmenu-glib.la \ $(top_builddir)/libdbusmenu-gtk/libdbusmenu-gtk$(VER).la \ $(DBUSMENUGTK_LIBS) \ $(DBUSMENUTESTS_LIBS) + ######################### # Test GTK Reorder ######################### diff --git a/tests/test-gtk-remove-server.c b/tests/test-gtk-remove-server.c new file mode 100644 index 0000000..0655fc0 --- /dev/null +++ b/tests/test-gtk-remove-server.c @@ -0,0 +1,118 @@ +/* + Confirm that no warnings/criticals get generated by including + multiple add/removes in a match w/o waiting on the mainloop to iterate. + + Copyright 2013 Canonical Ltd. + + Original sample code by Drew Bliss + Modified for automatic testing by Charles Kerr + */ + +#include /* exit() */ +#include +#include +#include +#include + +static GMainLoop * loop = NULL; +static GtkWidget * top_gtk = NULL; +static DbusmenuMenuitem * top_dbusmenu = NULL; +static DbusmenuServer * menuservice = NULL; + +static void +rebuild_menu (void) +{ + GList * l; + GList * children; + int i; + const int n = 10; + static int count = 0; + + if (top_gtk == NULL) + { + top_gtk = gtk_menu_new (); + gtk_widget_show (top_gtk); + top_dbusmenu = dbusmenu_gtk_parse_menu_structure (top_gtk); + menuservice = dbusmenu_server_new ("/org/ayatana/NotificationItem/test/Menu"); + dbusmenu_server_set_root (menuservice, top_dbusmenu); + } + + // remove all the previous children + children = gtk_container_get_children (GTK_CONTAINER(top_gtk)); + for (l=children; l!=NULL; l=l->next) + gtk_widget_destroy (GTK_WIDGET (l->data)); + + // add a handful of new children + for (i=0; i 5) + { + g_main_loop_quit (loop); + return G_SOURCE_REMOVE; + } + + if (iteration <= 2) + { + rebuild_menu (); + } + else + { + int i; + + for (i=0; i - Modified for automatic testing by Charles Kerr - */ - -#include /* exit() */ -#include -#include -#include -#include - -static GMainLoop * loop = NULL; -static GtkWidget * top_gtk = NULL; -static DbusmenuMenuitem * top_dbusmenu = NULL; -static DbusmenuServer * menuservice = NULL; - -static void -rebuild_menu (void) -{ - GList * l; - GList * children; - int i; - const int n = 10; - static int count = 0; - - if (top_gtk == NULL) - { - top_gtk = gtk_menu_new (); - gtk_widget_show (top_gtk); - top_dbusmenu = dbusmenu_gtk_parse_menu_structure (top_gtk); - menuservice = dbusmenu_server_new ("/org/ayatana/NotificationItem/test/Menu"); - dbusmenu_server_set_root (menuservice, top_dbusmenu); - } - - // remove all the previous children - children = gtk_container_get_children (GTK_CONTAINER(top_gtk)); - for (l=children; l!=NULL; l=l->next) - gtk_widget_destroy (GTK_WIDGET (l->data)); - - // add a handful of new children - for (i=0; i 5) - { - g_main_loop_quit (loop); - return G_SOURCE_REMOVE; - } - - if (iteration <= 2) - { - rebuild_menu (); - } - else - { - int i; - - for (i=0; i