diff options
author | Liang Qi <liang.qi@qt.io> | 2016-10-10 09:28:12 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2016-10-10 16:01:48 +0200 |
commit | 102fa9b6db82ecd2b95d168912fde0c8bc3798b3 (patch) | |
tree | 5bf934c323dcafb67cb508ace579110191ad782d /tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | |
parent | a6be2d77aa6dc9f834b971eaff749a02cf982525 (diff) | |
parent | fff4477661ae240c43088fa6d9069ccf969dbee8 (diff) |
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts:
examples/quick/quickwidgets/quickwidget/main.cpp
src/qml/jsruntime/qv4jsonobject.cpp
src/qml/jsruntime/qv4qobjectwrapper.cpp
src/qml/jsruntime/qv4qobjectwrapper_p.h
src/qml/qml/qqmlengine.cpp
src/qml/qml/qqmlpropertycache.cpp
src/qml/qml/qqmlpropertycache_p.h
src/quick/items/qquickanimatedsprite.cpp
src/quick/items/qquickitem.cpp
src/quick/items/qquickitem.h
src/quick/items/qquickitem_p.h
src/quick/items/qquickview_p.h
src/quick/scenegraph/qsgcontext.cpp
src/quick/scenegraph/qsgdefaultrendercontext.cpp
Change-Id: I172c6fbff97208f21ed4c8b6db3d1747a889f22b
Diffstat (limited to 'tests/auto/quick/qquickflickable/tst_qquickflickable.cpp')
-rw-r--r-- | tests/auto/quick/qquickflickable/tst_qquickflickable.cpp | 162 |
1 files changed, 144 insertions, 18 deletions
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 18dd1bc325..b774481592 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -70,6 +70,7 @@ private slots: void returnToBounds(); void returnToBounds_data(); void wheel(); + void trackpad(); void movingAndFlicking(); void movingAndFlicking_data(); void movingAndDragging(); @@ -489,8 +490,20 @@ void tst_qquickflickable::nestedPressDelay() // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec. QTRY_VERIFY(outer->property("pressed").toBool()); + QTest::mouseMove(window.data(), QPoint(130, 150)); + QTest::mouseMove(window.data(), QPoint(110, 150)); + QTest::mouseMove(window.data(), QPoint(90, 150)); + + QVERIFY(!outer->property("moving").toBool()); + QVERIFY(!outer->property("dragging").toBool()); + QVERIFY(inner->property("moving").toBool()); + QVERIFY(inner->property("dragging").toBool()); + QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150)); + QVERIFY(!inner->property("dragging").toBool()); + QTRY_VERIFY(!inner->property("moving").toBool()); + // Dragging inner Flickable should work moveAndPress(window.data(), QPoint(80, 150)); // the MouseArea is not pressed immediately @@ -502,10 +515,15 @@ void tst_qquickflickable::nestedPressDelay() QTest::mouseMove(window.data(), QPoint(20, 150)); QVERIFY(inner->property("moving").toBool()); + QVERIFY(inner->property("dragging").toBool()); QVERIFY(!outer->property("moving").toBool()); + QVERIFY(!outer->property("dragging").toBool()); QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(20, 150)); + QVERIFY(!inner->property("dragging").toBool()); + QTRY_VERIFY(!inner->property("moving").toBool()); + // Dragging the MouseArea in the inner Flickable should move the inner Flickable moveAndPress(window.data(), QPoint(150, 150)); // the MouseArea is not pressed immediately @@ -515,11 +533,15 @@ void tst_qquickflickable::nestedPressDelay() QTest::mouseMove(window.data(), QPoint(110, 150)); QTest::mouseMove(window.data(), QPoint(90, 150)); - QVERIFY(!outer->property("moving").toBool()); + QVERIFY(!outer->property("dragging").toBool()); QVERIFY(inner->property("moving").toBool()); + QVERIFY(inner->property("dragging").toBool()); QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(90, 150)); + + QVERIFY(!inner->property("dragging").toBool()); + QTRY_VERIFY(!inner->property("moving").toBool()); } void tst_qquickflickable::filterReplayedPress() @@ -722,7 +744,10 @@ void tst_qquickflickable::wheel() QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("flick"); QVERIFY(flick != 0); + QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flick); + QSignalSpy moveEndSpy(flick, SIGNAL(movementEnded())); + // test a vertical flick { QPoint pos(200, 200); QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(0,-120), -120, Qt::Vertical, Qt::NoButton, Qt::NoModifier); @@ -733,9 +758,19 @@ void tst_qquickflickable::wheel() QTRY_VERIFY(flick->contentY() > 0); QCOMPARE(flick->contentX(), qreal(0)); - flick->setContentY(0); + QTRY_COMPARE(moveEndSpy.count(), 1); + QCOMPARE(fp->velocityTimeline.isActive(), false); + QCOMPARE(fp->timeline.isActive(), false); + QTest::qWait(50); // make sure that onContentYChanged won't sneak in again + QCOMPARE(flick->property("movementsAfterEnd").value<int>(), 0); // QTBUG-55886 + + // get ready to test horizontal flick + flick->setContentY(0); // which triggers movementEnded again + flick->setProperty("movementsAfterEnd", 0); + flick->setProperty("ended", false); QCOMPARE(flick->contentY(), qreal(0)); + // test a horizontal flick { QPoint pos(200, 200); QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(-120,0), -120, Qt::Horizontal, Qt::NoButton, Qt::NoModifier); @@ -746,6 +781,55 @@ void tst_qquickflickable::wheel() QTRY_VERIFY(flick->contentX() > 0); QCOMPARE(flick->contentY(), qreal(0)); + QTRY_COMPARE(moveEndSpy.count(), 2); + QCOMPARE(fp->velocityTimeline.isActive(), false); + QCOMPARE(fp->timeline.isActive(), false); + QTest::qWait(50); // make sure that onContentXChanged won't sneak in again + QCOMPARE(flick->property("movementsAfterEnd").value<int>(), 0); // QTBUG-55886 +} + +void tst_qquickflickable::trackpad() +{ + QScopedPointer<QQuickView> window(new QQuickView); + window->setSource(testFileUrl("wheel.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QVERIFY(window->rootObject() != 0); + + QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("flick"); + QVERIFY(flick != 0); + QSignalSpy moveEndSpy(flick, SIGNAL(movementEnded())); + QPoint pos(200, 200); + + { + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(0,-100), QPoint(0,-120), -120, Qt::Vertical, Qt::NoButton, Qt::NoModifier, Qt::ScrollBegin); + event.setAccepted(false); + QGuiApplication::sendEvent(window.data(), &event); + } + + QTRY_VERIFY(flick->contentY() > 0); + QCOMPARE(flick->contentX(), qreal(0)); + + flick->setContentY(0); + QCOMPARE(flick->contentY(), qreal(0)); + + { + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(-100,0), QPoint(-120,0), -120, Qt::Horizontal, Qt::NoButton, Qt::NoModifier, Qt::ScrollUpdate); + event.setAccepted(false); + QGuiApplication::sendEvent(window.data(), &event); + } + + QTRY_VERIFY(flick->contentX() > 0); + QCOMPARE(flick->contentY(), qreal(0)); + + { + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(0,0), QPoint(0,0), 0, Qt::Horizontal, Qt::NoButton, Qt::NoModifier, Qt::ScrollEnd); + event.setAccepted(false); + QGuiApplication::sendEvent(window.data(), &event); + } + + QTRY_COMPARE(moveEndSpy.count(), 1); // QTBUG-55871 + QCOMPARE(flick->property("movementsAfterEnd").value<int>(), 0); // QTBUG-55886 } void tst_qquickflickable::movingAndFlicking_data() @@ -1477,20 +1561,26 @@ void tst_qquickflickable::nestedStopAtBounds_data() QTest::addColumn<bool>("invert"); QTest::addColumn<int>("boundsBehavior"); QTest::addColumn<qreal>("margin"); - - QTest::newRow("left,stop") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(0); - QTest::newRow("right,stop") << false << true << int(QQuickFlickable::StopAtBounds) << qreal(0); - QTest::newRow("top,stop") << true << false << int(QQuickFlickable::StopAtBounds) << qreal(0); - QTest::newRow("bottom,stop") << true << true << int(QQuickFlickable::StopAtBounds) << qreal(0); - QTest::newRow("left,over") << false << false << int(QQuickFlickable::DragOverBounds) << qreal(0); - QTest::newRow("right,over") << false << true << int(QQuickFlickable::DragOverBounds) << qreal(0); - QTest::newRow("top,over") << true << false << int(QQuickFlickable::DragOverBounds) << qreal(0); - QTest::newRow("bottom,over") << true << true << int(QQuickFlickable::DragOverBounds) << qreal(0); - - QTest::newRow("left,stop,margin") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(20); - QTest::newRow("right,stop,margin") << false << true << int(QQuickFlickable::StopAtBounds) << qreal(20); - QTest::newRow("top,stop,margin") << true << false << int(QQuickFlickable::StopAtBounds) << qreal(20); - QTest::newRow("bottom,stop,margin") << true << true << int(QQuickFlickable::StopAtBounds) << qreal(20); + QTest::addColumn<bool>("innerFiltering"); + QTest::addColumn<int>("pressDelay"); + QTest::addColumn<bool>("waitForPressDelay"); + + QTest::newRow("left,stop") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(0) << false << 0 << false; + QTest::newRow("right,stop") << false << true << int(QQuickFlickable::StopAtBounds) << qreal(0) << false << 0 << false; + QTest::newRow("top,stop") << true << false << int(QQuickFlickable::StopAtBounds) << qreal(0) << false << 0 << false; + QTest::newRow("bottom,stop") << true << true << int(QQuickFlickable::StopAtBounds) << qreal(0) << false << 0 << false; + QTest::newRow("left,over") << false << false << int(QQuickFlickable::DragOverBounds) << qreal(0) << false << 0 << false; + QTest::newRow("right,over") << false << true << int(QQuickFlickable::DragOverBounds) << qreal(0) << false << 0 << false; + QTest::newRow("top,over") << true << false << int(QQuickFlickable::DragOverBounds) << qreal(0) << false << 0 << false; + QTest::newRow("bottom,over") << true << true << int(QQuickFlickable::DragOverBounds) << qreal(0) << false << 0 << false; + + QTest::newRow("left,stop,margin") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(20) << false << 0 << false; + QTest::newRow("right,stop,margin") << false << true << int(QQuickFlickable::StopAtBounds) << qreal(20) << false << 0 << false; + QTest::newRow("top,stop,margin") << true << false << int(QQuickFlickable::StopAtBounds) << qreal(20) << false << 0 << false; + QTest::newRow("bottom,stop,margin") << true << true << int(QQuickFlickable::StopAtBounds) << qreal(20) << false << 0 << false; + + QTest::newRow("left,stop,after press delay") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(0) << true << 50 << true; + QTest::newRow("left,stop,before press delay") << false << false << int(QQuickFlickable::StopAtBounds) << qreal(0) << true << 50 << false; } void tst_qquickflickable::nestedStopAtBounds() @@ -1499,6 +1589,9 @@ void tst_qquickflickable::nestedStopAtBounds() QFETCH(bool, invert); QFETCH(int, boundsBehavior); QFETCH(qreal, margin); + QFETCH(bool, innerFiltering); + QFETCH(int, pressDelay); + QFETCH(bool, waitForPressDelay); QQuickView view; view.setSource(testFileUrl("nestedStopAtBounds.qml")); @@ -1531,6 +1624,12 @@ void tst_qquickflickable::nestedStopAtBounds() QCOMPARE(inner->isAtYBeginning(), invert); QCOMPARE(inner->isAtYEnd(), !invert); + inner->setPressDelay(pressDelay); + + QQuickMouseArea *mouseArea = inner->findChild<QQuickMouseArea *>("mouseArea"); + QVERIFY(mouseArea); + mouseArea->setEnabled(innerFiltering); + const int threshold = qApp->styleHints()->startDragDistance(); QPoint position(200, 200); @@ -1538,17 +1637,25 @@ void tst_qquickflickable::nestedStopAtBounds() // drag toward the aligned boundary. Outer flickable dragged. moveAndPress(&view, position); - QTest::qWait(10); + if (waitForPressDelay) { + QVERIFY(innerFiltering); // isPressed will never be true if the mouse area isn't enabled. + QTRY_VERIFY(mouseArea->pressed()); + } + axis += invert ? threshold * 2 : -threshold * 2; QTest::mouseMove(&view, position); axis += invert ? threshold : -threshold; QTest::mouseMove(&view, position); QCOMPARE(outer->isDragging(), true); + QCOMPARE(outer->isMoving(), true); QCOMPARE(inner->isDragging(), false); + QCOMPARE(inner->isMoving(), false); QTest::mouseRelease(&view, Qt::LeftButton, 0, position); QVERIFY(!outer->isDragging()); QTRY_VERIFY(!outer->isMoving()); + QVERIFY(!inner->isDragging()); + QVERIFY(!inner->isMoving()); axis = 200; outer->setContentX(50); @@ -1562,10 +1669,15 @@ void tst_qquickflickable::nestedStopAtBounds() axis += invert ? -threshold : threshold; QTest::mouseMove(&view, position); QCOMPARE(outer->isDragging(), false); + QCOMPARE(outer->isMoving(), false); QCOMPARE(inner->isDragging(), true); + QCOMPARE(inner->isMoving(), true); QTest::mouseRelease(&view, Qt::LeftButton, 0, position); - QTRY_VERIFY(!outer->isMoving()); + QVERIFY(!inner->isDragging()); + QTRY_VERIFY(!inner->isMoving()); + QVERIFY(!outer->isDragging()); + QVERIFY(!outer->isMoving()); axis = 200; inner->setContentX(-margin); @@ -1581,9 +1693,16 @@ void tst_qquickflickable::nestedStopAtBounds() axis += invert ? -threshold : threshold; QTest::mouseMove(&view, position); QCOMPARE(outer->isDragging(), true); + QCOMPARE(outer->isMoving(), true); QCOMPARE(inner->isDragging(), false); + QCOMPARE(inner->isMoving(), false); QTest::mouseRelease(&view, Qt::LeftButton, 0, position); + QVERIFY(!outer->isDragging()); + QTRY_VERIFY(!outer->isMoving()); + QVERIFY(!inner->isDragging()); + QVERIFY(!inner->isMoving()); + axis = 200; inner->setContentX(-margin); inner->setContentY(-margin); @@ -1598,8 +1717,15 @@ void tst_qquickflickable::nestedStopAtBounds() axis += invert ? -threshold : threshold; QTest::mouseMove(&view, position); QCOMPARE(outer->isDragging(), true); + QCOMPARE(outer->isMoving(), true); QCOMPARE(inner->isDragging(), false); + QCOMPARE(inner->isMoving(), false); QTest::mouseRelease(&view, Qt::LeftButton, 0, position); + + QVERIFY(!outer->isDragging()); + QTRY_VERIFY(!outer->isMoving()); + QVERIFY(!inner->isDragging()); + QVERIFY(!inner->isMoving()); } void tst_qquickflickable::stopAtBounds_data() |