File indexing completed on 2025-01-19 04:46:44

0001 /*
0002    SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "antispamplugininterfacetest.h"
0008 #include "../antispamplugininterface.h"
0009 #include <KActionCollection>
0010 #include <QSignalSpy>
0011 #include <QTest>
0012 
0013 AntiSpamPluginInterfaceTest::AntiSpamPluginInterfaceTest(QObject *parent)
0014     : QObject(parent)
0015 {
0016 }
0017 
0018 AntiSpamPluginInterfaceTest::~AntiSpamPluginInterfaceTest() = default;
0019 
0020 void AntiSpamPluginInterfaceTest::shouldHaveDefaultValue()
0021 {
0022     AntiSpamPluginInterface interface;
0023     QVERIFY(!interface.parentWidget());
0024     QVERIFY(interface.actionTypes().isEmpty());
0025 }
0026 
0027 void AntiSpamPluginInterfaceTest::shouldCreateAction()
0028 {
0029     AntiSpamPluginInterface interface;
0030     interface.createAction(new KActionCollection(this));
0031     QCOMPARE(interface.actionTypes().count(), 1);
0032     QVERIFY(interface.actionTypes().at(0).action());
0033 }
0034 
0035 void AntiSpamPluginInterfaceTest::shouldEmitActivatedSignal()
0036 {
0037     AntiSpamPluginInterface interface;
0038     interface.createAction(new KActionCollection(this));
0039 
0040     QSignalSpy spy1(&interface, &PimCommon::AbstractGenericPluginInterface::emitPluginActivated);
0041     interface.actionTypes().at(0).action()->trigger();
0042     QCOMPARE(spy1.count(), 1);
0043 }
0044 
0045 QTEST_MAIN(AntiSpamPluginInterfaceTest)
0046 
0047 #include "moc_antispamplugininterfacetest.cpp"