aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pitt <martin@piware.de>2011-02-21 14:06:43 +0100
committerMartin Pitt <martin@piware.de>2011-02-21 14:06:43 +0100
commit83a270fd9db6cda2dbff19335c97361aa4ad6781 (patch)
tree5c730b3f984df880cc9fb84b2b0ee3df6cf8c683
parentded5bb1e7c5bf42c24ed25a66c7e73ae8eaa54e0 (diff)
downloadlibdbusmenu-83a270fd9db6cda2dbff19335c97361aa4ad6781.tar.gz
libdbusmenu-83a270fd9db6cda2dbff19335c97361aa4ad6781.tar.bz2
libdbusmenu-83a270fd9db6cda2dbff19335c97361aa4ad6781.zip
add test-gtk-shortcut-client.py Python GI test
This replicates tests/test-gtk-shortcut-client.c using Python and GI.
-rw-r--r--tests/Makefile.am7
-rwxr-xr-xtests/test-gtk-shortcut-client.py52
2 files changed, 59 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c0081b0..f9102ed 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -16,6 +16,7 @@ TESTS = \
test-gtk-objects-test \
test-gtk-label \
test-gtk-shortcut \
+ test-gtk-shortcut-python \
test-gtk-reorder \
test-gtk-submenu \
test-gtk-parser-test \
@@ -476,6 +477,12 @@ test-gtk-shortcut: test-gtk-shortcut-client test-gtk-shortcut-server Makefile.am
@echo $(DBUS_RUNNER) --task ./test-gtk-shortcut-client --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@
@chmod +x $@
+test-gtk-shortcut-python: test-gtk-shortcut-server Makefile.am
+ @echo "#!/bin/bash" > $@
+ @echo $(XVFB_RUN) >> $@
+ @echo $(DBUS_RUNNER) --task ./test-gtk-shortcut-client.py --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@
+ @chmod +x $@
+
test_gtk_shortcut_server_SOURCES = \
test-gtk-shortcut-server.c
diff --git a/tests/test-gtk-shortcut-client.py b/tests/test-gtk-shortcut-client.py
new file mode 100755
index 0000000..885d227
--- /dev/null
+++ b/tests/test-gtk-shortcut-client.py
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+
+# A test for libdbusmenu to ensure its quality. This is the Python GI version
+# of test-gtk-shortcut-client.c
+#
+# Copyright 2011 Canonical Ltd.
+# Authors:
+# Martin Pitt <martin.pitt@ubuntu.com>
+
+import sys
+import gobject
+from gi.repository import Gtk, DbusmenuGtk
+Gtk.require_version('2.0')
+
+passed = True
+main_loop = gobject.MainLoop()
+
+def timer_func(data):
+ passed = True
+ main_loop.quit()
+ return False
+
+# main
+print 'Building Window'
+window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
+menubar = Gtk.MenuBar()
+menuitem = Gtk.MenuItem(label='Test')
+
+dmenu = DbusmenuGtk.Menu(dbus_name='glib.label.test', dbus_object='/org/test')
+dclient = dmenu.get_client()
+agroup = Gtk.AccelGroup()
+dclient.set_accel_group(agroup)
+
+menuitem.set_submenu(dmenu)
+menuitem.show()
+menubar.append(menuitem)
+menubar.show()
+window.add(menubar)
+window.set_title('libdbusmenu-gtk test')
+window.add_accel_group(agroup)
+window.show_all()
+
+gobject.timeout_add_seconds(10, timer_func, window)
+
+print 'Entering Mainloop'
+main_loop.run()
+
+if passed:
+ print 'Quiting'
+else:
+ print "Quiting as we're a failure"
+ sys.exit(1)