aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 14:41:17 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-06 21:12:57 +0100
commiteda4b3dc3c9421a0b3009c11b858f4e5fe1d8ba2 (patch)
tree9cb4e33784961df6ed97d5211ef3bdf3d5b70498 /tests
parent6f6fe27cf48ddcc98deb3c5d9b65a9a00a90bf02 (diff)
Fix acceptance of unhandled mouse events.
Mouse events not handled by the canvas need to be ignored, in order for features like touch synthetization to work. In case of the initially delivered mouse press event, the canvas did not ignore the event if it was not handled. This patch corrects that and adds an auto-test to verify the new behaviour. Change-Id: I8499701f5a161ce1e90a70303aa7ca4ccf2f0b6f Reviewed-by: Andras Becsi <andras.becsi@nokia.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp
index 795580cc6e..4a238429bb 100644
--- a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp
+++ b/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp
@@ -210,6 +210,8 @@ private slots:
void focusObject();
+ void ignoreUnhandledMouseEvents();
+
private:
QTouchDevice *touchDevice;
};
@@ -696,6 +698,43 @@ void tst_qquickcanvas::focusObject()
delete canvas;
}
+void tst_qquickcanvas::ignoreUnhandledMouseEvents()
+{
+ QQuickCanvas* canvas = new QQuickCanvas;
+ canvas->resize(100, 100);
+ canvas->show();
+
+ QQuickItem* item = new QQuickItem;
+ item->setSize(QSizeF(100, 100));
+ item->setParentItem(canvas->rootItem());
+
+ {
+ QMouseEvent me(QEvent::MouseButtonPress, QPointF(50, 50), Qt::LeftButton, Qt::LeftButton,
+ Qt::NoModifier);
+ me.setAccepted(true);
+ QVERIFY(QCoreApplication::sendEvent(canvas, &me));
+ QVERIFY(!me.isAccepted());
+ }
+
+ {
+ QMouseEvent me(QEvent::MouseMove, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton,
+ Qt::NoModifier);
+ me.setAccepted(true);
+ QVERIFY(QCoreApplication::sendEvent(canvas, &me));
+ QVERIFY(!me.isAccepted());
+ }
+
+ {
+ QMouseEvent me(QEvent::MouseButtonRelease, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton,
+ Qt::NoModifier);
+ me.setAccepted(true);
+ QVERIFY(QCoreApplication::sendEvent(canvas, &me));
+ QVERIFY(!me.isAccepted());
+ }
+
+ delete canvas;
+}
+
QTEST_MAIN(tst_qquickcanvas)
#include "tst_qquickcanvas.moc"