Extends the QKeySequence unit test.

The test adds conversions from QString and Python string to a
QKeySequence.

Reviewed by Hugo Parente <hugo.lima@openbossa.org>
This commit is contained in:
Marcelo Lira 2010-03-04 18:38:56 -03:00
commit ceae06a748
2 changed files with 30 additions and 8 deletions

View file

@ -1,7 +1,7 @@
file(GLOB TEST_FILES */*_test.py) file(GLOB TEST_FILES */*_test.py)
set(test_blacklist "") set(test_blacklist "qtgui_qstring_qkeysequence")
foreach(test_file ${TEST_FILES}) foreach(test_file ${TEST_FILES})
string(REGEX MATCH "/([^/]+)//?([^/]+)_test.py" test_name ${test_file} ) string(REGEX MATCH "/([^/]+)//?([^/]+)_test.py" test_name ${test_file} )

View file

@ -1,17 +1,39 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
'''Tests QString using QKeySequence parameter''' '''Tests conversions of QString to and from QKeySequence.'''
import unittest import unittest
from helper import UsesQApplication
from PySide.QtCore import QString from PySide.QtCore import QString
from PySide.QtGui import QKeySequence from PySide.QtGui import QKeySequence, QAction
class QStringQKeySequenceTest(unittest.TestCase): class QStringQKeySequenceTest(UsesQApplication):
'''Tests QString using QKeySequence parameter''' '''Tests conversions of QString to and from QKeySequence.'''
def testQStringQKeySequence(self): def testQStringFromQKeySequence(self):
a = QString(QKeySequence("Ctrl+A")) '''Creates a QString from a QKeySequence.'''
keyseq = 'Ctrl+A'
a = QString(QKeySequence(keyseq))
self.assertEqual(a, keyseq)
def testQStringAsQKeySequence(self):
'''Passes a QString to an argument expecting a QKeySequence.'''
keyseq = QString('Ctrl+A')
action = QAction(None)
action.setShortcut(keyseq)
shortcut = action.shortcut()
self.assert_(isinstance(shortcut, QKeySequence))
self.assertEqual(shortcut.toString(), keyseq)
def testPythonStringAsQKeySequence(self):
'''Passes a Python string to an argument expecting a QKeySequence.'''
keyseq = 'Ctrl+A'
action = QAction(None)
action.setShortcut(keyseq)
shortcut = action.shortcut()
self.assert_(isinstance(shortcut, QKeySequence))
self.assertEqual(shortcut.toString(), keyseq)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()