Adding qInstallMsgHandler() method support.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Hugo Parente Lima <hugo.lima@openbossa.org>
This commit is contained in:
parent
928e0b2795
commit
54b69c3595
3 changed files with 86 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ PYSIDE_TEST(qfileinfo_test.py)
|
|||
PYSIDE_TEST(qfile_test.py)
|
||||
PYSIDE_TEST(qflags_test.py)
|
||||
PYSIDE_TEST(qhandle_test.py)
|
||||
PYSIDE_TEST(qinstallmsghandler_test.py)
|
||||
PYSIDE_TEST(qlinef_test.py)
|
||||
PYSIDE_TEST(qlocale_test.py)
|
||||
PYSIDE_TEST(qmetaobject_test.py)
|
||||
|
|
|
|||
53
tests/QtCore/qinstallmsghandler_test.py
Normal file
53
tests/QtCore/qinstallmsghandler_test.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
'''Test cases for qInstallMsgHandler'''
|
||||
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
from PySide.QtCore import *
|
||||
|
||||
param = []
|
||||
|
||||
def handler(msgt, msg):
|
||||
global param
|
||||
param = [msgt, msg]
|
||||
|
||||
def handleruseless(msgt, msg):
|
||||
pass
|
||||
|
||||
class QInstallMsgHandlerTest(unittest.TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
# Ensure that next test will have a clear environment
|
||||
qInstallMsgHandler(None)
|
||||
|
||||
def testNone(self):
|
||||
ret = qInstallMsgHandler(None)
|
||||
self.assertEqual(ret, None)
|
||||
|
||||
def testRet(self):
|
||||
ret = qInstallMsgHandler(None)
|
||||
self.assertEqual(ret, None)
|
||||
refcount = sys.getrefcount(handleruseless)
|
||||
retNone = qInstallMsgHandler(handleruseless)
|
||||
self.assertEqual(sys.getrefcount(handleruseless), refcount + 1)
|
||||
rethandler = qInstallMsgHandler(None)
|
||||
self.assertEqual(rethandler, handleruseless)
|
||||
del rethandler
|
||||
self.assertEqual(sys.getrefcount(handleruseless), refcount)
|
||||
|
||||
def testHandler(self):
|
||||
rethandler = qInstallMsgHandler(handler)
|
||||
qDebug("Test Debug")
|
||||
self.assertEqual(param[0], QtDebugMsg)
|
||||
self.assertEqual(param[1], "Test Debug")
|
||||
qWarning("Test Warning")
|
||||
self.assertEqual(param[0], QtWarningMsg)
|
||||
self.assertEqual(param[1], "Test Warning")
|
||||
qCritical("Test Critical")
|
||||
self.assertEqual(param[0], QtCriticalMsg)
|
||||
self.assertEqual(param[1], "Test Critical")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue