aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Pitt <martin@piware.de>2011-02-21 11:30:50 +0100
committerMartin Pitt <martin@piware.de>2011-02-21 11:30:50 +0100
commit52e9e4c8125943abc8d7513501aad1698ab4d7f6 (patch)
tree96e92b55b8d315eac3aaa34aa10d6c3e58501044 /tests
parent558fa9265c05452de03ddd9f8543dfdce1b81e7b (diff)
downloadlibdbusmenu-52e9e4c8125943abc8d7513501aad1698ab4d7f6.tar.gz
libdbusmenu-52e9e4c8125943abc8d7513501aad1698ab4d7f6.tar.bz2
libdbusmenu-52e9e4c8125943abc8d7513501aad1698ab4d7f6.zip
add test-glib-simple-items.py Python GI test
This replicates tests/test-glib-simple-items.c using Python and GI. Update the Makefile to use the locally generated GI typelibs for the tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am8
-rwxr-xr-xtests/test-glib-simple-items.py35
2 files changed, 41 insertions, 2 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 62142dc..9259ed1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -17,7 +17,8 @@ TESTS = \
test-gtk-shortcut \
test-gtk-reorder \
test-gtk-submenu \
- test-gtk-parser-test
+ test-gtk-parser-test \
+ test-glib-simple-items.py
check_PROGRAMS = \
glib-server-nomenu \
@@ -48,6 +49,9 @@ check_PROGRAMS = \
XVFB_RUN=". $(srcdir)/run-xvfb.sh"
+# for the GI tests, prefer/use the typelibs from the local build tree
+TESTS_ENVIRONMENT = env GI_TYPELIB_PATH=$(top_builddir)/libdbusmenu-glib:$(top_builddir)/libdbusmenu-gtk:$(GI_TYPELIB_PATH)
+
######################
# JSON Loader lib
######################
@@ -623,7 +627,7 @@ distclean-local:
-rm -rf $(builddir)/mago.results
DISTCLEANFILES = \
- $(TESTS) \
+ $(filter-out %.py, $(TESTS)) \
$(OBJECT_XML_REPORT) \
$(GTK_OBJECT_XML_REPORT)
diff --git a/tests/test-glib-simple-items.py b/tests/test-glib-simple-items.py
new file mode 100755
index 0000000..d7ad7d7
--- /dev/null
+++ b/tests/test-glib-simple-items.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+# This is the Python GI version of test-glib-simple-items.c
+
+import gobject
+from gi.repository import Dbusmenu
+
+dummies = ['Bob', 'Jim', 'Alvin', 'Mary']
+
+def dummy_users(root):
+ count = 0
+ for user in dummies:
+ mi = Dbusmenu.Menuitem()
+ print 'Creating item: %d %s' % (mi.get_id(), user)
+ print '\tRoot ID:', root.get_id()
+ mi.property_set('label', user)
+ root.child_add_position(mi, count)
+ assert mi.property_get('label') == user
+ count += 1
+
+def quititall(mainloop):
+ mainloop.quit()
+ return False
+
+# main
+
+server = Dbusmenu.Server.new('/test/object')
+root_menuitem = Dbusmenu.Menuitem()
+server.set_root(root_menuitem)
+print 'Root ID:', root_menuitem.get_id()
+
+dummy_users(root_menuitem)
+
+mainloop = gobject.MainLoop()
+gobject.timeout_add_seconds(1, quititall, mainloop)
+mainloop.run()