summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2019-10-22 13:01:38 +0200
committerAndy Shaw <andy.shaw@qt.io>2019-10-29 10:45:19 +0200
commitccd3bf0871b81dfc09bb469b161f32dfb47ee53e (patch)
tree13fd6e178bc30c35ec612e04ce7ee2bcfcf3080c /tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
parentd86192e5ba7911407881f5079c4486c1fb084dc6 (diff)
Ensure that child windows are visible again when showing their parent
When a window is closed, then it will cause the child windows to be closed as well as a result. Therefore in order to ensure that they are shown again as a result, we need to remove the WA_WState_ExplicitShowHide attribute if the widget was not already hidden before. This enables us to test for this attribute when calling showChildren(), so that if the window has a windowHandle then we can make sure that this widget is shown again. Fixes: QTBUG-73021 Change-Id: I1186242b889899dfcd38d782a67567348e2055ee Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp')
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index a95d6e76b3..ebf08883fd 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -399,6 +399,7 @@ private slots:
void tabletTracking();
void closeEvent();
+ void closeWithChildWindow();
private:
bool ensureScreenSize(int width, int height);
@@ -11115,5 +11116,27 @@ void tst_QWidget::closeEvent()
QCOMPARE(widget.closeCount, 1);
}
+void tst_QWidget::closeWithChildWindow()
+{
+ QWidget widget;
+ auto childWidget = new QWidget(&widget);
+ childWidget->setAttribute(Qt::WA_NativeWindow);
+ childWidget->windowHandle()->create();
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ widget.windowHandle()->close();
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ // Check that the child window inside the window is now visible
+ QVERIFY(childWidget->isVisible());
+
+ // Now explicitly hide the childWidget
+ childWidget->hide();
+ widget.windowHandle()->close();
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ QVERIFY(!childWidget->isVisible());
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"