diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2010-11-18 14:21:10 +0100 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2010-11-18 14:21:10 +0100 |
commit | b2020b7f2acf380c5e40fa701a98424ade5be6c0 (patch) | |
tree | bd8ed6663d5703b0590d36b40f5dec58e96e8b69 /tests | |
parent | d3de00c14e5ee3897921ad78f6e15575f6167213 (diff) | |
download | libnotify-b2020b7f2acf380c5e40fa701a98424ade5be6c0.tar.gz |
Add Python test script for GIR
https://bugzilla.gnome.org/show_bug.cgi?id=635169
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rwxr-xr-x | tests/test-gir.py | 55 |
2 files changed, 56 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index eb37030..7acf9a3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -84,6 +84,6 @@ test_resident_LDADD = $(common_ldflags) test_transient_SOURCES = test-transient.c test_transient_LDADD = $(common_ldflags) -EXTRA_DIST = applet-critical.png +EXTRA_DIST = applet-critical.png test-gir.py -include $(top_srcdir)/git.mk diff --git a/tests/test-gir.py b/tests/test-gir.py new file mode 100755 index 0000000..ffd49e9 --- /dev/null +++ b/tests/test-gir.py @@ -0,0 +1,55 @@ +#!/usr/bin/python + +# @file tests/test-gir.py Unit test: Test GI repository +# +# @Copyright (C) 2010 Canonical Ltd. +# Author: Martin Pitt <martin.pitt@ubuntu.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +import os + +# use our local typelib +os.environ['GI_TYPELIB_PATH'] = 'libnotify:' + os.environ.get('GI_TYPELIB_PATH', '') + +from gi.repository import Notify + +assert Notify.is_initted() == False +Notify.init('test') +assert Notify.is_initted() == True + +print 'server info:', Notify.get_server_info() +print 'server capabilities:', Notify.get_server_caps() + +n = Notify.Notification.new('title', None, None) +n.show() +n = Notify.Notification.new('title', 'text', None) +n.show() +n = Notify.Notification.new('title', 'text', 'gtk-ok') +n.show() + +n.update('New Title', None, None) +n.show() +n.update('Newer Title', 'New Body', None) +n.show() + +def callback(): + print 'Do it! Callback' + +n = Notify.Notification.new('Action', 'Here we go!', 'gtk-alert') +n.add_action('doit', 'Do it!', callback, None, None) +n.show() + |