diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-08-23 18:27:59 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-08-24 12:26:31 +0200 |
commit | 826177eccab7ee3ac16b456bc57c0f271da14507 (patch) | |
tree | dd5cee1cbbc9d1e538c2a4c6f1a6e096d04d5d03 /tests | |
parent | 5d995ae122aa07486ead849560b74d2b62b883bb (diff) |
Stabilize image and borderimage multiFrame tests
There are various problems on QEMU: color depth may not be 32-bit,
and for some reason grabWindow isn't always working.
Task-number: QTBUG-77817
Change-Id: I10db56e93643722d1d6a85e66b9dd552ee654432
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp | 32 | ||||
-rw-r--r-- | tests/auto/quick/qquickimage/tst_qquickimage.cpp | 6 |
2 files changed, 28 insertions, 10 deletions
diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp index 4181f46551..dc3a783600 100644 --- a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp +++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp @@ -46,6 +46,8 @@ #include "../../shared/util.h" #include "../shared/visualtestutil.h" +Q_LOGGING_CATEGORY(lcTests, "qt.quick.tests") + Q_DECLARE_METATYPE(QQuickImageBase::Status) class tst_qquickborderimage : public QQmlDataTest @@ -615,6 +617,10 @@ void tst_qquickborderimage::multiFrame_data() void tst_qquickborderimage::multiFrame() { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QFETCH(QString, qmlfile); QFETCH(bool, asynchronous); Q_UNUSED(asynchronous) @@ -634,24 +640,30 @@ void tst_qquickborderimage::multiFrame() QCOMPARE(image->currentFrame(), 0); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); + QCoreApplication::processEvents(); // Process all queued events QImage contents = view.grabWindow(); - // The first frame looks blue, approximately qRgba(0x43, 0x7e, 0xd6, 0xff) - QRgb color = contents.pixel(60, 60); - QVERIFY(qRed(color) < 0xc0); - QVERIFY(qGreen(color) < 0xc0); - QVERIFY(qBlue(color) > 0xc0); + if (contents.width() < 160) + QSKIP("Skipping due to grabWindow not functional"); + + // The middle of the first frame looks blue, approximately qRgba(0x43, 0x7e, 0xd6, 0xff) + QColor color = contents.pixelColor(60, 60); + qCDebug(lcTests) << "expected bluish color, got" << color; + QVERIFY(color.redF() < 0.75); + QVERIFY(color.greenF() < 0.75); + QVERIFY(color.blueF() > 0.75); image->setCurrentFrame(1); QTRY_COMPARE(image->status(), QQuickImageBase::Ready); QCOMPARE(currentSpy.count(), 1); QCOMPARE(image->currentFrame(), 1); contents = view.grabWindow(); - // The second frame looks green, approximately qRgba(0x3a, 0xd2, 0x31, 0xff) - color = contents.pixel(60, 60); - QVERIFY(qRed(color) < 0xc0); - QVERIFY(qGreen(color) > 0xc0); - QVERIFY(qBlue(color) < 0xc0); + // The middle of the second frame looks green, approximately qRgba(0x3a, 0xd2, 0x31, 0xff) + color = contents.pixelColor(60, 60); + qCDebug(lcTests) << "expected greenish color, got" << color; + QVERIFY(color.redF() < 0.75); + QVERIFY(color.green() > 0.75); + QVERIFY(color.blueF() < 0.75); } QTEST_MAIN(tst_qquickborderimage) diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp index 23635590e4..abc7cd86bd 100644 --- a/tests/auto/quick/qquickimage/tst_qquickimage.cpp +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -1145,6 +1145,10 @@ void tst_qquickimage::multiFrame_data() void tst_qquickimage::multiFrame() { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QFETCH(QString, qmlfile); QFETCH(bool, asynchronous); Q_UNUSED(asynchronous) @@ -1166,6 +1170,8 @@ void tst_qquickimage::multiFrame() QVERIFY(QTest::qWaitForWindowExposed(&view)); QImage contents = view.grabWindow(); + if (contents.width() < 40) + QSKIP("Skipping due to grabWindow not functional"); // The first frame is a blue ball, approximately qRgba(0x33, 0x6d, 0xcc, 0xff) QRgb color = contents.pixel(16, 16); QVERIFY(qRed(color) < 0xc0); |