summaryrefslogtreecommitdiffstats
path: root/tests/test_signal.py
diff options
context:
space:
mode:
authorJohan Dahlin <jdahlin@async.com.br>2007-04-29 21:45:33 +0000
committerJohan Dahlin <johan@src.gnome.org>2007-04-29 21:45:33 +0000
commit986ca14bd42f0cae3551f5b6aa97ef5e66e9a02c (patch)
tree7df3465c83bfc758e3b0e0fb4f535f44231e863f /tests/test_signal.py
parentf7a7b38d5dd5de98d9bccd3e0b6d400601cd4c26 (diff)
downloadpygobject-986ca14bd42f0cae3551f5b6aa97ef5e66e9a02c.tar.gz
pygobject-986ca14bd42f0cae3551f5b6aa97ef5e66e9a02c.tar.xz
pygobject-986ca14bd42f0cae3551f5b6aa97ef5e66e9a02c.zip
Add a generic CClosure marshaller based on ffi. This makes it possible to
2007-04-29 Johan Dahlin <jdahlin@async.com.br> * README: * configure.ac: * gobject/Makefile.am: * gobject/ffi-marshaller.c: (g_value_to_ffi_type), (g_value_from_ffi_type), (g_cclosure_marshal_generic_ffi): * gobject/ffi-marshaller.h: * gobject/gobjectmodule.c: (create_signal), (init_gobject): * pygobject-2.0.pc.in: * tests/test_signal.py: * tests/testhelpermodule.c: (test1_callback), (test1_callback_swapped), (test2_callback), (test3_callback), (test4_callback), (test_float_callback), (test_double_callback), (test_string_callback), (test_object_callback), (connectcallbacks), (_wrap_connectcallbacks), (inittesthelper): Add a generic CClosure marshaller based on ffi. This makes it possible to connect to signals on PyGObjects from C. libffi is now an optional dependency Fixes #353816 (Edward Hervey) svn path=/trunk/; revision=651
Diffstat (limited to 'tests/test_signal.py')
-rw-r--r--tests/test_signal.py63
1 files changed, 62 insertions, 1 deletions
diff --git a/tests/test_signal.py b/tests/test_signal.py
index d22281e..99bb45b 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -3,7 +3,7 @@
import gc
import unittest
-from common import gobject
+from common import gobject, testhelper
class C(gobject.GObject):
__gsignals__ = { 'my_signal': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
@@ -303,5 +303,66 @@ class TestSigProp(unittest.TestCase):
obj = SigPropClass()
self.failIf(obj.signal_emission_failed)
+f = gobject.SIGNAL_RUN_FIRST
+l = gobject.SIGNAL_RUN_LAST
+float = gobject.TYPE_FLOAT
+double = gobject.TYPE_DOUBLE
+uint = gobject.TYPE_UINT
+ulong = gobject.TYPE_ULONG
+
+class CM(gobject.GObject):
+ __gsignals__ = dict(
+ test1=(f, None, ()),
+ test2=(l, None, (str,)),
+ test3=(l, int, (double,)),
+ test4=(f, None, (bool, long, float, double, int, uint, ulong)),
+ test_float=(l, float, (float,)),
+ test_double=(l, double, (double, )),
+ test_string=(l, str, (str, )),
+ test_object=(l, object, (object, )),
+ )
+
+class _TestCMarshaller:
+ def setUp(self):
+ self.obj = CM()
+ testhelper.connectcallbacks(self.obj)
+
+ def testTest1(self):
+ self.obj.emit("test1")
+
+ def testTest2(self):
+ self.obj.emit("test2", "string")
+
+ def testTest3(self):
+ rv = self.obj.emit("test3", 42.0)
+ self.assertEqual(rv, 20)
+
+ def testTest4(self):
+ self.obj.emit("test4", True, 10L, 3.14, 1.78, 20, 30L, 31L)
+
+ def testTestReturnFloat(self):
+ rv = self.obj.emit("test-float", 1.234)
+ self.failUnless(rv >= 1.233999 and rv <= 1.2400001, rv)
+
+ def testTestReturnDouble(self):
+ rv = self.obj.emit("test-double", 1.234)
+ self.assertEqual(rv, 1.234)
+
+ def testTestReturnString(self):
+ rv = self.obj.emit("test-string", "str")
+ self.assertEqual(rv, "str")
+
+ def testTestReturnObject(self):
+ rv = self.obj.emit("test-object", self)
+ self.assertEqual(rv, self)
+
+if 'generic-c-marshaller' in gobject.features:
+ class TestCMarshaller(_TestCMarshaller, unittest.TestCase):
+ pass
+else:
+ print
+ print '** WARNING: LIBFFI disabled, not testing'
+ print
+
if __name__ == '__main__':
unittest.main()