From b324ee38a67c6e8529023f3f4e34be8af5f60166 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 12 Feb 2013 22:19:10 -0600 Subject: A MouseArea should not receive move or release events if the press was not accepted. Change-Id: If70650d7150b224f4460697a953611dd37d57af1 Reviewed-by: Frederik Gladhorn --- .../data/moveAndReleaseWithoutPress.qml | 14 +++++++++++++ .../quick/qquickmousearea/tst_qquickmousearea.cpp | 24 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/auto/quick/qquickmousearea/data/moveAndReleaseWithoutPress.qml (limited to 'tests/auto/quick/qquickmousearea') diff --git a/tests/auto/quick/qquickmousearea/data/moveAndReleaseWithoutPress.qml b/tests/auto/quick/qquickmousearea/data/moveAndReleaseWithoutPress.qml new file mode 100644 index 0000000000..6c68f0c7c8 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/moveAndReleaseWithoutPress.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +MouseArea { + width: 200 + height: 200 + + property bool hadMove: false + property bool hadRelease: false + + onPressed: mouse.accepted = false + onPositionChanged: hadMove = true + onReleased: hadRelease = true +} + diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index ffe7b51537..37ce0fd394 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -88,6 +88,7 @@ private slots: #ifndef QT_NO_CURSOR void cursorShape(); #endif + void moveAndReleaseWithoutPress(); private: void acceptedButton_data(); @@ -1402,6 +1403,29 @@ void tst_QQuickMouseArea::cursorShape() } #endif +void tst_QQuickMouseArea::moveAndReleaseWithoutPress() +{ + QQuickView *window = createView(); + + window->setSource(testFileUrl("moveAndReleaseWithoutPress.qml")); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QObject *root = window->rootObject(); + QVERIFY(root); + + QTest::mousePress(window, Qt::LeftButton, 0, QPoint(100,100)); + + QTest::mouseMove(window, QPoint(110,110), 50); + QTRY_COMPARE(root->property("hadMove").toBool(), false); + + QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(110,110)); + QTRY_COMPARE(root->property("hadRelease").toBool(), false); + + delete window; +} + QTEST_MAIN(tst_QQuickMouseArea) #include "tst_qquickmousearea.moc" -- cgit v1.2.3