aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/drawer
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-15 06:46:54 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-19 14:34:06 +0000
commit541a7a8e785476e2e93f88f770715f25ce7e6dc8 (patch)
tree2d988212f8f4faa4feb43d6956048c3c1b5801c7 /tests/auto/drawer
parent60bbe9d5157c50a35f891105819aaf851eb136bc (diff)
Drawer: fix drag to close from the outside on touch
Set mouseGrabberPopup in QQuickOverlay::childMouseEventFilter() the same way it is set in QQuickOverlay::mousePressEvent() to ensure that the consequent mouse move events are routed to the appropriate popup. This worked with "genuine" mouse move events that were caught by the same child mouse event filter and that way routed to the appropriate popup, but not with "synthesized" mouse move events that are caught by QQuickOverlay::mousePressEvent() instead. Change-Id: Ic59afd85e55c13ebec482bc4dc534accd1f92b2c Task-number: QTBUG-56010 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/drawer')
-rw-r--r--tests/auto/drawer/BLACKLIST2
-rw-r--r--tests/auto/drawer/tst_drawer.cpp58
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/auto/drawer/BLACKLIST b/tests/auto/drawer/BLACKLIST
new file mode 100644
index 00000000..1b06b49c
--- /dev/null
+++ b/tests/auto/drawer/BLACKLIST
@@ -0,0 +1,2 @@
+[touch]
+windows
diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp
index 8b02e95c..3a02e9a9 100644
--- a/tests/auto/drawer/tst_drawer.cpp
+++ b/tests/auto/drawer/tst_drawer.cpp
@@ -40,7 +40,10 @@
#include "../shared/visualtestutil.h"
#include <QtGui/qstylehints.h>
+#include <QtGui/qtouchdevice.h>
#include <QtGui/qguiapplication.h>
+#include <QtGui/qpa/qwindowsysteminterface.h>
+#include <QtQuick/private/qquickwindow_p.h>
#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h>
#include <QtQuickTemplates2/private/qquickoverlay_p.h>
#include <QtQuickTemplates2/private/qquickdrawer_p.h>
@@ -74,6 +77,9 @@ private slots:
void wheel();
void multiple();
+
+ void touch_data();
+ void touch();
};
void tst_Drawer::visible_data()
@@ -615,6 +621,58 @@ void tst_Drawer::multiple()
QCOMPARE(leftDrawer->position(), 0.0);
}
+void tst_Drawer::touch_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::newRow("Window") << "window.qml";
+ QTest::newRow("ApplicationWindow") << "applicationwindow.qml";
+}
+
+void tst_Drawer::touch()
+{
+ QFETCH(QString, source);
+ QQuickApplicationHelper helper(this, source);
+
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickDrawer *drawer = window->property("drawer").value<QQuickDrawer*>();
+ QVERIFY(drawer);
+
+ struct TouchDeviceDeleter
+ {
+ static inline void cleanup(QTouchDevice *device)
+ {
+ QWindowSystemInterface::unregisterTouchDevice(device);
+ delete device;
+ }
+ };
+
+ QScopedPointer<QTouchDevice, TouchDeviceDeleter> device(new QTouchDevice);
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device.data());
+
+ // drag to open
+ QTest::touchEvent(window, device.data()).press(0, QPoint(0, 100));
+ QTest::touchEvent(window, device.data()).move(0, QPoint(100, 100));
+ QTRY_COMPARE(drawer->position(), 0.5);
+ QTest::touchEvent(window, device.data()).release(0, QPoint(100, 100));
+ QTRY_COMPARE(drawer->position(), 1.0);
+
+ // drag to close
+ QTest::touchEvent(window, device.data()).press(0, QPoint(300, 100));
+ QTest::touchEvent(window, device.data()).move(0, QPoint(300 - drawer->dragMargin(), 100));
+ for (int x = 300; x > 100; x -= 10) {
+ QTest::touchEvent(window, device.data()).move(0, QPoint(x, 100));
+ QQuickWindowPrivate::get(window)->flushDelayedTouchEvent();
+ }
+ QTest::touchEvent(window, device.data()).move(0, QPoint(100, 100));
+ QTRY_COMPARE(drawer->position(), 0.5);
+ QTest::touchEvent(window, device.data()).release(0, QPoint(100, 100));
+ QTRY_COMPARE(drawer->position(), 0.0);
+}
+
QTEST_MAIN(tst_Drawer)
#include "tst_drawer.moc"