Commit e4d7d6cb authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add autotest

parent 03f5df51
Pipeline #200392 passed with stage
in 11 minutes and 54 seconds
# SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
# SPDX-License-Identifier: BSD-3-Clause
macro(add_kmail_akonadidatabasetoolsplugin_unittest _source _additional)
set( _test ${_source} ${_additional})
get_filename_component(_name ${_source} NAME_WE)
add_executable( ${_name} ${_test} )
add_test(NAME ${_name} COMMAND ${_name} )
ecm_mark_as_test(kmail_antivirusplugin-${_name})
target_link_libraries( ${_name} KF5::PimCommon Qt${QT_MAJOR_VERSION}::Test KF5::XmlGui KF5::Completion KF5::AkonadiWidgets KF5::MailCommon KF5::Libkdepim KF5::I18n KF5::GuiAddons)
endmacro ()
add_kmail_akonadidatabasetoolsplugin_unittest(akonadidatabasetoolsplugininterfacetest.cpp "../akonadidatabasetoolsplugininterface.cpp")
/*
SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "akonadidatabasetoolsplugininterfacetest.h"
#include "../akonadidatabasetoolsplugininterface.h"
#include <KActionCollection>
#include <QSignalSpy>
#include <QTest>
QTEST_MAIN(AkonadiDatabaseToolsPluginInterfaceTest)
AkonadiDatabaseToolsPluginInterfaceTest::AkonadiDatabaseToolsPluginInterfaceTest(QObject *parent)
: QObject(parent)
{
}
AkonadiDatabaseToolsPluginInterfaceTest::~AkonadiDatabaseToolsPluginInterfaceTest() = default;
void AkonadiDatabaseToolsPluginInterfaceTest::shouldHaveDefaultValue()
{
AkonadiDatabaseToolsPluginInterface interface;
QVERIFY(!interface.parentWidget());
QCOMPARE(interface.actionTypes().count(), 0);
}
void AkonadiDatabaseToolsPluginInterfaceTest::shouldCreateAction()
{
AkonadiDatabaseToolsPluginInterface interface;
interface.createAction(new KActionCollection(this));
QCOMPARE(interface.actionTypes().count(), 1);
QVERIFY(interface.actionTypes().at(0).action());
}
void AkonadiDatabaseToolsPluginInterfaceTest::shouldEmitActivatedSignal()
{
AkonadiDatabaseToolsPluginInterface interface;
interface.createAction(new KActionCollection(this));
QSignalSpy spy1(&interface, &PimCommon::AbstractGenericPluginInterface::emitPluginActivated);
interface.actionTypes().at(0).action()->trigger();
QCOMPARE(spy1.count(), 1);
}
/*
SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QObject>
class AkonadiDatabaseToolsPluginInterfaceTest : public QObject
{
Q_OBJECT
public:
explicit AkonadiDatabaseToolsPluginInterfaceTest(QObject *parent = nullptr);
~AkonadiDatabaseToolsPluginInterfaceTest() override;
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldCreateAction();
void shouldEmitActivatedSignal();
};
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