diff options
Diffstat (limited to 'tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp')
-rw-r--r-- | tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp | 81 |
1 files changed, 53 insertions, 28 deletions
diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp index 5419778cfc..a8a00b51e9 100644 --- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp +++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp @@ -36,6 +36,9 @@ #include "../../shared/util.h" +#include <QtGui/private/qguiapplication_p.h> +#include <QtGui/qpa/qplatformintegration.h> + class tst_QQuickItemLayer: public QQmlDataTest { Q_OBJECT @@ -54,7 +57,7 @@ public: } private slots: - void initTestCase() Q_DECL_OVERRIDE; + void initTestCase() override; void layerEnabled(); void layerSmooth(); #if QT_CONFIG(opengl) @@ -102,35 +105,37 @@ void tst_QQuickItemLayer::initTestCase() { QQmlDataTest::initTestCase(); #if QT_CONFIG(opengl) - QWindow window; - QOpenGLContext context; - window.setSurfaceType(QWindow::OpenGLSurface); - window.create(); - QVERIFY(context.create()); - QVERIFY(context.makeCurrent(&window)); - const char *vendor = (const char *)context.functions()->glGetString(GL_VENDOR); - const char *renderer = (const char *)context.functions()->glGetString(GL_RENDERER); - m_isMesaSoftwareRasterizer = strcmp(vendor, "Mesa Project") == 0 - && strcmp(renderer, "Software Rasterizer") == 0; - if (m_isMesaSoftwareRasterizer) { - // Expects format: <OpenGL version> Mesa <Mesa version>[-devel] [...] - const char *version = (const char *)context.functions()->glGetString(GL_VERSION); - QList<QByteArray> list = QByteArray(version).split(' '); - if (list.size() >= 3) { - list = list.at(2).split('-').at(0).split('.'); - int major = 0; - int minor = 0; - int patch = 0; - if (list.size() >= 1) - major = list.at(0).toInt(); - if (list.size() >= 2) - minor = list.at(1).toInt(); - if (list.size() >= 3) - patch = list.at(2).toInt(); - m_mesaVersion = QT_VERSION_CHECK(major, minor, patch); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { + QWindow window; + QOpenGLContext context; + window.setSurfaceType(QWindow::OpenGLSurface); + window.create(); + QVERIFY(context.create()); + QVERIFY(context.makeCurrent(&window)); + const char *vendor = (const char *)context.functions()->glGetString(GL_VENDOR); + const char *renderer = (const char *)context.functions()->glGetString(GL_RENDERER); + m_isMesaSoftwareRasterizer = strcmp(vendor, "Mesa Project") == 0 + && strcmp(renderer, "Software Rasterizer") == 0; + if (m_isMesaSoftwareRasterizer) { + // Expects format: <OpenGL version> Mesa <Mesa version>[-devel] [...] + const char *version = (const char *)context.functions()->glGetString(GL_VERSION); + QList<QByteArray> list = QByteArray(version).split(' '); + if (list.size() >= 3) { + list = list.at(2).split('-').at(0).split('.'); + int major = 0; + int minor = 0; + int patch = 0; + if (list.size() >= 1) + major = list.at(0).toInt(); + if (list.size() >= 2) + minor = list.at(1).toInt(); + if (list.size() >= 3) + patch = list.at(2).toInt(); + m_mesaVersion = QT_VERSION_CHECK(major, minor, patch); + } } + window.create(); } - window.create(); #endif QQuickView view; view.showNormal(); @@ -147,6 +152,11 @@ void tst_QQuickItemLayer::layerSmooth() { if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("Smooth.qml"); QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff)); @@ -166,6 +176,11 @@ void tst_QQuickItemLayer::layerEnabled() { if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("Enabled.qml"); // Verify the banding QCOMPARE(fb.pixel(0, 0), fb.pixel(0, 1)); @@ -181,6 +196,7 @@ void tst_QQuickItemLayer::layerMipmap() { if (m_isMesaSoftwareRasterizer) QSKIP("Mipmapping does not work with the Mesa Software Rasterizer."); + QImage fb = runTest("Mipmap.qml"); QVERIFY(fb.pixel(0, 0) != 0xff000000); QVERIFY(fb.pixel(0, 0) != 0xffffffff); @@ -195,6 +211,11 @@ void tst_QQuickItemLayer::layerEffect() { if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("Effect.qml"); QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0)); @@ -451,6 +472,10 @@ void tst_QQuickItemLayer::itemEffect() void tst_QQuickItemLayer::rectangleEffect() { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QImage fb = runTest("RectangleEffect.qml"); QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0)); QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0)); |