aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-05-13 15:50:42 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-05-17 19:53:54 -0300
commitc5fd4d4830cb49c9f8087d7e54335f4c248f76bf (patch)
tree6a4fd6a9e30f1d5a1b3ead182d768d2f4fc38a79 /tests
parentd2a6f35ef914b000ddd7685925075985c76817ac (diff)
Implemented support to modify slot return type.
Included method type in DynamicQMetaObject metadata. Moved Signal/Slot objet to libpyside. Create unittest to signal class. Implemented disconnection function. Fixed emit method on signal object
Diffstat (limited to 'tests')
-rw-r--r--tests/signals/decorators_test.py17
-rw-r--r--tests/signals/signal_object_test.py39
2 files changed, 53 insertions, 3 deletions
diff --git a/tests/signals/decorators_test.py b/tests/signals/decorators_test.py
index 43ae799b..db068d00 100644
--- a/tests/signals/decorators_test.py
+++ b/tests/signals/decorators_test.py
@@ -24,8 +24,12 @@ class MyObject(QObject):
def foo(self):
self._slotCalledCount = self._slotCalledCount + 1
- @Slot(QString)
- def mySlot4(self, a):
+ @Slot(QString, int)
+ def mySlot4(self, a, b):
+ self._slotCalledCount = self._slotCalledCount + 1
+
+ @Slot(result=int)
+ def mySlot5(self):
self._slotCalledCount = self._slotCalledCount + 1
class StaticMetaObjectTest(unittest.TestCase):
@@ -37,7 +41,7 @@ class StaticMetaObjectTest(unittest.TestCase):
self.assert_(m.indexOfSlot('mySlot2(int)') > 0)
self.assert_(m.indexOfSlot('mySlot2(QString)') > 0)
self.assert_(m.indexOfSlot('mySlot3()') > 0)
- self.assert_(m.indexOfSlot('mySlot4(QString)') > 0)
+ self.assert_(m.indexOfSlot('mySlot4(QString,int)') > 0)
def testEmission(self):
o = MyObject()
@@ -45,5 +49,12 @@ class StaticMetaObjectTest(unittest.TestCase):
o.emit(SIGNAL("mySignal()"))
self.assert_(o._slotCalledCount == 1)
+ def testResult(self):
+ o = MyObject()
+ mo = o.metaObject()
+ i = mo.indexOfSlot('mySlot5()')
+ m = mo.method(i)
+ self.assertEqual(m.typeName(), "int")
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/signals/signal_object_test.py b/tests/signals/signal_object_test.py
new file mode 100644
index 00000000..89e114d6
--- /dev/null
+++ b/tests/signals/signal_object_test.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+
+import sys
+import unittest
+import functools
+
+from PySide.QtCore import *
+
+class MyObject(QObject):
+ sig1 = Signal()
+ sig2 = Signal(int, name='rangeChanged')
+
+
+ @Slot(int)
+ def myRange(self, r):
+ print "Range changed:", r
+
+
+ def slot1(self):
+ self._called = True
+
+
+
+class SignalObjectTest(unittest.TestCase):
+
+ def testsingleConnect(self):
+ o = MyObject()
+ o.sig1.connect(o.slot1)
+ o.sig1.emit()
+ self.assert_(o._called)
+
+ def testSignatureParse(self):
+ o = MyObject()
+ o.sig2.connect(o.myRange)
+ o.sig2.emit(10)
+
+
+if __name__ == '__main__':
+ unittest.main()