File indexing completed on 2024-12-22 04:45:56

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 "showdiscussionswidgettest.h"
0008 #include "discussions/showdiscussionswidget.h"
0009 #include <QLabel>
0010 #include <QLineEdit>
0011 #include <QListView>
0012 #include <QTest>
0013 #include <QVBoxLayout>
0014 QTEST_MAIN(ShowDiscussionsWidgetTest)
0015 ShowDiscussionsWidgetTest::ShowDiscussionsWidgetTest(QObject *parent)
0016     : QObject(parent)
0017 {
0018 }
0019 
0020 void ShowDiscussionsWidgetTest::shouldHaveDefaultValues()
0021 {
0022     ShowDiscussionsWidget w(nullptr);
0023 
0024     auto mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
0025     QVERIFY(mainLayout);
0026     QCOMPARE(mainLayout->contentsMargins(), QMargins{});
0027 
0028     auto mSearchDiscussionLineEdit = w.findChild<QLineEdit *>(QStringLiteral("mSearchDiscussionLineEdit"));
0029     QVERIFY(mSearchDiscussionLineEdit);
0030     QVERIFY(mSearchDiscussionLineEdit->text().isEmpty());
0031     QVERIFY(mSearchDiscussionLineEdit->isClearButtonEnabled());
0032     QVERIFY(!mSearchDiscussionLineEdit->placeholderText().isEmpty());
0033 
0034     auto mDiscussionInfoLabel = w.findChild<QLabel *>(QStringLiteral("mInfo"));
0035     QVERIFY(mDiscussionInfoLabel);
0036     QVERIFY(mDiscussionInfoLabel->text().isEmpty());
0037     QCOMPARE(mDiscussionInfoLabel->textFormat(), Qt::RichText);
0038 
0039     auto mListDiscussions = w.findChild<QListView *>(QStringLiteral("mListDiscussions"));
0040     QVERIFY(mListDiscussions);
0041     QVERIFY(mListDiscussions->itemDelegate());
0042 }
0043 
0044 #include "moc_showdiscussionswidgettest.cpp"