diff options
Diffstat (limited to 'tests/auto/gui/kernel')
-rw-r--r-- | tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp | 6 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qpalette/tst_qpalette.cpp | 3 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/BLACKLIST | 1 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 99 |
4 files changed, 98 insertions, 11 deletions
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index fc011d726d..a304981cd1 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -374,6 +374,9 @@ public: void tst_QGuiApplication::changeFocusWindow() { +#ifdef Q_OS_WINRT + QSKIP("WinRt does not support multiple native windows."); +#endif int argc = 0; QGuiApplication app(argc, 0); @@ -594,6 +597,9 @@ public: void tst_QGuiApplication::modalWindow() { +#ifdef Q_OS_WINRT + QSKIP("WinRt does not support multiple native windows."); +#endif int argc = 0; QGuiApplication app(argc, 0); const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp index ca6f677ba6..a0ac1b3631 100644 --- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp +++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp @@ -67,9 +67,10 @@ void tst_QPalette::roleValues_data() QTest::newRow("QPalette::NoRole") << int(QPalette::NoRole) << 17; QTest::newRow("QPalette::ToolTipBase") << int(QPalette::ToolTipBase) << 18; QTest::newRow("QPalette::ToolTipText") << int(QPalette::ToolTipText) << 19; + QTest::newRow("QPalette::PlaceholderText") << int(QPalette::PlaceholderText) << 20; // Change this value as you add more roles. - QTest::newRow("QPalette::NColorRoles") << int(QPalette::NColorRoles) << 20; + QTest::newRow("QPalette::NColorRoles") << int(QPalette::NColorRoles) << 21; } void tst_QPalette::roleValues() diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST index df02b5b33e..d1f14de794 100644 --- a/tests/auto/gui/kernel/qwindow/BLACKLIST +++ b/tests/auto/gui/kernel/qwindow/BLACKLIST @@ -1,6 +1,7 @@ [positioning:default] linux osx-10.12 ci +winrt [positioning:fake] osx-10.12 ci [modalWithChildWindow] diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 722405377e..7c24bbaadd 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -48,6 +48,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 +103,7 @@ private slots: void modalWindowPosition(); #ifndef QT_NO_CURSOR void modalWindowEnterEventOnHide_QTBUG35109(); + void spuriousMouseMove(); #endif void windowsTransientChildren(); void requestUpdate(); @@ -234,6 +241,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 +407,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 +492,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 +603,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 +802,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 +839,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 +911,7 @@ void tst_QWindow::isActive() QVERIFY(child.isActive()); } -class InputTestWindow : public QWindow +class InputTestWindow : public ColoredWindow { public: void keyPressEvent(QKeyEvent *event) { @@ -989,7 +1005,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 +1861,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 +1875,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 +1887,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 +1932,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 +1979,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 +2008,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 +2062,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 +2124,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 +2246,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) { |