[libnotify] Add Python test script for GIR



commit b2020b7f2acf380c5e40fa701a98424ade5be6c0
Author: Martin Pitt <martin pitt ubuntu com>
Date:   Thu Nov 18 14:21:10 2010 +0100

    Add Python test script for GIR
    
    https://bugzilla.gnome.org/show_bug.cgi?id=635169

 tests/Makefile.am |    2 +-
 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()
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]