aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-09-13 12:50:48 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-16 02:15:03 +0200
commite79c448e28c67cb6acd63e8b4bac6c7b08c1f897 (patch)
treefddd6c707e744849f73f4aca4cb14b70a17fcd10 /tests
parent8c175bee55f1e0e0bb27cbf72911fedf370c26c6 (diff)
Velocities reported by Flickable in onFlickStarted can be 0
Change 55cfbdb7c64068ae68f7baaceb8acfb96cb0c07e manually applied from Qt 4.7 Ensure the smoothed velocity is set at the start of the flick. Ensure that the smoothed velocity animation isn't restarted unless there is new valid data. Change-Id: Ia77249be9980aba268a1bfa0ea3f69c49fa09e5e Reviewed-by: Bea Lam Reviewed-on: http://codereview.qt-project.org/4712 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qsgflickable/data/flickable03.qml2
-rw-r--r--tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp48
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml2
-rw-r--r--tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp49
4 files changed, 99 insertions, 2 deletions
diff --git a/tests/auto/declarative/qsgflickable/data/flickable03.qml b/tests/auto/declarative/qsgflickable/data/flickable03.qml
index e34b63b6ac..ebc49ba90a 100644
--- a/tests/auto/declarative/qsgflickable/data/flickable03.qml
+++ b/tests/auto/declarative/qsgflickable/data/flickable03.qml
@@ -1,7 +1,7 @@
import QtQuick 2.0
Flickable {
- width: 100; height: 100
+ width: 100; height: 200
contentWidth: column.width; contentHeight: column.height
Column {
diff --git a/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp b/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp
index 0b9fdf0004..d12008f5b7 100644
--- a/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp
+++ b/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp
@@ -79,10 +79,12 @@ private slots:
void wheel();
void movingAndDragging();
void disabled();
+ void flickVelocity();
private:
QDeclarativeEngine engine;
+ void flick(QSGView *canvas, const QPoint &from, const QPoint &to, int duration);
template<typename T>
T *findItem(QSGItem *parent, const QString &objectName);
};
@@ -545,6 +547,52 @@ void tst_qsgflickable::disabled()
QVERIFY(canvas->rootObject()->property("clicked").toBool() == true);
}
+void tst_qsgflickable::flickVelocity()
+{
+#ifdef Q_WS_MAC
+ QSKIP("Producing flicks on Mac CI impossible due to timing problems", SkipAll);
+#endif
+
+ QSGView *canvas = new QSGView;
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QSGFlickable *flickable = qobject_cast<QSGFlickable*>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ // flick up
+ flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
+ QVERIFY(flickable->verticalVelocity() > 0.0);
+ QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+
+ // flick down
+ flick(canvas, QPoint(20,10), QPoint(20, 140), 200);
+ QVERIFY(flickable->verticalVelocity() < 0.0);
+ QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+
+ delete canvas;
+}
+
+void tst_qsgflickable::flick(QSGView *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, Qt::LeftButton, 0, from);
+
+ for (int i = 0; i < pointCount; ++i) {
+ QMouseEvent mv(QEvent::MouseMove, from + (i+1)*diff/pointCount, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QApplication::sendEvent(canvas, &mv);
+ QTest::qWait(duration/pointCount);
+ QCoreApplication::processEvents();
+ }
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, to);
+}
+
template<typename T>
T *tst_qsgflickable::findItem(QSGItem *parent, const QString &objectName)
{
diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml
index a3e92fe6a6..8359ad1bb4 100644
--- a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml
+++ b/tests/auto/qtquick1/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/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
index 80bf71a191..2d8c75ba22 100644
--- a/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ b/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -79,10 +79,12 @@ private slots:
void testQtQuick11Attributes_data();
void wheel();
void disabled();
+ void flickVelocity();
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);
};
@@ -514,6 +516,53 @@ void tst_qdeclarativeflickable::disabled()
QVERIFY(canvas->rootObject()->property("clicked").toBool() == true);
}
+void tst_qdeclarativeflickable::flickVelocity()
+{
+#ifdef Q_WS_MAC
+ QSKIP("Producing flicks on Mac CI impossible due to timing problems", SkipAll);
+#endif
+
+ QDeclarativeView *canvas = new QDeclarativeView;
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
+ canvas->show();
+ canvas->setFocus();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarative1Flickable *flickable = qobject_cast<QDeclarative1Flickable*>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ // flick up
+ flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
+ QVERIFY(flickable->verticalVelocity() > 0.0);
+ QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+
+ // flick down
+ flick(canvas, QPoint(20,10), QPoint(20, 140), 200);
+ 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);
+ QCoreApplication::processEvents();
+ }
+
+ QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(to));
+}
+
+
template<typename T>
T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName)
{