summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/kernel/qkeysequence
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2011-12-21 20:15:25 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-22 13:20:40 +0100
commitc02ca6752a1b6cb7d427e59594a600de3a46697d (patch)
tree180116b28bb1fd48843225c01efe89db9b16c8ab /tests/auto/gui/kernel/qkeysequence
parent500fd522324a891f4683723a0f69bfda968adb8e (diff)
Fix handling of invalid modifiers in QKeySequence.
When decoding a string don't assume valid modifier strings. If a modifier string is unknown return Qt::Key_unknown instead of skipping the modifier. Currently 'Win+a' is decoded to 'A' but should be Qt::Key_unknown. Change-Id: I1c82031159a8b3c19924a7c9e991bc6b1f90d617 Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'tests/auto/gui/kernel/qkeysequence')
-rw-r--r--tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
index 6fbd77c54f..9845b388b4 100644
--- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
@@ -124,6 +124,8 @@ private slots:
void toString();
void streamOperators_data();
void streamOperators();
+ void parseString_data();
+ void parseString();
void fromString_data();
void fromString();
void ensureSorted();
@@ -501,6 +503,31 @@ void tst_QKeySequence::streamOperators()
QVERIFY( orgK != copyOrgK );
}
+
+void tst_QKeySequence::parseString_data()
+{
+ QTest::addColumn<QString>("strSequence");
+ QTest::addColumn<QKeySequence>("keycode");
+
+ QTest::newRow("A") << "A" << QKeySequence(Qt::Key_A);
+ QTest::newRow("a") << "a" << QKeySequence(Qt::Key_A);
+ QTest::newRow("Ctrl+Left") << "Ctrl+Left" << QKeySequence(Qt::CTRL + Qt::Key_Left);
+ QTest::newRow("Ctrl++") << "Ctrl++" << QKeySequence(Qt::CTRL + Qt::Key_Plus);
+ QTest::newRow("Meta+A") << "Meta+a" << QKeySequence(Qt::META + Qt::Key_A);
+ QTest::newRow("Win+A") << "Win+a" << QKeySequence(Qt::Key_unknown);
+ QTest::newRow("4+3=2") << "4+3=2" << QKeySequence(Qt::Key_unknown);
+ QTest::newRow("Super+Meta+A") << "Super+Meta+A" << QKeySequence(Qt::Key_unknown);
+}
+
+void tst_QKeySequence::parseString()
+{
+ QFETCH( QString, strSequence );
+ QFETCH( QKeySequence, keycode );
+
+ QCOMPARE( QKeySequence(strSequence).toString(), keycode.toString() );
+ QVERIFY( QKeySequence(strSequence) == keycode );
+}
+
void tst_QKeySequence::fromString_data()
{
toString_data();