aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickitem
diff options
context:
space:
mode:
authorOleg Yadrov <oleg.yadrov@qt.io>2017-02-16 11:04:44 -0800
committerOleg Yadrov <oleg.yadrov@qt.io>2017-02-17 18:01:15 +0000
commit52470e2d6ff707762c38b81d4dedcdc55b898323 (patch)
treedd9a6b04a6707dad28f8396717d7d9b7c02c4ea1 /tests/auto/quick/qquickitem
parent038c98fb79dc11b34d2c5934d4d94ea99252a632 (diff)
QQuickWindowPrivate::deliverWheelEvent: fix global position of the event
[ChangeLog][QtQuick] QWheelEvent in QQuickItem::wheelEvent now keeps correct global position. Task-number: QTBUG-58845 Change-Id: I7f88d5152927a157e2bd07ee4d5f2208be884eec Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickitem')
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index 8d974f4d17..10a3a0bfa8 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -48,7 +48,8 @@ public:
TestItem(QQuickItem *parent = 0)
: QQuickItem(parent), focused(false), pressCount(0), releaseCount(0)
, wheelCount(0), acceptIncomingTouchEvents(true)
- , touchEventReached(false), timestamp(0) {}
+ , touchEventReached(false), timestamp(0)
+ , lastWheelEventPos(0, 0), lastWheelEventGlobalPos(0, 0) {}
bool focused;
int pressCount;
@@ -57,6 +58,8 @@ public:
bool acceptIncomingTouchEvents;
bool touchEventReached;
ulong timestamp;
+ QPoint lastWheelEventPos;
+ QPoint lastWheelEventGlobalPos;
protected:
virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; }
virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; }
@@ -66,7 +69,13 @@ protected:
touchEventReached = true;
event->setAccepted(acceptIncomingTouchEvents);
}
- virtual void wheelEvent(QWheelEvent *event) { event->accept(); ++wheelCount; timestamp = event->timestamp(); }
+ virtual void wheelEvent(QWheelEvent *event) {
+ event->accept();
+ ++wheelCount;
+ timestamp = event->timestamp();
+ lastWheelEventPos = event->pos();
+ lastWheelEventGlobalPos = event->globalPos();
+ }
};
class TestWindow: public QQuickWindow
@@ -1422,19 +1431,24 @@ void tst_qquickitem::wheelEvent()
const bool shouldReceiveWheelEvents = visible && enabled;
+ const int width = 200;
+ const int height = 200;
+
QQuickWindow window;
- window.resize(200, 200);
+ window.resize(width, height);
window.show();
QTest::qWaitForWindowExposed(&window);
TestItem *item = new TestItem;
- item->setSize(QSizeF(200, 100));
+ item->setSize(QSizeF(width, height));
item->setParentItem(window.contentItem());
item->setEnabled(enabled);
item->setVisible(visible);
- QWheelEvent event(QPoint(100, 50), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical);
+ QPoint localPoint(width / 2, height / 2);
+ QPoint globalPoint = window.mapToGlobal(localPoint);
+ QWheelEvent event(localPoint, globalPoint, -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical);
event.setTimestamp(123456UL);
event.setAccepted(false);
QGuiApplication::sendEvent(&window, &event);
@@ -1443,6 +1457,8 @@ void tst_qquickitem::wheelEvent()
QVERIFY(event.isAccepted());
QCOMPARE(item->wheelCount, 1);
QCOMPARE(item->timestamp, 123456UL);
+ QCOMPARE(item->lastWheelEventPos, localPoint);
+ QCOMPARE(item->lastWheelEventGlobalPos, globalPoint);
} else {
QVERIFY(!event.isAccepted());
QCOMPARE(item->wheelCount, 0);