Created unit test for QObject.eventFilter function.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
9408505a24
commit
606a90d406
2 changed files with 40 additions and 0 deletions
|
|
@ -63,6 +63,7 @@ PYSIDE_TEST(bug_844.py)
|
||||||
PYSIDE_TEST(bug_854.py)
|
PYSIDE_TEST(bug_854.py)
|
||||||
PYSIDE_TEST(customproxywidget_test.py)
|
PYSIDE_TEST(customproxywidget_test.py)
|
||||||
PYSIDE_TEST(deepcopy_test.py)
|
PYSIDE_TEST(deepcopy_test.py)
|
||||||
|
PYSIDE_TEST(event_filter_test.py)
|
||||||
PYSIDE_TEST(float_to_int_implicit_conversion_test.py)
|
PYSIDE_TEST(float_to_int_implicit_conversion_test.py)
|
||||||
PYSIDE_TEST(grandparent_method_test.py)
|
PYSIDE_TEST(grandparent_method_test.py)
|
||||||
PYSIDE_TEST(hashabletype_test.py)
|
PYSIDE_TEST(hashabletype_test.py)
|
||||||
|
|
|
||||||
39
tests/QtGui/event_filter_test.py
Normal file
39
tests/QtGui/event_filter_test.py
Normal file
|
|
@ -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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue