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