summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-06-29 06:23:28 (GMT)
committerMartin Jones <martin.jones@nokia.com>2011-07-08 06:57:04 (GMT)
commit0d670396f7e4b24f0800ad0e7f219727a47bfba6 (patch)
tree28c5c5a57a3c7b7653ddddb7711f646d120048d9 /tests/auto
parent55cfbdb7c64068ae68f7baaceb8acfb96cb0c07e (diff)
downloadQt-0d670396f7e4b24f0800ad0e7f219727a47bfba6.zip
Qt-0d670396f7e4b24f0800ad0e7f219727a47bfba6.tar.gz
Qt-0d670396f7e4b24f0800ad0e7f219727a47bfba6.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 (cherry picked from commit 6fb7cdf8741ca924413dd7cbc09fad91ddc04823)
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp69
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)