aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-01-06 18:45:44 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:51:44 -0300
commitece91be2e6ab129085d372ce3aac08d4073b42ec (patch)
tree79174267f9a11fce73eeec9f7dd12c7dda155015 /tests
parent42e52dec9cd5db837a9fda2663b9c873dac1cd7b (diff)
Fixes connecting signal to decorated slot.
Decorated methods on classes derived from QObject are not called when connected to Qt signals because they get a name different from the decorated method. To solve this decorated methods are registered as global slots. An unit test was added. Reviewed by Hugo Parente <hugo.lima@openbossa.org> Reviewed by Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/pysidetest/CMakeLists.txt5
-rw-r--r--tests/pysidetest/decoratedslot_test.py39
2 files changed, 42 insertions, 2 deletions
diff --git a/tests/pysidetest/CMakeLists.txt b/tests/pysidetest/CMakeLists.txt
index 4b94a2aff..61ee424e4 100644
--- a/tests/pysidetest/CMakeLists.txt
+++ b/tests/pysidetest/CMakeLists.txt
@@ -72,9 +72,10 @@ target_link_libraries(testbinding
add_dependencies(testbinding pyside QtCore QtGui libpyside pysidetest)
-PYSIDE_TEST(homonymoussignalandmethod_test.py)
+PYSIDE_TEST(decoratedslot_test.py)
PYSIDE_TEST(delegatecreateseditor_test.py)
+PYSIDE_TEST(homonymoussignalandmethod_test.py)
+PYSIDE_TEST(list_signal_test.py)
PYSIDE_TEST(modelview_test.py)
PYSIDE_TEST(version_test.py)
-PYSIDE_TEST(list_signal_test.py)
diff --git a/tests/pysidetest/decoratedslot_test.py b/tests/pysidetest/decoratedslot_test.py
new file mode 100644
index 000000000..63a5be72a
--- /dev/null
+++ b/tests/pysidetest/decoratedslot_test.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python
+
+import unittest
+from PySide.QtCore import QObject
+from testbinding import TestObject
+
+class Receiver(QObject):
+ def __init__(self):
+ QObject.__init__(self)
+ self.called = False
+
+ def ReceiverDecorator(func):
+ def decoratedFunction(self, *args, **kw):
+ func(self, *args, **kw)
+ return decoratedFunction
+
+ # This method with the same name of the internal decorated function
+ # is here to test the binding capabilities.
+ def decoratedFunction(self):
+ pass
+
+ @ReceiverDecorator
+ def slot(self):
+ self.called = True
+
+
+class DecoratedSlotTest(unittest.TestCase):
+
+ def testCallingOfDecoratedSlot(self):
+ obj = TestObject(0)
+ receiver = Receiver()
+ obj.staticMethodDouble.connect(receiver.slot)
+ obj.emitStaticMethodDoubleSignal()
+ self.assert_(receiver.called)
+
+
+if __name__ == '__main__':
+ unittest.main()
+