aboutsummaryrefslogtreecommitdiffstats
path: root/tests
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
parent928e0b2795244d18a87764effe3d2a94504ac272 (diff)
Adding qInstallMsgHandler() method support.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.lima@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/QtCore/CMakeLists.txt1
-rw-r--r--tests/QtCore/qinstallmsghandler_test.py53
2 files changed, 54 insertions, 0 deletions
diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt
index 35fa7b97..b5f59d47 100644
--- a/tests/QtCore/CMakeLists.txt
+++ b/tests/QtCore/CMakeLists.txt
@@ -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)
diff --git a/tests/QtCore/qinstallmsghandler_test.py b/tests/QtCore/qinstallmsghandler_test.py
new file mode 100644
index 00000000..d76c6cee
--- /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()
+