File indexing completed on 2024-05-26 05:05:33
0001 /* 0002 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #include "ldapsettingswidgettest.h" 0007 #include "administratorsettingsdialog/ldap/ldapsettingswidget.h" 0008 #include "settingswidgetshelper.h" 0009 #include <KPasswordLineEdit> 0010 #include <QCheckBox> 0011 #include <QLineEdit> 0012 #include <QSpinBox> 0013 0014 QTEST_MAIN(LDapSettingsWidgetTest) 0015 LDapSettingsWidgetTest::LDapSettingsWidgetTest(QObject *parent) 0016 : QObject{parent} 0017 { 0018 } 0019 0020 void LDapSettingsWidgetTest::shouldHaveDefaultValues() 0021 { 0022 LDapSettingsWidget w(nullptr); 0023 auto mEnabled = w.findChild<QCheckBox *>(QStringLiteral("mEnabled")); 0024 QVERIFY(mEnabled); 0025 QVERIFY(!mEnabled->isChecked()); 0026 QVERIFY(!mEnabled->text().isEmpty()); 0027 QVERIFY(!mEnabled->toolTip().isEmpty()); 0028 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mEnabled), QStringLiteral("LDAP_Enable")); 0029 0030 auto mHost = w.findChild<QLineEdit *>(QStringLiteral("mHost")); 0031 QVERIFY(mHost); 0032 QVERIFY(mHost->text().isEmpty()); 0033 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mHost), QStringLiteral("LDAP_Host")); 0034 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("LDAP_Host")); 0035 0036 auto mPort = w.findChild<QSpinBox *>(QStringLiteral("mPort")); 0037 QVERIFY(mPort); 0038 QVERIFY(!mPort->toolTip().isEmpty()); 0039 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mPort), QStringLiteral("LDAP_Port")); 0040 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("LDAP_Port")); 0041 0042 auto mReconnect = w.findChild<QCheckBox *>(QStringLiteral("mReconnect")); 0043 QVERIFY(mReconnect); 0044 QVERIFY(!mReconnect->isChecked()); 0045 QVERIFY(!mReconnect->text().isEmpty()); 0046 QVERIFY(!mReconnect->toolTip().isEmpty()); 0047 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mReconnect), QStringLiteral("LDAP_Reconnect")); 0048 0049 auto mAuthenticationEnabled = w.findChild<QCheckBox *>(QStringLiteral("mAuthenticationEnabled")); 0050 QVERIFY(mAuthenticationEnabled); 0051 QVERIFY(!mAuthenticationEnabled->isChecked()); 0052 QVERIFY(!mAuthenticationEnabled->text().isEmpty()); 0053 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mAuthenticationEnabled), QStringLiteral("LDAP_Authentication")); 0054 0055 auto authenticationLabel = w.findChild<QLabel *>(QStringLiteral("authenticationLabel")); 0056 QVERIFY(authenticationLabel); 0057 QVERIFY(!authenticationLabel->text().isEmpty()); 0058 0059 auto mAuthenticationUserDN = w.findChild<QLineEdit *>(QStringLiteral("mAuthenticationUserDN")); 0060 QVERIFY(mAuthenticationUserDN); 0061 QVERIFY(mAuthenticationUserDN->text().isEmpty()); 0062 QVERIFY(!mAuthenticationUserDN->toolTip().isEmpty()); 0063 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mAuthenticationUserDN), QStringLiteral("LDAP_Authentication_UserDN")); 0064 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("LDAP_Authentication_UserDN")); 0065 0066 auto timeoutLabel = w.findChild<QLabel *>(QStringLiteral("timeoutLabel")); 0067 QVERIFY(timeoutLabel); 0068 QVERIFY(!timeoutLabel->text().isEmpty()); 0069 0070 auto mTimeouts = w.findChild<QSpinBox *>(QStringLiteral("mTimeouts")); 0071 QVERIFY(mTimeouts); 0072 QVERIFY(!mTimeouts->toolTip().isEmpty()); 0073 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mTimeouts), QStringLiteral("LDAP_Timeout")); 0074 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("LDAP_Timeout")); 0075 0076 auto mConnectionTimeouts = w.findChild<QSpinBox *>(QStringLiteral("mConnectionTimeouts")); 0077 QVERIFY(mConnectionTimeouts); 0078 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mConnectionTimeouts), QStringLiteral("LDAP_Connect_Timeout")); 0079 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("LDAP_Connect_Timeout")); 0080 0081 auto mIdleTimeouts = w.findChild<QSpinBox *>(QStringLiteral("mIdleTimeouts")); 0082 QVERIFY(mIdleTimeouts); 0083 QVERIFY(!mIdleTimeouts->toolTip().isEmpty()); 0084 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mIdleTimeouts), QStringLiteral("LDAP_Idle_Timeout")); 0085 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("LDAP_Idle_Timeout")); 0086 0087 auto mAuthenticationPassword = w.findChild<KPasswordLineEdit *>(QStringLiteral("mAuthenticationPassword")); 0088 QVERIFY(mAuthenticationPassword); 0089 QVERIFY(mAuthenticationPassword->password().isEmpty()); 0090 QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mAuthenticationPassword), QStringLiteral("LDAP_Authentication_Password")); 0091 SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("LDAP_Authentication_Password")); 0092 } 0093 0094 #include "moc_ldapsettingswidgettest.cpp"