From 52e9e4c8125943abc8d7513501aad1698ab4d7f6 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 21 Feb 2011 11:30:50 +0100 Subject: 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. --- tests/Makefile.am | 8 ++++++-- tests/test-glib-simple-items.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100755 tests/test-glib-simple-items.py (limited to 'tests') 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() -- cgit v1.2.3 From 83a270fd9db6cda2dbff19335c97361aa4ad6781 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 21 Feb 2011 14:06:43 +0100 Subject: add test-gtk-shortcut-client.py Python GI test This replicates tests/test-gtk-shortcut-client.c using Python and GI. --- tests/Makefile.am | 7 ++++++ tests/test-gtk-shortcut-client.py | 52 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100755 tests/test-gtk-shortcut-client.py (limited to 'tests') 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 + +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) -- cgit v1.2.3 From f3eb3cbb4623b9e996d2cc62a21b6fcc4a2331c7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 10:18:48 -0600 Subject: Fixing distcheck by including py file and cleaning up it's pyc --- tests/Makefile.am | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index f9102ed..1f8faec 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,6 +3,7 @@ DBUS_RUNNER=dbus-test-runner CLEANFILES= DISTCLEANFILES= +EXTRA_DIST = TESTS = \ test-glib-objects-test \ @@ -477,12 +478,6 @@ 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 @@ -513,6 +508,19 @@ test_gtk_shortcut_client_LDADD = \ $(DBUSMENUGTK_LIBS) \ $(DBUSMENUTESTS_LIBS) +######################### +# Test GTK Shortcut Python +######################### + +test-gtk-shortcut-python: test-gtk-shortcut-server test-gtk-shortcut-client.py 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 $@ + +EXTRA_DIST += test-gtk-shortcut-client.py +CLEANFILES += test-gtk-shortcut-client.pyc + ######################### # Test GTK Reorder ######################### @@ -607,7 +615,7 @@ jsondir = $(datadir)/${PACKAGE}/json/ json_DATA = \ test-gtk-label.json -EXTRA_DIST = \ +EXTRA_DIST += \ $(examples_DATA) \ run-xvfb.sh \ $(json_DATA) \ -- cgit v1.2.3 From dcf34291bd1cc3f58652c96bd37de3162497b269 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 10:22:35 -0600 Subject: Bringing along the simple items test as well --- tests/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 1f8faec..09bc4c5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -367,6 +367,8 @@ test_glib_simple_items_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ $(DBUSMENUGLIB_LIBS) +EXTRA_DIST += test-glib-simple-items.py + ###################### # Test GTK Object ###################### -- cgit v1.2.3 From 5b9418cb4be5823df8eb7c01f854eed0a13a2c9f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 10:50:34 -0600 Subject: Fixing the path of the python in the test --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 09bc4c5..61b3e69 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -517,7 +517,7 @@ test_gtk_shortcut_client_LDADD = \ test-gtk-shortcut-python: test-gtk-shortcut-server test-gtk-shortcut-client.py 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 >> $@ + @echo $(DBUS_RUNNER) --task $(srcdir)/test-gtk-shortcut-client.py --task-name Client --task ./test-gtk-shortcut-server --task-name Server --ignore-return >> $@ @chmod +x $@ EXTRA_DIST += test-gtk-shortcut-client.py -- cgit v1.2.3