summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-03-11 22:10:05 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-21 21:08:27 +0100
commitefcfa0b252a96a7064dcd9b1767ff61e7875bab5 (patch)
treef1af80216a646ca3044404a3f1af0f10864898ba /tests/auto
parent584088f2007d36658e3667df38c4e7f66fe66c9a (diff)
QGuiApplication: send TouchCancel when touch is interrupted by popup
QQuickWindow depends on maintaining state of known touch points between events, so it needs to be notified when it will not be receiving the corresponding release event for one or more. This temporary fix needs to be reverted when we have a proper event forwarding solution. Task-number: QTBUG-37371 Change-Id: I5dc40af6feac425be8103c1586f8ebe3a6aad20d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 7e6313295b..da142c80a6 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -71,6 +71,7 @@ private slots:
void mouseToTouchLoop();
void touchCancel();
void touchCancelWithTouchToMouse();
+ void touchInterruptedByPopup();
void orientation();
void sizes();
void close();
@@ -772,6 +773,56 @@ void tst_QWindow::touchCancelWithTouchToMouse()
QTRY_COMPARE(window.mouseReleaseButton, 0);
}
+void tst_QWindow::touchInterruptedByPopup()
+{
+ InputTestWindow window;
+ window.setGeometry(80, 80, 200, 200);
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ QList<QWindowSystemInterface::TouchPoint> points;
+ QWindowSystemInterface::TouchPoint tp1;
+ tp1.id = 1;
+
+ // Start a touch.
+ tp1.state = Qt::TouchPointPressed;
+ tp1.area = QRect(10, 10, 4, 4);
+ points << tp1;
+ QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(window.touchEventType, QEvent::TouchBegin);
+ QTRY_COMPARE(window.touchPressedCount, 1);
+
+ // Launch a popup window
+ InputTestWindow popup;
+ popup.setFlags(Qt::Popup);
+ popup.setModality(Qt::WindowModal);
+ popup.setWidth(160);
+ popup.setHeight(160);
+ popup.setTransientParent(&window);
+ popup.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&popup));
+
+ // Send a move -> will not be delivered to the original window
+ // (TODO verify where it is forwarded, after we've defined that)
+ QTRY_COMPARE(window.touchMovedCount, 0);
+ points[0].state = Qt::TouchPointMoved;
+ tp1.area.adjust(2, 2, 2, 2);
+ QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(window.touchMovedCount, 0);
+
+ // Send a touch end -> will not be delivered to the original window
+ QTRY_COMPARE(window.touchReleasedCount, 0);
+ points[0].state = Qt::TouchPointReleased;
+ QWindowSystemInterface::handleTouchEvent(&window, touchDevice, points);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(window.touchReleasedCount, 0);
+
+ // Due to temporary fix for QTBUG-37371: the original window should receive a TouchCancel
+ QTRY_COMPARE(window.touchEventType, QEvent::TouchCancel);
+}
+
void tst_QWindow::orientation()
{
qRegisterMetaType<Qt::ScreenOrientation>("Qt::ScreenOrientation");