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

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 "webrtcsettingswidgettest.h"
0008 #include "administratorsettingsdialog/webrtc/webrtcsettingswidget.h"
0009 #include "settingswidgetshelper.h"
0010 #include <QComboBox>
0011 #include <QFormLayout>
0012 #include <QLineEdit>
0013 
0014 QTEST_MAIN(WebRtcSettingsWidgetTest)
0015 
0016 WebRtcSettingsWidgetTest::WebRtcSettingsWidgetTest(QObject *parent)
0017     : QObject{parent}
0018 {
0019 }
0020 
0021 void WebRtcSettingsWidgetTest::shouldHaveDefaultValues()
0022 {
0023     WebRtcSettingsWidget w(nullptr);
0024     auto mEnabled = w.findChild<QCheckBox *>(QStringLiteral("mEnabled"));
0025     QVERIFY(mEnabled);
0026     QVERIFY(!mEnabled->isChecked());
0027     QVERIFY(!mEnabled->text().isEmpty());
0028     QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mEnabled), QStringLiteral("WebRTC_Enabled"));
0029 
0030     auto mEnablePublicChannels = w.findChild<QCheckBox *>(QStringLiteral("mEnablePublicChannels"));
0031     QVERIFY(mEnablePublicChannels);
0032     QVERIFY(!mEnablePublicChannels->isChecked());
0033     QVERIFY(!mEnablePublicChannels->text().isEmpty());
0034     QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mEnablePublicChannels), QStringLiteral("WebRTC_Enable_Channel"));
0035 
0036     auto mEnablePrivateChannels = w.findChild<QCheckBox *>(QStringLiteral("mEnablePrivateChannels"));
0037     QVERIFY(mEnablePrivateChannels);
0038     QVERIFY(!mEnablePrivateChannels->isChecked());
0039     QVERIFY(!mEnablePrivateChannels->text().isEmpty());
0040     QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mEnablePrivateChannels), QStringLiteral("WebRTC_Enable_Private"));
0041 
0042     auto mEnableDirectMessages = w.findChild<QCheckBox *>(QStringLiteral("mEnableDirectMessages"));
0043     QVERIFY(mEnableDirectMessages);
0044     QVERIFY(!mEnableDirectMessages->isChecked());
0045     QVERIFY(!mEnableDirectMessages->text().isEmpty());
0046     QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mEnableDirectMessages), QStringLiteral("WebRTC_Enable_Direct"));
0047 
0048     auto mServer = w.findChild<QLineEdit *>(QStringLiteral("mServer"));
0049     QVERIFY(mServer);
0050     QVERIFY(mServer->text().isEmpty());
0051     QVERIFY(!mServer->toolTip().isEmpty());
0052     QCOMPARE(SettingsWidgetHelper::widgetSettingsName(mServer), QStringLiteral("WebRTC_Servers"));
0053     SettingsWidgetHelper::checkLabelToolButton(&w, QStringLiteral("WebRTC_Servers"));
0054 }
0055 
0056 #include "moc_webrtcsettingswidgettest.cpp"