diff --git a/src/modules/keyboard/CMakeLists.txt b/src/modules/keyboard/CMakeLists.txt index 4ee83ec14..40e8a85d7 100644 --- a/src/modules/keyboard/CMakeLists.txt +++ b/src/modules/keyboard/CMakeLists.txt @@ -21,3 +21,10 @@ calamares_add_plugin( keyboard calamaresui SHARED_LIB ) + +calamares_add_test( + keyboardtest + SOURCES + Tests.cpp + SetKeyboardLayoutJob.cpp +) diff --git a/src/modules/keyboard/Tests.cpp b/src/modules/keyboard/Tests.cpp new file mode 100644 index 000000000..95c317b79 --- /dev/null +++ b/src/modules/keyboard/Tests.cpp @@ -0,0 +1,64 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2020 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ +#include "utils/Logger.h" + +#include + +// 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"