File indexing completed on 2024-12-01 06:44:11

0001 /*
0002     SPDX-License-Identifier: LGPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2020 Laurent Montel <montel@kde.org>
0004 */
0005 
0006 #include "kcursorsavertest.h"
0007 #include "util/kcursorsaver.h"
0008 #include <QTest>
0009 QTEST_MAIN(KCursorSaverTest)
0010 
0011 KCursorSaverTest::KCursorSaverTest(QObject *parent)
0012     : QObject(parent)
0013 {
0014 }
0015 
0016 void KCursorSaverTest::ignoreWarning()
0017 {
0018     {
0019         // Emit qwarning when we call twice restoreCursor
0020         KCursorSaver saver(Qt::WaitCursor);
0021         saver.restoreCursor();
0022         QTest::ignoreMessage(QtWarningMsg, "This KCursorSaver doesn't own the cursor anymore, invalid call to restoreCursor().");
0023         saver.restoreCursor();
0024     }
0025     {
0026         // Emit qwarning when "moving A to B and then calling A::restoreCursor()"
0027         KCursorSaver saverA(Qt::WaitCursor);
0028         KCursorSaver saverB = std::move(saverA);
0029         QTest::ignoreMessage(QtWarningMsg, "This KCursorSaver doesn't own the cursor anymore, invalid call to restoreCursor().");
0030         saverA.restoreCursor();
0031         QTest::ignoreMessage(QtWarningMsg, "This KCursorSaver doesn't own the cursor anymore, invalid call to restoreCursor().");
0032         saverB.restoreCursor();
0033     }
0034 }
0035 
0036 #include "moc_kcursorsavertest.cpp"