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

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 "encryptionsettingswidgettest.h"
0008 #include "administratorsettingsdialog/encryption/encryptionsettingswidget.h"
0009 #include "settingswidgetshelper.h"
0010 #include <QCheckBox>
0011 #include <QFormLayout>
0012 
0013 QTEST_MAIN(EncryptionSettingsWidgetTest)
0014 EncryptionSettingsWidgetTest::EncryptionSettingsWidgetTest(QObject *parent)
0015     : QObject{parent}
0016 {
0017 }
0018 
0019 void EncryptionSettingsWidgetTest::shouldHaveDefaultValues()
0020 {
0021     EncryptionSettingsWidget w(nullptr);
0022     QVERIFY(w.widgetResizable());
0023 
0024     auto mainLayout = w.findChild<QFormLayout *>(QStringLiteral("mainLayout"));
0025     QVERIFY(mainLayout);
0026 
0027     auto mEnableE2E = w.findChild<QCheckBox *>(QStringLiteral("mEnableE2E"));
0028     QVERIFY(mEnableE2E);
0029     QVERIFY(!mEnableE2E->isChecked());
0030     QVERIFY(!mEnableE2E->text().isEmpty());
0031     QVERIFY(!mEnableE2E->toolTip().isEmpty());
0032     QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mEnableE2E), QStringLiteral("E2E_Enable"));
0033 
0034     auto mEnableEncryptionDirectRoomsByDefault = w.findChild<QCheckBox *>(QStringLiteral("mEnableEncryptionDirectRoomsByDefault"));
0035     QVERIFY(mEnableEncryptionDirectRoomsByDefault);
0036     QVERIFY(!mEnableEncryptionDirectRoomsByDefault->isChecked());
0037     QVERIFY(!mEnableEncryptionDirectRoomsByDefault->text().isEmpty());
0038     QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mEnableEncryptionDirectRoomsByDefault), QStringLiteral("E2E_Enabled_Default_DirectRooms"));
0039 
0040     auto mEnableEncryptionPrivateRoomsByDefault = w.findChild<QCheckBox *>(QStringLiteral("mEnableEncryptionPrivateRoomsByDefault"));
0041     QVERIFY(mEnableEncryptionPrivateRoomsByDefault);
0042     QVERIFY(!mEnableEncryptionPrivateRoomsByDefault->isChecked());
0043     QVERIFY(!mEnableEncryptionPrivateRoomsByDefault->text().isEmpty());
0044     QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mEnableEncryptionPrivateRoomsByDefault), QStringLiteral("E2E_Enabled_Default_PrivateRooms"));
0045 
0046     auto mEnableOtr = w.findChild<QCheckBox *>(QStringLiteral("mEnableOtr"));
0047     QVERIFY(mEnableOtr);
0048     QVERIFY(!mEnableOtr->isChecked());
0049     QVERIFY(!mEnableOtr->text().isEmpty());
0050     QVERIFY(!mEnableOtr->toolTip().isEmpty());
0051     QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mEnableOtr), QStringLiteral("OTR_Enabled"));
0052 }
0053 
0054 #include "moc_encryptionsettingswidgettest.cpp"