From 9d685e92f0df6ca92f2b14d53199c6d12cd95858 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Jul 2009 00:34:05 -0500 Subject: Adding a really simple test to add items to a stack. --- .bzrignore | 1 + tests/Makefile.am | 16 +++++++++++++-- tests/test-glib-simple-items.c | 45 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 tests/test-glib-simple-items.c diff --git a/.bzrignore b/.bzrignore index e3fa0f4..1bac747 100644 --- a/.bzrignore +++ b/.bzrignore @@ -40,3 +40,4 @@ libdbusmenu_gtk_la-client.lo dbusmenu.xml dbusmenu.py mago.results +test-glib-simple-items diff --git a/tests/Makefile.am b/tests/Makefile.am index 452f4f6..8c47a93 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,7 +4,7 @@ check: tests DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf -tests: test-glib-layout test-glib-properties test-gtk-label +tests: test-glib-layout test-glib-properties test-gtk-label test-glib-simple-items libexec_PROGRAMS = \ glib-server-nomenu \ @@ -13,7 +13,8 @@ libexec_PROGRAMS = \ test-glib-properties-client \ test-glib-properties-server \ test-gtk-label-client \ - test-gtk-label-server + test-gtk-label-server \ + test-glib-simple-items glib_server_nomenu_SOURCES = \ glib-server-nomenu.c @@ -85,6 +86,17 @@ test_glib_properties_client_LDADD = \ $(DBUSMENUGLIB_LIBS) +test_glib_simple_items_SOURCES = \ + test-glib-simple-items.c + +test_glib_simple_items_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_glib_simple_items_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + $(DBUSMENUGLIB_LIBS) + test-gtk-label: test-gtk-label-client test-gtk-label-server test-gtk-label.json $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-label-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return diff --git a/tests/test-glib-simple-items.c b/tests/test-glib-simple-items.c new file mode 100644 index 0000000..56536e9 --- /dev/null +++ b/tests/test-glib-simple-items.c @@ -0,0 +1,45 @@ +#include +#include + +#include +#include + +static DbusmenuMenuitem * root_menuitem = NULL; +static GMainLoop * mainloop = NULL; + +gchar * dummies[] = { + "Bob", "Jim", "Alvin", "Mary", NULL +}; + +static void +dummy_users (DbusmenuMenuitem * root) { + int count; + for (count = 0; dummies[count] != NULL; count++) { + DbusmenuMenuitem * mi = dbusmenu_menuitem_new(); + g_debug("Creating item: %d %s", dbusmenu_menuitem_get_id(mi), dummies[count]); + g_debug("\tRoot ID: %d", dbusmenu_menuitem_get_id(root)); + dbusmenu_menuitem_property_set(mi, "label", dummies[count]); + dbusmenu_menuitem_child_add_position(root, mi, count); + } + + return; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + DbusmenuServer * server = dbusmenu_server_new("/test/object"); + root_menuitem = dbusmenu_menuitem_new(); + dbusmenu_server_set_root(server, root_menuitem); + g_debug("Root ID: %d", dbusmenu_menuitem_get_id(root_menuitem)); + + dummy_users(root_menuitem); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return 0; +} + -- cgit v1.2.3 From e8393a9d2fd78c79f50ab003de728665f74d4e5e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 1 Jul 2009 00:36:24 -0500 Subject: Bad prototype for dealing with the new items added signal which also has the position in it. This made it so the server was the position, which causes bad stuff to happen. --- libdbusmenu-glib/server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index cf8ea85..ab5951f 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -86,7 +86,7 @@ static void dbusmenu_server_finalize (GObject *object); static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); static void menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, gchar * value, DbusmenuServer * server); -static void menuitem_child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, DbusmenuServer * server); +static void menuitem_child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint pos, DbusmenuServer * server); static void menuitem_child_removed (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, DbusmenuServer * server); static void menuitem_signals_create (DbusmenuMenuitem * mi, gpointer data); static void menuitem_signals_remove (DbusmenuMenuitem * mi, gpointer data); @@ -306,7 +306,7 @@ menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, gchar * valu } static void -menuitem_child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, DbusmenuServer * server) +menuitem_child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint pos, DbusmenuServer * server) { menuitem_signals_create(child, server); /* TODO: We probably need to group the layout update signals to make the number more reasonble. */ -- cgit v1.2.3