diff options
Diffstat (limited to 'tests/auto/quick/qquickwindow/tst_qquickwindow.cpp')
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index f7fc549069..3e907a5204 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -312,6 +312,11 @@ private slots: void ownershipRootItem(); + void hideThenDelete_data(); + void hideThenDelete(); + + void showHideAnimate(); + #ifndef QT_NO_CURSOR void cursor(); #endif @@ -945,6 +950,8 @@ void tst_qquickwindow::headless() QScopedPointer<QObject> cleanup(created); QQuickWindow* window = qobject_cast<QQuickWindow*>(created); + window->setPersistentOpenGLContext(false); + window->setPersistentSceneGraph(false); QVERIFY(window); window->show(); @@ -1212,6 +1219,88 @@ void tst_qquickwindow::cursor() } #endif +void tst_qquickwindow::hideThenDelete_data() +{ + QTest::addColumn<bool>("persistentSG"); + QTest::addColumn<bool>("persistentGL"); + + QTest::newRow("persistent:SG=false,GL=false") << false << false; + QTest::newRow("persistent:SG=true,GL=false") << true << false; + QTest::newRow("persistent:SG=false,GL=true") << false << true; + QTest::newRow("persistent:SG=true,GL=true") << true << true; +} + +void tst_qquickwindow::hideThenDelete() +{ + if (QGuiApplication::platformName() == QStringLiteral("xcb")) { + QSKIP("For some obscure reason this test fails in CI only"); + return; + } + + QFETCH(bool, persistentSG); + QFETCH(bool, persistentGL); + + QSignalSpy *openglDestroyed = 0; + QSignalSpy *sgInvalidated = 0; + + { + QQuickWindow window; + window.setColor(Qt::red); + + window.setPersistentSceneGraph(persistentSG); + window.setPersistentOpenGLContext(persistentGL); + + window.resize(400, 300); + window.show(); + + QTest::qWaitForWindowExposed(&window); + + openglDestroyed = new QSignalSpy(window.openglContext(), SIGNAL(aboutToBeDestroyed())); + sgInvalidated = new QSignalSpy(&window, SIGNAL(sceneGraphInvalidated())); + + window.hide(); + + QTRY_VERIFY(!window.isExposed()); + + if (!persistentSG) { + QVERIFY(sgInvalidated->size() > 0); + if (!persistentGL) + QVERIFY(openglDestroyed->size() > 0); + else + QVERIFY(openglDestroyed->size() == 0); + } else { + QVERIFY(sgInvalidated->size() == 0); + QVERIFY(openglDestroyed->size() == 0); + } + } + + QVERIFY(sgInvalidated->size() > 0); + QVERIFY(openglDestroyed->size() > 0); +} + +void tst_qquickwindow::showHideAnimate() +{ + // This test tries to mimick a bug triggered in the qquickanimatedimage test + // A window is shown, then removed again before it is exposed. This left + // traces in the render loop which prevent other animations from running + // later on. + { + QQuickWindow window; + window.resize(400, 300); + window.show(); + } + + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("showHideAnimate.qml")); + QQuickItem* created = qobject_cast<QQuickItem *>(component.create()); + + QVERIFY(created); + + QTRY_VERIFY(created->opacity() > 0.5); + QTRY_VERIFY(created->opacity() < 0.5); +} + QTEST_MAIN(tst_qquickwindow) #include "tst_qquickwindow.moc" |