File indexing completed on 2024-06-09 04:59:29
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #include "servererrorinfomessagehistorywidgettest.h" 0007 #include "misc/serverscombobox.h" 0008 #include "servererrorinfohistory/servererrorinfohistorydelegate.h" 0009 #include "servererrorinfohistory/servererrorinfomessagehistorywidget.h" 0010 #include <QLineEdit> 0011 #include <QListView> 0012 #include <QTest> 0013 #include <QVBoxLayout> 0014 0015 QTEST_MAIN(ServerErrorInfoMessageHistoryWidgetTest) 0016 ServerErrorInfoMessageHistoryWidgetTest::ServerErrorInfoMessageHistoryWidgetTest(QObject *parent) 0017 : QObject{parent} 0018 { 0019 } 0020 0021 void ServerErrorInfoMessageHistoryWidgetTest::shouldHaveDefaultValues() 0022 { 0023 ServerErrorInfoMessageHistoryWidget w; 0024 0025 auto mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout")); 0026 QVERIFY(mainLayout); 0027 QCOMPARE(mainLayout->contentsMargins(), QMargins{}); 0028 0029 auto mListNotifications = w.findChild<QListView *>(QStringLiteral("mListServerInfosListView")); 0030 QVERIFY(mListNotifications); 0031 QCOMPARE(mListNotifications->horizontalScrollBarPolicy(), Qt::ScrollBarAlwaysOff); 0032 QCOMPARE(mListNotifications->horizontalScrollBarPolicy(), Qt::ScrollBarAlwaysOff); 0033 QVERIFY(mListNotifications->wordWrap()); 0034 QCOMPARE(mListNotifications->verticalScrollMode(), QAbstractItemView::ScrollPerPixel); 0035 0036 auto mListServerErrorInfosDelegate = w.findChild<ServerErrorInfoHistoryDelegate *>(QStringLiteral("mListServerErrorInfosDelegate")); 0037 QVERIFY(mListServerErrorInfosDelegate); 0038 QCOMPARE(mListNotifications->itemDelegate(), mListServerErrorInfosDelegate); 0039 0040 auto searchLayout = w.findChild<QHBoxLayout *>(QStringLiteral("searchLayout")); 0041 QVERIFY(searchLayout); 0042 QCOMPARE(searchLayout->contentsMargins(), QMargins{}); 0043 0044 auto mSearchLineEdit = w.findChild<QLineEdit *>(QStringLiteral("mSearchLineEdit")); 0045 QVERIFY(mSearchLineEdit); 0046 QVERIFY(mSearchLineEdit->isClearButtonEnabled()); 0047 QVERIFY(!mSearchLineEdit->placeholderText().isEmpty()); 0048 0049 auto mServersComboBox = w.findChild<ServersComboBox *>(QStringLiteral("mServersComboBox")); 0050 QVERIFY(mServersComboBox); 0051 } 0052 0053 #include "moc_servererrorinfomessagehistorywidgettest.cpp"