diff options
author | Tang Haixiang <tanghaixiang@uniontech.com> | 2022-05-24 19:00:07 +0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-07-05 15:26:45 +0000 |
commit | 4c0bbf51791f52a5c0ee70717236a726a6c21cb1 (patch) | |
tree | aad7f4def5fb860efad9e3d8821ad7214c8fd97b /tests/auto/gui/kernel | |
parent | 47955142301c3391fefafabe930ccbacb4eced12 (diff) | |
download | qtbase-4c0bbf51791f52a5c0ee70717236a726a6c21cb1.tar.gz |
tst_qwindow: modify some abnormal touch tests
Under normal circumstances, when the second point is touched, the
first point has not been released, and the message at this time
should contain two touch points. We are simulating the case where
the message is lost when the popup is closed by touch. Amends
efc02f9cc301f98c77079adae026ffd07f50d5ab
Change-Id: Ic722e3dbd615c46076ede26611d0107501c5e274
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit c2a63b40140e09ad12bec54714302db5baad9d35)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/gui/kernel')
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index dafa69fb96..f2fb2d85cc 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -86,6 +86,7 @@ private slots: void keepPendingUpdateRequests(); void activateDeactivateEvent(); void qobject_castOnDestruction(); + void touchToMouseTranslationByPopup(); private: QPoint m_availableTopLeft; @@ -950,6 +951,9 @@ public: if (spinLoopWhenPressed) QCoreApplication::processEvents(); } + if (closeOnTap) + this->close(); + } void mouseReleaseEvent(QMouseEvent *event) override { @@ -1017,6 +1021,8 @@ public: touchPressLocalPos = point.position(); touchPressGlobalPos = point.globalPosition(); } + if (closeOnTap) + this->close(); break; case QEventPoint::State::Released: ++touchReleasedCount; @@ -1073,6 +1079,8 @@ public: const QPointingDevice *mouseDevice = nullptr; const QPointingDevice *touchDevice = nullptr; + + bool closeOnTap = false; }; static void simulateMouseClick(QWindow *target, const QPointF &local, const QPointF &global) @@ -1157,18 +1165,14 @@ void tst_QWindow::touchToMouseTranslation() QVERIFY(QTest::qWaitForWindowExposed(&window)); QList<QWindowSystemInterface::TouchPoint> points; - QWindowSystemInterface::TouchPoint tp1, tp2, tp3; + QWindowSystemInterface::TouchPoint tp1, tp2; const QRectF pressArea(101, 102, 4, 4); - const QRectF pressArea1(107, 110, 4, 4); const QRectF moveArea(105, 108, 4, 4); tp1.id = 1; tp1.state = QEventPoint::State::Pressed; tp1.area = QHighDpi::toNativePixels(pressArea, &window); tp2.id = 2; tp2.state = QEventPoint::State::Pressed; - tp3.id = 3; - tp3.state = QEventPoint::State::Pressed; - tp3.area = QHighDpi::toNativePixels(pressArea1, &window); points << tp1 << tp2; QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); // Now an update but with changed list order. The mouse event should still @@ -1250,40 +1254,6 @@ void tst_QWindow::touchToMouseTranslation() QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); QCoreApplication::processEvents(); QTRY_COMPARE(window.mouseReleaseButton, 1); - - points.clear(); - points.append(tp1); - points[0].state = QEventPoint::State::Pressed; - QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); - QCoreApplication::processEvents(); - points.clear(); - points.append(tp2); - points[0].state = QEventPoint::State::Pressed; - QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); - QCoreApplication::processEvents(); - points.clear(); - points.append(tp3); - points[0].state = QEventPoint::State::Pressed; - QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); - QCoreApplication::processEvents(); - QTRY_COMPARE(window.mousePressButton, 1); - - points.clear(); - points.append(tp2); - points[0].state = QEventPoint::State::Released; - QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); - QCoreApplication::processEvents(); - points.clear(); - points.append(tp3); - points[0].state = QEventPoint::State::Released; - QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); - QCoreApplication::processEvents(); - points.clear(); - points.append(tp1); - points[0].state = QEventPoint::State::Released; - QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points); - QCoreApplication::processEvents(); - QTRY_COMPARE(window.mouseReleaseButton, 1); } void tst_QWindow::touchToMouseTranslationForDevices() @@ -2770,6 +2740,36 @@ void tst_QWindow::qobject_castOnDestruction() }); } +void tst_QWindow::touchToMouseTranslationByPopup() +{ + InputTestWindow window; + window.setTitle(QLatin1String(QTest::currentTestFunction())); + window.ignoreTouch = true; + window.setGeometry(QRect(m_availableTopLeft, m_testWindowSize)); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + InputTestWindow popupWindow; + popupWindow.setGeometry(QRect(m_availableTopLeft + QPoint(20, 20), + QSize(m_testWindowSize.width(), m_testWindowSize.height() / 2))); + popupWindow.setFlag(Qt::Popup); + popupWindow.setTransientParent(&window); + popupWindow.ignoreTouch = true; + popupWindow.closeOnTap = true; + popupWindow.show(); + QVERIFY(QTest::qWaitForWindowExposed(&popupWindow)); + + QTest::touchEvent(&popupWindow, touchDevice).press(0, {1, 1}, &window); + QVERIFY(!popupWindow.isVisible()); + + // Omit touchpoint 0: because the popup was closed, touchpoint0.release is not sent. + const QPoint tp1(50, 1); + QTest::touchEvent(&window, touchDevice).press(1, tp1, &window); + QTRY_COMPARE(window.mousePressButton, int(Qt::LeftButton)); + QTest::touchEvent(&window, touchDevice).release(1, tp1, &window); + QTRY_COMPARE(window.mouseReleaseButton, int(Qt::LeftButton)); +} + #include <tst_qwindow.moc> QTEST_MAIN(tst_QWindow) |