aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtCore
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-05-23 11:39:17 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:54:25 -0300
commit77559ac63945da93f7e90c2910232c6eb2629487 (patch)
treed5647375e1b48d7cef0d344433ddf9c578433829 /tests/QtCore
parentd9c43275a09fc68146a210a9da281a9491d62980 (diff)
Created DestroyListener class.
This class is used to keep the Python object live until the signal destroyed emission. With this is possible to use the QObject on destruction signal. Fixes bug #505. Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'tests/QtCore')
-rw-r--r--tests/QtCore/CMakeLists.txt1
-rw-r--r--tests/QtCore/destroysignal_test.py27
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt
index 251add10d..365305fef 100644
--- a/tests/QtCore/CMakeLists.txt
+++ b/tests/QtCore/CMakeLists.txt
@@ -21,6 +21,7 @@ PYSIDE_TEST(classinfo_test.py)
PYSIDE_TEST(child_event_test.py)
PYSIDE_TEST(deepcopy_test.py)
PYSIDE_TEST(deletelater_test.py)
+PYSIDE_TEST(destroysignal_test.py)
PYSIDE_TEST(duck_punching_test.py)
PYSIDE_TEST(hash_test.py)
PYSIDE_TEST(max_signals.py)
diff --git a/tests/QtCore/destroysignal_test.py b/tests/QtCore/destroysignal_test.py
new file mode 100644
index 000000000..1c5f986bc
--- /dev/null
+++ b/tests/QtCore/destroysignal_test.py
@@ -0,0 +1,27 @@
+from PySide.QtCore import QTimer, QObject
+import sys
+import unittest
+
+class TestDestroySignal(unittest.TestCase):
+ def onObjectDestroyed(self, timer):
+ self.assert_(isinstance(timer, QTimer))
+ self._destroyed = True
+
+ def testSignal(self):
+ self._destroyed = False
+ t = QTimer()
+ t.destroyed[QObject].connect(self.onObjectDestroyed)
+ del t
+ self.assert_(self._destroyed)
+
+ def testWithParent(self):
+ self._destroyed = False
+ p = QTimer()
+ t = QTimer(p)
+ t.destroyed[QObject].connect(self.onObjectDestroyed)
+ del p
+ self.assert_(self._destroyed)
+
+if __name__ == '__main__':
+ unittest.main()
+