diff options
author | Ted Gould <ted@canonical.com> | 2009-07-01 00:34:05 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-07-01 00:34:05 -0500 |
commit | 9d685e92f0df6ca92f2b14d53199c6d12cd95858 (patch) | |
tree | 9e8ad086c3964c9791aabbbdde04a6995825342a /tests | |
parent | 7675f60a41c7a7fe7a4aa9ed853f005798054111 (diff) | |
download | libdbusmenu-9d685e92f0df6ca92f2b14d53199c6d12cd95858.tar.gz libdbusmenu-9d685e92f0df6ca92f2b14d53199c6d12cd95858.tar.bz2 libdbusmenu-9d685e92f0df6ca92f2b14d53199c6d12cd95858.zip |
Adding a really simple test to add items to a stack.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 16 | ||||
-rw-r--r-- | tests/test-glib-simple-items.c | 45 |
2 files changed, 59 insertions, 2 deletions
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 <dbus/dbus-glib.h> +#include <dbus/dbus-glib-bindings.h> + +#include <libdbusmenu-glib/server.h> +#include <libdbusmenu-glib/menuitem.h> + +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; +} + |