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

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "roleeditwidgettest.h"
0008 #include "administratordialog/roles/roleeditwidget.h"
0009 #include "administratordialog/roles/rolescopecombobox.h"
0010 #include <QCheckBox>
0011 #include <QFormLayout>
0012 #include <QLineEdit>
0013 #include <QTest>
0014 QTEST_MAIN(RoleEditWidgetTest)
0015 RoleEditWidgetTest::RoleEditWidgetTest(QObject *parent)
0016     : QObject{parent}
0017 {
0018 }
0019 
0020 void RoleEditWidgetTest::shouldHaveDefaultValues()
0021 {
0022     RoleEditWidget w;
0023     auto mainLayout = w.findChild<QFormLayout *>(QStringLiteral("mainLayout"));
0024     QVERIFY(mainLayout);
0025     QCOMPARE(mainLayout->contentsMargins(), QMargins{});
0026 
0027     auto mName = w.findChild<QLineEdit *>(QStringLiteral("mName"));
0028     QVERIFY(mName);
0029     QVERIFY(mName->text().isEmpty());
0030 
0031     auto mDescription = w.findChild<QLineEdit *>(QStringLiteral("mDescription"));
0032     QVERIFY(mDescription);
0033     QVERIFY(mDescription->text().isEmpty());
0034 
0035     auto mTwoFactor = w.findChild<QCheckBox *>(QStringLiteral("mTwoFactor"));
0036     QVERIFY(mTwoFactor);
0037     QVERIFY(!mTwoFactor->isChecked());
0038     QVERIFY(!mTwoFactor->text().isEmpty());
0039 
0040     auto mRoleScopeComboBox = w.findChild<RoleScopeComboBox *>(QStringLiteral("mRoleScopeComboBox"));
0041     QVERIFY(mRoleScopeComboBox);
0042 
0043     QVERIFY(!w.roleEditDialogInfo().isValid());
0044 }
0045 
0046 void RoleEditWidgetTest::shouldVerifyRoleEditDialogInfoValues()
0047 {
0048     RoleEditWidget::RoleEditDialogInfo info;
0049     QVERIFY(!info.isValid());
0050     QVERIFY(info.mName.isEmpty());
0051     QVERIFY(info.mDescription.isEmpty());
0052     QVERIFY(info.mScope.isEmpty());
0053     QVERIFY(!info.mTwoFactor);
0054     QVERIFY(!info.mIsProtected);
0055 }
0056 
0057 #include "moc_roleeditwidgettest.cpp"