File indexing completed on 2026-06-07 12:41:36

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "prunemessageswidgettest.h"
0008 #include "misc/adduserswidget.h"
0009 #include "prunemessages/prunemessageswidget.h"
0010 #include <QCheckBox>
0011 #include <QDateTimeEdit>
0012 #include <QLabel>
0013 #include <QTest>
0014 #include <QVBoxLayout>
0015 QTEST_MAIN(PruneMessagesWidgetTest)
0016 
0017 PruneMessagesWidgetTest::PruneMessagesWidgetTest(QObject *parent)
0018     : QObject(parent)
0019 {
0020 }
0021 
0022 void PruneMessagesWidgetTest::shouldHaveDefaultValues()
0023 {
0024     PruneMessagesWidget w(nullptr);
0025 
0026     auto mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
0027     QVERIFY(mainLayout);
0028     QCOMPARE(mainLayout->contentsMargins(), QMargins{});
0029 
0030     auto lastestLayout = w.findChild<QHBoxLayout *>(QStringLiteral("lastestLayout"));
0031     QVERIFY(lastestLayout);
0032     QCOMPARE(lastestLayout->contentsMargins(), QMargins{});
0033 
0034     auto lastestLabel = w.findChild<QLabel *>(QStringLiteral("lastestLabel"));
0035     QVERIFY(lastestLabel);
0036     QVERIFY(!lastestLabel->text().isEmpty());
0037 
0038     auto mLastestDateTimeEdit = w.findChild<QDateTimeEdit *>(QStringLiteral("mLastestDateTimeEdit"));
0039     QVERIFY(mLastestDateTimeEdit);
0040 
0041     auto oldestLayout = w.findChild<QHBoxLayout *>(QStringLiteral("oldestLayout"));
0042     QVERIFY(oldestLayout);
0043     QCOMPARE(oldestLayout->contentsMargins(), QMargins{});
0044 
0045     auto oldestLabel = w.findChild<QLabel *>(QStringLiteral("oldestLabel"));
0046     QVERIFY(oldestLabel);
0047     QVERIFY(!oldestLabel->text().isEmpty());
0048 
0049     auto mOldestDateTimeEdit = w.findChild<QDateTimeEdit *>(QStringLiteral("mLastestDateTimeEdit"));
0050     QVERIFY(mOldestDateTimeEdit);
0051 
0052     auto usersLabel = w.findChild<QLabel *>(QStringLiteral("usersLabel"));
0053     QVERIFY(usersLabel);
0054     QVERIFY(!usersLabel->text().isEmpty());
0055     QVERIFY(usersLabel->wordWrap());
0056     QCOMPARE(usersLabel->textFormat(), Qt::PlainText);
0057 
0058     auto mUsers = w.findChild<AddUsersWidget *>(QStringLiteral("mUsers"));
0059     QVERIFY(mUsers);
0060     mainLayout->addWidget(mUsers);
0061 
0062     auto mInclusive = w.findChild<QCheckBox *>(QStringLiteral("mInclusive"));
0063     QVERIFY(mInclusive);
0064     QVERIFY(!mInclusive->text().isEmpty());
0065     QVERIFY(!mInclusive->isChecked());
0066 
0067     auto mDoNotPrunePinnedMessage = w.findChild<QCheckBox *>(QStringLiteral("mDoNotPrunePinnedMessage"));
0068     QVERIFY(mDoNotPrunePinnedMessage);
0069     QVERIFY(!mDoNotPrunePinnedMessage->text().isEmpty());
0070     QVERIFY(!mDoNotPrunePinnedMessage->isChecked());
0071 
0072     auto mDoNotPruneDiscussionMessage = w.findChild<QCheckBox *>(QStringLiteral("mDoNotPruneDiscussionMessage"));
0073     QVERIFY(mDoNotPruneDiscussionMessage);
0074     QVERIFY(!mDoNotPruneDiscussionMessage->text().isEmpty());
0075     QVERIFY(!mDoNotPruneDiscussionMessage->isChecked());
0076 
0077     auto mDoNotPruneThreads = w.findChild<QCheckBox *>(QStringLiteral("mDoNotPruneThreads"));
0078     QVERIFY(mDoNotPruneThreads);
0079     QVERIFY(!mDoNotPruneThreads->text().isEmpty());
0080     QVERIFY(!mDoNotPruneThreads->isChecked());
0081 
0082     auto mOnlyRemoveAttachedFiles = w.findChild<QCheckBox *>(QStringLiteral("mOnlyRemoveAttachedFiles"));
0083     QVERIFY(mOnlyRemoveAttachedFiles);
0084     QVERIFY(!mOnlyRemoveAttachedFiles->text().isEmpty());
0085     QVERIFY(!mOnlyRemoveAttachedFiles->isChecked());
0086 
0087     auto mInfoLabel = w.findChild<QLabel *>(QStringLiteral("mInfoLabel"));
0088     QVERIFY(mInfoLabel);
0089     QVERIFY(mInfoLabel->text().isEmpty());
0090     QVERIFY(mInfoLabel->wordWrap());
0091 }
0092 
0093 #include "moc_prunemessageswidgettest.cpp"