File indexing completed on 2024-12-22 04:46:00

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "myaccount2faconfigurewidgettest.h"
0008 #include "myaccount/myaccount2faconfigurewidget.h"
0009 #include "myaccount/myaccount2fadisabletotpwidget.h"
0010 #include "myaccount/myaccount2fatotpwidget.h"
0011 #include <QCheckBox>
0012 #include <QLabel>
0013 #include <QStackedWidget>
0014 #include <QTest>
0015 #include <QVBoxLayout>
0016 QTEST_MAIN(MyAccount2FaConfigureWidgetTest)
0017 MyAccount2FaConfigureWidgetTest::MyAccount2FaConfigureWidgetTest(QObject *parent)
0018     : QObject(parent)
0019 {
0020 }
0021 
0022 void MyAccount2FaConfigureWidgetTest::shouldHaveDefaultValues()
0023 {
0024     MyAccount2FaConfigureWidget w(nullptr);
0025     auto mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
0026     QVERIFY(mainLayout);
0027 
0028     auto mActivate2FAViaEmailCheckbox = w.findChild<QCheckBox *>(QStringLiteral("mActivate2FAViaEmailCheckbox"));
0029     QVERIFY(mActivate2FAViaEmailCheckbox);
0030     QVERIFY(!mActivate2FAViaEmailCheckbox->isChecked());
0031     QVERIFY(!mActivate2FAViaEmailCheckbox->text().isEmpty());
0032 
0033     auto mActivate2FAViaTOTPCheckbox = w.findChild<QCheckBox *>(QStringLiteral("mActivate2FAViaTOTPCheckbox"));
0034     QVERIFY(mActivate2FAViaTOTPCheckbox);
0035     QVERIFY(!mActivate2FAViaTOTPCheckbox->isChecked());
0036     QVERIFY(!mActivate2FAViaTOTPCheckbox->text().isEmpty());
0037 
0038     auto mTotpQrCode = w.findChild<QLabel *>(QStringLiteral("mTotpQrCode"));
0039     QVERIFY(mTotpQrCode);
0040     QVERIFY(mTotpQrCode->text().isEmpty());
0041 
0042     auto mMyAccount2FaTotpWidget = w.findChild<MyAccount2FaTotpWidget *>(QStringLiteral("mMyAccount2FaTotpWidget"));
0043     QVERIFY(mMyAccount2FaTotpWidget);
0044 
0045     auto mMyAccountDisable2FaTotpWidget = w.findChild<MyAccount2FaDisableTotpWidget *>(QStringLiteral("mMyAccountDisable2FaTotpWidget"));
0046     QVERIFY(mMyAccountDisable2FaTotpWidget);
0047 
0048     auto mMyAccount2FaEmpty = w.findChild<QWidget *>(QStringLiteral("mMyAccount2FaEmpty"));
0049     QVERIFY(mMyAccount2FaEmpty);
0050 
0051     auto mStackedWidget = w.findChild<QStackedWidget *>(QStringLiteral("mStackedWidget"));
0052     QVERIFY(mStackedWidget);
0053 }
0054 
0055 #include "moc_myaccount2faconfigurewidgettest.cpp"