aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2016-08-04 13:12:57 +0200
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2016-08-04 13:15:54 +0200
commit175f53860af034edf5a2dd5e9a5555376e604180 (patch)
treec3ce4eb15fc9918d7bf4b45f9ddc2d7fb8f65e60 /tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
parente2329c91e2999b4533a38c2b9f204af88e0e31ec (diff)
parentecf365c0b2ceeda97e42e4bc408964a9588cb6f2 (diff)
Merge branch 'dev' into wip/pointerhandler
Conflicts: src/quick/items/qquickwindow.cpp: we need the fix for QTBUG-31861 but now using QQuickPointerMouseEvent src/quick/items/qquickwindow_p.h: hover events need timestamps (e4f7ab42) tests/auto/quick/qquickwindow/tst_qquickwindow.cpp: added test for QTBUG-31861 Change-Id: Ic120513b69b318df3ba62d8174c276cbf6b7b55e
Diffstat (limited to 'tests/auto/quick/qquickwindow/tst_qquickwindow.cpp')
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index a9953b944c..acccac8eca 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -365,6 +365,7 @@ private slots:
void testRenderJob();
void testHoverChildMouseEventFilter();
+ void testHoverTimestamp();
void pointerEventTypeAndPointCount();
@@ -2398,6 +2399,90 @@ void tst_qquickwindow::testHoverChildMouseEventFilter()
QCOMPARE(middleItem->eventCount(QEvent::HoverEnter), 0);
}
+class HoverTimestampConsumer : public QQuickItem
+{
+ Q_OBJECT
+public:
+ HoverTimestampConsumer(QQuickItem *parent = 0)
+ : QQuickItem(parent)
+ {
+ setAcceptHoverEvents(true);
+ }
+
+ void hoverEnterEvent(QHoverEvent *event) { hoverTimestamps << event->timestamp(); }
+ void hoverLeaveEvent(QHoverEvent *event) { hoverTimestamps << event->timestamp(); }
+ void hoverMoveEvent(QHoverEvent *event) { hoverTimestamps << event->timestamp(); }
+
+ QList<ulong> hoverTimestamps;
+};
+
+// Checks that a QHoverEvent carries the timestamp of the QMouseEvent that caused it.
+// QTBUG-54600
+void tst_qquickwindow::testHoverTimestamp()
+{
+ QQuickWindow window;
+
+ window.resize(200, 200);
+ window.setPosition(100, 100);
+ window.setTitle(QTest::currentTestFunction());
+ window.show();
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+
+ HoverTimestampConsumer *hoverConsumer = new HoverTimestampConsumer(window.contentItem());
+ hoverConsumer->setWidth(100);
+ hoverConsumer->setHeight(100);
+ hoverConsumer->setX(50);
+ hoverConsumer->setY(50);
+
+ // First position, outside
+ {
+ QMouseEvent mouseEvent(QEvent::MouseMove, QPointF(40, 40), QPointF(40, 40), QPointF(140, 140),
+ Qt::NoButton, Qt::NoButton, Qt::NoModifier, Qt::MouseEventNotSynthesized);
+ mouseEvent.setTimestamp(10);
+ QVERIFY(QCoreApplication::sendEvent(&window, &mouseEvent));
+ }
+
+ // Enter
+ {
+ QMouseEvent mouseEvent(QEvent::MouseMove, QPointF(50, 50), QPointF(50, 50), QPointF(150, 150),
+ Qt::NoButton, Qt::NoButton, Qt::NoModifier, Qt::MouseEventNotSynthesized);
+ mouseEvent.setTimestamp(20);
+ QVERIFY(QCoreApplication::sendEvent(&window, &mouseEvent));
+ }
+ QCOMPARE(hoverConsumer->hoverTimestamps.size(), 1);
+ QCOMPARE(hoverConsumer->hoverTimestamps.last(), 20UL);
+
+ // Move
+ {
+ QMouseEvent mouseEvent(QEvent::MouseMove, QPointF(60, 60), QPointF(60, 60), QPointF(160, 160),
+ Qt::NoButton, Qt::NoButton, Qt::NoModifier, Qt::MouseEventNotSynthesized);
+ mouseEvent.setTimestamp(30);
+ QVERIFY(QCoreApplication::sendEvent(&window, &mouseEvent));
+ }
+ QCOMPARE(hoverConsumer->hoverTimestamps.size(), 2);
+ QCOMPARE(hoverConsumer->hoverTimestamps.last(), 30UL);
+
+ // Move
+ {
+ QMouseEvent mouseEvent(QEvent::MouseMove, QPointF(100, 100), QPointF(100, 100), QPointF(200, 200),
+ Qt::NoButton, Qt::NoButton, Qt::NoModifier, Qt::MouseEventNotSynthesized);
+ mouseEvent.setTimestamp(40);
+ QVERIFY(QCoreApplication::sendEvent(&window, &mouseEvent));
+ }
+ QCOMPARE(hoverConsumer->hoverTimestamps.size(), 3);
+ QCOMPARE(hoverConsumer->hoverTimestamps.last(), 40UL);
+
+ // Leave
+ {
+ QMouseEvent mouseEvent(QEvent::MouseMove, QPointF(160, 160), QPointF(160, 160), QPointF(260, 260),
+ Qt::NoButton, Qt::NoButton, Qt::NoModifier, Qt::MouseEventNotSynthesized);
+ mouseEvent.setTimestamp(5);
+ QVERIFY(QCoreApplication::sendEvent(&window, &mouseEvent));
+ }
+ QCOMPARE(hoverConsumer->hoverTimestamps.size(), 4);
+ QCOMPARE(hoverConsumer->hoverTimestamps.last(), 5UL);
+}
+
void tst_qquickwindow::pointerEventTypeAndPointCount()
{
QPointF localPosition(33, 66);