diff options
Diffstat (limited to 'tests/auto/quick/scenegraph/tst_scenegraph.cpp')
-rw-r--r-- | tests/auto/quick/scenegraph/tst_scenegraph.cpp | 97 |
1 files changed, 57 insertions, 40 deletions
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index 2cd3a041c8..d8d9cd26e0 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -47,6 +47,9 @@ #include "../../shared/util.h" #include "../shared/visualtestutil.h" +#include <QtGui/private/qguiapplication_p.h> +#include <QtGui/qpa/qplatformintegration.h> + using namespace QQuickVisualTestUtil; class PerPixelRect : public QQuickItem @@ -114,6 +117,7 @@ private slots: private: bool m_brokenMipmapSupport; QQuickView *createView(const QString &file, QWindow *parent = 0, int x = -1, int y = -1, int w = -1, int h = -1); + bool isRunningOnOpenGL(); }; template <typename T> class ScopedList : public QList<T> { @@ -131,38 +135,40 @@ void tst_SceneGraph::initTestCase() qDebug() << "RenderLoop: " << loop; #if QT_CONFIG(opengl) - QOpenGLContext context; - context.setFormat(loop->sceneGraphContext()->defaultSurfaceFormat()); - context.create(); - QSurfaceFormat format = context.format(); - - QOffscreenSurface surface; - surface.setFormat(format); - surface.create(); - if (!context.makeCurrent(&surface)) - qFatal("Failed to create a GL context..."); - - QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); - qDebug() << "R/G/B/A Buffers: " << format.redBufferSize() << format.greenBufferSize() << format.blueBufferSize() << format.alphaBufferSize(); - qDebug() << "Depth Buffer: " << format.depthBufferSize(); - qDebug() << "Stencil Buffer: " << format.stencilBufferSize(); - qDebug() << "Samples: " << format.samples(); - int textureSize; - funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &textureSize); - qDebug() << "Max Texture Size: " << textureSize; - qDebug() << "GL_VENDOR: " << (const char *) funcs->glGetString(GL_VENDOR); - qDebug() << "GL_RENDERER: " << (const char *) funcs->glGetString(GL_RENDERER); - QByteArray version = (const char *) funcs->glGetString(GL_VERSION); - qDebug() << "GL_VERSION: " << version.constData(); - QSet<QByteArray> exts = context.extensions(); - QByteArray all; - foreach (const QByteArray &e, exts) all += ' ' + e; - qDebug() << "GL_EXTENSIONS: " << all.constData(); - - m_brokenMipmapSupport = version.contains("Mesa 10.1") || version.contains("Mesa 9."); - qDebug() << "Broken Mipmap: " << m_brokenMipmapSupport; - - context.doneCurrent(); + if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { + QOpenGLContext context; + context.setFormat(loop->sceneGraphContext()->defaultSurfaceFormat()); + context.create(); + QSurfaceFormat format = context.format(); + + QOffscreenSurface surface; + surface.setFormat(format); + surface.create(); + if (!context.makeCurrent(&surface)) + qFatal("Failed to create a GL context..."); + + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); + qDebug() << "R/G/B/A Buffers: " << format.redBufferSize() << format.greenBufferSize() << format.blueBufferSize() << format.alphaBufferSize(); + qDebug() << "Depth Buffer: " << format.depthBufferSize(); + qDebug() << "Stencil Buffer: " << format.stencilBufferSize(); + qDebug() << "Samples: " << format.samples(); + int textureSize; + funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &textureSize); + qDebug() << "Max Texture Size: " << textureSize; + qDebug() << "GL_VENDOR: " << (const char *) funcs->glGetString(GL_VENDOR); + qDebug() << "GL_RENDERER: " << (const char *) funcs->glGetString(GL_RENDERER); + QByteArray version = (const char *) funcs->glGetString(GL_VERSION); + qDebug() << "GL_VERSION: " << version.constData(); + QSet<QByteArray> exts = context.extensions(); + QByteArray all; + foreach (const QByteArray &e, exts) all += ' ' + e; + qDebug() << "GL_EXTENSIONS: " << all.constData(); + + m_brokenMipmapSupport = version.contains("Mesa 10.1") || version.contains("Mesa 9."); + qDebug() << "Broken Mipmap: " << m_brokenMipmapSupport; + + context.doneCurrent(); + } #endif } @@ -231,6 +237,10 @@ public: void tst_SceneGraph::manyWindows() { + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); + QFETCH(QString, file); QFETCH(bool, toplevel); QFETCH(bool, shared); @@ -430,12 +440,8 @@ void tst_SceneGraph::render_data() void tst_SceneGraph::render() { - QQuickView dummy; - dummy.show(); - QTest::qWaitForWindowExposed(&dummy); - if (dummy.rendererInterface()->graphicsApi() != QSGRendererInterface::OpenGL) + if (!isRunningOnOpenGL()) QSKIP("Skipping complex rendering tests due to not running with OpenGL"); - dummy.hide(); QFETCH(QString, file); QFETCH(QList<Sample>, baseStage); @@ -485,6 +491,9 @@ void tst_SceneGraph::render() // current on the other window. void tst_SceneGraph::hideWithOtherContext() { + if (!isRunningOnOpenGL()) + QSKIP("Skipping OpenGL context test due to not running with OpenGL"); + QWindow window; window.setSurfaceType(QWindow::OpenGLSurface); window.resize(100, 100); @@ -500,9 +509,6 @@ void tst_SceneGraph::hideWithOtherContext() view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - if (view.rendererInterface()->graphicsApi() != QSGRendererInterface::OpenGL) - QSKIP("Skipping OpenGL context test due to not running with OpenGL"); - renderingOnMainThread = view.openglContext()->thread() == QGuiApplication::instance()->thread(); // Make the local context current on the local window... @@ -549,6 +555,17 @@ void tst_SceneGraph::createTextureFromImage() QCOMPARE(texture->hasAlphaChannel(), expectedAlpha); } +bool tst_SceneGraph::isRunningOnOpenGL() +{ + bool retval = false; + QQuickView dummy; + dummy.show(); + QTest::qWaitForWindowExposed(&dummy); + if (dummy.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL) + retval = true; + dummy.hide(); + return retval; +} #include "tst_scenegraph.moc" |