File indexing completed on 2024-09-22 04:19:06

0001 /*
0002    SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "translatorconfigurelanguagelistwidgettest.h"
0008 #include "translator/widgets/translatorconfigurelanguagelistwidget.h"
0009 #include <QLabel>
0010 #include <QLineEdit>
0011 #include <QListView>
0012 #include <QTest>
0013 #include <QVBoxLayout>
0014 QTEST_MAIN(TranslatorConfigureLanguageListWidgetTest)
0015 TranslatorConfigureLanguageListWidgetTest::TranslatorConfigureLanguageListWidgetTest(QObject *parent)
0016     : QObject{parent}
0017 {
0018 }
0019 
0020 void TranslatorConfigureLanguageListWidgetTest::shouldHaveDefaultValues()
0021 {
0022     TextTranslator::TranslatorConfigureLanguageListWidget w({});
0023     auto mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
0024     QVERIFY(mainLayout);
0025     QCOMPARE(mainLayout->contentsMargins(), QMargins{});
0026 
0027     auto mLanguageListWidget = w.findChild<QListView *>(QStringLiteral("mLanguageListWidget"));
0028     QVERIFY(mLanguageListWidget);
0029 
0030     auto mListSearchLine = w.findChild<QLineEdit *>(QStringLiteral("mListSearchLine"));
0031     QVERIFY(mListSearchLine);
0032     QVERIFY(!mListSearchLine->placeholderText().isEmpty());
0033 
0034     auto mLabel = w.findChild<QLabel *>(QStringLiteral("mLabel"));
0035     QVERIFY(mLabel);
0036     QVERIFY(mLabel->text().isEmpty());
0037     QVERIFY(w.selectedLanguages().isEmpty());
0038 }
0039 
0040 void TranslatorConfigureLanguageListWidgetTest::shouldAssignLabel()
0041 {
0042     const QString label{QStringLiteral("FOO")};
0043     TextTranslator::TranslatorConfigureLanguageListWidget w(label);
0044     auto mLabel = w.findChild<QLabel *>(QStringLiteral("mLabel"));
0045     QVERIFY(mLabel);
0046     QCOMPARE(mLabel->text(), label);
0047 }
0048 
0049 #include "moc_translatorconfigurelanguagelistwidgettest.cpp"