summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2011-12-22 19:02:34 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-02 09:04:12 +0100
commit05ca21411eaaf3ea5e9cc9d82ecfaa8753f9f319 (patch)
tree45c68b5d1d14cd18a31f501391af7e542436936e /tests/auto
parent628d3f85d2d06e25851684aede396fd1b0a12db9 (diff)
Handle -1 (Invalid Key) and Qt::Key_unknown gracefully in encodeString.
Previously they would fall into the unicode handling and return very strange values. Change-Id: I62a53894c0983bf53fd79f924b40a6fd3ba02993 Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
index 9845b388b4..f8eae2067e 100644
--- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
@@ -122,6 +122,8 @@ private slots:
void mnemonic();
void toString_data();
void toString();
+ void toStringFromKeycode_data();
+ void toStringFromKeycode();
void streamOperators_data();
void streamOperators();
void parseString_data();
@@ -476,6 +478,24 @@ void tst_QKeySequence::toString()
}
+void tst_QKeySequence::toStringFromKeycode_data()
+{
+ QTest::addColumn<QKeySequence>("keycode");
+ QTest::addColumn<QString>("expectedString");
+
+ QTest::newRow("A") << QKeySequence(Qt::Key_A) << "A";
+ QTest::newRow("-1") << QKeySequence(-1) << "";
+ QTest::newRow("Unknown") << QKeySequence(Qt::Key_unknown) << "";
+}
+
+void tst_QKeySequence::toStringFromKeycode()
+{
+ QFETCH(QKeySequence, keycode);
+ QFETCH(QString, expectedString);
+
+ QCOMPARE(QKeySequence(keycode).toString(), expectedString);
+}
+
void tst_QKeySequence::streamOperators_data()
{
operatorQString_data();