Warning, file /network/neochat/autotests/actionshandlertest.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com> 0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0003 0004 #include <QTest> 0005 0006 #include "actionshandler.h" 0007 #include "chatbarcache.h" 0008 0009 #include "testutils.h" 0010 0011 class ActionsHandlerTest : public QObject 0012 { 0013 Q_OBJECT 0014 0015 private: 0016 Quotient::Connection *connection = Quotient::Connection::makeMockConnection(QStringLiteral("@bob:kde.org")); 0017 ActionsHandler *actionsHandler = new ActionsHandler(this); 0018 0019 private Q_SLOTS: 0020 void nullObject(); 0021 }; 0022 0023 void ActionsHandlerTest::nullObject() 0024 { 0025 QTest::ignoreMessage(QtWarningMsg, "ActionsHandler::handleMessageEvent - called with m_room and/or chatBarCache set to nullptr."); 0026 actionsHandler->handleMessageEvent(nullptr); 0027 0028 auto chatBarCache = new ChatBarCache(this); 0029 QTest::ignoreMessage(QtWarningMsg, "ActionsHandler::handleMessageEvent - called with m_room and/or chatBarCache set to nullptr."); 0030 actionsHandler->handleMessageEvent(chatBarCache); 0031 0032 auto room = new TestUtils::TestRoom(connection, QStringLiteral("#myroom:kde.org")); 0033 actionsHandler->setRoom(room); 0034 QTest::ignoreMessage(QtWarningMsg, "ActionsHandler::handleMessageEvent - called with m_room and/or chatBarCache set to nullptr."); 0035 actionsHandler->handleMessageEvent(nullptr); 0036 0037 // The final one should throw no warning so we make sure. 0038 QTest::failOnWarning("ActionsHandler::handleMessageEvent - called with m_room and/or chatBarCache set to nullptr."); 0039 actionsHandler->handleMessageEvent(chatBarCache); 0040 } 0041 0042 QTEST_GUILESS_MAIN(ActionsHandlerTest) 0043 #include "actionshandlertest.moc"