aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtCore/qinstallmsghandler_test.py
diff options
context:
space:
mode:
authorLuciano Wolf <luciano.wolf@openbossa.org>2010-06-18 19:37:21 -0300
committerLuciano Wolf <luciano.wolf@openbossa.org>2010-06-21 17:38:41 -0300
commit54b69c3595cadfbfa5f65849d4dd106718920976 (patch)
treeacad023984f3be17d0e0db72206eedc446038604 /tests/QtCore/qinstallmsghandler_test.py
parent928e0b2795244d18a87764effe3d2a94504ac272 (diff)
Adding qInstallMsgHandler() method support.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.lima@openbossa.org>
Diffstat (limited to 'tests/QtCore/qinstallmsghandler_test.py')
-rw-r--r--tests/QtCore/qinstallmsghandler_test.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/QtCore/qinstallmsghandler_test.py b/tests/QtCore/qinstallmsghandler_test.py
new file mode 100644
index 000000000..d76c6ceec
--- /dev/null
+++ b/tests/QtCore/qinstallmsghandler_test.py
@@ -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()
+