File indexing completed on 2024-12-22 04:46:01

0001 /*
0002    SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "notificationhistorywidgettest.h"
0008 #include "misc/serverscombobox.h"
0009 #include "notificationhistory/notificationhistorydelegate.h"
0010 #include "notificationhistory/notificationhistorywidget.h"
0011 #include <QHBoxLayout>
0012 #include <QLineEdit>
0013 #include <QListView>
0014 #include <QTest>
0015 #include <QVBoxLayout>
0016 
0017 QTEST_MAIN(NotificationHistoryWidgetTest)
0018 
0019 NotificationHistoryWidgetTest::NotificationHistoryWidgetTest(QObject *parent)
0020     : QObject{parent}
0021 {
0022 }
0023 
0024 void NotificationHistoryWidgetTest::shouldHaveDefaultValues()
0025 {
0026     NotificationHistoryWidget w;
0027 
0028     auto mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
0029     QVERIFY(mainLayout);
0030     QCOMPARE(mainLayout->contentsMargins(), QMargins{});
0031 
0032     auto mListNotifications = w.findChild<QListView *>(QStringLiteral("mListNotifications"));
0033     QVERIFY(mListNotifications);
0034     QCOMPARE(mListNotifications->horizontalScrollBarPolicy(), Qt::ScrollBarAlwaysOff);
0035     QCOMPARE(mListNotifications->horizontalScrollBarPolicy(), Qt::ScrollBarAlwaysOff);
0036     QVERIFY(mListNotifications->wordWrap());
0037     QCOMPARE(mListNotifications->verticalScrollMode(), QAbstractItemView::ScrollPerPixel);
0038 
0039     auto listNotificationsDelegate = w.findChild<NotificationHistoryDelegate *>(QStringLiteral("listNotificationsDelegate"));
0040     QVERIFY(listNotificationsDelegate);
0041     QCOMPARE(mListNotifications->itemDelegate(), listNotificationsDelegate);
0042 
0043     auto searchLayout = w.findChild<QHBoxLayout *>(QStringLiteral("searchLayout"));
0044     QVERIFY(searchLayout);
0045     QCOMPARE(searchLayout->contentsMargins(), QMargins{});
0046 
0047     auto mSearchLineEdit = w.findChild<QLineEdit *>(QStringLiteral("mSearchLineEdit"));
0048     QVERIFY(mSearchLineEdit);
0049     QVERIFY(mSearchLineEdit->isClearButtonEnabled());
0050     QVERIFY(!mSearchLineEdit->placeholderText().isEmpty());
0051 
0052     auto mServersComboBox = w.findChild<ServersComboBox *>(QStringLiteral("mServersComboBox"));
0053     QVERIFY(mServersComboBox);
0054 }
0055 
0056 #include "moc_notificationhistorywidgettest.cpp"