Changeset View
Changeset View
Standalone View
Standalone View
src/autotests/KeyboardTranslatorTest.cpp
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | Copyright 2013 by Kurt Hindenburg <kurt.hindenburg@gmail.com> | 2 | Copyright 2013, 2018 by Kurt Hindenburg <kurt.hindenburg@gmail.com> | ||
3 | 3 | | |||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | 6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | 7 | (at your option) any later version. | ||
8 | 8 | | |||
9 | This program is distributed in the hope that it will be useful, | 9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | 87 | { | |||
91 | QFETCH(Qt::KeyboardModifiers, modifiers); | 91 | QFETCH(Qt::KeyboardModifiers, modifiers); | ||
92 | 92 | | |||
93 | KeyboardTranslator::Entry entry; | 93 | KeyboardTranslator::Entry entry; | ||
94 | entry.setText(text); | 94 | entry.setText(text); | ||
95 | 95 | | |||
96 | QCOMPARE(entry.text(wildcards, modifiers), result); | 96 | QCOMPARE(entry.text(wildcards, modifiers), result); | ||
97 | } | 97 | } | ||
98 | 98 | | |||
99 | // Use FallbackKeyboardTranslator to test basic functionality | ||||
100 | void KeyboardTranslatorTest::testFallback() | ||||
101 | { | ||||
102 | auto fallback = new FallbackKeyboardTranslator(); | ||||
103 | | ||||
104 | QCOMPARE(QStringLiteral("fallback"), fallback->name()); | ||||
105 | QCOMPARE(QStringLiteral("Fallback Keyboard Translator"), fallback->description()); | ||||
106 | | ||||
107 | auto entries = fallback->entries(); | ||||
108 | QCOMPARE(1, entries.size()); | ||||
109 | auto entry = fallback->findEntry(Qt::Key_Tab, nullptr); | ||||
110 | QVERIFY(!entry.isNull()); | ||||
111 | QCOMPARE(FallbackKeyboardTranslator::Command::NoCommand, entry.command()); | ||||
112 | QCOMPARE(Qt::Key_Tab, entry.keyCode()); | ||||
113 | QCOMPARE(QByteArray("\t"), entry.text()); | ||||
114 | QCOMPARE(QByteArray("\\t"), entry.escapedText()); | ||||
115 | QCOMPARE(Qt::NoModifier, entry.modifiers()); | ||||
116 | QCOMPARE(Qt::NoModifier, entry.modifierMask()); | ||||
117 | QCOMPARE(KeyboardTranslator::NoState, entry.state()); | ||||
118 | QCOMPARE(QStringLiteral("Tab"), entry.conditionToString()); | ||||
119 | QCOMPARE(QStringLiteral("\\t"), entry.resultToString()); | ||||
120 | QVERIFY(entry.matches(Qt::Key_Tab, Qt::NoModifier, KeyboardTranslator::NoState)); | ||||
121 | QVERIFY(entry == fallback->findEntry(Qt::Key_Tab, nullptr)); | ||||
122 | } | ||||
123 | | ||||
99 | QTEST_GUILESS_MAIN(KeyboardTranslatorTest) | 124 | QTEST_GUILESS_MAIN(KeyboardTranslatorTest) | ||
100 | 125 | |