Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b48d052a authored by Kurt Hindenburg's avatar Kurt Hindenburg

Add some testing of KeyboardTranslator using fallback class

parent db932cc0
......@@ -312,7 +312,7 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(KeyboardTranslator::States)
Q_DECLARE_OPERATORS_FOR_FLAGS(KeyboardTranslator::Commands)
class FallbackKeyboardTranslator : public KeyboardTranslator
class KONSOLEPRIVATE_EXPORT FallbackKeyboardTranslator : public KeyboardTranslator
{
public:
FallbackKeyboardTranslator();
......
/*
Copyright 2013 by Kurt Hindenburg <kurt.hindenburg@gmail.com>
Copyright 2013, 2018 by Kurt Hindenburg <kurt.hindenburg@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -96,5 +96,30 @@ void KeyboardTranslatorTest::testEntryTextWildcards()
QCOMPARE(entry.text(wildcards, modifiers), result);
}
// Use FallbackKeyboardTranslator to test basic functionality
void KeyboardTranslatorTest::testFallback()
{
auto fallback = new FallbackKeyboardTranslator();
QCOMPARE(QStringLiteral("fallback"), fallback->name());
QCOMPARE(QStringLiteral("Fallback Keyboard Translator"), fallback->description());
auto entries = fallback->entries();
QCOMPARE(1, entries.size());
auto entry = fallback->findEntry(Qt::Key_Tab, nullptr);
QVERIFY(!entry.isNull());
QCOMPARE(FallbackKeyboardTranslator::Command::NoCommand, entry.command());
QCOMPARE(Qt::Key_Tab, entry.keyCode());
QCOMPARE(QByteArray("\t"), entry.text());
QCOMPARE(QByteArray("\\t"), entry.escapedText());
QCOMPARE(Qt::NoModifier, entry.modifiers());
QCOMPARE(Qt::NoModifier, entry.modifierMask());
QCOMPARE(KeyboardTranslator::NoState, entry.state());
QCOMPARE(QStringLiteral("Tab"), entry.conditionToString());
QCOMPARE(QStringLiteral("\\t"), entry.resultToString());
QVERIFY(entry.matches(Qt::Key_Tab, Qt::NoModifier, KeyboardTranslator::NoState));
QVERIFY(entry == fallback->findEntry(Qt::Key_Tab, nullptr));
}
QTEST_GUILESS_MAIN(KeyboardTranslatorTest)
......@@ -33,6 +33,7 @@ class KeyboardTranslatorTest : public QObject
private Q_SLOTS:
void testEntryTextWildcards();
void testEntryTextWildcards_data();
void testFallback();
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment