diff --git a/kmail/grammarplugins/languagetool/autotests/languagetoolconfigwidgettest.cpp b/kmail/grammarplugins/languagetool/autotests/languagetoolconfigwidgettest.cpp index 8a2a9745..e3742085 100644 --- a/kmail/grammarplugins/languagetool/autotests/languagetoolconfigwidgettest.cpp +++ b/kmail/grammarplugins/languagetool/autotests/languagetoolconfigwidgettest.cpp @@ -1,73 +1,93 @@ /* Copyright (C) 2019 Montel Laurent 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "languagetoolconfigwidgettest.h" #include "languagetoolconfigwidget.h" #include "languagetoolcombobox.h" #include "kdepimtest_layout.h" #include #include #include #include #include #include #include QTEST_MAIN(LanguageToolConfigWidgetTest) LanguageToolConfigWidgetTest::LanguageToolConfigWidgetTest(QObject *parent) : QObject(parent) { QStandardPaths::setTestModeEnabled(true); } void LanguageToolConfigWidgetTest::shouldHaveDefaultValue() { LanguageToolConfigWidget w; QVBoxLayout *mainLayout = w.findChild(QStringLiteral("mainlayout")); QVERIFY(mainLayout); KdepimTestLayout::checkContentsMargins(0, mainLayout); QCheckBox *mUseLocalInstance = w.findChild(QStringLiteral("uselocalinstance")); QVERIFY(mUseLocalInstance); QVERIFY(!mUseLocalInstance->text().isEmpty()); QVERIFY(!mUseLocalInstance->isChecked()); QLabel *instancePathLabel = w.findChild(QStringLiteral("instancepath")); QVERIFY(instancePathLabel); QVERIFY(!instancePathLabel->text().isEmpty()); QVERIFY(!instancePathLabel->isEnabled()); QLineEdit *mInstancePath = w.findChild(QStringLiteral("instancepath")); QVERIFY(mInstancePath); //We load default value QVERIFY(!mInstancePath->text().isEmpty()); QVERIFY(!mInstancePath->isEnabled()); QVERIFY(mInstancePath->isClearButtonEnabled()); QLabel *languageLabel = w.findChild(QStringLiteral("languageLabel")); QVERIFY(languageLabel); QVERIFY(!languageLabel->text().isEmpty()); LanguageToolComboBox *mLanguageToolCombobox = w.findChild(QStringLiteral("languagecombobox")); QVERIFY(mLanguageToolCombobox); QToolButton *refreshButton = w.findChild(QStringLiteral("refreshbutton")); QVERIFY(refreshButton); QVERIFY(!refreshButton->icon().isNull()); } + +void LanguageToolConfigWidgetTest::shouldUpdateWidgets() +{ + LanguageToolConfigWidget w; + + QCheckBox *mUseLocalInstance = w.findChild(QStringLiteral("uselocalinstance")); + + QLabel *instancePathLabel = w.findChild(QStringLiteral("instancepath")); + + QLineEdit *mInstancePath = w.findChild(QStringLiteral("instancepath")); + mUseLocalInstance->setChecked(true); + QVERIFY(mUseLocalInstance->isEnabled()); + QVERIFY(instancePathLabel->isEnabled()); + QVERIFY(mInstancePath->isEnabled()); + + mUseLocalInstance->setChecked(false); + QVERIFY(mUseLocalInstance->isEnabled()); + QVERIFY(!instancePathLabel->isEnabled()); + QVERIFY(!mInstancePath->isEnabled()); +} diff --git a/kmail/grammarplugins/languagetool/autotests/languagetoolconfigwidgettest.h b/kmail/grammarplugins/languagetool/autotests/languagetoolconfigwidgettest.h index e970e3ab..f536213a 100644 --- a/kmail/grammarplugins/languagetool/autotests/languagetoolconfigwidgettest.h +++ b/kmail/grammarplugins/languagetool/autotests/languagetoolconfigwidgettest.h @@ -1,35 +1,36 @@ /* Copyright (C) 2019 Montel Laurent 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LANGUAGETOOLCONFIGWIDGETTEST_H #define LANGUAGETOOLCONFIGWIDGETTEST_H #include class LanguageToolConfigWidgetTest : public QObject { Q_OBJECT public: explicit LanguageToolConfigWidgetTest(QObject *parent = nullptr); ~LanguageToolConfigWidgetTest() = default; private Q_SLOTS: void shouldHaveDefaultValue(); + void shouldUpdateWidgets(); }; #endif // LANGUAGETOOLCONFIGWIDGETTEST_H