File indexing completed on 2025-01-05 04:49:45

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 "viewerplugincreateeventtest.h"
0008 #include "../createeventplugin/viewerplugincreateevent.h"
0009 #include <KActionCollection>
0010 #include <MessageViewer/ViewerPluginInterface>
0011 #include <QHBoxLayout>
0012 #include <QStandardItemModel>
0013 #include <QTest>
0014 
0015 namespace MessageViewer
0016 {
0017 extern MESSAGEVIEWER_EXPORT QAbstractItemModel *_k_eventEditStubModel;
0018 }
0019 
0020 ViewerPluginCreateeventTest::ViewerPluginCreateeventTest(QObject *parent)
0021     : QObject(parent)
0022 {
0023     auto model = new QStandardItemModel;
0024     MessageViewer::_k_eventEditStubModel = model;
0025 }
0026 
0027 ViewerPluginCreateeventTest::~ViewerPluginCreateeventTest() = default;
0028 
0029 void ViewerPluginCreateeventTest::shouldCreateAction()
0030 {
0031     auto event = new MessageViewer::ViewerPluginCreateevent(this);
0032     QVERIFY(!event->viewerPluginName().isEmpty());
0033     auto parent = new QWidget(nullptr);
0034     parent->setLayout(new QHBoxLayout);
0035     MessageViewer::ViewerPluginInterface *interface = event->createView(parent, new KActionCollection(this));
0036     QVERIFY(interface);
0037     QVERIFY(!interface->actions().isEmpty());
0038 }
0039 
0040 void ViewerPluginCreateeventTest::shouldShowWidget()
0041 {
0042     auto event = new MessageViewer::ViewerPluginCreateevent(this);
0043     auto parent = new QWidget(nullptr);
0044     parent->setLayout(new QHBoxLayout);
0045     MessageViewer::ViewerPluginInterface *interface = event->createView(parent, new KActionCollection(this));
0046     interface->execute();
0047     auto createeventwidget = parent->findChild<QWidget *>(QStringLiteral("eventedit"));
0048     QVERIFY(createeventwidget);
0049     QCOMPARE(createeventwidget->isHidden(), false);
0050 }
0051 
0052 QTEST_MAIN(ViewerPluginCreateeventTest)
0053 
0054 #include "moc_viewerplugincreateeventtest.cpp"