diff options
author | Morten Johan Sørvig <morten.sorvig@theqtcompany.com> | 2015-06-18 17:01:01 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2015-07-30 18:09:12 +0000 |
commit | 63090627220a6209652d236cf991305fbeb188b8 (patch) | |
tree | 2c619db451803c7619618eab2ed7540c60dcb76b /tests/auto/gui | |
parent | 0f7bc885aa7ae8cc3c448cc751aba4eba8c1c8b8 (diff) |
high-DPI tweaks for autotests
Task-number: QTBUG-46615
Change-Id: I724f56fb3bc1a4b671b5d010765ef4e354412e2e
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp | 136 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 70 | ||||
-rw-r--r-- | tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 1 | ||||
-rw-r--r-- | tests/auto/gui/text/qtexttable/tst_qtexttable.cpp | 2 |
4 files changed, 104 insertions, 105 deletions
diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index fd3cfd55ff..d754e0b3c3 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -39,33 +39,8 @@ #include <QtWidgets/QWidget> #include <QtTest> #include <qpa/qwindowsysteminterface.h> - -// FIXME: Use static functions of QWindowSystemInterface introduced with HighDPI scaling in 5.6 instead. -static QWindowSystemInterface::TouchPoint touchPoint(const QTouchEvent::TouchPoint& pt) -{ - QWindowSystemInterface::TouchPoint p; - p.id = pt.id(); - p.flags = pt.flags(); - p.normalPosition = pt.normalizedPos(); - p.area = pt.screenRect(); - p.pressure = pt.pressure(); - p.state = pt.state(); - p.velocity = pt.velocity(); - p.rawPositions = pt.rawScreenPositions(); - return p; -} - -static QList<struct QWindowSystemInterface::TouchPoint> touchPointList(const QList<QTouchEvent::TouchPoint>& pointList) -{ - QList<struct QWindowSystemInterface::TouchPoint> newList; - - Q_FOREACH (QTouchEvent::TouchPoint p, pointList) - { - newList.append(touchPoint(p)); - } - return newList; -} - +#include <qpa/qwindowsysteminterface_p.h> +#include <private/qhighdpiscaling_p.h> class tst_QTouchEventWidget : public QWidget { @@ -622,11 +597,10 @@ void tst_QTouchEvent::basicRawEventTranslation() rawPosList << QPointF(12, 34) << QPointF(56, 78); rawTouchPoint.setRawScreenPositions(rawPosList); const ulong timestamp = 1234; - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - timestamp, - touchScreenDevice, - touchPointList( - QList<QTouchEvent::TouchPoint>() << rawTouchPoint)); + QWindow *window = touchWidget.windowHandle(); + QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, window); + QWindowSystemInterface::handleTouchEvent(window, timestamp, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -653,16 +627,16 @@ void tst_QTouchEvent::basicRawEventTranslation() QCOMPARE(touchBeginPoint.sceneRect(), touchBeginPoint.screenRect()); QCOMPARE(touchBeginPoint.pressure(), qreal(1.)); QCOMPARE(touchBeginPoint.velocity(), QVector2D()); - QCOMPARE(touchBeginPoint.rawScreenPositions(), rawPosList); + if (!QHighDpiScaling::isActive()) + QCOMPARE(touchBeginPoint.rawScreenPositions(), rawPosList); // moving the point should translate to TouchUpdate rawTouchPoint.setState(Qt::TouchPointMoved); rawTouchPoint.setScreenPos(screenPos + delta); rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(QList<QTouchEvent::TouchPoint>() << rawTouchPoint)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); @@ -692,10 +666,9 @@ void tst_QTouchEvent::basicRawEventTranslation() rawTouchPoint.setState(Qt::TouchPointReleased); rawTouchPoint.setScreenPos(screenPos + delta + delta); rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(QList<QTouchEvent::TouchPoint>() << rawTouchPoint)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(touchWidget.seenTouchBegin); QVERIFY(touchWidget.seenTouchUpdate); @@ -762,10 +735,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() rawTouchPoints[1].setState(Qt::TouchPointPressed); rawTouchPoints[1].setScreenPos(rightScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(rawTouchPoints)); + QWindow *window = touchWidget.windowHandle(); + QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -827,10 +800,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() rawTouchPoints[1].setState(Qt::TouchPointMoved); rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(rawTouchPoints)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -892,10 +864,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() rawTouchPoints[1].setState(Qt::TouchPointReleased); rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(rawTouchPoints)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -992,10 +963,10 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() rawTouchPoints[1].setState(Qt::TouchPointPressed); rawTouchPoints[1].setScreenPos(rightScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchPadDevice, - touchPointList(rawTouchPoints)); + QWindow *window = touchWidget.windowHandle(); + QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchPadDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -1058,10 +1029,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() rawTouchPoints[1].setState(Qt::TouchPointMoved); rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchPadDevice, - touchPointList(rawTouchPoints)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchPadDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -1123,10 +1093,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() rawTouchPoints[1].setState(Qt::TouchPointReleased); rawTouchPoints[1].setScreenPos(centerScreenPos); rawTouchPoints[1].setNormalizedPos(normalized(rawTouchPoints[1].pos(), screenGeometry)); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchPadDevice, - touchPointList(rawTouchPoints)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchPadDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(!touchWidget.seenTouchBegin); QVERIFY(!touchWidget.seenTouchUpdate); @@ -1385,10 +1354,10 @@ void tst_QTouchEvent::deleteInRawEventTranslation() rawTouchPoints[2].setNormalizedPos(normalized(rawTouchPoints[2].pos(), screenGeometry)); // generate begin events on all widgets, the left widget should die - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(rawTouchPoints)); + QWindow *window = touchWidget.windowHandle(); + QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); QVERIFY(leftWidget.isNull()); QVERIFY(!centerWidget.isNull()); @@ -1398,20 +1367,18 @@ void tst_QTouchEvent::deleteInRawEventTranslation() rawTouchPoints[0].setState(Qt::TouchPointMoved); rawTouchPoints[1].setState(Qt::TouchPointMoved); rawTouchPoints[2].setState(Qt::TouchPointMoved); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(rawTouchPoints)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); // generate end events on all widget, the right widget should die rawTouchPoints[0].setState(Qt::TouchPointReleased); rawTouchPoints[1].setState(Qt::TouchPointReleased); rawTouchPoints[2].setState(Qt::TouchPointReleased); - QWindowSystemInterface::handleTouchEvent(touchWidget.windowHandle(), - 0, - touchScreenDevice, - touchPointList(rawTouchPoints)); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); QCoreApplication::processEvents(); } @@ -1447,6 +1414,8 @@ void tst_QTouchEvent::crashInQGraphicsSceneAfterNotHandlingTouchBegin() void tst_QTouchEvent::touchBeginWithGraphicsWidget() { + if (QHighDpiScaling::isActive()) + QSKIP("Fails when scaling is active"); QGraphicsScene scene; QGraphicsView view(&scene); view.setWindowTitle(QTest::currentTestFunction()); @@ -1605,12 +1574,15 @@ void tst_QTouchEvent::testMultiDevice() QWindowSystemInterface::TouchPoint tp; tp.id = 0; tp.state = Qt::TouchPointPressed; - tp.area = QRectF(120, 120, 20, 20); + const QPoint screenOrigin = w.screen()->geometry().topLeft(); + const QRect area0(120, 120, 20, 20); + tp.area = QHighDpi::toNative(area0, QHighDpiScaling::factor(&w), screenOrigin); pointsOne.append(tp); pointsTwo.append(tp); tp.id = 1; - tp.area = QRectF(140, 140, 20, 20); + const QRect area1(140, 140, 20, 20); + tp.area = QHighDpi::toNative(area1, QHighDpiScaling::factor(&w), screenOrigin); pointsTwo.append(tp); QWindowSystemInterface::handleTouchEvent(&w, deviceOne, pointsOne); @@ -1625,12 +1597,12 @@ void tst_QTouchEvent::testMultiDevice() QCOMPARE(filter.d.value(deviceOne).points.count(), 1); QCOMPARE(filter.d.value(deviceTwo).points.count(), 2); - QCOMPARE(filter.d.value(deviceOne).points.at(0).screenRect(), pointsOne[0].area); + QCOMPARE(filter.d.value(deviceOne).points.at(0).screenRect(), QRectF(area0)); QCOMPARE(filter.d.value(deviceOne).points.at(0).state(), pointsOne[0].state); - QCOMPARE(filter.d.value(deviceTwo).points.at(0).screenRect(), pointsTwo[0].area); + QCOMPARE(filter.d.value(deviceTwo).points.at(0).screenRect(), QRectF(area0)); QCOMPARE(filter.d.value(deviceTwo).points.at(0).state(), pointsTwo[0].state); - QCOMPARE(filter.d.value(deviceTwo).points.at(1).screenRect(), pointsTwo[1].area); + QCOMPARE(filter.d.value(deviceTwo).points.at(1).screenRect(), QRectF(area1)); QCOMPARE(filter.d.value(deviceTwo).points.at(1).state(), pointsTwo[1].state); } diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 6c5a0141cb..4e596a24d4 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -35,6 +35,7 @@ #include <qpa/qwindowsysteminterface.h> #include <qpa/qplatformintegration.h> #include <private/qguiapplication_p.h> +#include <private/qhighdpiscaling_p.h> #include <QtGui/QPainter> #include <QtTest/QtTest> @@ -265,6 +266,19 @@ void tst_QWindow::positioning_data() #endif } +// Compare a window position that may go through scaling in the platform plugin with fuzz. +static inline bool qFuzzyCompareWindowPosition(const QPoint &p1, const QPoint p2, int fuzz) +{ + return (p1 - p2).manhattanLength() <= fuzz; +} + +static QString msgPointMismatch(const QPoint &p1, const QPoint p2) +{ + QString result; + QDebug(&result) << p1 << "!=" << p2 << ", manhattanLength=" << (p1 - p2).manhattanLength(); + return result; +} + void tst_QWindow::positioning() { if (!QGuiApplicationPrivate::platformIntegration()->hasCapability( @@ -327,21 +341,25 @@ void tst_QWindow::positioning() // if our positioning is actually fully respected by the window manager // test whether it correctly handles frame positioning as well if (originalPos == geometry.topLeft() && (originalMargins.top() != 0 || originalMargins.left() != 0)) { - QPoint framePos = QPlatformScreen::platformScreenForWindow(&window)->availableGeometry().center(); + const QScreen *screen = window.screen(); + const QRect availableGeometry = screen->availableGeometry(); + const QPoint framePos = availableGeometry.center(); window.reset(); const QPoint oldFramePos = window.framePosition(); window.setFramePosition(framePos); QTRY_VERIFY(window.received(QEvent::Move)); - if (window.framePosition() != framePos) { + const int fuzz = int(QHighDpiScaling::factor(&window)); + if (!qFuzzyCompareWindowPosition(window.framePosition(), framePos, fuzz)) { qDebug() << "About to fail auto-test. Here is some additional information:"; qDebug() << "window.framePosition() == " << window.framePosition(); qDebug() << "old frame position == " << oldFramePos; qDebug() << "We received " << window.received(QEvent::Move) << " move events"; qDebug() << "frame positions after each move event:" << window.m_framePositionsOnMove; } - QTRY_COMPARE(framePos, window.framePosition()); + QTRY_VERIFY2(qFuzzyCompareWindowPosition(window.framePosition(), framePos, fuzz), + qPrintable(msgPointMismatch(window.framePosition(), framePos))); QTRY_COMPARE(originalMargins, window.frameMargins()); QCOMPARE(window.position(), window.framePosition() + QPoint(originalMargins.left(), originalMargins.top())); @@ -655,15 +673,13 @@ void tst_QWindow::testInputEvents() window.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&window)); - QWindowSystemInterface::handleKeyEvent(&window, QEvent::KeyPress, Qt::Key_A, Qt::NoModifier); - QWindowSystemInterface::handleKeyEvent(&window, QEvent::KeyRelease, Qt::Key_A, Qt::NoModifier); + QTest::keyClick(&window, Qt::Key_A, Qt::NoModifier); QCoreApplication::processEvents(); QCOMPARE(window.keyPressCode, int(Qt::Key_A)); QCOMPARE(window.keyReleaseCode, int(Qt::Key_A)); QPointF local(12, 34); - QWindowSystemInterface::handleMouseEvent(&window, local, local, Qt::LeftButton); - QWindowSystemInterface::handleMouseEvent(&window, local, local, Qt::NoButton); + QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, local.toPoint()); QCoreApplication::processEvents(); QCOMPARE(window.mousePressButton, int(Qt::LeftButton)); QCOMPARE(window.mouseReleaseButton, int(Qt::LeftButton)); @@ -689,15 +705,17 @@ void tst_QWindow::testInputEvents() // Now with null pointer as window. local param should not be utilized: // handleMouseEvent() with tlw == 0 means the event is in global coords only. window.mousePressButton = window.mouseReleaseButton = 0; - QPointF nonWindowGlobal(window.geometry().topRight() + QPoint(200, 50)); // not inside the window - QWindowSystemInterface::handleMouseEvent(0, nonWindowGlobal, nonWindowGlobal, Qt::LeftButton); - QWindowSystemInterface::handleMouseEvent(0, nonWindowGlobal, nonWindowGlobal, Qt::NoButton); + const QPointF nonWindowGlobal(window.geometry().topRight() + QPoint(200, 50)); // not inside the window + const QPointF deviceNonWindowGlobal = QHighDpi::toNativePixels(nonWindowGlobal, window.screen()); + QWindowSystemInterface::handleMouseEvent(0, deviceNonWindowGlobal, deviceNonWindowGlobal, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(0, deviceNonWindowGlobal, deviceNonWindowGlobal, Qt::NoButton); QCoreApplication::processEvents(); QCOMPARE(window.mousePressButton, 0); QCOMPARE(window.mouseReleaseButton, 0); - QPointF windowGlobal = window.mapToGlobal(local.toPoint()); - QWindowSystemInterface::handleMouseEvent(0, windowGlobal, windowGlobal, Qt::LeftButton); - QWindowSystemInterface::handleMouseEvent(0, windowGlobal, windowGlobal, Qt::NoButton); + const QPointF windowGlobal = window.mapToGlobal(local.toPoint()); + const QPointF deviceWindowGlobal = QHighDpi::toNativePixels(windowGlobal, window.screen()); + QWindowSystemInterface::handleMouseEvent(0, deviceWindowGlobal, deviceWindowGlobal, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(0, deviceWindowGlobal, deviceWindowGlobal, Qt::NoButton); QCoreApplication::processEvents(); QCOMPARE(window.mousePressButton, int(Qt::LeftButton)); QCOMPARE(window.mouseReleaseButton, int(Qt::LeftButton)); @@ -719,7 +737,7 @@ void tst_QWindow::touchToMouseTranslation() const QRectF moveArea(105, 108, 4, 4); tp1.id = 1; tp1.state = Qt::TouchPointPressed; - tp1.area = pressArea; + tp1.area = QHighDpi::toNativePixels(pressArea, &window); tp2.id = 2; tp2.state = Qt::TouchPointPressed; points << tp1 << tp2; @@ -730,7 +748,7 @@ void tst_QWindow::touchToMouseTranslation() tp1.state = Qt::TouchPointStationary; tp2.id = 1; tp2.state = Qt::TouchPointMoved; - tp2.area = moveArea; + tp2.area = QHighDpi::toNativePixels(moveArea, &window); points.clear(); points << tp1 << tp2; QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); @@ -947,12 +965,15 @@ void tst_QWindow::touchCancelWithTouchToMouse() tp1.id = 1; tp1.state = Qt::TouchPointPressed; - tp1.area = QRect(100, 100, 4, 4); + const QRect area(100, 100, 4, 4); + tp1.area = QHighDpi::toNativePixels(area, &window); points << tp1; QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); QCoreApplication::processEvents(); QTRY_COMPARE(window.mousePressButton, int(Qt::LeftButton)); - QTRY_COMPARE(window.mousePressScreenPos, points[0].area.center()); + const int fuzz = 2 * int(QHighDpiScaling::factor(&window)); + QTRY_VERIFY2(qFuzzyCompareWindowPosition(window.mousePressScreenPos.toPoint(), area.center(), fuzz), + qPrintable(msgPointMismatch(window.mousePressScreenPos.toPoint(), area.center()))); // Cancel the touch. Should result in a mouse release for windows that have // have an active touch-to-mouse sequence. @@ -1150,8 +1171,9 @@ void tst_QWindow::mouseEventSequence() ulong timestamp = 0; QPointF local(12, 34); - QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::LeftButton); - QWindowSystemInterface::handleMouseEvent(&window, timestamp++, local, local, Qt::NoButton); + const QPointF deviceLocal = QHighDpi::toNativePixels(local, &window); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, deviceLocal, deviceLocal, Qt::LeftButton); + QWindowSystemInterface::handleMouseEvent(&window, timestamp++, deviceLocal, deviceLocal, Qt::NoButton); QCoreApplication::processEvents(); QCOMPARE(window.mousePressedCount, 1); QCOMPARE(window.mouseReleasedCount, 1); @@ -1338,14 +1360,16 @@ void tst_QWindow::tabletEvents() window.setGeometry(QRect(m_availableTopLeft + QPoint(10, 10), m_testWindowSize)); qGuiApp->installEventFilter(&window); - QPoint local(10, 10); - QPoint global = window.mapToGlobal(local); - QWindowSystemInterface::handleTabletEvent(&window, true, local, global, 1, 2, 0.5, 1, 2, 0.1, 0, 0, 0); + const QPoint local(10, 10); + const QPoint global = window.mapToGlobal(local); + const QPoint deviceLocal = QHighDpi::toNativeLocalPosition(local, &window); + const QPoint deviceGlobal = QHighDpi::toNativePixels(global, window.screen()); + QWindowSystemInterface::handleTabletEvent(&window, true, deviceLocal, deviceGlobal, 1, 2, 0.5, 1, 2, 0.1, 0, 0, 0); QCoreApplication::processEvents(); QTRY_VERIFY(window.eventType == QEvent::TabletPress); QTRY_COMPARE(window.eventGlobal.toPoint(), global); QTRY_COMPARE(window.eventLocal.toPoint(), local); - QWindowSystemInterface::handleTabletEvent(&window, false, local, global, 1, 2, 0.5, 1, 2, 0.1, 0, 0, 0); + QWindowSystemInterface::handleTabletEvent(&window, false, deviceLocal, deviceGlobal, 1, 2, 0.5, 1, 2, 0.1, 0, 0, 0); QCoreApplication::processEvents(); QTRY_VERIFY(window.eventType == QEvent::TabletRelease); diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 105afa9a91..f7c871fc0f 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -1653,6 +1653,7 @@ void tst_QTextLayout::testTabDPIScale() case QPaintDevice::PdmPhysicalDpiY: return 72; case QPaintDevice::PdmDevicePixelRatio: + case QPaintDevice::PdmDevicePixelRatioScaled: ; // fall through } return 0; diff --git a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp index c8d3122e6d..d7ff4e6c1e 100644 --- a/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp +++ b/tests/auto/gui/text/qtexttable/tst_qtexttable.cpp @@ -1086,6 +1086,8 @@ public: { if (PdmDevicePixelRatio == metric) return 1; + if (PdmDevicePixelRatioScaled == metric) + return 1 * QPaintDevice::devicePixelRatioFScale(); if (PdmDpiY == metric) return 96; if (PdmDpiX == metric) |