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

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 "administratorserverinfowidgettest.h"
0008 #include "administratordialog/serverinfo/administratorserverinfowidget.h"
0009 #include <KTreeWidgetSearchLineWidget>
0010 #include <QHeaderView>
0011 #include <QPushButton>
0012 #include <QTest>
0013 #include <QTreeWidget>
0014 #include <QVBoxLayout>
0015 QTEST_MAIN(AdministratorServerInfoWidgetTest)
0016 AdministratorServerInfoWidgetTest::AdministratorServerInfoWidgetTest(QObject *parent)
0017     : QObject(parent)
0018 {
0019 }
0020 
0021 void AdministratorServerInfoWidgetTest::shouldHaveDefaultValues()
0022 {
0023     AdministratorServerInfoWidget w(nullptr);
0024     auto mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
0025     QVERIFY(mainLayout);
0026 
0027     auto mTreeWidget = w.findChild<QTreeWidget *>(QStringLiteral("mTreeWidget"));
0028     QVERIFY(mTreeWidget);
0029     QCOMPARE(mTreeWidget->columnCount(), 2);
0030     QCOMPARE(mTreeWidget->contextMenuPolicy(), Qt::CustomContextMenu);
0031     QVERIFY(mTreeWidget->header()->isHidden());
0032 
0033     auto mSearchLineWidget = w.findChild<KTreeWidgetSearchLineWidget *>(QStringLiteral("mSearchLineWidget"));
0034     QVERIFY(mSearchLineWidget);
0035 
0036     auto hboxLayout = w.findChild<QHBoxLayout *>(QStringLiteral("hboxLayout"));
0037     QVERIFY(hboxLayout);
0038     QCOMPARE(hboxLayout->contentsMargins(), QMargins{});
0039 
0040     auto mRefreshButton = w.findChild<QPushButton *>(QStringLiteral("mRefreshButton"));
0041     QVERIFY(mRefreshButton);
0042     QVERIFY(mRefreshButton->text().isEmpty());
0043     QVERIFY(!mRefreshButton->toolTip().isEmpty());
0044 }
0045 
0046 #include "moc_administratorserverinfowidgettest.cpp"