[keyboard] Add a stub for unit tests

This commit is contained in:
Adriaan de Groot 2020-09-08 17:13:44 +02:00
parent af3261b16f
commit 0d8e0d9b96
2 changed files with 71 additions and 0 deletions

View File

@ -21,3 +21,10 @@ calamares_add_plugin( keyboard
calamaresui
SHARED_LIB
)
calamares_add_test(
keyboardtest
SOURCES
Tests.cpp
SetKeyboardLayoutJob.cpp
)

View File

@ -0,0 +1,64 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*/
#include "utils/Logger.h"
#include <QtTest/QtTest>
// Internals of SetKeyboardLayoutJob.cpp
extern QString findLegacyKeymap( const QString& layout, const QString& model, const QString& variant );
class KeyboardLayoutTests : public QObject
{
Q_OBJECT
public:
KeyboardLayoutTests() {}
virtual ~KeyboardLayoutTests() {}
private Q_SLOTS:
void initTestCase();
void testSimpleLayoutLookup_data();
void testSimpleLayoutLookup();
};
void
KeyboardLayoutTests::initTestCase()
{
Logger::setupLogLevel( Logger::LOGDEBUG );
}
void
KeyboardLayoutTests::testSimpleLayoutLookup_data()
{
QTest::addColumn< QString >( "layout" );
QTest::addColumn< QString >( "model" );
QTest::addColumn< QString >( "variant" );
QTest::addColumn< QString >( "vconsole" );
QTest::newRow( "us" ) << QString( "us" ) << QString() << QString() << QString( "us" );
}
void
KeyboardLayoutTests::testSimpleLayoutLookup()
{
QFETCH( QString, layout );
QFETCH( QString, model );
QFETCH( QString, variant );
QFETCH( QString, vconsole );
QCOMPARE( findLegacyKeymap( layout, model, variant ), vconsole );
}
QTEST_GUILESS_MAIN( KeyboardLayoutTests )
#include "utils/moc-warnings.h"
#include "Tests.moc"