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