File indexing completed on 2025-02-16 04:55:55

0001 /*
0002    SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "selectheadersdialogtest.h"
0008 #include "../sieveconditions/widgets/selectheadertypecombobox.h"
0009 #include <QDialogButtonBox>
0010 #include <QLabel>
0011 #include <QLineEdit>
0012 #include <QPushButton>
0013 #include <QStandardPaths>
0014 #include <QTest>
0015 #include <QVBoxLayout>
0016 
0017 SelectHeadersDialogTest::SelectHeadersDialogTest(QObject *parent)
0018     : QObject(parent)
0019 {
0020     QStandardPaths::setTestModeEnabled(true);
0021 }
0022 
0023 SelectHeadersDialogTest::~SelectHeadersDialogTest() = default;
0024 
0025 void SelectHeadersDialogTest::shouldHaveDefaultValue()
0026 {
0027     KSieveUi::SelectHeadersDialog dlg;
0028     QVERIFY(!dlg.windowTitle().isEmpty());
0029 
0030     auto buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
0031     QVERIFY(buttonBox);
0032 
0033     auto lay = dlg.findChild<QVBoxLayout *>(QStringLiteral("widgetlayout"));
0034     QVERIFY(lay);
0035     QCOMPARE(lay->contentsMargins(), QMargins(0, 0, 0, 0));
0036 
0037     auto mListWidget = dlg.findChild<KSieveUi::SelectHeadersWidget *>(QStringLiteral("listwidget"));
0038     QVERIFY(mListWidget);
0039 
0040     auto lab = dlg.findChild<QLabel *>(QStringLiteral("label"));
0041     QVERIFY(lab);
0042     QVERIFY(!lab->text().isEmpty());
0043 
0044     auto mNewHeader = dlg.findChild<QLineEdit *>(QStringLiteral("newheader"));
0045     QVERIFY(mNewHeader);
0046     QVERIFY(mNewHeader->isClearButtonEnabled());
0047 
0048     auto mAddNewHeader = dlg.findChild<QPushButton *>(QStringLiteral("addnewheader"));
0049     QVERIFY(mAddNewHeader);
0050     QVERIFY(!mAddNewHeader->isEnabled());
0051 }
0052 
0053 QTEST_MAIN(SelectHeadersDialogTest)
0054 
0055 #include "moc_selectheadersdialogtest.cpp"