diff options
Diffstat (limited to 'tests/auto/quick/qquickflickable/tst_qquickflickable.cpp')
-rw-r--r-- | tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | 66 |
1 files changed, 55 insertions, 11 deletions
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 8ab86bf2d3..80aaf5895f 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -75,6 +75,7 @@ private slots: void flickDeceleration(); void pressDelay(); void nestedPressDelay(); + void nestedClickThenFlick(); void flickableDirection(); void resizeContent(); void returnToBounds(); @@ -100,7 +101,7 @@ private slots: void pressDelayWithLoader(); private: - void flickWithTouch(QWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to); + void flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to); QQmlEngine engine; }; @@ -513,6 +514,51 @@ void tst_qquickflickable::nestedPressDelay() QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(90, 150)); } +// QTBUG-37316 +void tst_qquickflickable::nestedClickThenFlick() +{ + QScopedPointer<QQuickView> window(new QQuickView); + window->setSource(testFileUrl("nestedClickThenFlick.qml")); + QTRY_COMPARE(window->status(), QQuickView::Ready); + QQuickViewTestUtil::centerOnScreen(window.data()); + QQuickViewTestUtil::moveMouseAway(window.data()); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + QVERIFY(window->rootObject() != 0); + + QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(window->rootObject()); + QVERIFY(outer != 0); + + QQuickFlickable *inner = window->rootObject()->findChild<QQuickFlickable*>("innerFlickable"); + QVERIFY(inner != 0); + + QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 150)); + + // the MouseArea is not pressed immediately + QVERIFY(outer->property("pressed").toBool() == false); + QTRY_VERIFY(outer->property("pressed").toBool() == true); + + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150)); + + QVERIFY(outer->property("pressed").toBool() == false); + + // Dragging inner Flickable should work + QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(80, 150)); + // the MouseArea is not pressed immediately + + QVERIFY(outer->property("pressed").toBool() == false); + + QTest::mouseMove(window.data(), QPoint(80, 148)); + QTest::mouseMove(window.data(), QPoint(80, 140)); + QTest::mouseMove(window.data(), QPoint(80, 120)); + QTest::mouseMove(window.data(), QPoint(80, 100)); + + QVERIFY(outer->property("moving").toBool() == false); + QVERIFY(inner->property("moving").toBool() == true); + + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(80, 100)); +} + void tst_qquickflickable::flickableDirection() { QQmlComponent component(&engine); @@ -1349,20 +1395,18 @@ void tst_qquickflickable::flickTwiceUsingTouches() QTRY_VERIFY(contentYAfterSecondFlick > (contentYAfterFirstFlick + 80.0f)); } -void tst_qquickflickable::flickWithTouch(QWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to) +void tst_qquickflickable::flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to) { - QTest::touchEvent(window, touchDevice) - .press(0, from, window); - QTest::qWait(1); + QTest::touchEvent(window, touchDevice).press(0, from, window); + QQuickTouchUtils::flush(window); + QPoint diff = to - from; for (int i = 1; i <= 8; ++i) { - QTest::touchEvent(window, touchDevice) - .move(0, from + i*diff/8, window); - QTest::qWait(1); + QTest::touchEvent(window, touchDevice).move(0, from + i*diff/8, window); + QQuickTouchUtils::flush(window); } - QTest::touchEvent(window, touchDevice) - .release(0, to, window); - QTest::qWait(1); + QTest::touchEvent(window, touchDevice).release(0, to, window); + QQuickTouchUtils::flush(window); } void tst_qquickflickable::nestedStopAtBounds_data() |