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

0001 /*
0002    SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "explorepermissionswidgettest.h"
0008 #include "explorepermissionsdialog/explorepermissionswidget.h"
0009 
0010 #include <QLabel>
0011 #include <QLineEdit>
0012 #include <QSortFilterProxyModel>
0013 #include <QStandardPaths>
0014 #include <QTest>
0015 #include <QTreeView>
0016 #include <QVBoxLayout>
0017 
0018 QTEST_MAIN(ExplorePermissionsWidgetTest)
0019 ExplorePermissionsWidgetTest::ExplorePermissionsWidgetTest(QObject *parent)
0020     : QObject{parent}
0021 {
0022     QStandardPaths::setTestModeEnabled(true);
0023 }
0024 
0025 void ExplorePermissionsWidgetTest::shouldHaveDefaultValues()
0026 {
0027     ExplorePermissionsWidget w;
0028     auto mTreeView = w.findChild<QTreeView *>(QStringLiteral("mTreeView"));
0029     QVERIFY(mTreeView);
0030     QVERIFY(!mTreeView->rootIsDecorated());
0031 
0032     auto mSearchLineWidget = w.findChild<QLineEdit *>(QStringLiteral("mSearchLineWidget"));
0033     QVERIFY(mSearchLineWidget);
0034     QVERIFY(mSearchLineWidget->text().isEmpty());
0035 
0036     auto mPermissionFilterProxyModel = w.findChild<QSortFilterProxyModel *>(QStringLiteral("permissionFilterProxyModel"));
0037     QVERIFY(mPermissionFilterProxyModel);
0038 
0039     auto mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
0040     QVERIFY(mainLayout);
0041     QCOMPARE(mainLayout->contentsMargins(), QMargins{});
0042 
0043     auto mOwnRoles = w.findChild<QLabel *>(QStringLiteral("mOwnRoles"));
0044     QVERIFY(mOwnRoles);
0045     QVERIFY(mOwnRoles->text().isEmpty());
0046     QCOMPARE(mOwnRoles->textInteractionFlags(), Qt::TextBrowserInteraction);
0047 }
0048 
0049 #include "moc_explorepermissionswidgettest.cpp"