diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index 975c2acefd..4018c00a38 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -78,6 +78,7 @@ private slots: void openGLPaintDevice_data(); void openGLPaintDevice(); void aboutToBeDestroyed(); + void sizeLessWindow(); void QTBUG15621_triangulatingStrokerDivZero(); void textureblitterFullSourceRectTransform(); void textureblitterPartOriginBottomLeftSourceRectTransform(); @@ -645,6 +646,43 @@ void tst_QOpenGL::aboutToBeDestroyed() QCOMPARE(spy.size(), 1); } +// Verify that QOpenGLContext works with QWindows that do +// not have an explicit size set. +void tst_QOpenGL::sizeLessWindow() +{ + // top-level window + { + QWindow window; + window.setSurfaceType(QWindow::OpenGLSurface); + + QOpenGLContext context; + QVERIFY(context.create()); + + window.show(); + QVERIFY(context.makeCurrent(&window)); + QVERIFY(QOpenGLContext::currentContext()); + } + + QVERIFY(!QOpenGLContext::currentContext()); + + // child window + { + QWindow parent; + QWindow window(&parent); + window.setSurfaceType(QWindow::OpenGLSurface); + + QOpenGLContext context; + QVERIFY(context.create()); + + parent.show(); + window.show(); + QVERIFY(context.makeCurrent(&window)); + QVERIFY(QOpenGLContext::currentContext()); + } + + QVERIFY(!QOpenGLContext::currentContext()); +} + void tst_QOpenGL::QTBUG15621_triangulatingStrokerDivZero() { #if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__)