summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-05-31 15:45:44 -0300
committerRenato Filho <renato.filho@openbossa.org>2011-06-01 14:05:29 -0300
commit606a90d4069bbad479216e4dc1dfa92ede39f2e9 (patch)
treea8b17020d7ddccfd37043ff8687a343cebc005af
parent9408505a24d26725e518dd0852d8a1fb1640de6b (diff)
downloadpyside-606a90d4069bbad479216e4dc1dfa92ede39f2e9.tar.gz
pyside-606a90d4069bbad479216e4dc1dfa92ede39f2e9.tar.xz
pyside-606a90d4069bbad479216e4dc1dfa92ede39f2e9.zip
Created unit test for QObject.eventFilter function.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
-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 6a142d3..27cf8b5 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 0000000..88dbd96
--- /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()