Warning, file /libraries/perceptualcolor/autotests/testasyncimagerenderthread.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: Lukas Sommer <sommerluk@gmail.com>
0002 // SPDX-License-Identifier: BSD-2-Clause OR MIT
0003 
0004 // First included header is the public header of the class we are testing;
0005 // this forces the header to be self-contained.
0006 #include "asyncimagerenderthread.h"
0007 
0008 #include "asyncimagerendercallback.h"
0009 #include <qglobal.h>
0010 #include <qimage.h>
0011 #include <qobject.h>
0012 #include <qtest.h>
0013 #include <qvariant.h>
0014 
0015 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
0016 #include <qtmetamacros.h>
0017 #else
0018 #include <qobjectdefs.h>
0019 #include <qstring.h>
0020 #endif
0021 
0022 namespace PerceptualColor
0023 {
0024 class TestAsyncImageRenderThread : public QObject
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     explicit TestAsyncImageRenderThread(QObject *parent = nullptr)
0030         : QObject(parent)
0031     {
0032     }
0033 
0034     static void renderEmptyImage(const QVariant &variantParameters, AsyncImageRenderCallback &callbackObject)
0035     {
0036         callbackObject.deliverInterlacingPass( //
0037             QImage(),
0038             variantParameters,
0039             AsyncImageRenderCallback::InterlacingState::Intermediate);
0040         if (!callbackObject.shouldAbort()) {
0041             callbackObject.deliverInterlacingPass( //
0042                 QImage(),
0043                 variantParameters,
0044                 AsyncImageRenderCallback::InterlacingState::Intermediate);
0045         }
0046         return;
0047     }
0048 
0049 private Q_SLOTS:
0050     void initTestCase()
0051     {
0052         // Called before the first test function is executed
0053     }
0054 
0055     void cleanupTestCase()
0056     {
0057         // Called after the last test function was executed
0058     }
0059 
0060     void init()
0061     {
0062         // Called before each test function is executed
0063     }
0064 
0065     void cleanup()
0066     {
0067         // Called after every test function
0068     }
0069 
0070     void testConstructorDestructor()
0071     {
0072         AsyncImageRenderThread test( //
0073             &TestAsyncImageRenderThread::renderEmptyImage);
0074     }
0075 
0076     void testStartRenderingAsync()
0077     {
0078         AsyncImageRenderThread test( //
0079             &TestAsyncImageRenderThread::renderEmptyImage);
0080         test.startRenderingAsync(QVariant());
0081     }
0082 
0083     void testShouldAbort()
0084     {
0085         AsyncImageRenderThread test( //
0086             &TestAsyncImageRenderThread::renderEmptyImage);
0087         Q_UNUSED(test.shouldAbort());
0088     }
0089 
0090     void testDeliver()
0091     {
0092         AsyncImageRenderThread test( //
0093             &TestAsyncImageRenderThread::renderEmptyImage);
0094         test.deliverInterlacingPass( //
0095             QImage(), //
0096             QVariant(), //
0097             AsyncImageRenderCallback::InterlacingState::Intermediate);
0098     }
0099 
0100     void testWaitForIdle()
0101     {
0102         AsyncImageRenderThread test( //
0103             &TestAsyncImageRenderThread::renderEmptyImage);
0104         test.waitForIdle();
0105     }
0106 
0107     void testWaitForIdleAfterRenderingTriggered()
0108     {
0109         AsyncImageRenderThread test( //
0110             &TestAsyncImageRenderThread::renderEmptyImage);
0111         test.startRenderingAsync(QVariant());
0112         test.waitForIdle();
0113     }
0114 };
0115 
0116 } // namespace PerceptualColor
0117 
0118 QTEST_MAIN(PerceptualColor::TestAsyncImageRenderThread)
0119 
0120 // The following “include” is necessary because we do not use a header file:
0121 #include "testasyncimagerenderthread.moc"