File indexing completed on 2025-03-09 04:54:27

0001 /*
0002    SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "dkimwidgetinfotest.h"
0008 #include "dkim-verify/dkimwidgetinfo.h"
0009 #include <MessageViewer/DKIMCheckSignatureJob>
0010 #include <QHBoxLayout>
0011 #include <QLabel>
0012 #include <QTest>
0013 
0014 QTEST_MAIN(DKIMWidgetInfoTest)
0015 DKIMWidgetInfoTest::DKIMWidgetInfoTest(QObject *parent)
0016     : QObject(parent)
0017 {
0018 }
0019 
0020 void DKIMWidgetInfoTest::shouldHaveDefaultValues()
0021 {
0022     MessageViewer::DKIMWidgetInfo w;
0023 
0024     auto mainLayout = w.findChild<QHBoxLayout *>(QStringLiteral("mainLayout"));
0025     QVERIFY(mainLayout);
0026     QCOMPARE(mainLayout->contentsMargins(), QMargins(0, 0, 0, 0));
0027 
0028     auto mLabel = w.findChild<QLabel *>(QStringLiteral("label"));
0029     QVERIFY(mLabel);
0030     QVERIFY(mLabel->text().isEmpty());
0031 
0032     QCOMPARE(w.currentItemId(), -1);
0033 }
0034 
0035 void DKIMWidgetInfoTest::shouldClearWidget()
0036 {
0037     MessageViewer::DKIMWidgetInfo w;
0038     auto mLabel = w.findChild<QLabel *>(QStringLiteral("label"));
0039     MessageViewer::DKIMCheckSignatureJob::CheckSignatureResult result;
0040     result.fromEmail = QStringLiteral("bla");
0041     result.sdid = QStringLiteral("bli");
0042     result.status = MessageViewer::DKIMCheckSignatureJob::DKIMStatus::NeedToBeSigned;
0043     result.error = MessageViewer::DKIMCheckSignatureJob::DKIMError::CorruptedBodyHash;
0044     result.warning = MessageViewer::DKIMCheckSignatureJob::DKIMWarning::HashAlgorithmUnsafe;
0045     w.setResult(result, -1);
0046     QVERIFY(!mLabel->text().isEmpty());
0047     w.clear();
0048     QVERIFY(mLabel->text().isEmpty());
0049     QCOMPARE(w.result(), MessageViewer::DKIMCheckSignatureJob::CheckSignatureResult());
0050 }
0051 
0052 #include "moc_dkimwidgetinfotest.cpp"