File indexing completed on 2025-01-05 04:58:19

0001 /*
0002   SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: LGPL-2.0-or-later
0005 
0006 */
0007 
0008 #include "completionconfiguredialogtest.h"
0009 #include "addressline/completionconfiguredialog/completionconfiguredialog.h"
0010 #include <QDialogButtonBox>
0011 #include <QStandardPaths>
0012 #include <QTabWidget>
0013 #include <QTest>
0014 
0015 CompletionConfigureDialogTest::CompletionConfigureDialogTest(QObject *parent)
0016     : QObject(parent)
0017 {
0018 }
0019 
0020 CompletionConfigureDialogTest::~CompletionConfigureDialogTest() = default;
0021 
0022 void CompletionConfigureDialogTest::initTestCase()
0023 {
0024     QStandardPaths::setTestModeEnabled(true);
0025 }
0026 
0027 void CompletionConfigureDialogTest::shouldHaveDefaultValue()
0028 {
0029     PimCommon::CompletionConfigureDialog dlg;
0030 
0031     auto buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
0032     QVERIFY(buttonBox);
0033     QCOMPARE(buttonBox->standardButtons(), QDialogButtonBox::StandardButtons{QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel});
0034 
0035     auto tabWidget = dlg.findChild<QTabWidget *>(QStringLiteral("tabwidget"));
0036     QVERIFY(tabWidget);
0037     QVERIFY(tabWidget->count() > 0);
0038     for (int i = 0; i < tabWidget->count(); ++i) {
0039         const QString objName = tabWidget->widget(i)->objectName();
0040         const bool hasName = (objName == QLatin1StringView("completionorder_widget")) || (objName == QLatin1StringView("recentaddress_widget"))
0041             || (objName == QLatin1StringView("blacklistbaloo_widget"));
0042         QVERIFY(hasName);
0043     }
0044 }
0045 
0046 QTEST_MAIN(CompletionConfigureDialogTest)
0047 
0048 #include "moc_completionconfiguredialogtest.cpp"