aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickflickable
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquickflickable')
-rw-r--r--tests/auto/quick/qquickflickable/BLACKLIST2
-rw-r--r--tests/auto/quick/qquickflickable/data/movementSignals.qml26
-rw-r--r--tests/auto/quick/qquickflickable/data/nestedPressDelay.qml10
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp276
4 files changed, 224 insertions, 90 deletions
diff --git a/tests/auto/quick/qquickflickable/BLACKLIST b/tests/auto/quick/qquickflickable/BLACKLIST
index 92ed8708de..647bf819a5 100644
--- a/tests/auto/quick/qquickflickable/BLACKLIST
+++ b/tests/auto/quick/qquickflickable/BLACKLIST
@@ -10,7 +10,7 @@ osx-10.10
osx-10.10
[stopAtBounds]
osx-10.10
-windows 32bit developer-build
+windows developer-build
[returnToBounds]
osx
[pressWhileFlicking]
diff --git a/tests/auto/quick/qquickflickable/data/movementSignals.qml b/tests/auto/quick/qquickflickable/data/movementSignals.qml
new file mode 100644
index 0000000000..581e882139
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/data/movementSignals.qml
@@ -0,0 +1,26 @@
+import QtQuick 2.0
+
+Flickable {
+ width: 400; height: 400
+ contentWidth: 400; contentHeight: 1200
+
+ property string signalString
+
+ Rectangle {
+ width: 400; height: 400
+ color: "red"
+ }
+ Rectangle {
+ y: 400; width: 400; height: 400
+ color: "yellow"
+ }
+ Rectangle {
+ y: 800; width: 400; height: 400
+ color: "green"
+ }
+
+ onMovementStarted: signalString += "ms"
+ onMovementEnded: signalString += "me"
+ onFlickStarted: signalString += "fs"
+ onFlickEnded: signalString += "fe"
+}
diff --git a/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml
index 742656641f..bdb866ce65 100644
--- a/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml
+++ b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml
@@ -8,12 +8,18 @@ Flickable {
contentHeight: 320
flickableDirection: Flickable.HorizontalFlick
pressDelay: 10000
- Rectangle {
+ MouseArea {
+ objectName: "filteringMouseArea"
x: 20
y: 20
width: 400
height: 300
- color: "yellow"
+ drag.filterChildren: true
+ Rectangle {
+ id: rectangle
+ color: "yellow"
+ anchors.fill: parent
+ }
Flickable {
objectName: "innerFlickable"
anchors.fill: parent
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 7d08c3c81e..dc7171746c 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -67,6 +67,7 @@ private slots:
void flickDeceleration();
void pressDelay();
void nestedPressDelay();
+ void filterReplayedPress();
void nestedClickThenFlick();
void flickableDirection();
void resizeContent();
@@ -91,7 +92,9 @@ private slots:
void stopAtBounds_data();
void nestedMouseAreaUsingTouch();
void pressDelayWithLoader();
+ void movementFromProgrammaticFlick();
void cleanup();
+ void contentSize();
private:
void flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to);
@@ -195,9 +198,9 @@ void tst_qquickflickable::properties()
QCOMPARE(obj->pressDelay(), 200);
QCOMPARE(obj->maximumFlickVelocity(), 2000.);
- QVERIFY(obj->property("ok").toBool() == false);
+ QVERIFY(!obj->property("ok").toBool());
QMetaObject::invokeMethod(obj, "check");
- QVERIFY(obj->property("ok").toBool() == true);
+ QVERIFY(obj->property("ok").toBool());
delete obj;
}
@@ -211,28 +214,28 @@ void tst_qquickflickable::boundsBehavior()
QSignalSpy spy(flickable, SIGNAL(boundsBehaviorChanged()));
QVERIFY(flickable);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
+ QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::StopAtBounds);
flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragAndOvershootBounds);
+ QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::DragAndOvershootBounds);
QCOMPARE(spy.count(),1);
flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
QCOMPARE(spy.count(),1);
flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragOverBounds);
+ QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::DragOverBounds);
QCOMPARE(spy.count(),2);
flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
QCOMPARE(spy.count(),2);
flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
+ QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::StopAtBounds);
QCOMPARE(spy.count(),3);
flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
QCOMPARE(spy.count(),3);
flickable->setBoundsBehavior(QQuickFlickable::OvershootBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::OvershootBounds);
+ QCOMPARE(flickable->boundsBehavior(), QQuickFlickable::OvershootBounds);
QCOMPARE(spy.count(),4);
flickable->setBoundsBehavior(QQuickFlickable::OvershootBounds);
QCOMPARE(spy.count(),4);
@@ -249,7 +252,7 @@ void tst_qquickflickable::rebound()
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -295,11 +298,11 @@ void tst_qquickflickable::rebound()
// flick and trigger the transition multiple times
// (moving signals are emitted as soon as the first transition starts)
- flick(window.data(), QPoint(20,20), QPoint(120,120), 200); // both x and y will bounce back
- flick(window.data(), QPoint(20,120), QPoint(120,20), 200); // only x will bounce back
+ flick(window.data(), QPoint(20,20), QPoint(120,120), 50); // both x and y will bounce back
+ flick(window.data(), QPoint(20,120), QPoint(120,20), 50); // only x will bounce back
QVERIFY(flickable->isMoving());
- QVERIFY(window->rootObject()->property("transitionsStarted").toInt() >= 1);
+ QTRY_VERIFY(window->rootObject()->property("transitionsStarted").toInt() >= 1);
QCOMPARE(hMoveSpy.count(), 1);
QCOMPARE(vMoveSpy.count(), 1);
QCOMPARE(movementStartedSpy.count(), 1);
@@ -388,7 +391,7 @@ void tst_qquickflickable::pressDelay()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -406,13 +409,13 @@ void tst_qquickflickable::pressDelay()
QQuickItem *mouseArea = window->rootObject()->findChild<QQuickItem*>("mouseArea");
QSignalSpy clickedSpy(mouseArea, SIGNAL(clicked(QQuickMouseEvent*)));
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
+ moveAndPress(window.data(), QPoint(150, 150));
// The press should not occur immediately
- QVERIFY(mouseArea->property("pressed").toBool() == false);
+ QVERIFY(!mouseArea->property("pressed").toBool());
// But, it should occur eventually
- QTRY_VERIFY(mouseArea->property("pressed").toBool() == true);
+ QTRY_VERIFY(mouseArea->property("pressed").toBool());
QCOMPARE(clickedSpy.count(),0);
@@ -427,10 +430,10 @@ void tst_qquickflickable::pressDelay()
// Test a quick tap within the pressDelay timeout
clickedSpy.clear();
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(180, 180));
+ moveAndPress(window.data(), QPoint(180, 180));
// The press should not occur immediately
- QVERIFY(mouseArea->property("pressed").toBool() == false);
+ QVERIFY(!mouseArea->property("pressed").toBool());
QCOMPARE(clickedSpy.count(),0);
@@ -444,16 +447,16 @@ void tst_qquickflickable::pressDelay()
// QTBUG-31168
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 110));
+ moveAndPress(window.data(), QPoint(150, 110));
// The press should not occur immediately
- QVERIFY(mouseArea->property("pressed").toBool() == false);
+ QVERIFY(!mouseArea->property("pressed").toBool());
QTest::mouseMove(window.data(), QPoint(150, 190));
// As we moved pass the drag threshold, we should never receive the press
- QVERIFY(mouseArea->property("pressed").toBool() == false);
- QTRY_VERIFY(mouseArea->property("pressed").toBool() == false);
+ QVERIFY(!mouseArea->property("pressed").toBool());
+ QTRY_VERIFY(!mouseArea->property("pressed").toBool());
// On release the clicked signal should *not* be emitted
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 190));
@@ -469,7 +472,7 @@ void tst_qquickflickable::nestedPressDelay()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -478,48 +481,90 @@ void tst_qquickflickable::nestedPressDelay()
QQuickFlickable *inner = window->rootObject()->findChild<QQuickFlickable*>("innerFlickable");
QVERIFY(inner != 0);
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
+ moveAndPress(window.data(), QPoint(150, 150));
// the MouseArea is not pressed immediately
- QVERIFY(outer->property("pressed").toBool() == false);
- QVERIFY(inner->property("pressed").toBool() == false);
+ QVERIFY(!outer->property("pressed").toBool());
+ QVERIFY(!inner->property("pressed").toBool());
// The inner pressDelay will prevail (50ms, vs. 10sec)
// QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec.
- QTRY_VERIFY(outer->property("pressed").toBool() == true);
+ QTRY_VERIFY(outer->property("pressed").toBool());
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
// Dragging inner Flickable should work
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(80, 150));
+ moveAndPress(window.data(), QPoint(80, 150));
// the MouseArea is not pressed immediately
- QVERIFY(outer->property("pressed").toBool() == false);
- QVERIFY(inner->property("pressed").toBool() == false);
+ QVERIFY(!outer->property("pressed").toBool());
+ QVERIFY(!inner->property("pressed").toBool());
QTest::mouseMove(window.data(), QPoint(60, 150));
QTest::mouseMove(window.data(), QPoint(40, 150));
QTest::mouseMove(window.data(), QPoint(20, 150));
- QVERIFY(inner->property("moving").toBool() == true);
- QVERIFY(outer->property("moving").toBool() == false);
+ QVERIFY(inner->property("moving").toBool());
+ QVERIFY(!outer->property("moving").toBool());
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(20, 150));
// Dragging the MouseArea in the inner Flickable should move the inner Flickable
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
+ moveAndPress(window.data(), QPoint(150, 150));
// the MouseArea is not pressed immediately
- QVERIFY(outer->property("pressed").toBool() == false);
+ QVERIFY(!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() == false);
- QVERIFY(inner->property("moving").toBool() == true);
+ QVERIFY(!outer->property("moving").toBool());
+ QVERIFY(inner->property("moving").toBool());
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(90, 150));
}
+void tst_qquickflickable::filterReplayedPress()
+{
+ QScopedPointer<QQuickView> window(new QQuickView);
+ window->setSource(testFileUrl("nestedPressDelay.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(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);
+
+ QQuickItem *filteringMouseArea = outer->findChild<QQuickItem *>("filteringMouseArea");
+ QVERIFY(filteringMouseArea);
+
+ moveAndPress(window.data(), QPoint(150, 150));
+ // the MouseArea filtering the Flickable is pressed immediately.
+ QCOMPARE(filteringMouseArea->property("pressed").toBool(), true);
+
+ // Some event causes the mouse area to set keepMouseGrab.
+ filteringMouseArea->setKeepMouseGrab(true);
+ QCOMPARE(filteringMouseArea->keepMouseGrab(), true);
+
+ // The inner pressDelay will prevail (50ms, vs. 10sec)
+ // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec.
+ QTRY_VERIFY(outer->property("pressed").toBool());
+
+ // The replayed press event isn't delivered to parent items of the
+ // flickable with the press delay, and the state of the parent mouse
+ // area is therefore unaffected.
+ QCOMPARE(filteringMouseArea->property("pressed").toBool(), true);
+ QCOMPARE(filteringMouseArea->keepMouseGrab(), true);
+
+ QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
+}
+
+
// QTBUG-37316
void tst_qquickflickable::nestedClickThenFlick()
{
@@ -529,7 +574,7 @@ void tst_qquickflickable::nestedClickThenFlick()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -538,29 +583,29 @@ void tst_qquickflickable::nestedClickThenFlick()
QQuickFlickable *inner = window->rootObject()->findChild<QQuickFlickable*>("innerFlickable");
QVERIFY(inner != 0);
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
+ moveAndPress(window.data(), QPoint(150, 150));
// the MouseArea is not pressed immediately
- QVERIFY(outer->property("pressed").toBool() == false);
- QTRY_VERIFY(outer->property("pressed").toBool() == true);
+ QVERIFY(!outer->property("pressed").toBool());
+ QTRY_VERIFY(outer->property("pressed").toBool());
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
- QVERIFY(outer->property("pressed").toBool() == false);
+ QVERIFY(!outer->property("pressed").toBool());
// Dragging inner Flickable should work
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(80, 150));
+ moveAndPress(window.data(), QPoint(80, 150));
// the MouseArea is not pressed immediately
- QVERIFY(outer->property("pressed").toBool() == false);
+ QVERIFY(!outer->property("pressed").toBool());
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);
+ QVERIFY(!outer->property("moving").toBool());
+ QVERIFY(inner->property("moving").toBool());
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(80, 100));
}
@@ -628,6 +673,8 @@ void tst_qquickflickable::returnToBounds()
window->rootContext()->setContextProperty("setRebound", setRebound);
window->setSource(testFileUrl("resize.qml"));
+ window->show();
+ QTest::qWaitForWindowActive(window.data());
QVERIFY(window->rootObject() != 0);
QQuickFlickable *obj = findItem<QQuickFlickable>(window->rootObject(), "flick");
@@ -671,7 +718,7 @@ void tst_qquickflickable::wheel()
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("wheel.qml"));
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("flick");
@@ -685,10 +732,10 @@ void tst_qquickflickable::wheel()
}
QTRY_VERIFY(flick->contentY() > 0);
- QVERIFY(flick->contentX() == 0);
+ QCOMPARE(flick->contentX(), qreal(0));
flick->setContentY(0);
- QVERIFY(flick->contentY() == 0);
+ QCOMPARE(flick->contentY(), qreal(0));
{
QPoint pos(200, 200);
@@ -699,7 +746,7 @@ void tst_qquickflickable::wheel()
}
QTRY_VERIFY(flick->contentX() > 0);
- QVERIFY(flick->contentY() == 0);
+ QCOMPARE(flick->contentY(), qreal(0));
}
void tst_qquickflickable::movingAndFlicking_data()
@@ -740,7 +787,7 @@ void tst_qquickflickable::movingAndFlicking()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -903,7 +950,7 @@ void tst_qquickflickable::movingAndDragging()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -922,7 +969,7 @@ void tst_qquickflickable::movingAndDragging()
QSignalSpy moveEndSpy(flickable, SIGNAL(movementEnded()));
// start the drag
- QTest::mousePress(window.data(), Qt::LeftButton, 0, moveFrom);
+ moveAndPress(window.data(), moveFrom);
QTest::mouseMove(window.data(), moveFrom + moveByWithoutSnapBack);
QTest::mouseMove(window.data(), moveFrom + moveByWithoutSnapBack*2);
QTest::mouseMove(window.data(), moveFrom + moveByWithoutSnapBack*3);
@@ -962,7 +1009,7 @@ void tst_qquickflickable::movingAndDragging()
// Don't test whether moving finished because a flick could occur
// wait for any motion to end
- QTRY_VERIFY(flickable->isMoving() == false);
+ QTRY_VERIFY(!flickable->isMoving());
QVERIFY(!flickable->isMovingHorizontally());
QVERIFY(!flickable->isMovingVertically());
@@ -998,7 +1045,7 @@ void tst_qquickflickable::movingAndDragging()
flickable->setContentX(0);
flickable->setContentY(0);
QTRY_VERIFY(!flickable->isMoving());
- QTest::mousePress(window.data(), Qt::LeftButton, 0, moveFrom);
+ moveAndPress(window.data(), moveFrom);
QTest::mouseMove(window.data(), moveFrom + moveByWithSnapBack);
QTest::mouseMove(window.data(), moveFrom + moveByWithSnapBack*2);
QTest::mouseMove(window.data(), moveFrom + moveByWithSnapBack*3);
@@ -1072,7 +1119,7 @@ void tst_qquickflickable::flickOnRelease()
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("flickable03.qml"));
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -1085,14 +1132,14 @@ void tst_qquickflickable::flickOnRelease()
// underlying drivers will hopefully provide a pre-calculated velocity
// (based on more data than what the UI gets), thus making this use case
// working even with small movements.
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(50, 300));
+ moveAndPress(window.data(), QPoint(50, 300));
QTest::mouseMove(window.data(), QPoint(50, 10), 10);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 10), 10);
QCOMPARE(vFlickSpy.count(), 1);
// wait for any motion to end
- QTRY_VERIFY(flickable->isMoving() == false);
+ QTRY_VERIFY(!flickable->isMoving());
#ifdef Q_OS_MAC
QEXPECT_FAIL("", "QTBUG-26094 stopping on a full pixel doesn't work on OS X", Continue);
@@ -1109,7 +1156,7 @@ void tst_qquickflickable::pressWhileFlicking()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -1159,27 +1206,27 @@ void tst_qquickflickable::disabled()
QScopedPointer<QQuickView> window(new QQuickView);
window->setSource(testFileUrl("disabled.qml"));
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("flickable");
QVERIFY(flick != 0);
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(50, 90));
+ moveAndPress(window.data(), QPoint(50, 90));
QTest::mouseMove(window.data(), QPoint(50, 80));
QTest::mouseMove(window.data(), QPoint(50, 70));
QTest::mouseMove(window.data(), QPoint(50, 60));
- QVERIFY(flick->isMoving() == false);
+ QVERIFY(!flick->isMoving());
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 60));
// verify that mouse clicks on other elements still work (QTBUG-20584)
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(50, 10));
+ moveAndPress(window.data(), QPoint(50, 10));
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 10));
- QTRY_VERIFY(window->rootObject()->property("clicked").toBool() == true);
+ QTRY_VERIFY(window->rootObject()->property("clicked").toBool());
}
void tst_qquickflickable::flickVelocity()
@@ -1190,7 +1237,7 @@ void tst_qquickflickable::flickVelocity()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
@@ -1199,12 +1246,12 @@ void tst_qquickflickable::flickVelocity()
// flick up
flick(window.data(), QPoint(20,190), QPoint(20, 50), 200);
QVERIFY(flickable->verticalVelocity() > 0.0);
- QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+ QTRY_COMPARE(flickable->verticalVelocity(), 0.0);
// flick down
flick(window.data(), QPoint(20,10), QPoint(20, 140), 200);
QTRY_VERIFY(flickable->verticalVelocity() < 0.0);
- QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+ QTRY_COMPARE(flickable->verticalVelocity(), 0.0);
#ifdef Q_OS_MAC
QSKIP("boost doesn't work on OS X");
@@ -1223,7 +1270,7 @@ void tst_qquickflickable::flickVelocity()
// Flick in opposite direction -> boost cancelled.
flick(window.data(), QPoint(20,10), QPoint(20, 340), 200);
QTRY_VERIFY(flickable->verticalVelocity() < 0.0);
- QVERIFY(fp->flickBoost == 1.0);
+ QCOMPARE(fp->flickBoost, 1.0);
}
void tst_qquickflickable::margins()
@@ -1235,7 +1282,7 @@ void tst_qquickflickable::margins()
QQuickViewTestUtil::moveMouseAway(window.data());
window->setTitle(QTest::currentTestFunction());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QQuickItem *root = window->rootObject();
QVERIFY(root);
QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(root);
@@ -1298,13 +1345,13 @@ void tst_qquickflickable::cancelOnMouseGrab()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
QVERIFY(flickable != 0);
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(10, 10));
+ moveAndPress(window.data(), QPoint(10, 10));
// drag out of bounds
QTest::mouseMove(window.data(), QPoint(50, 50));
QTest::mouseMove(window.data(), QPoint(100, 100));
@@ -1324,7 +1371,7 @@ void tst_qquickflickable::cancelOnMouseGrab()
QTRY_VERIFY(!flickable->isMoving());
QTRY_VERIFY(!flickable->isDragging());
- QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(50, 10));
+ moveAndRelease(window.data(), QPoint(50, 10));
}
@@ -1336,41 +1383,41 @@ void tst_qquickflickable::clickAndDragWhenTransformed()
QQuickViewTestUtil::centerOnScreen(view.data());
QQuickViewTestUtil::moveMouseAway(view.data());
view->show();
- QVERIFY(QTest::qWaitForWindowExposed(view.data()));
+ QVERIFY(QTest::qWaitForWindowActive(view.data()));
QVERIFY(view->rootObject() != 0);
QQuickFlickable *flickable = view->rootObject()->findChild<QQuickFlickable*>("flickable");
QVERIFY(flickable != 0);
// click outside child rect
- QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(190, 190));
+ moveAndPress(view.data(), QPoint(190, 190));
QTRY_COMPARE(flickable->property("itemPressed").toBool(), false);
QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(190, 190));
// click inside child rect
- QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(200, 200));
+ moveAndPress(view.data(), QPoint(200, 200));
QTRY_COMPARE(flickable->property("itemPressed").toBool(), true);
QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(200, 200));
const int threshold = qApp->styleHints()->startDragDistance();
// drag outside bounds
- QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(160, 160));
+ moveAndPress(view.data(), QPoint(160, 160));
QTest::qWait(10);
QTest::mouseMove(view.data(), QPoint(160 + threshold * 2, 160));
QTest::mouseMove(view.data(), QPoint(160 + threshold * 3, 160));
QCOMPARE(flickable->isDragging(), false);
QCOMPARE(flickable->property("itemPressed").toBool(), false);
- QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(180, 160));
+ moveAndRelease(view.data(), QPoint(180, 160));
// drag inside bounds
- QTest::mousePress(view.data(), Qt::LeftButton, 0, QPoint(200, 140));
+ moveAndPress(view.data(), QPoint(200, 140));
QTest::qWait(10);
QTest::mouseMove(view.data(), QPoint(200 + threshold * 2, 140));
QTest::mouseMove(view.data(), QPoint(200 + threshold * 3, 140));
QCOMPARE(flickable->isDragging(), true);
QCOMPARE(flickable->property("itemPressed").toBool(), false);
- QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(220, 140));
+ moveAndRelease(view.data(), QPoint(220, 140));
}
void tst_qquickflickable::flickTwiceUsingTouches()
@@ -1459,7 +1506,7 @@ void tst_qquickflickable::nestedStopAtBounds()
QQuickViewTestUtil::moveMouseAway(&view);
view.show();
view.requestActivate();
- QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(view.rootObject());
QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(view.rootObject());
@@ -1489,7 +1536,7 @@ void tst_qquickflickable::nestedStopAtBounds()
int &axis = transpose ? position.ry() : position.rx();
// drag toward the aligned boundary. Outer flickable dragged.
- QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ moveAndPress(&view, position);
QTest::qWait(10);
axis += invert ? threshold * 2 : -threshold * 2;
QTest::mouseMove(&view, position);
@@ -1507,7 +1554,7 @@ void tst_qquickflickable::nestedStopAtBounds()
outer->setContentY(50);
// drag away from the aligned boundary. Inner flickable dragged.
- QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ moveAndPress(&view, position);
QTest::qWait(10);
axis += invert ? -threshold * 2 : threshold * 2;
QTest::mouseMove(&view, position);
@@ -1526,7 +1573,7 @@ void tst_qquickflickable::nestedStopAtBounds()
inner->setContentHeight(inner->height() - margin);
// Drag inner with equal size and contentSize
- QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ moveAndPress(&view, position);
QTest::qWait(10);
axis += invert ? -threshold * 2 : threshold * 2;
QTest::mouseMove(&view, position);
@@ -1543,7 +1590,7 @@ void tst_qquickflickable::nestedStopAtBounds()
inner->setContentHeight(inner->height() - 100);
// Drag inner with size greater than contentSize
- QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ moveAndPress(&view, position);
QTest::qWait(10);
axis += invert ? -threshold * 2 : threshold * 2;
QTest::mouseMove(&view, position);
@@ -1583,7 +1630,7 @@ void tst_qquickflickable::stopAtBounds()
QQuickViewTestUtil::moveMouseAway(&view);
view.show();
view.requestActivate();
- QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QVERIFY(QTest::qWaitForWindowActive(&view));
QVERIFY(view.rootObject());
QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(view.rootObject());
@@ -1601,7 +1648,7 @@ void tst_qquickflickable::stopAtBounds()
int &axis = transpose ? position.ry() : position.rx();
// drag away from the aligned boundary. View should not move
- QTest::mousePress(&view, Qt::LeftButton, 0, position);
+ moveAndPress(&view, position);
QTest::qWait(10);
for (int i = 0; i < 3; ++i) {
axis += invert ? -threshold : threshold;
@@ -1649,12 +1696,14 @@ void tst_qquickflickable::stopAtBounds()
} else {
flickable->setContentX(invert ? 100 : 0);
}
+
+ QSignalSpy flickSignal(flickable, SIGNAL(flickingChanged()));
if (invert)
flick(&view, QPoint(20,20), QPoint(120,120), 100);
else
flick(&view, QPoint(120,120), QPoint(20,20), 100);
- QVERIFY(flickable->isFlicking());
+ QVERIFY(flickSignal.count() > 0);
if (transpose) {
if (invert)
QTRY_COMPARE(flickable->isAtYBeginning(), true);
@@ -1707,14 +1756,67 @@ void tst_qquickflickable::pressDelayWithLoader()
QQuickViewTestUtil::centerOnScreen(window.data());
QQuickViewTestUtil::moveMouseAway(window.data());
window->show();
- QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
QVERIFY(window->rootObject() != 0);
// do not crash
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
+ moveAndPress(window.data(), QPoint(150, 150));
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(150, 150));
}
+// QTBUG-34507
+void tst_qquickflickable::movementFromProgrammaticFlick()
+{
+ QScopedPointer<QQuickView> window(new QQuickView);
+ window->setSource(testFileUrl("movementSignals.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
+ QVERIFY(flickable != 0);
+
+ // verify that the signals for movement and flicking are called in the right order
+ flickable->flick(0, -1000);
+ QTRY_COMPARE(flickable->property("signalString").toString(), QString("msfsfeme"));
+}
+
+// QTBUG_35038
+void tst_qquickflickable::contentSize()
+{
+ QQuickFlickable flickable;
+ QCOMPARE(flickable.contentWidth(), qreal(-1));
+ QCOMPARE(flickable.contentHeight(), qreal(-1));
+
+ QSignalSpy cwspy(&flickable, SIGNAL(contentWidthChanged()));
+ QVERIFY(cwspy.isValid());
+
+ QSignalSpy chspy(&flickable, SIGNAL(contentHeightChanged()));
+ QVERIFY(chspy.isValid());
+
+ flickable.setWidth(100);
+ QCOMPARE(flickable.width(), qreal(100));
+ QCOMPARE(flickable.contentWidth(), qreal(-1.0));
+ QCOMPARE(cwspy.count(), 0);
+
+ flickable.setContentWidth(10);
+ QCOMPARE(flickable.width(), qreal(100));
+ QCOMPARE(flickable.contentWidth(), qreal(10));
+ QCOMPARE(cwspy.count(), 1);
+
+ flickable.setHeight(100);
+ QCOMPARE(flickable.height(), qreal(100));
+ QCOMPARE(flickable.contentHeight(), qreal(-1.0));
+ QCOMPARE(chspy.count(), 0);
+
+ flickable.setContentHeight(10);
+ QCOMPARE(flickable.height(), qreal(100));
+ QCOMPARE(flickable.contentHeight(), qreal(10));
+ QCOMPARE(chspy.count(), 1);
+}
+
QTEST_MAIN(tst_qquickflickable)
#include "tst_qquickflickable.moc"