summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-05-23 15:07:39 +0300
committerQt by Nokia <qt-info@nokia.com>2012-05-31 09:13:01 +0200
commitb551d5e4f7d9785baef5c24abb902dafa71350e2 (patch)
tree5ff65dec7dbd3112e7689418fa0def4432f6aebf /tests
parentce7b3c972038636d8026dce949f1bd58e0bdd610 (diff)
QPA tablet event support
Should be sufficient to allow implementing the actual functionality in xcb/cocoa/windows to match the Qt 4 level of tablet event support. Task-number: QTBUG-25864 Change-Id: Iebcca256dfba841d8976b58fda1b76026d3133a3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 6e6db12268..55a9a39882 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 mouseEventSequence();
void windowModality();
void inputReentrancy();
+ void tabletEvents();
void initTestCase()
{
@@ -925,5 +926,62 @@ void tst_QWindow::inputReentrancy()
QCOMPARE(window.touchReleasedCount, 1);
}
+#ifndef QT_NO_TABLETEVENT
+class TabletTestWindow : public QWindow
+{
+public:
+ TabletTestWindow() : eventType(0) { }
+ void tabletEvent(QTabletEvent *ev) {
+ eventType = ev->type();
+ eventGlobal = ev->globalPosF();
+ eventLocal = ev->posF();
+ eventDevice = ev->device();
+ }
+ int eventType;
+ QPointF eventGlobal, eventLocal;
+ int eventDevice;
+ bool eventFilter(QObject *obj, QEvent *ev) {
+ if (ev->type() == QEvent::TabletEnterProximity
+ || ev->type() == QEvent::TabletLeaveProximity) {
+ eventType = ev->type();
+ QTabletEvent *te = static_cast<QTabletEvent *>(ev);
+ eventDevice = te->device();
+ }
+ return QWindow::eventFilter(obj, ev);
+ }
+};
+#endif
+
+void tst_QWindow::tabletEvents()
+{
+#ifndef QT_NO_TABLETEVENT
+ TabletTestWindow window;
+ window.setGeometry(10, 10, 100, 100);
+ 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);
+ 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);
+ QCoreApplication::processEvents();
+ QTRY_VERIFY(window.eventType == QEvent::TabletRelease);
+
+ QWindowSystemInterface::handleTabletEnterProximityEvent(1, 2, 3);
+ QCoreApplication::processEvents();
+ QTRY_VERIFY(window.eventType == QEvent::TabletEnterProximity);
+ QTRY_COMPARE(window.eventDevice, 1);
+
+ QWindowSystemInterface::handleTabletLeaveProximityEvent(1, 2, 3);
+ QCoreApplication::processEvents();
+ QTRY_VERIFY(window.eventType == QEvent::TabletLeaveProximity);
+ QTRY_COMPARE(window.eventDevice, 1);
+
+#endif
+}
+
#include <tst_qwindow.moc>
QTEST_MAIN(tst_QWindow)