summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/kernel/qwindow/tst_qwindow.cpp')
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp122
1 files changed, 112 insertions, 10 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 722405377e..9415908383 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -29,6 +29,7 @@
#include <qrasterwindow.h>
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformwindow.h>
#include <private/qguiapplication_p.h>
#include <private/qhighdpiscaling_p.h>
#include <QtGui/QPainter>
@@ -48,6 +49,12 @@
Q_DECLARE_METATYPE(Qt::ScreenOrientation)
Q_DECLARE_METATYPE(QWindow::Visibility)
+static bool isPlatformWinRT()
+{
+ static const bool isWinRT = !QGuiApplication::platformName().compare(QLatin1String("winrt"), Qt::CaseInsensitive);
+ return isWinRT;
+}
+
class tst_QWindow: public QObject
{
Q_OBJECT
@@ -97,6 +104,7 @@ private slots:
void modalWindowPosition();
#ifndef QT_NO_CURSOR
void modalWindowEnterEventOnHide_QTBUG35109();
+ void spuriousMouseMove();
#endif
void windowsTransientChildren();
void requestUpdate();
@@ -107,6 +115,7 @@ private slots:
void cleanup();
void testBlockingWindowShownAfterModalDialog();
void generatedMouseMove();
+ void keepPendingUpdateRequests();
private:
QPoint m_availableTopLeft;
@@ -234,6 +243,8 @@ void tst_QWindow::setVisible()
QVERIFY(h.handle());
i.setParent(&h);
QVERIFY2(i.handle(), "Making a visible but not created child window child of a created window should create it");
+ if (isPlatformWinRT())
+ QEXPECT_FAIL("", "Child windows are unsupported on winrt", Continue);
QVERIFY(QTest::qWaitForWindowExposed(&i));
}
@@ -398,11 +409,15 @@ void tst_QWindow::resizeEventAfterResize()
// Make sure we get a resizeEvent after calling resize
window.resize(m_testWindowSize);
+ if (isPlatformWinRT())
+ QEXPECT_FAIL("", "Winrt windows are fullscreen by default.", Continue);
QTRY_COMPARE(window.received(QEvent::Resize), 2);
}
void tst_QWindow::exposeEventOnShrink_QTBUG54040()
{
+ if (isPlatformWinRT())
+ QSKIP("", "WinRT does not support non-maximized/non-fullscreen top level windows. QTBUG-54528", Continue);
Window window;
window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.setTitle(QTest::currentTestFunction());
@@ -479,7 +494,7 @@ void tst_QWindow::positioning()
}
if (isPlatformWayland())
- QSKIP("Wayland: This fails. Figure out why.");
+ QSKIP("Wayland: This fails. See QTBUG-68660.");
// Some platforms enforce minimum widths for windows, which can cause extra resize
// events, so set the width to suitably large value to avoid those.
@@ -590,6 +605,8 @@ void tst_QWindow::childWindowPositioning()
{
if (isPlatformWayland())
QSKIP("Wayland: This is flaky (protocol errors for xdg-shell v6). See QTBUG-67648.");
+ else if (isPlatformWinRT())
+ QSKIP("WinRT does not support child windows.");
const QPoint topLeftOrigin(0, 0);
@@ -787,11 +804,10 @@ void tst_QWindow::isExposed()
window.hide();
- if (isPlatformWayland())
- QSKIP("Wayland: This is flaky. Figure out why.");
-
QCoreApplication::processEvents();
QTRY_VERIFY(window.received(QEvent::Expose) > 1);
+ if (isPlatformWinRT())
+ QEXPECT_FAIL("", "WinRT does not destroy the window. Figure out why. QTBUG-68297", Continue);
QTRY_VERIFY(!window.isExposed());
}
@@ -825,6 +841,8 @@ void tst_QWindow::isActive()
child.setGeometry(10, 10, 20, 20);
child.show();
+ if (isPlatformWinRT())
+ QEXPECT_FAIL("", "WinRT does not support native child windows.", Abort);
QTRY_VERIFY(child.isExposed());
child.requestActivate();
@@ -895,7 +913,7 @@ void tst_QWindow::isActive()
QVERIFY(child.isActive());
}
-class InputTestWindow : public QWindow
+class InputTestWindow : public ColoredWindow
{
public:
void keyPressEvent(QKeyEvent *event) {
@@ -989,7 +1007,9 @@ public:
enterEventCount = leaveEventCount = 0;
}
- InputTestWindow() {
+ explicit InputTestWindow(const QColor &color = Qt::white, QWindow *parent = nullptr)
+ : ColoredWindow(color, parent)
+ {
keyPressCode = keyReleaseCode = 0;
mousePressButton = mouseReleaseButton = mouseMoveButton = 0;
ignoreMouse = ignoreTouch = false;
@@ -1843,7 +1863,7 @@ void tst_QWindow::mask()
void tst_QWindow::initialSize()
{
if (isPlatformWayland())
- QSKIP("Wayland: This fails. Figure out why.");
+ QSKIP("Wayland: This fails. See QTBUG-66818.");
QSize defaultSize(0,0);
{
@@ -1857,6 +1877,8 @@ void tst_QWindow::initialSize()
Window w;
w.setWidth(m_testWindowSize.width());
w.showNormal();
+ if (isPlatformWinRT())
+ QEXPECT_FAIL("", "WinRT shows windows as fullscreen by default.", Continue);
QTRY_COMPARE(w.width(), m_testWindowSize.width());
QTRY_VERIFY(w.height() > 0);
}
@@ -1867,6 +1889,8 @@ void tst_QWindow::initialSize()
w.showNormal();
const QSize expectedSize = testSize;
+ if (isPlatformWinRT())
+ QEXPECT_FAIL("", "WinRT shows windows as fullscreen by default.", Continue);
QTRY_COMPARE(w.size(), expectedSize);
}
}
@@ -1910,13 +1934,15 @@ void tst_QWindow::modalDialog()
return;
}
+ if (isPlatformWinRT())
+ QEXPECT_FAIL("", "WinRT only support one native window.", Continue);
QTRY_COMPARE(QGuiApplication::focusWindow(), &dialog);
}
void tst_QWindow::modalDialogClosingOneOfTwoModal()
{
- if (isPlatformWayland())
- QSKIP("Wayland: This fails. Figure out why.");
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
QWindow normalWindow;
normalWindow.setFramePosition(m_availableTopLeft + QPoint(80, 80));
@@ -1955,6 +1981,8 @@ void tst_QWindow::modalDialogClosingOneOfTwoModal()
return;
}
+ if (isPlatformWinRT())
+ QEXPECT_FAIL("", "WinRT only support one native window.", Continue);
QTRY_COMPARE(QGuiApplication::focusWindow(), &first_dialog);
}
@@ -1982,6 +2010,8 @@ void tst_QWindow::modalWithChildWindow()
tlw_dialog.show();
QVERIFY(QTest::qWaitForWindowExposed(&tlw_dialog));
+ if (isPlatformWinRT())
+ QEXPECT_FAIL("", "WinRT only support one native window.", Abort);
QVERIFY(QTest::qWaitForWindowExposed(&sub_window));
QTRY_COMPARE(QGuiApplication::focusWindow(), &tlw_dialog);
@@ -2034,6 +2064,8 @@ void tst_QWindow::modalWindowPosition()
window.setModality(Qt::WindowModal);
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
+ if (isPlatformWinRT())
+ QEXPECT_FAIL("", "WinRT windows are fullscreen by default.", Continue);
QCOMPARE(window.geometry(), origGeo);
}
@@ -2094,6 +2126,9 @@ void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109()
root.resetCounters();
modal.close();
+ if (isPlatformWinRT())
+ QEXPECT_FAIL("", "WinRT does not trigger the enter event correctly"
+ "- QTBUG-68297.", Abort);
// Check for the enter event
QTRY_COMPARE(root.enterEventCount, 1);
}
@@ -2213,7 +2248,53 @@ void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109()
QTRY_COMPARE(root.enterEventCount, 1);
}
}
-#endif
+
+// Verify that no spurious mouse move events are received. On Windows, there is
+// no enter event, the OS sends mouse move events instead. Test that the QPA
+// plugin properly suppresses those since they can interfere with tests.
+// Simulate a main window setup with a modal dialog on top, keep the cursor
+// in the center and check that no mouse events are recorded.
+void tst_QWindow::spuriousMouseMove()
+{
+ const QString &platformName = QGuiApplication::platformName();
+ if (platformName == QLatin1String("offscreen") || platformName == QLatin1String("cocoa"))
+ QSKIP("No enter events sent");
+ if (isPlatformWayland() || isPlatformWinRT())
+ QSKIP("QCursor::setPos() is not supported on this platform");
+ const QRect screenGeometry = QGuiApplication::primaryScreen()->geometry();
+ const QPoint center = screenGeometry.center();
+ QCursor::setPos(center);
+ QRect windowGeometry(QPoint(), 2 * m_testWindowSize);
+ windowGeometry.moveCenter(center);
+ QTRY_COMPARE(QCursor::pos(), center);
+ InputTestWindow topLevel;
+ topLevel.setTitle(QTest::currentTestFunction());
+ topLevel.setGeometry(windowGeometry);
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+ QTRY_VERIFY(topLevel.enterEventCount > 0);
+ InputTestWindow dialog(Qt::yellow);
+ dialog.setTransientParent(&topLevel);
+ dialog.setTitle("Dialog " + topLevel.title());
+ dialog.setModality(Qt::ApplicationModal);
+ windowGeometry.setSize(m_testWindowSize);
+ windowGeometry.moveCenter(center);
+ dialog.setGeometry(windowGeometry);
+ dialog.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&dialog));
+ QTRY_VERIFY(dialog.enterEventCount > 0);
+ dialog.setVisible(false);
+ QCOMPARE(dialog.mousePressedCount, 0);
+ QCOMPARE(dialog.mouseReleasedCount, 0);
+ QCOMPARE(dialog.mouseMovedCount, 0);
+ QCOMPARE(dialog.mouseDoubleClickedCount, 0);
+ topLevel.setVisible(false);
+ QCOMPARE(topLevel.mousePressedCount, 0);
+ QCOMPARE(topLevel.mouseReleasedCount, 0);
+ QCOMPARE(topLevel.mouseMovedCount, 0);
+ QCOMPARE(topLevel.mouseDoubleClickedCount, 0);
+}
+#endif // !QT_NO_CURSOR
static bool isNativeWindowVisible(const QWindow *window)
{
@@ -2372,6 +2453,27 @@ void tst_QWindow::generatedMouseMove()
QVERIFY(w.mouseMovedCount == 5);
}
+void tst_QWindow::keepPendingUpdateRequests()
+{
+ QRect geometry(m_availableTopLeft + QPoint(80, 80), m_testWindowSize);
+
+ Window window;
+ window.setGeometry(geometry);
+ window.show();
+ QCoreApplication::processEvents();
+ QTRY_VERIFY(window.isExposed());
+
+ window.requestUpdate();
+ window.close();
+ window.setVisible(true);
+
+ QPlatformWindow *platformWindow = window.handle();
+ QVERIFY(platformWindow);
+
+ QVERIFY(platformWindow->hasPendingUpdateRequest());
+ QTRY_VERIFY(!platformWindow->hasPendingUpdateRequest());
+}
+
#include <tst_qwindow.moc>
QTEST_MAIN(tst_QWindow)