summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtouchevent
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-06-23 10:45:26 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-06-23 10:45:26 (GMT)
commit5e21e9b357a51eb6b3fa349dccf63e33c621fc72 (patch)
treefad2769e30786b098c2986232e1bbd8bbeb69ebe /tests/auto/qtouchevent
parentf11f41fe9e507d1f3eb8994960f0226f229bc76c (diff)
downloadQt-5e21e9b357a51eb6b3fa349dccf63e33c621fc72.zip
Qt-5e21e9b357a51eb6b3fa349dccf63e33c621fc72.tar.gz
Qt-5e21e9b357a51eb6b3fa349dccf63e33c621fc72.tar.bz2
Add functions to report normalized positions in QTouchEvent::TouchPoint
This introduces normalizedPos(), startNormalizedPos(), and lastNormalizedPos() in QTouchEvent::TouchPoint, and must be set by the implementation before being fed into Qt. We are assuming and hoping that these functions will make it easier to implement certain types of gestures (especially on a touchpad).
Diffstat (limited to 'tests/auto/qtouchevent')
-rw-r--r--tests/auto/qtouchevent/tst_qtouchevent.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/qtouchevent/tst_qtouchevent.cpp b/tests/auto/qtouchevent/tst_qtouchevent.cpp
index 6885e8b..b21ba40 100644
--- a/tests/auto/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/qtouchevent/tst_qtouchevent.cpp
@@ -251,6 +251,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
QPointF pos = touchWidget.rect().center();
QPointF screenPos = touchWidget.mapToGlobal(pos.toPoint());
QPointF delta(10, 10);
+ QRect screenGeometry = qApp->desktop()->screenGeometry(&touchWidget);
QTouchEvent::TouchPoint rawTouchPoint;
rawTouchPoint.setId(0);
@@ -258,6 +259,8 @@ void tst_QTouchEvent::basicRawEventTranslation()
// this should be translated to a TouchBegin
rawTouchPoint.setState(Qt::TouchPointPressed);
rawTouchPoint.setScreenPos(screenPos);
+ rawTouchPoint.setNormalizedPos(QPointF(rawTouchPoint.pos().x() / screenGeometry.width(),
+ rawTouchPoint.pos().y() / screenGeometry.height()));
qt_translateRawTouchEvent(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, &touchWidget);
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
@@ -275,6 +278,9 @@ void tst_QTouchEvent::basicRawEventTranslation()
QCOMPARE(touchBeginPoint.screenPos(), rawTouchPoint.screenPos());
QCOMPARE(touchBeginPoint.startScreenPos(), rawTouchPoint.screenPos());
QCOMPARE(touchBeginPoint.lastScreenPos(), rawTouchPoint.screenPos());
+ QCOMPARE(touchBeginPoint.normalizedPos(), rawTouchPoint.normalizedPos());
+ QCOMPARE(touchBeginPoint.startNormalizedPos(), touchBeginPoint.normalizedPos());
+ QCOMPARE(touchBeginPoint.lastNormalizedPos(), touchBeginPoint.normalizedPos());
QCOMPARE(touchBeginPoint.rect(), QRectF(pos, QSizeF(0, 0)));
QCOMPARE(touchBeginPoint.screenRect(), QRectF(rawTouchPoint.screenPos(), QSizeF(0, 0)));
QCOMPARE(touchBeginPoint.sceneRect(), touchBeginPoint.screenRect());
@@ -283,6 +289,8 @@ void tst_QTouchEvent::basicRawEventTranslation()
// moving the point should translate to TouchUpdate
rawTouchPoint.setState(Qt::TouchPointMoved);
rawTouchPoint.setScreenPos(screenPos + delta);
+ rawTouchPoint.setNormalizedPos(QPointF(rawTouchPoint.pos().x() / screenGeometry.width(),
+ rawTouchPoint.pos().y() / screenGeometry.height()));
qt_translateRawTouchEvent(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, &touchWidget);
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
@@ -300,6 +308,9 @@ void tst_QTouchEvent::basicRawEventTranslation()
QCOMPARE(touchUpdatePoint.screenPos(), rawTouchPoint.screenPos());
QCOMPARE(touchUpdatePoint.startScreenPos(), screenPos);
QCOMPARE(touchUpdatePoint.lastScreenPos(), screenPos);
+ QCOMPARE(touchUpdatePoint.normalizedPos(), rawTouchPoint.normalizedPos());
+ QCOMPARE(touchUpdatePoint.startNormalizedPos(), touchBeginPoint.normalizedPos());
+ QCOMPARE(touchUpdatePoint.lastNormalizedPos(), touchBeginPoint.normalizedPos());
QCOMPARE(touchUpdatePoint.rect(), QRectF(pos + delta, QSizeF(0, 0)));
QCOMPARE(touchUpdatePoint.screenRect(), QRectF(rawTouchPoint.screenPos(), QSizeF(0, 0)));
QCOMPARE(touchUpdatePoint.sceneRect(), touchUpdatePoint.screenRect());
@@ -308,6 +319,8 @@ void tst_QTouchEvent::basicRawEventTranslation()
// releasing the point translates to TouchEnd
rawTouchPoint.setState(Qt::TouchPointReleased);
rawTouchPoint.setScreenPos(screenPos + delta + delta);
+ rawTouchPoint.setNormalizedPos(QPointF(rawTouchPoint.pos().x() / screenGeometry.width(),
+ rawTouchPoint.pos().y() / screenGeometry.height()));
qt_translateRawTouchEvent(QList<QTouchEvent::TouchPoint>() << rawTouchPoint, &touchWidget);
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
@@ -325,6 +338,9 @@ void tst_QTouchEvent::basicRawEventTranslation()
QCOMPARE(touchEndPoint.screenPos(), rawTouchPoint.screenPos());
QCOMPARE(touchEndPoint.startScreenPos(), screenPos);
QCOMPARE(touchEndPoint.lastScreenPos(), screenPos + delta);
+ QCOMPARE(touchEndPoint.normalizedPos(), rawTouchPoint.normalizedPos());
+ QCOMPARE(touchEndPoint.startNormalizedPos(), touchBeginPoint.normalizedPos());
+ QCOMPARE(touchEndPoint.lastNormalizedPos(), touchUpdatePoint.normalizedPos());
QCOMPARE(touchEndPoint.rect(), QRectF(pos + delta + delta, QSizeF(0, 0)));
QCOMPARE(touchEndPoint.screenRect(), QRectF(rawTouchPoint.screenPos(), QSizeF(0, 0)));
QCOMPARE(touchEndPoint.sceneRect(), touchEndPoint.screenRect());