diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/quick/qquickflickable/data/dragon.qml | 15 | ||||
-rw-r--r-- | tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | 50 |
2 files changed, 65 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickflickable/data/dragon.qml b/tests/auto/quick/qquickflickable/data/dragon.qml new file mode 100644 index 0000000000..b82477453b --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/dragon.qml @@ -0,0 +1,15 @@ +import QtQuick 2.12 + +Flickable { + id: flick + width: 320 + height: 320 + contentWidth: 500 + contentHeight: 500 + Text { + anchors.centerIn: parent + font.pixelSize: 50 + text: "🐉" + color: flick.dragging ? "orange" : "grey" + } +} diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 57c9dda230..2146836048 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -205,6 +205,8 @@ private slots: void synchronousDrag(); void visibleAreaBinding(); void parallelTouch(); + void ignoreNonLeftMouseButtons(); + void ignoreNonLeftMouseButtons_data(); private: void flickWithTouch(QQuickWindow *window, const QPoint &from, const QPoint &to); @@ -2649,6 +2651,54 @@ void tst_qquickflickable::parallelTouch() // QTBUG-30840 QTRY_VERIFY(!flickable2->isMoving()); } +void tst_qquickflickable::ignoreNonLeftMouseButtons() // QTBUG-96909 +{ + QFETCH(Qt::MouseButton, otherButton); + const int threshold = qApp->styleHints()->startDragDistance(); + QQuickView view; + view.setSource(testFileUrl("dragon.qml")); + view.show(); + view.requestActivate(); + QQuickFlickable *flickable = static_cast<QQuickFlickable *>(view.rootObject()); + QSignalSpy dragSpy(flickable, &QQuickFlickable::draggingChanged); + + // Drag with left button + QPoint p1(100, 100); + moveAndPress(&view, p1); + for (int i = 0; i < 8; ++i) { + p1 -= QPoint(threshold, threshold); + QTest::mouseMove(&view, p1, 50); + } + QVERIFY(flickable->isDragging()); + QCOMPARE(dragSpy.count(), 1); + + // Press other button too, then release left button: dragging changes to false + QTest::mousePress(&view, otherButton); + QTest::mouseRelease(&view, Qt::LeftButton); + QTRY_COMPARE(flickable->isDragging(), false); + QCOMPARE(dragSpy.count(), 2); + + // Drag further with the other button held: Flickable ignores it + for (int i = 0; i < 8; ++i) { + p1 -= QPoint(threshold, threshold); + QTest::mouseMove(&view, p1, 50); + } + QCOMPARE(flickable->isDragging(), false); + QCOMPARE(dragSpy.count(), 2); + + // Release other button: nothing happens + QTest::mouseRelease(&view, otherButton); + QCOMPARE(dragSpy.count(), 2); +} + +void tst_qquickflickable::ignoreNonLeftMouseButtons_data() +{ + QTest::addColumn<Qt::MouseButton>("otherButton"); + + QTest::newRow("right") << Qt::RightButton; + QTest::newRow("middle") << Qt::MiddleButton; +} + QTEST_MAIN(tst_qquickflickable) #include "tst_qquickflickable.moc" |