From 69a8c59b3ffe81f20cb5f1425d72cca8053a0527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 15 Nov 2013 19:25:54 +0100 Subject: tst_QWindow: Set explicit window position to please qWaitForWindowActive qWaitForWindowActive waits until the timeout for the window to receive a non-0x0 position, even when it's active, just in case the WM sets the position as a response to focus-in. Change-Id: I748cce2747f406a8cdff556465175f02675fcd13 Reviewed-by: Friedemann Kleint Reviewed-by: Gunnar Sletta --- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index c4983f4462..bd5959786f 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -843,7 +843,10 @@ void tst_QWindow::activateAndClose() { for (int i = 0; i < 10; ++i) { QWindow window; - window.show(); + // qWaitForWindowActive will block for the duration of + // of the timeout if the window is at 0,0 + window.setGeometry(QGuiApplication::primaryScreen()->availableGeometry().adjusted(1, 1, -1, -1)); + window.showNormal(); window.requestActivate(); QVERIFY(QTest::qWaitForWindowActive(&window)); QCOMPARE(qGuiApp->focusWindow(), &window); -- cgit v1.2.3 From 829b1d13b225e87b8a385397e2b53c7a9f8cda9e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 28 Oct 2013 14:11:50 +0100 Subject: Ensure Qt::WA_Mapped is set in case of obscured native windows. Task-number: QTBUG-33520 Change-Id: I51f9b4634be29fd32f4ad9cc8b5d3e10b19ea2f5 Reviewed-by: Oliver Wolff Reviewed-by: Joerg Bornemann Reviewed-by: Gunnar Sletta --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 4 ++++ .../kernel/qwidget_window/tst_qwidget_window.cpp | 28 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 03d6c1cdbd..7bb5fd4614 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -7192,6 +7192,10 @@ void tst_QWidget::hideOpaqueChildWhileHidden() #if !defined(Q_OS_WINCE) void tst_QWidget::updateWhileMinimized() { +#ifdef Q_OS_UNIX + if (qgetenv("XDG_CURRENT_DESKTOP").contains("Unity")) + QSKIP("This test fails on Unity."); // Minimized windows are not unmapped for some reason. +#endif // Q_OS_UNIX UpdateWidget widget; // Filter out activation change and focus events to avoid update() calls in QWidget. widget.updateOnActivationChangeAndFocusIn = false; diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 1bbbfd610e..f5585c583a 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -91,6 +91,8 @@ private slots: void tst_showWithoutActivating(); void tst_paintEventOnSecondShow(); + void obscuredNativeMapped(); + #ifndef QT_NO_DRAGANDDROP void tst_dnd(); #endif @@ -368,6 +370,32 @@ void tst_QWidget_window::tst_paintEventOnSecondShow() QTRY_VERIFY(w.paintEventReceived); } +// QTBUG-33520, a toplevel fully obscured by native children should still receive Qt::WA_Mapped +void tst_QWidget_window::obscuredNativeMapped() +{ + enum { size = 200 }; + + QWidget topLevel; + topLevel.setWindowFlags(Qt::FramelessWindowHint); + QWidget *child = new QWidget(&topLevel); + child->resize(size, size); + topLevel.resize(size, size); + topLevel.move(QGuiApplication::primaryScreen()->availableGeometry().center() - QPoint(size /2 , size / 2)); + child->winId(); + topLevel.show(); + QTRY_VERIFY(topLevel.testAttribute(Qt::WA_Mapped)); +#if defined(Q_OS_MAC) + QSKIP("This test fails on Mac."); // Minimized windows are not unmapped for some reason. +#elif defined(Q_OS_UNIX) + if (qgetenv("XDG_CURRENT_DESKTOP").contains("Unity")) + QSKIP("This test fails on Unity."); // Minimized windows are not unmapped for some reason. +#endif // Q_OS_UNIX + topLevel.setWindowState(Qt::WindowMinimized); + QTRY_VERIFY(!topLevel.testAttribute(Qt::WA_Mapped)); + topLevel.setWindowState(Qt::WindowNoState); + QTRY_VERIFY(topLevel.testAttribute(Qt::WA_Mapped)); +} + #ifndef QT_NO_DRAGANDDROP /* DnD test for QWidgetWindow (handleDrag*Event() functions). -- cgit v1.2.3 From 49a3fe0cf8c8cddba6dacfb796e9db13c4ac74c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 15 Nov 2013 17:55:25 +0100 Subject: tst_QWindow: Use showNormal() to prevent maximize/fullscreen interference We don't want platform behavior for whether or not maximized/fullscreen windows can be resized to affect the test for resize event propagation. Change-Id: I8c118733ca5d2553aacf24d0b8debeb1a4e27103 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Gunnar Sletta --- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index bd5959786f..259c840ae7 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -177,7 +177,7 @@ void tst_QWindow::resizeEventAfterResize() Window window; window.setGeometry(geometry); - window.show(); + window.showNormal(); QTRY_COMPARE(window.received(QEvent::Resize), 1); -- cgit v1.2.3 From 54b8c27e03d04c1e5cd35f75d5c0a8111240eb74 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 15 Nov 2013 11:26:38 +0100 Subject: Fix crash when windowcontainer is used in a dockwidget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dockwidget's toplevel window would be a parent of the container's window when floating. When plugged back into the mainwindow the dockwidget's window is destroyed and the container's window along with it. Added a function toplevelAboutToBeDestroyed to unparent the containers window before this happens so parentWasChanged will work correctly. Change-Id: I06679cfb3a8fa3834c0db0be5973c012b8277275 Reviewed-by: Ulf Hermann Reviewed-by: Jørgen Lind --- .../qwindowcontainer/tst_qwindowcontainer.cpp | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests') diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp index c17a03e058..cd6433bbe7 100644 --- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp +++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp @@ -46,6 +46,8 @@ #include #include +#include +#include class Window : public QWindow @@ -80,6 +82,7 @@ private slots: void testUnparenting(); void testActivation(); void testAncestorChange(); + void testDockWidget(); }; @@ -278,6 +281,7 @@ void tst_QWindowContainer::testAncestorChange() newRoot->setGeometry(100, 100, 200, 200); newRoot->show(); QVERIFY(QTest::qWaitForWindowExposed(newRoot)); + QCOMPARE(newRoot->windowHandle(), window->parent()); // newRoot // + right // + container @@ -285,6 +289,31 @@ void tst_QWindowContainer::testAncestorChange() QCOMPARE(window->geometry(), QRect(100, 0, 100, 100)); } + +void tst_QWindowContainer::testDockWidget() +{ + QMainWindow mainWindow; + mainWindow.resize(200, 200); + + QDockWidget *dock = new QDockWidget(); + QWindow *window = new QWindow(); + QWidget *container = QWidget::createWindowContainer(window); + dock->setWidget(container); + mainWindow.addDockWidget(Qt::RightDockWidgetArea, dock); + + mainWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&mainWindow)); + QVERIFY(window->parent() == mainWindow.window()->windowHandle()); + + QTest::qWait(1000); + dock->setFloating(true); + QTRY_VERIFY(window->parent() != mainWindow.window()->windowHandle()); + + QTest::qWait(1000); + dock->setFloating(false); + QTRY_VERIFY(window->parent() == mainWindow.window()->windowHandle()); +} + QTEST_MAIN(tst_QWindowContainer) #include "tst_qwindowcontainer.moc" -- cgit v1.2.3