File indexing completed on 2024-06-16 04:27:58
0001 /* 0002 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "grammalecteconfigwidgettest.h" 0008 #include "grammalecte/grammalecteconfigwidget.h" 0009 #include "grammalecte/grammalecteurlrequesterwidget.h" 0010 #include <QFormLayout> 0011 #include <QLabel> 0012 #include <QScrollArea> 0013 #include <QStackedWidget> 0014 #include <QStandardPaths> 0015 #include <QTabWidget> 0016 #include <QTest> 0017 #include <QToolButton> 0018 #include <QVBoxLayout> 0019 QTEST_MAIN(GrammalecteConfigWidgetTest) 0020 GrammalecteConfigWidgetTest::GrammalecteConfigWidgetTest(QObject *parent) 0021 : QObject(parent) 0022 { 0023 QStandardPaths::setTestModeEnabled(true); 0024 } 0025 0026 void GrammalecteConfigWidgetTest::shouldHaveDefaultValue() 0027 { 0028 TextGrammarCheck::GrammalecteConfigWidget w(nullptr, true); 0029 auto mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout")); 0030 QVERIFY(mainLayout); 0031 QCOMPARE(mainLayout->contentsMargins(), QMargins()); 0032 0033 auto mTab = w.findChild<QTabWidget *>(QStringLiteral("mTab")); 0034 QVERIFY(mTab); 0035 0036 auto generalWidget = mTab->findChild<QWidget *>(QStringLiteral("general")); 0037 QVERIFY(generalWidget); 0038 auto lay = generalWidget->findChild<QFormLayout *>(QStringLiteral("generallayout")); 0039 QVERIFY(lay); 0040 0041 auto mPythonPath = generalWidget->findChild<TextGrammarCheck::GrammalecteUrlRequesterWidget *>(QStringLiteral("pythonpath")); 0042 QVERIFY(mPythonPath); 0043 QVERIFY(!mPythonPath->path().isEmpty()); 0044 0045 auto mGrammalectePath = generalWidget->findChild<TextGrammarCheck::GrammalecteUrlRequesterWidget *>(QStringLiteral("grammalectepath")); 0046 QVERIFY(mGrammalectePath); 0047 QVERIFY(mGrammalectePath->path().isEmpty()); 0048 0049 auto grammalecteInfoDownload = generalWidget->findChild<QLabel *>(QStringLiteral("grammalecteInfoDownload")); 0050 QVERIFY(grammalecteInfoDownload); 0051 QVERIFY(!grammalecteInfoDownload->text().isEmpty()); 0052 QVERIFY(grammalecteInfoDownload->openExternalLinks()); 0053 QCOMPARE(grammalecteInfoDownload->textFormat(), Qt::RichText); 0054 0055 auto mStackedWidget = mTab->findChild<QStackedWidget *>(QStringLiteral("stackedwidget")); 0056 QVERIFY(mStackedWidget); 0057 auto mScrollArea = mStackedWidget->findChild<QScrollArea *>(QStringLiteral("scrollarea")); 0058 QVERIFY(mScrollArea); 0059 QVERIFY(mScrollArea->widget()); 0060 QCOMPARE(mScrollArea->widget()->objectName(), QStringLiteral("grammar")); 0061 0062 auto mReloadSettingsWidget = mStackedWidget->findChild<QWidget *>(QStringLiteral("reloadwidget")); 0063 QVERIFY(mReloadSettingsWidget); 0064 0065 auto reloadSettingsLayout = mReloadSettingsWidget->findChild<QVBoxLayout *>(QStringLiteral("reloadSettingsLayout")); 0066 QVERIFY(reloadSettingsLayout); 0067 0068 auto label = mReloadSettingsWidget->findChild<QLabel *>(QStringLiteral("label")); 0069 QVERIFY(label); 0070 QVERIFY(!label->text().isEmpty()); 0071 auto buttonReloadSettings = mReloadSettingsWidget->findChild<QToolButton *>(QStringLiteral("buttonReloadSettings")); 0072 QVERIFY(buttonReloadSettings); 0073 // QVERIFY(!buttonReloadSettings->icon().isNull()); 0074 } 0075 0076 #include "moc_grammalecteconfigwidgettest.cpp"