aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-03-04 18:38:56 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2010-03-04 19:59:55 -0300
commitceae06a748c5120eee89a2983b1cc994c09844ca (patch)
tree547c42f7a85dd8057ed6d7916b61ce1e6d89ae3c
parent965dd2d917500cf03076de721a691f9a7ad63420 (diff)
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>
-rw-r--r--tests/CMakeLists.txt2
-rw-r--r--tests/qtgui/qstring_qkeysequence_test.py36
2 files changed, 30 insertions, 8 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 044823247..2a1d422ce 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,7 +1,7 @@
file(GLOB TEST_FILES */*_test.py)
-set(test_blacklist "")
+set(test_blacklist "qtgui_qstring_qkeysequence")
foreach(test_file ${TEST_FILES})
string(REGEX MATCH "/([^/]+)//?([^/]+)_test.py" test_name ${test_file} )
diff --git a/tests/qtgui/qstring_qkeysequence_test.py b/tests/qtgui/qstring_qkeysequence_test.py
index d39459cef..1f435e6ee 100644
--- a/tests/qtgui/qstring_qkeysequence_test.py
+++ b/tests/qtgui/qstring_qkeysequence_test.py
@@ -1,17 +1,39 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-'''Tests QString using QKeySequence parameter'''
+'''Tests conversions of QString to and from QKeySequence.'''
import unittest
+from helper import UsesQApplication
from PySide.QtCore import QString
-from PySide.QtGui import QKeySequence
+from PySide.QtGui import QKeySequence, QAction
-class QStringQKeySequenceTest(unittest.TestCase):
- '''Tests QString using QKeySequence parameter'''
-
- def testQStringQKeySequence(self):
- a = QString(QKeySequence("Ctrl+A"))
+class QStringQKeySequenceTest(UsesQApplication):
+ '''Tests conversions of QString to and from QKeySequence.'''
+
+ def testQStringFromQKeySequence(self):
+ '''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__':
unittest.main()