aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore1
-rw-r--r--tests/Makefile.am16
-rw-r--r--tests/test-glib-simple-items.c45
3 files changed, 60 insertions, 2 deletions
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 <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;
+}
+