From 5a5441f38e0529d852536b776cd9f26dad410e62 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 5 Apr 2019 10:03:49 +0200 Subject: Tests: Fix warnings about ignoring return value of QTest::qWaitForWindowExposed() Fix warnings like: ../shared/particlestestsshared.h: In function 'QQuickView* createView(const QUrl&, int)': ../shared/particlestestsshared.h:64:33: warning: ignoring return value of 'bool QTest::qWaitForWindowExposed(QWindow*, int)', declared with attribute nodiscard [-Wunused-result] by checking the return and adding some handling. Change-Id: I1390f9738430042fcc45e243567a9d5a4f632a6d Reviewed-by: Qt CI Bot Reviewed-by: Ulf Hermann --- tests/auto/particles/shared/particlestestsshared.h | 11 +++++++---- .../qquickhoverhandler/tst_qquickhoverhandler.cpp | 2 +- tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp | 13 ++++++++++--- .../tst_qquickmultipointtoucharea.cpp | 10 ++++++---- 4 files changed, 24 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/auto/particles/shared/particlestestsshared.h b/tests/auto/particles/shared/particlestestsshared.h index 5ef1d2cabb..e1fc6f4ccd 100644 --- a/tests/auto/particles/shared/particlestestsshared.h +++ b/tests/auto/particles/shared/particlestestsshared.h @@ -31,6 +31,8 @@ #include #include #include +#include + const qreal EPSILON = 0.0001; bool extremelyFuzzyCompare(qreal a, qreal b, qreal e)//For cases which can have larger variances @@ -55,17 +57,18 @@ bool myFuzzyGEQ(qreal a, qreal b) QQuickView* createView(const QUrl &filename, int additionalWait=0) { - QQuickView *view = new QQuickView(0); + QScopedPointer view(new QQuickView(nullptr)); view->setSource(filename); if (view->status() != QQuickView::Ready) - return 0; + return nullptr; view->show(); - QTest::qWaitForWindowExposed(view); + if (!QTest::qWaitForWindowExposed(view.data())) + return nullptr; if (additionalWait) QTest::qWait(additionalWait); - return view; + return view.take(); } void ensureAnimTime(int requiredTime, QAbstractAnimation* anim)//With consistentTiming, who knows how long an animation really takes... diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp index f141a2546c..575139f851 100644 --- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp @@ -252,7 +252,7 @@ void tst_HoverHandler::movingItemWithHoverHandler() QTRY_COMPARE(window->isVisible(), false); QCursor::setPos(paddlePos); window->show(); - QTest::qWaitForWindowExposed(window); + QVERIFY(QTest::qWaitForWindowExposed(window)); QTRY_COMPARE(paddleHH->isHovered(), true); diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp index 1a289a2087..2f90632841 100644 --- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp +++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp @@ -51,9 +51,8 @@ public: view.setSource(testFileUrl(fileName)); view.showNormal(); - QTest::qWaitForWindowExposed(&view); - - return view.grabWindow(); + return QTest::qWaitForWindowExposed(&view) + ? view.grabWindow() : QImage(); } private slots: @@ -153,6 +152,7 @@ void tst_QQuickItemLayer::layerSmooth() QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); QImage fb = runTest("Smooth.qml"); + QVERIFY(!fb.size().isEmpty()); QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff)); @@ -177,6 +177,7 @@ void tst_QQuickItemLayer::layerEnabled() QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); QImage fb = runTest("Enabled.qml"); + QVERIFY(!fb.size().isEmpty()); // Verify the banding QCOMPARE(fb.pixel(0, 0), fb.pixel(0, 1)); // Verify the gradient @@ -212,6 +213,7 @@ void tst_QQuickItemLayer::layerEffect() QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); QImage fb = runTest("Effect.qml"); + QVERIFY(!fb.size().isEmpty()); QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0)); } @@ -229,6 +231,7 @@ void tst_QQuickItemLayer::layerSourceRect() QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects"); QImage fb = runTest("SourceRect.qml"); + QVERIFY(!fb.size().isEmpty()); // Check that the edges are converted to blue QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff)); @@ -253,6 +256,7 @@ void tst_QQuickItemLayer::layerIsTextureProvider() QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects"); QImage fb = runTest("TextureProvider.qml"); + QVERIFY(!fb.size().isEmpty()); QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0)); } @@ -448,6 +452,7 @@ void tst_QQuickItemLayer::changeSamplerName() QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects"); QImage fb = runTest("SamplerNameChange.qml"); + QVERIFY(!fb.size().isEmpty()); QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff)); } @@ -459,6 +464,7 @@ void tst_QQuickItemLayer::itemEffect() QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects"); QImage fb = runTest("ItemEffect.qml"); + QVERIFY(!fb.size().isEmpty()); QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(199, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(0, 199), qRgb(0, 0, 0xff)); @@ -472,6 +478,7 @@ void tst_QQuickItemLayer::rectangleEffect() QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); QImage fb = runTest("RectangleEffect.qml"); + QVERIFY(!fb.size().isEmpty()); QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0)); QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0)); QCOMPARE(fb.pixel(0, 199), qRgb(0, 0xff, 0)); diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp index d4ad282701..cd66fc4ede 100644 --- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp +++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp @@ -1145,16 +1145,18 @@ void tst_QQuickMultiPointTouchArea::transformedTouchArea() QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file) { - QQuickView *window = new QQuickView(nullptr); + QScopedPointer window(new QQuickView(nullptr)); window->setSource(testFileUrl(file)); + if (window->status() != QQuickView::Ready) + return nullptr; const QRect screenGeometry = window->screen()->availableGeometry(); const QSize size = window->size(); const QPoint offset = QPoint(size.width() / 2, size.height() / 2); window->setFramePosition(screenGeometry.center() - offset); window->show(); - QTest::qWaitForWindowExposed(window); - - return window; + if (!QTest::qWaitForWindowExposed(window.data())) + return nullptr; + return window.take(); } void tst_QQuickMultiPointTouchArea::mouseInteraction_data() -- cgit v1.2.3