diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2020-08-10 19:00:56 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-09-02 20:34:48 +0200 |
commit | 8c2fda1ef5cb913522cad1fa74b321ed5744b870 (patch) | |
tree | 1dcdbdd5fbeaa40540553d11190266a75d005682 /tests/auto/gui | |
parent | 7ba75d088c3eba81a1d2bb708119442991d9f30b (diff) |
Test QWindow close() behavior
Verify that closing a QWindow using either the close()
API or a close event works as expected, and that the window
can be re-created. Also test QWindows with child windows.
Task-number: QTBUG-46701
Change-Id: I4c12452ff58e1233536c2d6932e72cf924d8ed74
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 87 |
1 files changed, 77 insertions, 10 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index e4cee0e89c..67ea378c66 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -1604,18 +1604,85 @@ void tst_QWindow::sizes() void tst_QWindow::close() { - QWindow a; - a.setTitle(QLatin1String(QTest::currentTestFunction())); - QWindow b; - QWindow c(&a); + { + QWindow a; + QWindow b; + QWindow c(&a); + + a.show(); + b.show(); + + // we can not close a non top level window + QVERIFY(!c.close()); + QVERIFY(a.close()); + QVERIFY(b.close()); + } - a.show(); - b.show(); + // Verify that closing a QWindow deletes its platform window, + // independent of API used to close the window. + { + // Close with QWindow::close + { + QWindow w; + w.create(); + QVERIFY(w.handle()); + w.close(); + QVERIFY(!w.handle()); + } - // we can not close a non top level window - QVERIFY(!c.close()); - QVERIFY(a.close()); - QVERIFY(b.close()); + // Close with QWindowSystemInterface::handleCloseEvent(); + { + QWindow w; + w.create(); + QVERIFY(w.handle()); + QWindowSystemInterface::handleCloseEvent(&w); + QCoreApplication::processEvents(); + QVERIFY(!w.handle()); + } + } + + // Verify that closing a QWindow deletes the platform window for + // child windows + { + QWindow w; + QWindow c(&w); + w.create(); + c.create(); + QVERIFY(w.handle()); + QVERIFY(c.handle()); + w.close(); + QVERIFY(!w.handle()); + QVERIFY(!c.handle()); + } + + // Verify that re-creating closed windows is possble. + { + // Re-create top-level window + { + QWindow w; + w.create(); + QVERIFY(w.handle()); + w.close(); + QVERIFY(!w.handle()); + w.create(); + QVERIFY(w.handle()); + } + + // Re-create top-level window with child window + { + QWindow w; + QWindow c(&w); + c.create(); + QVERIFY(w.handle()); + QVERIFY(c.handle()); + w.close(); + QVERIFY(!w.handle()); + QVERIFY(!c.handle()); + c.create(); + QVERIFY(w.handle()); + QVERIFY(c.handle()); + } + } } void tst_QWindow::activateAndClose() |