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

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 "viewerplugincreatenotetest.h"
0008 #include "../createnoteplugin/viewerplugincreatenote.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_noteEditStubModel;
0018 }
0019 
0020 ViewerPluginCreateNoteTest::ViewerPluginCreateNoteTest(QObject *parent)
0021     : QObject(parent)
0022 {
0023     auto model = new QStandardItemModel;
0024     MessageViewer::_k_noteEditStubModel = model;
0025 }
0026 
0027 ViewerPluginCreateNoteTest::~ViewerPluginCreateNoteTest() = default;
0028 
0029 void ViewerPluginCreateNoteTest::shouldCreateAction()
0030 {
0031     auto note = new MessageViewer::ViewerPluginCreatenote(this);
0032     QVERIFY(!note->viewerPluginName().isEmpty());
0033     auto parent = new QWidget(nullptr);
0034     parent->setLayout(new QHBoxLayout);
0035     MessageViewer::ViewerPluginInterface *interface = note->createView(parent, new KActionCollection(this));
0036     QVERIFY(interface);
0037     QVERIFY(!interface->actions().isEmpty());
0038 }
0039 
0040 void ViewerPluginCreateNoteTest::shouldShowWidget()
0041 {
0042     auto note = new MessageViewer::ViewerPluginCreatenote(this);
0043     auto parent = new QWidget(nullptr);
0044     parent->setLayout(new QHBoxLayout);
0045     MessageViewer::ViewerPluginInterface *interface = note->createView(parent, new KActionCollection(this));
0046     interface->execute();
0047     auto createnotewidget = parent->findChild<QWidget *>(QStringLiteral("noteedit"));
0048     QVERIFY(createnotewidget);
0049     QCOMPARE(createnotewidget->isHidden(), false);
0050 }
0051 
0052 QTEST_MAIN(ViewerPluginCreateNoteTest)
0053 
0054 #include "moc_viewerplugincreatenotetest.cpp"