aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-05-31 15:45:44 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:54:26 -0300
commit7109418dbeac85be5513fa2a6e974576219e7582 (patch)
tree8199189b6cd50b8cf3a44466688046d27f07531b /tests
parent20f8953cb48ac03536e8101a4cfc061a31337b62 (diff)
Created unit test for QObject.eventFilter function.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/QtGui/CMakeLists.txt1
-rw-r--r--tests/QtGui/event_filter_test.py39
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt
index 6a142d379..27cf8b525 100644
--- a/tests/QtGui/CMakeLists.txt
+++ b/tests/QtGui/CMakeLists.txt
@@ -63,6 +63,7 @@ PYSIDE_TEST(bug_844.py)
PYSIDE_TEST(bug_854.py)
PYSIDE_TEST(customproxywidget_test.py)
PYSIDE_TEST(deepcopy_test.py)
+PYSIDE_TEST(event_filter_test.py)
PYSIDE_TEST(float_to_int_implicit_conversion_test.py)
PYSIDE_TEST(grandparent_method_test.py)
PYSIDE_TEST(hashabletype_test.py)
diff --git a/tests/QtGui/event_filter_test.py b/tests/QtGui/event_filter_test.py
new file mode 100644
index 000000000..88dbd960b
--- /dev/null
+++ b/tests/QtGui/event_filter_test.py
@@ -0,0 +1,39 @@
+import unittest
+import sys
+
+from helper import UsesQApplication
+from PySide.QtCore import QObject, QEvent, QTimer
+from PySide.QtGui import QWidget
+
+class MyFilter(QObject):
+ def eventFilter(self, obj, event):
+ if event.type() == QEvent.KeyPress:
+ pass
+ return QObject.eventFilter(self, obj, event)
+
+
+class EventFilter(UsesQApplication):
+ def testRefCount(self):
+ o = QObject()
+ filt = MyFilter()
+ o.installEventFilter(filt)
+ self.assertEqual(sys.getrefcount(o), 3)
+
+ o.installEventFilter(filt)
+ self.assertEqual(sys.getrefcount(o), 3)
+
+ o.removeEventFilter(filt)
+ self.assertEqual(sys.getrefcount(o), 2)
+
+ def testObjectDestructorOrder(self):
+ w = QWidget()
+ filt = MyFilter()
+ filt.app = self.app
+ w.installEventFilter(filt)
+ w.show()
+ w.close()
+ w = None
+ self.assert_(True)
+
+if __name__ == '__main__':
+ unittest.main()