Commit 8b32c83b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add autotests

parent dcc08b5c
Pipeline #91951 passed with stage
in 42 minutes and 6 seconds
......@@ -9,3 +9,9 @@ ecm_add_test(scamdetectionwebenginetest.cpp
NAME_PREFIX "messageviewer-scamwebenginedetection-"
LINK_LIBRARIES KF5::MessageViewer Qt::Test Qt::WebEngine Qt::WebEngineWidgets
)
ecm_add_test(scamdetectioninfotest.cpp
TEST_NAME scamdetectioninfotest
NAME_PREFIX "messageviewer-scamdetection-"
LINK_LIBRARIES KF5::MessageViewer Qt::Test Qt::WebEngine Qt::WebEngineWidgets
)
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "scamdetectioninfotest.h"
#include "scamdetection/scamdetectioninfo.h"
#include <QTest>
QTEST_GUILESS_MAIN(ScamDetectionInfoTest)
ScamDetectionInfoTest::ScamDetectionInfoTest(QObject *parent)
: QObject{parent}
{
}
void ScamDetectionInfoTest::shouldHaveDefaultValues()
{
MessageViewer::ScamDetectionInfo info;
QVERIFY(!info.enabled());
QVERIFY(info.domainOrEmail().isEmpty());
}
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#pragma once
#include <QObject>
class ScamDetectionInfoTest : public QObject
{
Q_OBJECT
public:
explicit ScamDetectionInfoTest(QObject *parent = nullptr);
~ScamDetectionInfoTest() override = default;
private Q_SLOTS:
void shouldHaveDefaultValues();
};
......@@ -14,3 +14,30 @@ ScamDetectionInfo::ScamDetectionInfo()
ScamDetectionInfo::~ScamDetectionInfo()
{
}
const QString &ScamDetectionInfo::domainOrEmail() const
{
return mDomainOrEmail;
}
void ScamDetectionInfo::setDomainOrEmail(const QString &newDomainOrEmail)
{
mDomainOrEmail = newDomainOrEmail;
}
bool ScamDetectionInfo::enabled() const
{
return mEnabled;
}
void ScamDetectionInfo::setEnabled(bool newEnabled)
{
mEnabled = newEnabled;
}
QDebug operator<<(QDebug d, const MessageViewer::ScamDetectionInfo &t)
{
d << "Enabled " << t.enabled();
d << "DomainOrName " << t.domainOrEmail();
return d;
}
......@@ -5,13 +5,30 @@
*/
#pragma once
#include "messageviewer_private_export.h"
#include <QDebug>
namespace MessageViewer
{
class ScamDetectionInfo
/**
* @brief The ScamDetectionInfo class
* @author Laurent Montel <montel@kde.org>
*/
class MESSAGEVIEWER_TESTS_EXPORT ScamDetectionInfo
{
public:
ScamDetectionInfo();
~ScamDetectionInfo();
Q_REQUIRED_RESULT const QString &domainOrEmail() const;
void setDomainOrEmail(const QString &newDomainOrEmail);
Q_REQUIRED_RESULT bool enabled() const;
void setEnabled(bool newEnabled);
private:
QString mDomainOrEmail;
bool mEnabled = false;
};
}
Q_DECLARE_TYPEINFO(MessageViewer::ScamDetectionInfo, Q_MOVABLE_TYPE);
MESSAGEVIEWER_EXPORT QDebug operator<<(QDebug d, const MessageViewer::ScamDetectionInfo &t);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment