diff options
author | Martin Jones <martin.jones@nokia.com> | 2011-06-29 06:23:28 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2011-06-29 06:23:28 (GMT) |
commit | 6fb7cdf8741ca924413dd7cbc09fad91ddc04823 (patch) | |
tree | 5fc5383909ce5e53bce768e9f855bab2d8e43f85 /tests/auto/declarative/qdeclarativeflickable | |
parent | a2d97672bfaace677a4308db93f5802ba53af46e (diff) | |
download | Qt-6fb7cdf8741ca924413dd7cbc09fad91ddc04823.zip Qt-6fb7cdf8741ca924413dd7cbc09fad91ddc04823.tar.gz Qt-6fb7cdf8741ca924413dd7cbc09fad91ddc04823.tar.bz2 |
Reduce timing dependancy in flickable test
Interval of 10ms between synthesized flick move events is too prone
to timing difference on CI platforms.
Change-Id: Id5da794a7294868c8f5e544fa71edeec967e31ca
Task-number: QTBUG-19676
Reviewed-by: Bea Lam
Diffstat (limited to 'tests/auto/declarative/qdeclarativeflickable')
-rw-r--r-- | tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml | 2 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp | 69 |
2 files changed, 22 insertions, 49 deletions
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml index a3e92fe..8359ad1 100644 --- a/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml +++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml @@ -1,7 +1,7 @@ import QtQuick 1.0 Flickable { - width: 100; height: 100 + width: 100; height: 200 contentWidth: column.width; contentHeight: column.height Column { diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index 31a6b10..05925cd 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -83,6 +83,7 @@ private slots: private: QDeclarativeEngine engine; + void flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration); template<typename T> T *findItem(QGraphicsObject *parent, const QString &objectName); }; @@ -492,63 +493,35 @@ void tst_qdeclarativeflickable::flickVelocity() QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(canvas->rootObject()); QVERIFY(flickable != 0); - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20, 90))); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,80)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,70)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,60)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,50)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20, 50))); - + // flick up + flick(canvas, QPoint(20,190), QPoint(20, 50), 100); QVERIFY(flickable->verticalVelocity() > 0.0); QTRY_VERIFY(flickable->verticalVelocity() == 0.0); - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20, 10))); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,20)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,30)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,40)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,50)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20, 50))); - + // flick down + flick(canvas, QPoint(20,10), QPoint(20, 100), 100); QVERIFY(flickable->verticalVelocity() < 0.0); QTRY_VERIFY(flickable->verticalVelocity() == 0.0); delete canvas; } +void tst_qdeclarativeflickable::flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration) +{ + const int pointCount = 5; + QPoint diff = to - from; + + // send press, five equally spaced moves, and release. + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(from)); + + for (int i = 0; i < pointCount; ++i) { + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(from + (i+1)*diff/pointCount), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + QTest::qWait(duration/pointCount); + } + + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(to)); +} template<typename T> T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName) |